/** * <p> * Fills aMenuManager with menu contributions from the * {@link NavigatorActionService}. * </p> * * @param aMenuManager * A popup menu * @see NavigatorActionService#fillContextMenu(IMenuManager) * */ protected void fillContextMenu(IMenuManager aMenuManager) { ISelection selection = commonNavigator.getCommonViewer().getSelection(); actionService.setContext(new ActionContext(selection)); actionService.fillContextMenu(aMenuManager); }
protected void fillContextMenu(StructuredViewer viewer, IMenuManager manager) { // Clear any handlers from the menu if (manager instanceof CommonMenuManager) { CommonMenuManager cmm = (CommonMenuManager) manager; cmm.clearHandlers(); } // Add the actions from the service (which willal so add the groups) ISelection selection = getViewer().getSelection(); actionService.setContext(new ActionContext(selection)); actionService.fillContextMenu(manager); // Add any programmatic menu items super.fillContextMenu(viewer, manager); }
@Override protected void fillContextMenu(StructuredViewer viewer, IMenuManager manager) { // Clear any handlers from the menu if (manager instanceof CommonMenuManager) { CommonMenuManager cmm = (CommonMenuManager) manager; cmm.clearHandlers(); } // Add the actions from the service (which willal so add the groups) ISelection selection = getViewer().getSelection(); actionService.setContext(new ActionContext(selection)); actionService.fillContextMenu(manager); // Add any programmatic menu items super.fillContextMenu(viewer, manager); }
/** * * @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()); } }
protected void updateActionBars(IStructuredSelection selection) { super.updateActionBars(selection); if (!getConfiguration().getSite().isModal()) { actionService.setContext(new ActionContext(selection)); // This is non-standard behavior that is required by the common navigator framework (see bug 122808) SubActionBars subActionBars = (SubActionBars)getConfiguration().getProperty(PROP_ACTION_SERVICE_ACTION_BARS); if (subActionBars == null) { subActionBars = new CommonSubActionBars(getConfiguration().getSite().getActionBars()); getConfiguration().setProperty(PROP_ACTION_SERVICE_ACTION_BARS, subActionBars); } actionService.fillActionBars(subActionBars); } }
@Override protected void updateActionBars(IStructuredSelection selection) { super.updateActionBars(selection); if (!getConfiguration().getSite().isModal()) { actionService.setContext(new ActionContext(selection)); // This is non-standard behavior that is required by the common navigator framework (see bug 122808) SubActionBars subActionBars = (SubActionBars)getConfiguration().getProperty(PROP_ACTION_SERVICE_ACTION_BARS); if (subActionBars == null) { subActionBars = new CommonSubActionBars(getConfiguration().getSite().getActionBars()); getConfiguration().setProperty(PROP_ACTION_SERVICE_ACTION_BARS, subActionBars); } actionService.fillActionBars(subActionBars); } }
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); commonNavigator.getCommonViewer().addOpenListener(new IOpenListener() { public void open(OpenEvent event) { actionService.setContext(new ActionContext(commonNavigator.getCommonViewer().getSelection())); actionService.fillActionBars(commonNavigator.getViewSite().getActionBars()); openAction.run(); } }); if(memento != null) restoreState(memento); initContextMenu(); initViewMenu(); }