예제 #1
0
  /** @return operation that reverts the effect of the latest local operation in the given editor */
  protected Operation calcUndoOperation(SPath editor) {

    if (!undoHistory.canUndo(editor)) return new NoOperation(); // nothing to undo

    Operation lastLocal = undoHistory.getLatestLocal(editor);

    assert lastLocal != null;

    Operation undoOperation = lastLocal.invert();

    for (EditorHistoryEntry entry : undoHistory.entriesToLatestLocal(editor)) {

      Operation operation = entry.getOperation();

      undoOperation = transformation.transform(undoOperation, operation, Boolean.TRUE);

      log.debug("transformed undo: " + undoOperation);
    }

    undoHistory.replaceType(editor, lastLocal, Type.LOCAL, Type.REMOTE);
    // it is not relevant any more, so it is set remote

    undoHistory.add(editor, Type.REDOABLE, undoOperation); // save for redo

    return undoOperation;
  }
예제 #2
0
  /** @return operation that reverts the effect of the latest undo in the given editor */
  protected Operation calcRedoOperation(SPath editor) {

    if (!undoHistory.canRedo(editor)) return new NoOperation(); // nothing to redo

    Operation lastUndo = undoHistory.getLatestRedoable(editor);

    assert lastUndo != null;

    Operation redoOperation = lastUndo.invert();

    for (EditorHistoryEntry entry : undoHistory.entriesToLatestRedoable(editor)) {

      redoOperation = transformation.transform(redoOperation, entry.getOperation(), Boolean.TRUE);
    }
    undoHistory.replaceType(editor, lastUndo, Type.REDOABLE, Type.REMOTE);
    // it is not relevant any more, so it is set remote

    undoHistory.add(editor, Type.LOCAL, redoOperation);
    log.debug("adding " + lastUndo + " (cause: redo internal)");

    return redoOperation;
  }