@Override public boolean canUndoOrRedo() { if (indexOfNextAdd == edits.size()) { return canUndo(); } else { return canRedo(); } }
@Override public void undo() throws CannotUndoException { if (inProgress) { UndoableEdit edit = editToBeUndone(); if (edit == null) { throw new CannotUndoException(); } undoTo(edit); } else { if (!canUndo()) { throw new CannotUndoException(); } int i = edits.size() - 1; try { for (; i >= 0; i--) { edits.get(i).undo(); // may throw CannotUndoException } hasBeenDone = false; } finally { if (i != -1) { // i-th edit's undo failed => redo the ones above int size = edits.size(); while (++i < size) { edits.get(i).redo(); } } } } cs.fireChange(); }
@Override public String getUndoPresentationName() { // The following code does an original code of: return this.canUndo() ? super.getUndoPresentationName() : ""; if (canUndo()) { // UndoManager.getUndoPresentationName() follows if (inProgress) { if (canUndo()) { return editToBeUndone().getUndoPresentationName(); } else { return UIManager.getString("AbstractUndoableEdit.undoText"); } } else { UndoableEdit last = lastEdit(); if (last != null) { return last.getUndoPresentationName(); } else { String name = getPresentationName(); if (!"".equals(name)) { name = UIManager.getString("AbstractUndoableEdit.undoText") + " " + name; } else { name = UIManager.getString("AbstractUndoableEdit.undoText"); } return name; } } } else { return ""; } }
public String getUndoPresentationName() { return this.canUndo() ? super.getUndoPresentationName() : ""; // NOI18N }
public String getUndoPresentationName() { return this.canUndo() ? super.getUndoPresentationName() : ""; // NOI18N }
public boolean canUndo() { return original.canUndo(); }
@Override public synchronized boolean canUndo() { return super.canUndo() && (component != null ? component.hasFocus() : false); }