public void init(IViewPart view) { IActionBars actionBars = view.getViewSite().getActionBars(); IToolBarManager toolBarManager = actionBars.getToolBarManager(); final UndoAction undoAction = new UndoAction(view); toolBarManager.add(undoAction); undoAction.setImageDescriptor(Activator.imageDescriptorFromPlugin(Activator.PLUGIN_ID, "icons/undo.png")); final RedoAction redoAction = new RedoAction(view); redoAction.setImageDescriptor(Activator.imageDescriptorFromPlugin(Activator.PLUGIN_ID, "icons/redo.png")); toolBarManager.add(redoAction); viewer.getEditDomain().getCommandStack().addCommandStackListener( new CommandStackListener() { @Override public void commandStackChanged(EventObject event) { undoAction.setEnabled(undoAction.isEnabled()); redoAction.setEnabled(redoAction.isEnabled()); } }); }
/** * @see org.eclipse.gef.commands.CommandStack#addCommandStackListener(org.eclipse.gef.commands.CommandStackListener) */ @Override public void addCommandStackListener(CommandStackListener listener) { if (!commandStackListenerList.contains(listener)) { commandStackListenerList.add(listener); } super.addCommandStackListener(listener); }
/** * * void */ @SuppressWarnings("unused") private void fireNotifyCommandStackListener() { for (Iterator<CommandStackListener> iter = this.commandStackListenerList.iterator(); iter.hasNext();) { iter.next().commandStackChanged(new EventObject(this)); } }
/** * Constructs the root entry using the given command stack. * * @param commandStack * the command stack to use * @since 3.1 */ public UndoablePropertySheetEntry(CommandStack commandStack) { this.commandStack = commandStack; this.commandStackListener = new CommandStackListener() { public void commandStackChanged(EventObject e) { refreshFromRoot(); } }; this.commandStack.addCommandStackListener(commandStackListener); }
/** * @deprecated * * Do not use, use * addCommandStackListener(ActivityStackListener) instead * * @see org.eclipse.gef.commands.CommandStack#addCommandStackListener(org.eclipse.gef.commands.CommandStackListener) */ public void addCommandStackListener( CommandStackListener listener ) { // use addCommandStackListener(ActivityStackListener) instead // this method will called by GEF. // can't assert false. // see bugzilla 147687 // assert false; }
protected CommandStackListener getDelegatingCommandStackListener() { return this.delegatingCommandStackListener; }
/** * @deprecated * * Do not use, use * removeCommandStackListener(ActivityStackListener) instead * * @see org.eclipse.gef.commands.CommandStack#removeCommandStackListener(org.eclipse.gef.commands.CommandStackListener) */ public void removeCommandStackListener( CommandStackListener listener ) { // use removeCommandStackListener(ActivityStackListener) instead // assert false; }