@Override protected boolean showPage(IPreferenceNode node) { final boolean success = super.showPage(node); if (success) { history.addHistoryEntry(new PreferenceHistoryEntry(node.getId(), node.getLabelText(), null)); } return success; }
@Override public boolean close() { if (showViewHandler != null) { IHandlerService service = PlatformUI.getWorkbench().getService(IHandlerService.class); service.deactivateHandler(showViewHandler); showViewHandler.getHandler().dispose(); showViewHandler = null; } removeKeyScrolling(); history.dispose(); return super.close(); }
/** * Get the toolbar for the container * * @return Control */ Control getContainerToolBar(Composite composite) { final ToolBarManager historyManager = new ToolBarManager(SWT.HORIZONTAL | SWT.FLAT); historyManager.createControl(composite); history.createHistoryControls(historyManager.getControl(), historyManager); Action popupMenuAction = new Action() { @Override public ImageDescriptor getImageDescriptor() { return WorkbenchImages.getImageDescriptor(IWorkbenchGraphicConstants.IMG_LCL_VIEW_MENU); } @Override public void run() { MenuManager manager = new MenuManager(); manager.add( new Action() { @Override public void run() { sash.addFocusListener( new FocusAdapter() { @Override public void focusGained(FocusEvent e) { sash.setBackground( sash.getDisplay().getSystemColor(SWT.COLOR_LIST_SELECTION)); } @Override public void focusLost(FocusEvent e) { sash.setBackground( sash.getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND)); } }); sash.setFocus(); } @Override public String getText() { return WorkbenchMessages.FilteredPreferenceDialog_Resize; } }); manager.add( new Action() { @Override public void run() { activeKeyScrolling(); } @Override public String getText() { return WorkbenchMessages.FilteredPreferenceDialog_Key_Scrolling; } }); Menu menu = manager.createContextMenu(getShell()); Rectangle bounds = historyManager.getControl().getBounds(); Point topLeft = new Point(bounds.x + bounds.width, bounds.y + bounds.height); topLeft = historyManager.getControl().toDisplay(topLeft); menu.setLocation(topLeft.x, topLeft.y); menu.setVisible(true); } }; popupMenuAction.setToolTipText(WorkbenchMessages.FilteredPreferenceDialog_FilterToolTip); historyManager.add(popupMenuAction); IHandlerService service = PlatformUI.getWorkbench().getService(IHandlerService.class); showViewHandler = service.activateHandler( IWorkbenchCommandConstants.WINDOW_SHOW_VIEW_MENU, new ActionHandler(popupMenuAction), new ActiveShellExpression(getShell())); historyManager.update(false); return historyManager.getControl(); }