/** Do the last entry that was undone again. */ public void redo() { if (canRedo()) { final HistoryAction entry = redoList.removeLast(); entry.redo(); undoList.addLast(entry); } }
/** Undo the last entry that was added to this history. */ public void undo() { if (canUndo()) { final HistoryAction entry = undoList.removeLast(); entry.undo(); redoList.addLast(entry); } }
/** Executes the action-list and changes the status */ public void execute() { if (_actions.size() == 0) return; int type = ((HistoryAction) _actions.get(0))._actionType; if (type == HistoryAction.UNDO) { // we have to walk backwards because the actions have to be undone in // the opposite order ListIterator it = _actions.listIterator(_actions.size()); while (it.hasPrevious()) { HistoryAction action = (HistoryAction) it.previous(); action.performAction(); } } else { Iterator it = _actions.iterator(); while (it.hasNext()) { HistoryAction action = (HistoryAction) it.next(); action.performAction(); } } }