private CommandContributionItem getCommandContributionItem( String commandId, String menuLabel) { CommandContributionItemParameter parameter = new CommandContributionItemParameter( site, commandId, commandId, CommandContributionItem.STYLE_PUSH); parameter.label = menuLabel; return new CommandContributionItem(parameter); }
private CommandContributionItem getCommandContributionItem( String commandId, String menuLabel, Map<String, String> parameters) { CommandContributionItemParameter parameter = new CommandContributionItemParameter( site, commandId, commandId, CommandContributionItem.STYLE_PUSH); parameter.label = menuLabel; parameter.parameters = parameters; return new CommandContributionItem(parameter); } }
private IContributionItem createShowRepositoriesViewItem() { CommandContributionItemParameter parm = new CommandContributionItemParameter(PlatformUI.getWorkbench(), RepositoryUi.ID_VIEW_REPOSITORIES, IWorkbenchCommandConstants.VIEWS_SHOW_VIEW, CommandContributionItem.STYLE_PUSH); Map<String, String> targetId = new HashMap<String, String>(); targetId.put(VIEWS_SHOW_VIEW_PARM_ID, RepositoryUi.ID_VIEW_REPOSITORIES); parm.parameters = targetId; parm.label = "Show Repositories View"; if (parm.label.length() > 0) { parm.mnemonic = parm.label.substring(0, 1); } //parm.icon = BuildImages.VIEW_BUILDS; return new CommandContributionItem(parm); }
private CommandContributionItem createCommandContributionItem( String commandId) { CommandContributionItemParameter parameter = new CommandContributionItemParameter( getSite(), commandId, commandId, CommandContributionItem.STYLE_PUSH); return new CommandContributionItem(parameter); }
/** * Return the appropriate command contribution item for the parameter. * @param viewDescriptor * @return the show in command contribution item */ protected IContributionItem getContributionItem(IViewDescriptor viewDescriptor) { CommandContributionItemParameter parm = new CommandContributionItemParameter( locator, viewDescriptor.getId(), IWorkbenchCommandConstants.NAVIGATE_SHOW_IN, CommandContributionItem.STYLE_PUSH); HashMap<String, String> targetId = new HashMap<>(); targetId.put(IWorkbenchCommandConstants.NAVIGATE_SHOW_IN_PARM_TARGET, viewDescriptor.getId()); parm.parameters = targetId; parm.label = viewDescriptor.getLabel(); if (parm.label.length() > 0) { parm.mnemonic = parm.label.substring(0, 1); } parm.icon = viewDescriptor.getImageDescriptor(); return new CommandContributionItem(parm); }
private void addItem(IServiceLocator serviceLocator, IContributionRoot additions, String commandLabel, String commandId, Map<String, Object> commandParamametersMap, String commandImageId, boolean visible) { CommandContributionItemParameter param = new CommandContributionItemParameter(serviceLocator, "", commandId, SWT.PUSH); param.label = commandLabel; param.icon = Activator.getImageDescriptor(commandImageId); param.parameters = commandParamametersMap; CommandContributionItem item = new CommandContributionItem(param); item.setVisible(visible); additions.addContributionItem(item, null); } }
continue; CommandContributionItem item = new CommandContributionItem(ccip); innerMgr.add(item);
@Override public IContributionItem create(final IWorkbenchWindow window) { if (window == null) { throw new IllegalArgumentException(); } CommandContributionItemParameter parameter = new CommandContributionItemParameter( window, COMMAND_ID, COMMAND_ID, null, WorkbenchImages .getImageDescriptor(IWorkbenchGraphicConstants.IMG_ETOOL_PIN_EDITOR), WorkbenchImages .getImageDescriptor(IWorkbenchGraphicConstants.IMG_ETOOL_PIN_EDITOR_DISABLED), null, null, null, WorkbenchMessages.PinEditorAction_toolTip, // Local workaround for http://bugs.eclipse.org/387583 CommandContributionItem.STYLE_CHECK, null, false); final CommandContributionItem action = new CommandContributionItem(parameter); action.setVisible(WorkbenchPlugin.getDefault().getPreferenceStore() .getBoolean(IPreferenceConstants.REUSE_EDITORS_BOOLEAN)); return action; } };
private CommandContributionItem createItem(String itemAction, final TableViewer tableViewer) { IWorkbench workbench = PlatformUI.getWorkbench(); CommandContributionItemParameter itemParam = new CommandContributionItemParameter( workbench, null, itemAction, STYLE_PUSH); IWorkbenchWindow activeWorkbenchWindow = workbench .getActiveWorkbenchWindow(); IHandlerService hsr = (IHandlerService) activeWorkbenchWindow .getService(IHandlerService.class); IEvaluationContext ctx = hsr.getCurrentState(); ctx.addVariable(ACTIVE_MENU_SELECTION_NAME, tableViewer.getSelection()); return new CommandContributionItem(itemParam); }
private CommandContributionItem createItem(String itemAction) { IWorkbench workbench = PlatformUI.getWorkbench(); CommandContributionItemParameter itemParam = new CommandContributionItemParameter( workbench, null, itemAction, STYLE_PUSH); IWorkbenchWindow activeWorkbenchWindow = workbench .getActiveWorkbenchWindow(); IHandlerService hsr = (IHandlerService) activeWorkbenchWindow .getService(IHandlerService.class); IEvaluationContext ctx = hsr.getCurrentState(); ctx.addVariable(ACTIVE_MENU_SELECTION_NAME, getContext().getSelection()); return new CommandContributionItem(itemParam); }
/** * Create the context menu for the text widget. * * @since 3.4 */ private void createTextMenu() { final MenuManager textManager = new MenuManager(); IServiceLocator serviceLocator = PlatformUI.getWorkbench(); ICommandService commandService = serviceLocator.getService(ICommandService.class); textManager.add(new CommandContributionItem( new CommandContributionItemParameter(serviceLocator, null, IWorkbenchCommandConstants.EDIT_COPY, CommandContributionItem.STYLE_PUSH))); if (commandService.getCommand(COPY_BUILD_ID_COMMAND).isDefined()) { textManager.add(new CommandContributionItem(new CommandContributionItemParameter(serviceLocator, null, COPY_BUILD_ID_COMMAND, CommandContributionItem.STYLE_PUSH))); } textManager.add(new CommandContributionItem(new CommandContributionItemParameter(serviceLocator, null, IWorkbenchCommandConstants.EDIT_SELECT_ALL, CommandContributionItem.STYLE_PUSH))); text.setMenu(textManager.createContextMenu(text)); text.addDisposeListener(e -> textManager.dispose()); }
private IContributionItem getItem(String actionId, String commandId, String image, String disabledImage, String label, String tooltip, String helpContextId) { ISharedImages sharedImages = getWindow().getWorkbench() .getSharedImages(); IActionCommandMappingService acms = getWindow() .getService(IActionCommandMappingService.class); acms.map(actionId, commandId); CommandContributionItemParameter commandParm = new CommandContributionItemParameter( getWindow(), actionId, commandId, null, sharedImages .getImageDescriptor(image), sharedImages .getImageDescriptor(disabledImage), null, label, null, tooltip, CommandContributionItem.STYLE_PUSH, null, false); return new CommandContributionItem(commandParm); } }
private void addSave(IMenuManager menu) { ICommandService commandService = fContainer.getWorkbenchPart().getSite().getService(ICommandService.class); final Command command= commandService.getCommand(IWorkbenchCommandConstants.FILE_SAVE); final IHandler handler = command.getHandler(); if (handler != null) { if (fSaveContributionItem == null) { fSaveContributionItem = new CommandContributionItem( new CommandContributionItemParameter(fContainer .getWorkbenchPart().getSite(), null, command .getId(), CommandContributionItem.STYLE_PUSH)); } // save is an editable dependent action, ie add only when edit // is possible if (handler.isHandled() && getSourceViewer().isEditable()) menu.add(fSaveContributionItem); } }
ccip.icon = imgService.getImageDescriptor(commandId); innerMgr.add(new CommandContributionItem(ccip));
CommandContributionItemParameter contributionParameters = new CommandContributionItemParameter(workbenchWindow, null, MaximizeActiveViewHandler.COMMAND_ID, params, InspectIT.getDefault().getImageDescriptor(InspectITImages.IMG_WINDOW), null, null, null, null, getTooltipTextForMaximizeContributionItem(), SWT.CHECK, null, true); CommandContributionItem maximizeCommandContribution = new CommandContributionItem(contributionParameters); toolBarManager.add(maximizeCommandContribution);
minimizeItem = new CommandContributionItem(minimizeParam); CommandContributionItemParameter zoomParam = new CommandContributionItemParameter(window, null, "org.eclipse.ui.cocoa.zoomWindow", CommandContributionItem.STYLE_PUSH); //$NON-NLS-1$ zoomItem = new CommandContributionItem(zoomParam); CommandContributionItemParameter fullscreenParam = new CommandContributionItemParameter( window, null, "org.eclipse.ui.cocoa.fullscreenWindow", CommandContributionItem.STYLE_PUSH); //$NON-NLS-1$ fullscreenItem = new CommandContributionItem(fullscreenParam); CommandContributionItemParameter arrangeWindowsParam = new CommandContributionItemParameter(window, null, "org.eclipse.ui.cocoa.arrangeWindowsInFront", CommandContributionItem.STYLE_PUSH); //$NON-NLS-1$ arrangeWindowsItem = new CommandContributionItem(arrangeWindowsParam);