コード例 #1
0
  /**
   * Whenever an UndoableEdit happens the edit will either be absorbed by the current compound edit
   * or a new compound edit will be started
   */
  @Override
  public void undoableEditHappened(UndoableEditEvent e) {
    //  Start a new compound edit

    AbstractDocument.DefaultDocumentEvent docEvt = (DefaultDocumentEvent) e.getEdit();

    if (compoundEdit == null) {
      compoundEdit = startCompoundEdit(e.getEdit());
      startCombine = false;
      updateDirty();
      return;
    }

    int editLine = ((SyntaxDocument) docEvt.getDocument()).getLineNumberAt(docEvt.getOffset());

    //  Check for an incremental edit or backspace.
    //  The Change in Caret position and Document length should both be
    //  either 1 or -1.
    if ((startCombine || Math.abs(docEvt.getLength()) == 1) && editLine == lastLine) {
      compoundEdit.addEdit(e.getEdit());
      startCombine = false;
      updateDirty();
      return;
    }

    //  Not incremental edit, end previous edit and start a new one
    lastLine = editLine;

    compoundEdit.end();
    compoundEdit = startCompoundEdit(e.getEdit());

    updateDirty();
  }
コード例 #2
0
  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) {
          e1.printStackTrace();
        }
      }

      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();
    }
  }
コード例 #3
0
ファイル: JBrowser.java プロジェクト: aliwebir/JBrowser
 @Override
 public void undoableEditHappened(UndoableEditEvent arg0) {
   undo.addEdit(arg0.getEdit());
 }
コード例 #4
0
 /**
  * We propagate all edit events from our children to undoable edit listeners, which have
  * registered with us.
  */
 public void undoableEditHappened(UndoableEditEvent e) {
   fireUndoableEditHappened(e.getEdit());
 }
コード例 #5
0
ファイル: Notepad.java プロジェクト: ArcherSys/ArcherSysRuby
 /**
  * Messaged when the Document has created an edit, the edit is added to <code>undo</code>, an
  * instance of UndoManager.
  */
 public void undoableEditHappened(UndoableEditEvent e) {
   undo.addEdit(e.getEdit());
   undoAction.update();
   redoAction.update();
 }
コード例 #6
0
 public void undoableEditHappened(UndoableEditEvent e) {
   undo.addEdit(e.getEdit());
   setUndoEnabled(e.getEdit().canUndo());
   setRedoEnabled(e.getEdit().canRedo());
 }
コード例 #7
0
ファイル: UndoListener.java プロジェクト: blickly/ptii
 /**
  * Remember the edit and update the action state.
  *
  * @param event The event that occurred.
  */
 public void undoableEditHappened(UndoableEditEvent event) {
   _undo.addEdit(event.getEdit());
   _undoAction._updateUndoState();
   _redoAction._updateRedoState();
 }
コード例 #8
0
 public void undoableEditHappened(UndoableEditEvent e) {
   undo.addEdit(e.getEdit());
 }
コード例 #9
0
 @Override
 public void undoableEditHappened(javax.swing.event.UndoableEditEvent e) {
   this.addEdit(e.getEdit());
   fireUndoHappen();
 };
コード例 #10
0
ファイル: UndoAdapter.java プロジェクト: asad/jcp
 /*
  * (non-Javadoc)
  *
  * @see javax.swing.event.UndoableEditListener#undoableEditHappened(javax.swing.event.UndoableEditEvent)
  */
 public void undoableEditHappened(UndoableEditEvent arg0) {
   UndoableEdit edit = arg0.getEdit();
   undoManager.addEdit(edit);
 }