Java Code Examples for javax.swing.undo.UndoableEdit#undo()

The following examples show how to use javax.swing.undo.UndoableEdit#undo() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: UndoRedoKeeper.java    From ghidra with Apache License 2.0 6 votes vote down vote up
void undo() {
	if (undoStack.isEmpty()) {
		return;
	}

	endOutstandingStyleEdits();

	UndoableEdit item = undoStack.pop();
	redoStack.push(item);
	item.undo();

	// (see header note)
	if (item instanceof StyleCompoundEdit) {
		undo(); // call again to get a 'real' edit
	}
}
 
Example 2
Source File: MultipleEdit.java    From PIPE with MIT License 5 votes vote down vote up
/**
 * Undoes every action in the multiple edits
 */
@Override
public void undo() {
    super.undo();

    for (UndoableEdit edit : multipleEdits) {
        edit.undo();
    }
}
 
Example 3
Source File: GhidraScriptEditorComponentProvider.java    From ghidra with Apache License 2.0 4 votes vote down vote up
private void undo() {
	UndoableEdit item = undoStack.pop();
	redoStack.push(item);
	item.undo();
	updateUndoRedoAction();
}
 
Example 4
Source File: TextEditorComponentProvider.java    From ghidra with Apache License 2.0 4 votes vote down vote up
private void undo() {
	UndoableEdit item = undoStack.pop();
	redoStack.push(item);
	item.undo();
	updateUndoRedoAction();
}
 
Example 5
Source File: BaseDocumentEvent.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public @Override void undo() throws CannotUndoException {
    BaseDocument doc = (BaseDocument)getDocument();

    inUndo = true;

    // Super of undo()
    doc.atomicLockImpl();
    if (!doc.modifiable) {
        throw new CannotUndoException();
    }
    try {
        doc.incrementDocVersion();
        
        if (!canUndo()) {
            throw new CannotUndoException();
        }
        hasBeenDone2 = false;
       
        doc.lastModifyUndoEdit = null; // #8692 check last modify undo edit

        if (debugUndo) {
            /*DEBUG*/System.err.println("UNDO in doc=" + doc);
        }
        
        int i = edits.size(); // i should be > 0 since only non-empty edits are fired
        while (--i >= 0) {
            UndoableEdit e = (UndoableEdit)edits.elementAt(i);
            e.undo();
        }

        // fire a DocumentEvent to notify the view(s)
        if (getType() == DocumentEvent.EventType.REMOVE) {
            doc.firePreInsertUpdate(this);
            doc.fireInsertUpdate(this);
        } else if (getType() == DocumentEvent.EventType.INSERT) {
            doc.firePreRemoveUpdate(this);
            doc.fireRemoveUpdate(this);
        } else {
            doc.fireChangedUpdate(this);
        }

        if (previous != null) {
            previous.undo();
        }
    } finally {
        doc.atomicUnlockImpl(false);
        inUndo = false;
    }
    // End super of undo()

}