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

The following examples show how to use javax.swing.undo.UndoableEdit#getPresentationName() . 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 5 votes vote down vote up
void addUndo(UndoableEdit edit) {

		String name = edit.getPresentationName();
		if (name.contains(STYLE_EDIT_KEY)) {
			// (see header note about style edits)
			addStyleEdit(edit);
			return;
		}

		endOutstandingStyleEdits();

		undoStack.push(edit);
		redoStack.clear(); // new edit added; clear redo
	}
 
Example 2
Source File: StableCompoundEdit.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
   public String getPresentationName() {
UndoableEdit last = lastEdit();
if (last != null) {
    return last.getPresentationName();
} else {
    return "";
}
   }
 
Example 3
Source File: StableCompoundEdit.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
   public String getPresentationName() {
UndoableEdit last = lastEdit();
if (last != null) {
    return last.getPresentationName();
} else {
    return "";
}
   }
 
Example 4
Source File: EditorUndoManager.java    From SikuliX1 with MIT License 4 votes vote down vote up
@Override
public void undoableEditHappened(UndoableEditEvent e) {
   UndoableEdit edit=e.getEdit();
   if (edit instanceof AbstractDocument.DefaultDocumentEvent) {
      AbstractDocument.DefaultDocumentEvent event=(AbstractDocument.DefaultDocumentEvent)edit;
      int start=event.getOffset();
      int len=event.getLength();
      Debug.log(9, "undoableEditHappened " + start + "," + len);
      boolean isNeedStart=false;
      if(event.getType().equals(DocumentEvent.EventType.CHANGE) ||
         event.getType().equals(DocumentEvent.EventType.INSERT) ){
         try {
            String text=event.getDocument().getText(start, len);
            if (text.contains("\n"))
               isNeedStart=true;
         } catch (BadLocationException e1) {
           Debug.error(me + "undoableEditHappened: Problem getting text\n%s", e1.getMessage());
         }
      }

      if (current==null) {
         isNeedStart=true;
      }
      else if (lastEditName==null || !lastEditName.equals(edit.getPresentationName())) {
         isNeedStart=true;
      }

      while (pointer<edits.size()-1) {
         edits.remove(edits.size()-1);
         isNeedStart=true;
      }
      if (isNeedStart) {
         createCompoundEdit();
      }

      current.addEdit(edit);
      lastEditName=edit.getPresentationName();

      refreshControls();
   }
}