public void dispose() {
   super.dispose();
   undoAction.removePropertyChangeListener(this);
   redoAction.removePropertyChangeListener(this);
   if (workbench != null) {
     workbench.removePartListener(this);
   }
 }
 public void init(IActionBars bars) {
   super.init(bars);
   IMenuManager menuMgr = bars.getMenuManager();
   IMenuManager editMenu = menuMgr.findMenuUsingPath(IWorkbenchActionConstants.M_EDIT);
   if (editMenu != null) {
     IContributionItem[] items = editMenu.getItems();
     undoAction = ((ActionContributionItem) items[0]).getAction();
     redoAction = ((ActionContributionItem) items[1]).getAction();
     undoAction.addPropertyChangeListener(this);
     redoAction.addPropertyChangeListener(this);
   }
 }
 public void setActiveEditor(IEditorPart targetEditor) {
   super.setActiveEditor(targetEditor);
   workbench = targetEditor.getSite().getWorkbenchWindow().getActivePage();
   workbench.addPartListener(this);
   targetEditor.addPropertyListener(this);
 }