/** * Constructs a new {@link UndoablePropertySheetPage}. * * @param commandStack * The {@link CommandStack} shared with the editor. * @param undoAction * The global action handler to be registered for undo * operations. * @param redoAction * The global action handler to be registered for redo * operations. */ public UndoablePropertySheetPage(final CommandStack commandStack, IAction undoAction, IAction redoAction) { this.undoHandler = undoAction; this.redoHandler = redoAction; this.commandStack = commandStack; this.commandStackEventListener = new CommandStackEventListener() { public void stackChanged(CommandStackEvent event) { if (event.getDetail() == CommandStack.PRE_UNDO || event.getDetail() == CommandStack.PRE_REDO) { // ensure the property sheet entry looses its current edit // state, otherwise it may revert the undo/redo operation // within valueChanged when the editor is activated again. refresh(); } } }; commandStack.addCommandStackEventListener(commandStackEventListener); setRootEntry(new UndoablePropertySheetEntry(commandStack)); }
/** * @see org.eclipse.gef.commands.CommandStack#addCommandStackEventListener(org.eclipse.gef.commands.CommandStackEventListener) */ @Override public void addCommandStackEventListener(CommandStackEventListener listener) { if (!commandStackEventListenerList.contains(listener)) { commandStackEventListenerList.add(listener); } super.addCommandStackEventListener(listener); }