예제 #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
 @Override
 public void undoableEditHappened(UndoableEditEvent arg0) {
   undo.addEdit(arg0.getEdit());
 }
 /**
  * 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
 /**
  * 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();
 }
 public void undoableEditHappened(UndoableEditEvent e) {
   undo.addEdit(e.getEdit());
   setUndoEnabled(e.getEdit().canUndo());
   setRedoEnabled(e.getEdit().canRedo());
 }
예제 #7
0
 /**
  * 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);
 }