private void init(IMemento memento) { updateActionBars = new UpdateActionBarsJob(commonNavigator.getTitle()); CommonViewer commonViewer = commonNavigator.getCommonViewer(); commonViewer.addSelectionChangedListener(this); commonViewer.addPostSelectionChangedListener(statusBarListener); updateStatusBar(commonViewer.getSelection()); ICommonViewerSite commonViewerSite = CommonViewerSiteFactory.createCommonViewerSite(commonNavigator.getViewSite()); actionService = new NavigatorActionService( commonViewerSite, commonViewer, commonViewer.getNavigatorContentService()); final RetargetAction openAction = new RetargetAction(ICommonActionConstants.OPEN, CommonNavigatorMessages.Open_action_label); commonNavigator.getViewSite().getPage().addPartListener(openAction); openAction.setActionDefinitionId(ICommonActionConstants.OPEN); // RAP [bmichalik]: help system // new OpenAndLinkWithEditorHelper(commonNavigator.getCommonViewer()) { // protected void activate(ISelection selection) { // final int currentMode = OpenStrategy.getOpenMethod(); // try { // /* // * XXX: // * Currently the only way to activate the editor because there is no API to // * get an editor input for a given object. // */ // OpenStrategy.setOpenMethod(OpenStrategy.DOUBLE_CLICK); // actionService.setContext(new // ActionContext(commonNavigator.getCommonViewer().getSelection())); // actionService.fillActionBars(commonNavigator.getViewSite().getActionBars()); // openAction.run(); // } finally { // OpenStrategy.setOpenMethod(currentMode); // } // } // // protected void linkToEditor(ISelection selection) { // // do nothing: this is handled by // org.eclipse.ui.internal.navigator.actions.LinkEditorAction // } // // protected void open(ISelection selection, boolean activate) { // actionService.setContext(new // ActionContext(commonNavigator.getCommonViewer().getSelection())); // actionService.fillActionBars(commonNavigator.getViewSite().getActionBars()); // openAction.run(); // } // // }; if (memento != null) restoreState(memento); initContextMenu(); initViewMenu(); }
protected void initViewMenu() { IMenuManager viewMenu = commonNavigator.getViewSite().getActionBars().getMenuManager(); viewMenu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS)); viewMenu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS + "-end")); // $NON-NLS-1$ updateActionBars.schedule(NavigatorPlugin.ACTION_BAR_DELAY); }
/** * @param anEvent An event indicating the current selection of the {@link CommonViewer} * @see * org.eclipse.jface.viewers.ISelectionChangedListener#selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent) */ public void selectionChanged(SelectionChangedEvent anEvent) { if (anEvent.getSelection() instanceof IStructuredSelection) { IStructuredSelection structuredSelection = (IStructuredSelection) anEvent.getSelection(); actionService.setContext(new ActionContext(structuredSelection)); actionService.fillActionBars(commonNavigator.getViewSite().getActionBars()); } }
/** * Adds listeners to aNavigator to listen for selection changes and respond to mouse events. * * @param aNavigator The CommonNavigator managed by this class. Requires a non-null value. * @param aMemento a memento for restoring state, or <code>null</code> */ public CommonNavigatorManager(CommonNavigator aNavigator, IMemento aMemento) { super(); commonNavigator = aNavigator; contentService = commonNavigator.getNavigatorContentService(); statusLineManager = commonNavigator.getViewSite().getActionBars().getStatusLineManager(); commonDescriptionProvider = contentService.createCommonDescriptionProvider(); labelProvider = (ILabelProvider) commonNavigator.getCommonViewer().getLabelProvider(); init(aMemento); }