コード例 #1
0
 /**
  * Performs the Undo action. A new corresponding Redo step is automatically pushed to the stack.
  */
 private void undo() {
   if (stack.hasUndo()) {
     isUndo = true;
     revertEvent(stack.popUndo());
     isUndo = false;
   }
 }
コード例 #2
0
 /**
  * Performs the Redo action. A new corresponding Undo step is automatically pushed to the stack.
  */
 private void redo() {
   if (stack.hasRedo()) {
     isRedo = true;
     revertEvent(stack.popRedo());
     isRedo = false;
   }
 }
コード例 #3
0
 /**
  * Creates a corresponding Undo or Redo step from the given event and pushes it to the stack. The
  * Redo stack is, logically, emptied if the event comes from a normal user action.
  *
  * @param event
  * @see org.eclipse.swt.custom.ExtendedModifyListener#modifyText(org.eclipse.
  *     swt.custom.ExtendedModifyEvent)
  */
 public void modifyText(ExtendedModifyEvent event) {
   if (isUndo) {
     stack.pushRedo(event);
   } else { // is Redo or a normal user action
     stack.pushUndo(event);
     if (!isRedo) {
       stack.clearRedo();
       // TODO Switch to treat consecutive characters as one event?
     }
   }
 }