@Override public void documentChanged(DocumentEvent event) { fPreservedRedoModificationStamp= event.getModificationStamp(); // record the current valid state for the top operation in case it remains the // top operation but changes state. IUndoableOperation op= fHistory.getUndoOperation(fUndoContext); boolean wasValid= false; if (op != null) wasValid= op.canUndo(); // Process the change, providing the before and after timestamps processChange(event.getOffset(), event.getOffset() + event.getLength(), event.getText(), fReplacedText, fPreservedUndoModificationStamp, fPreservedRedoModificationStamp); // now update fCurrent with the latest buffers from the document change. fCurrent.pretendCommit(); if (op == fCurrent) { // if the document change did not cause a new fCurrent to be created, then we should // notify the history that the current operation changed if its validity has changed. if (wasValid != fCurrent.isValid()) fHistory.operationChanged(op); } else { // if the change created a new fCurrent that we did not yet add to the // stack, do so if it's valid and we are not in the middle of a compound change. if (fCurrent != fLastAddedCommand && fCurrent.isValid()) { addToCommandStack(fCurrent); } } } }
@Override public void documentChanged(DocumentEvent event) { fPreservedRedoModificationStamp= event.getModificationStamp(); // record the current valid state for the top operation in case it remains the // top operation but changes state. IUndoableOperation op= fHistory.getUndoOperation(fUndoContext); boolean wasValid= false; if (op != null) wasValid= op.canUndo(); // Process the change, providing the before and after timestamps processChange(event.getOffset(), event.getOffset() + event.getLength(), event.getText(), fReplacedText, fPreservedUndoModificationStamp, fPreservedRedoModificationStamp); // now update fCurrent with the latest buffers from the document change. fCurrent.pretendCommit(); if (op == fCurrent) { // if the document change did not cause a new fCurrent to be created, then we should // notify the history that the current operation changed if its validity has changed. if (wasValid != fCurrent.isValid()) fHistory.operationChanged(op); } else { // if the change created a new fCurrent that we did not yet add to the // stack, do so if it's valid and we are not in the middle of a compound change. if (fCurrent != fLastAddedCommand && fCurrent.isValid()) { addToCommandStack(fCurrent); } } } }
/** * Attempt a commit of this command and answer true if a new * fCurrent was created as a result of the commit. * * @return true if the command was committed and created a * new fCurrent, false if not. * @since 3.1 */ protected boolean attemptCommit() { pretendCommit(); if (isValid()) { DefaultUndoManager.this.commit(); return true; } return false; }
/** * Closes the current editing command and opens a new one. */ private void commit() { // if fCurrent has never been placed on the command stack, do so now. // this can happen when there are multiple programmatically commits in a single // document change. if (fLastAddedCommand != fCurrent) { fCurrent.pretendCommit(); if (fCurrent.isValid()) addToCommandStack(fCurrent); } fCurrent.commit(); }
/** * Attempt a commit of this command and answer true if a new * fCurrent was created as a result of the commit. * * @return true if the command was committed and created a * new fCurrent, false if not. * @since 3.1 */ protected boolean attemptCommit() { pretendCommit(); if (isValid()) { DefaultUndoManager.this.commit(); return true; } return false; }
/** * Closes the current editing command and opens a new one. */ private void commit() { // if fCurrent has never been placed on the command stack, do so now. // this can happen when there are multiple programmatically commits in a single // document change. if (fLastAddedCommand != fCurrent) { fCurrent.pretendCommit(); if (fCurrent.isValid()) addToCommandStack(fCurrent); } fCurrent.commit(); }