void activate() { if (handler != null) { /* * Next check ensures that we don't overwrite newly activated editor contributions. * For details see https://bugs.eclipse.org/bugs/show_bug.cgi?id=297834. */ if (!handler.getClass().isInstance(command.getHandler())) command.setHandler(handler); } }
void activate() { if (handler != null) { /* * Next check ensures that we don't overwrite newly activated editor contributions. * For details see https://bugs.eclipse.org/bugs/show_bug.cgi?id=297834. */ if (!handler.getClass().isInstance(command.getHandler())) command.setHandler(handler); } }
private void replaceWith(IHandler newHandler) { if (command.isHandled()) { handler= command.getHandler(); command.setHandler(newHandler); } } }
private void replaceWith(IHandler newHandler) { if (command.isHandled()) { handler= command.getHandler(); command.setHandler(newHandler); } } }
Command cmd = getCommand(commandId); if (!cmd.isDefined() || !(cmd.getHandler() instanceof IElementUpdater)) { return; final IElementUpdater updater = (IElementUpdater) cmd.getHandler();
@Override public void registerElement(IElementReference elementReference) { List parameterizedCommands = (List) commandCallbacks .get(elementReference.getCommandId()); if (parameterizedCommands == null) { parameterizedCommands = new ArrayList(); commandCallbacks.put(elementReference.getCommandId(), parameterizedCommands); } parameterizedCommands.add(elementReference); // If the active handler wants to update the callback, it can do // so now Command command = getCommand(elementReference.getCommandId()); if (command.isDefined()) { if (command.getHandler() instanceof IElementUpdater) { ((IElementUpdater) command.getHandler()).updateElement( elementReference.getElement(), elementReference .getParameters()); } } }
/** * Creates links for given commands on the parent composite. * * @param parent * Parent composite. * @param toolkit * {@link FormToolkit} to use. * @param commandMap * IDs of the commands to display. Only active ones will be displayed. */ private void createLinks(Composite parent, FormToolkit toolkit, Map<String, String> commandMap) { for (Map.Entry<String, String> entry : commandMap.entrySet()) { Command command = commandService.getCommand(entry.getKey()); if (command.isDefined() && (null != command.getHandler()) && command.getHandler().isEnabled()) { toolkit.createLabel(parent, "", SWT.NONE).setImage(arrow); Hyperlink link = toolkit.createHyperlink(parent, entry.getValue(), SWT.WRAP); link.addHyperlinkListener(new CommandHyperlinkListener(command)); link.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); } } }
private void scan(IContributionItem item, StringBuilder buffer, SpyFormToolkit toolkit, FormText text) { // check for action set information if (item instanceof IActionSetContributionItem) { IActionSetContributionItem actionItem = (IActionSetContributionItem) item; buffer.append(toolkit.createIdentifierSection(text, PDERuntimeMessages.ActiveMenuSection_1, new String[] {actionItem.getActionSetId()})); } if (item instanceof ActionContributionItem) { createActionContributionItemText(item, buffer, toolkit, text); } else if (item instanceof SubContributionItem) { SubContributionItem subItem = (SubContributionItem) item; scan(subItem.getInnerItem(), buffer, toolkit, text); // recurse } else if (item instanceof CommandContributionItem) { // TODO... this is hard... CommandContributionItem contributionItem = (CommandContributionItem) item; Command command = contributionItem.getCommand().getCommand(); buffer.append(toolkit.createClassSection(text, PDERuntimeMessages.ActiveMenuSection_2, command.getClass())); buffer.append(toolkit.createClassSection(text, PDERuntimeMessages.ActiveMenuSection_3, command.getHandler().getClass())); } }
final IHandler handler = command.getHandler(); if (handler != null) { final String helpContextId = helpContextIdsByHandler.get(handler);
final IHandler handler = command.getHandler(); if (handler != null) { final String helpContextId = helpContextIdsByHandler.get(handler);
final IHandler handler = command.getHandler(); if (handler != null) { final String helpContextId = helpContextIdsByHandler.get(handler);
@Override public void handlerChanged(HandlerEvent handlerEvent) { IHandler handler = command.getHandler(); if (handler instanceof HandlerServiceHandler) { IEclipseContext appContext = ((Workbench) PlatformUI.getWorkbench()).getApplication() .getContext(); if (HandlerServiceImpl.lookUpHandler(appContext, command.getId()) == this) { ((HandlerServiceHandler) handler).fireHandlerChanged(handlerEvent); } } }
IHandler handler = commandEvent.getCommand().getHandler(); if (shouldRestoreAppearance(handler)) { label = contributedLabel;
@SuppressWarnings("restriction") @Override public void commandManagerChanged(CommandManagerEvent commandManagerEvent) { if (commandManagerEvent.isCommandChanged()) { if (commandManagerEvent.isCommandDefined()) { final String commandId = commandManagerEvent.getCommandId(); if (findCommand(commandId) != null) { return; } final Command command = commandManagerEvent.getCommandManager().getCommand( commandId); if (command.getHandler() == null) { command.setHandler(HandlerServiceImpl.getHandler(commandId)); } try { MCategory categoryModel = findCategory(command.getCategory().getId()); final MCommand createdCommand = createCommand(command, modelService, categoryModel); application.getCommands().add(createdCommand); } catch (NotDefinedException e) { Activator.getDefault().getLogService() .log(0, "Failed to create command " + commandId, e); //$NON-NLS-1$ } } } } };
@Override public void runWithEvent(Event event) { if (partHandler != null && getParameterizedCommand() != null) { IHandler oldHandler = getParameterizedCommand().getCommand() .getHandler(); try { getParameterizedCommand().getCommand().setHandler(partHandler); getParameterizedCommand().executeWithChecks(event, appContext); } catch (ExecutionException e) { // TODO some logging, perhaps? } catch (NotDefinedException e) { // TODO some logging, perhaps? } catch (NotEnabledException e) { // TODO some logging, perhaps? } catch (NotHandledException e) { // TODO some logging, perhaps? } finally { getParameterizedCommand().getCommand().setHandler(oldHandler); } } else { super.runWithEvent(event); } }
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); } }
IEvaluationContext context) throws ExecutionException, NotDefinedException, NotEnabledException, NotHandledException { IHandler handler = command.getCommand().getHandler(); boolean enabled = handler.isEnabled(); IEclipseContext staticContext = null;