@Override protected List<IAction> getActions(IMenuService menuService) { Object context = menuService.getCurrentState(); IProject project = getProjectFromContext(context); List<IAction> actions = new ArrayList<IAction>(); if (project != null) { StandaloneFacetHandler handler = new StandaloneFacetHandler(project); if (handler.canAddFacet()) { actions.add(new ConvertToStandaloneAction(project)); } else if (handler.hasFacet()) { actions.add(new RemoveStandaloneAction(project)); } } return actions; }
@Override public void createContributionItems(IServiceLocator serviceLocator, IContributionRoot additions) { IMenuService menuService = (IMenuService) serviceLocator.getService(IMenuService.class); if (menuService == null) { CloudFoundryPlugin .logError("Unable to retrieve Eclipse menu service. Cannot add Cloud Foundry context menus."); //$NON-NLS-1$ return; } List<IAction> debugActions = getActions(menuService); for (IAction action : debugActions) { additions.addContributionItem(new ActionContributionItem(action), new Expression() { public EvaluationResult evaluate(IEvaluationContext context) { return EvaluationResult.TRUE; } public void collectExpressionInfo(ExpressionInfo info) { } }); } }
@Override public void createContributionItems(IServiceLocator serviceLocator, IContributionRoot additions) { IMenuService menuService = (IMenuService) serviceLocator.getService(IMenuService.class); if (menuService == null) { DockerFoundryPlugin .logError("Unable to retrieve Eclipse menu service. Cannot add Cloud Foundry context menus."); //$NON-NLS-1$ return; } List<IAction> debugActions = getActions(menuService); for (IAction action : debugActions) { additions.addContributionItem(new ActionContributionItem(action), new Expression() { public EvaluationResult evaluate(IEvaluationContext context) { return EvaluationResult.TRUE; } public void collectExpressionInfo(ExpressionInfo info) { } }); } }
/** * The default behavior is to show the same content as clicking the dropdown arrow. Subclass could override. * * @param parent * the parent toolbar */ protected void run(ToolBar parent) { if (!isEnabled()) { return; } Point toolbarLocation = parent.getLocation(); toolbarLocation = parent.getParent().toDisplay(toolbarLocation.x, toolbarLocation.y); Point toolbarSize = parent.getSize(); MenuManager menuManager = new MenuManager(null, getMenuId()); IMenuService menuService = (IMenuService) partSite.getService(IMenuService.class); menuService.populateContributionManager(menuManager, MenuUtil.menuUri(menuManager.getId())); fillMenu(menuManager); Menu menu = menuManager.createContextMenu(parent); menu.setLocation(toolbarLocation.x, toolbarLocation.y + toolbarSize.y + 2); menu.setVisible(true); }
/** * 创建自定义的插件菜单 2012-03-07 * @return ; */ /* * private MenuManager createAutoPluginMenu() { MenuManager menu = new MenuManager("asdfasd", * "net.heartsome.cat.ts.ui.menu.plugin"); // menu = MenuManag * * // menu.appendToGroup(groupName, item) menu.add(helpSearchAction); return menu; } */ @Override public void dispose() { if (isDisposed) { return; } isDisposed = true; IMenuService menuService = (IMenuService) window.getService(IMenuService.class); menuService.releaseContributions(coolbarPopupMenuManager); coolbarPopupMenuManager.dispose(); super.dispose(); }
@Override public void fillPopupMenu(IMenuManager manager, SchemaViewer viewer) { for (String section : ORDERED_SECTIONS) { manager.add(new Separator(section)); } IMenuService service = serviceProvider.getMenuService(); service.populateContributionManager((ContributionManager) manager, getPopupMenuId()); }
@Override public Object execute(ExecutionEvent event) throws ExecutionException { ToolItem toolItem = findToolItem(event); String menuId = getMenuId(toolItem); IMenuService menuService = ServiceUtils.getService(event, IMenuService.class); openDropDownMenu(menuId, toolItem, menuService); return null; }
@Override protected List<IAction> getActions(IMenuService menuService) { // Return all context menu actions that are applicable to the given // context Object context = menuService.getCurrentState(); List<IAction> actions = new ArrayList<IAction>(); for (MenuActionHandler<?> actionHandler : ACTION_HANDLERS) { List<IAction> handlerActions = actionHandler.getActions(context); if (handlerActions != null && !handlerActions.isEmpty()) { actions.addAll(handlerActions); } } return actions; }
/** * This is a callback that will allow us to create the viewer and initialize it. * * @param parent * The parent ui element to create this editor in. */ public void createPartControl(Composite parent) { toolkit = new FormToolkit(parent.getDisplay()); form = toolkit.createForm(parent); form.setText("SPLevo Refinement Browser"); toolkit.decorateFormHeading(form); form.getMenuManager().add(new ApplyRefinementsAction(this, "Apply Refinements")); form.getMenuManager().add(new ApplySelectedRefinementsAction(this, "Apply Selected Refinements")); form.getBody().setLayout(new FillLayout(SWT.HORIZONTAL)); SashForm sashForm = new SashForm(form.getBody(), SWT.FILL); sashForm.setSashWidth(1); sashForm.setBackground(SWTResourceManager.getColor(SWT.COLOR_GRAY)); toolkit.adapt(sashForm); toolkit.paintBordersFor(sashForm); createRefinementListView(sashForm); createRefinementDetails(sashForm); // The listener must be added after the two connected required widgets have been created refinementListView.addSelectionChangedListener(new RefinementSelectionListener(detailsView)); refinementListView.addSelectionChangedListener(new RefinementInfoSelectionListener(detailsView)); IActionBars actionBars = getEditorSite().getActionBars(); refinementListView.addSelectionChangedListener(new RefinementActionBarListener(actionBars)); sashForm.setWeights(new int[] { 2, 8 }); ToolBarManager manager = (ToolBarManager) form.getToolBarManager(); manager.add(new ApplyRefinementsAction(this, "Apply Refinements")); manager.add(new ApplySelectedRefinementsAction(this, "Apply Selected Refinements")); manager.add(new ToggleVisualizationAction(this, getEnableVisualizationDefault())); manager.add(new CancelAction(this, "Cancel and close")); IMenuService menuService = (IMenuService) getSite().getService(IMenuService.class); menuService.populateContributionManager(manager, "popup:formsToolBar"); manager.update(true); initContextMenu(); initToolTips(refinementListView); }
public void contributeToMenu( IMenuManager menubar ) { super.contributeToMenu( menubar ); updateEditMenu( menubar ); // Insert Menu MenuManager insertMenu = new MenuManager( Messages.getString( "DesignerActionBarContributor.menu.insert" ), M_INSERT ); //$NON-NLS-1$ createInsertMenu( insertMenu ); insertMenu.addMenuListener( new IMenuListener( ) { public void menuAboutToShow( IMenuManager manager ) { manager.removeAll( ); insertElementActions = null; createInsertMenu( manager ); } } ); // insertMenu.add( getAction( ImportLibraryAction.ID ) ); menubar.insertAfter( IWorkbenchActionConstants.M_EDIT, insertMenu ); // Element Menu MenuManager elementMenu = new MenuManager( Messages.getString( "DesignerActionBarContributor.menu.element" ), M_ELEMENT ); //$NON-NLS-1$ contributeElementMenu( elementMenu ); menubar.insertAfter( M_INSERT, elementMenu ); // Data Menu MenuManager dataMenu = new MenuManager( Messages.getString( "DesignerActionBarContributor.menu.data" ), M_DATA ); //$NON-NLS-1$ // the data actions are now registered through eclipse menu extensions IMenuService menuService = (IMenuService) PlatformUI.getWorkbench( ) .getService( IMenuService.class ); menuService.populateContributionManager( dataMenu, "menu:birtData" ); //$NON-NLS-1$ menubar.insertAfter( M_ELEMENT, dataMenu ); menubar.update( ); }
@Override public IMenuService getMenuService() { return (IMenuService) PlatformUI.getWorkbench().getService(IMenuService.class); }
protected void fillPopupMenu(IMenuManager manager) { IMenuService service = (IMenuService) editor.getServiceProvider().getMenuService(); service.populateContributionManager((ContributionManager) manager, POPUP_MENU_ID); }
protected void populateToolBar(ToolBarManager manager, String toolBarId) { IMenuService service = serviceProvider.getMenuService(); service.populateContributionManager(manager, toolBarId); }
/** * Fills the coolbar with the workbench actions. */ protected void fillCoolBar(ICoolBarManager coolBar) { IActionBarConfigurer2 actionBarConfigurer = (IActionBarConfigurer2) getActionBarConfigurer(); // Set up the context Menu coolbarPopupMenuManager = new MenuManager(); coolBar.setContextMenuManager(coolbarPopupMenuManager); IMenuService menuService = (IMenuService) window.getService(IMenuService.class); menuService.populateContributionManager(coolbarPopupMenuManager, "popup:windowCoolbarContextMenu"); //$NON-NLS-1$ // File Group IToolBarManager fileToolBar = actionBarConfigurer.createToolBarManager(); fileToolBar.add(new Separator(IWorkbenchActionConstants.NEW_GROUP)); fileToolBar.add(new GroupMarker(IWorkbenchActionConstants.NEW_EXT)); fileToolBar.add(new GroupMarker(IWorkbenchActionConstants.SAVE_GROUP)); fileToolBar.add(saveAction); fileToolBar.add(saveAllAction); fileToolBar.add(new GroupMarker(IWorkbenchActionConstants.SAVE_EXT)); fileToolBar.add(getPrintItem()); fileToolBar.add(new GroupMarker(IWorkbenchActionConstants.PRINT_EXT)); fileToolBar.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS)); // Add to the cool bar manager coolBar.add(actionBarConfigurer.createToolBarContributionItem(fileToolBar, IWorkbenchActionConstants.TOOLBAR_FILE)); coolBar.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS)); coolBar.add(new GroupMarker(IWorkbenchActionConstants.GROUP_HELP)); // Help group IToolBarManager helpToolBar = actionBarConfigurer.createToolBarManager(); helpToolBar.add(new Separator(IWorkbenchActionConstants.GROUP_HELP)); // helpToolBar.add(searchComboItem); // Add the group for applications to contribute helpToolBar.add(new GroupMarker(IWorkbenchActionConstants.GROUP_APP)); // Add to the cool bar manager coolBar.add(actionBarConfigurer.createToolBarContributionItem(helpToolBar, IWorkbenchActionConstants.TOOLBAR_HELP)); }
/** * Disposes any resources and unhooks any listeners that are no longer needed. Called when the * window is closed. */ public void dispose() { if (isDisposed) { return; } isDisposed = true; IMenuService menuService = (IMenuService) window.getService(IMenuService.class); menuService.releaseContributions(coolbarPopupMenuManager); coolbarPopupMenuManager.dispose(); getActionBarConfigurer().getStatusLineManager().remove(statusLineItem); showInQuickMenu.dispose(); newQuickMenu.dispose(); // null out actions to make leak debugging easier closeAction = null; closeAllAction = null; closeAllSavedAction = null; closeOthersAction = null; saveAction = null; saveAllAction = null; newWindowAction = null; newEditorAction = null; helpContentsAction = null; helpSearchAction = null; dynamicHelpAction = null; aboutAction = null; saveAsAction = null; closePerspAction = null; closeAllPerspsAction = null; showViewMenuAction = null; undoAction = null; redoAction = null; quitAction = null; openWorkspaceAction = null; projectPropertyDialogAction = null; newWizardAction = null; quickStartAction = null; tipsAndTricksAction = null; showInQuickMenu = null; newQuickMenu = null; statusLineItem = null; introAction = null; super.dispose(); }
@Override protected void fillCoolBar(ICoolBarManager coolBar) { // Set up the context Menu coolbarPopupMenuManager = new MenuManager(); coolbarPopupMenuManager.add(new ActionContributionItem(lockToolBarAction)); coolBar.setContextMenuManager(coolbarPopupMenuManager); IMenuService menuService = (IMenuService) window.getService(IMenuService.class); menuService.populateContributionManager(coolbarPopupMenuManager, "popup:windowCoolbarContextMenu"); coolBar.add(new GroupMarker("group.file")); coolBar.add(new GroupMarker("group.search")); createToolItem(coolBar); coolBar.add(new GroupMarker("group.new.menu")); coolBar.add(new GroupMarker("group.undoredo")); coolBar.add(new GroupMarker("group.tu")); coolBar.add(new GroupMarker("group.tmxtool")); coolBar.add(new GroupMarker("group.tmxclear")); coolBar.add(new GroupMarker("group.copySource")); coolBar.add(new GroupMarker("group.completeTranslation")); coolBar.add(new GroupMarker("group.approve")); coolBar.add(new GroupMarker("group.addTerm")); coolBar.add(new GroupMarker("group.preview")); coolBar.add(new GroupMarker("group.tagoperation")); coolBar.add(new GroupMarker("group.sourceoperation")); coolBar.add(new GroupMarker("group.deleteTrans")); coolBar.add(new GroupMarker("group.changeLayout")); coolBar.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS)); coolBar.add(new GroupMarker(IWorkbenchActionConstants.GROUP_EDITOR)); coolBar.add(new GroupMarker(IWorkbenchActionConstants.GROUP_HELP)); //未提供 24 位图标,屏蔽工具栏。 // IToolBarManager toolbar = new ToolBarManager(coolBar.getStyle()); // coolBar.add(new ToolBarContributionItem(toolbar, "help")); // toolbar.add(helpAction); }
@Override protected void fillCoolBar(ICoolBarManager coolBar) { // Set up the context Menu coolbarPopupMenuManager = new MenuManager(); coolbarPopupMenuManager.add(new ActionContributionItem(lockToolBarAction)); coolBar.setContextMenuManager(coolbarPopupMenuManager); IMenuService menuService = (IMenuService) window.getService(IMenuService.class); menuService.populateContributionManager(coolbarPopupMenuManager, "popup:windowCoolbarContextMenu"); coolBar.add(new GroupMarker("group.file")); coolBar.add(new GroupMarker("group.new.menu")); coolBar.add(new GroupMarker("group.undoredo")); coolBar.add(new GroupMarker("group.copySource")); coolBar.add(new GroupMarker("group.search")); createToolItem(coolBar); coolBar.add(new GroupMarker("group.completeTranslation")); coolBar.add(new GroupMarker("group.approve")); coolBar.add(new GroupMarker("group.addTerm")); coolBar.add(new GroupMarker("group.preview")); coolBar.add(new GroupMarker("group.tagoperation")); coolBar.add(new GroupMarker("group.sourceoperation")); coolBar.add(new GroupMarker("group.deleteTrans")); coolBar.add(new GroupMarker("group.changeLayout")); coolBar.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS)); coolBar.add(new GroupMarker(IWorkbenchActionConstants.GROUP_EDITOR)); coolBar.add(new GroupMarker(IWorkbenchActionConstants.GROUP_HELP)); }
IMenuService getMenuService();
protected abstract List<IAction> getActions(IMenuService menuService);