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); } } }
final Object value = handlersByCommandId.get(commandId); if (value instanceof IHandler) { command.setHandler((IHandler) value); } else { command.setHandler(null);
final Object value = handlersByCommandId.get(commandId); if (value instanceof IHandler) { command.setHandler((IHandler) value); } else { command.setHandler(null);
final Object value = handlersByCommandId.get(commandId); if (value instanceof IHandler) { command.setHandler((IHandler) value); } else { command.setHandler(null);
private void replaceWith(IHandler newHandler) { if (command.isHandled()) { handler= command.getHandler(); command.setHandler(newHandler); } } }
private void activatePageActions() { IWorkbench workbench = PlatformUI.getWorkbench(); ICommandService commandSupport = workbench.getAdapter(ICommandService.class); if (commandSupport != null) { Command nextPage = commandSupport.getCommand(ID_NEXT_PAGE_COMMAND); if (fNextPageHandler == null) { fNextPageHandler = new AbstractHandler() { @Override public Object execute(ExecutionEvent arg0) throws ExecutionException { fNextAction.run(); return null; } }; } nextPage.setHandler(fNextPageHandler); Command prevPage = commandSupport.getCommand(ID_PREV_PAGE_COMMAND); if (fPrevPageHandler == null) { fPrevPageHandler = new AbstractHandler() { @Override public Object execute(ExecutionEvent arg0) throws ExecutionException { fPrevAction.run(); return null; } }; } prevPage.setHandler(fPrevPageHandler); } }
@Override public void deactivated() { fActivated = false; IWorkbench workbench = PlatformUI.getWorkbench(); ICommandService commandSupport = workbench.getAdapter(ICommandService.class); IContextService contextSupport = workbench.getAdapter(IContextService.class); if (commandSupport != null && contextSupport != null) { // remove handler Command command = commandSupport.getCommand(ID_GO_TO_ADDRESS_COMMAND); command.setHandler(null); command = commandSupport.getCommand(ID_NEXT_PAGE_COMMAND); command.setHandler(null); command = commandSupport.getCommand(ID_PREV_PAGE_COMMAND); command.setHandler(null); if (fContext != null) { contextSupport.deactivateContexts(fContext); } } super.deactivated(); }
@Override public Command defineCommand(String id, String name, String description, Category category, IParameter[] parameters, String helpContextId) { Command cmd = commandManager.getCommand(id); if (!cmd.isDefined()) { cmd.define(name, description, category, parameters, null, helpContextId); cmd.setHandler(HandlerServiceImpl.getHandler(id)); } return cmd; }
@Override public ICommand getCommand(String commandId) { final Command command = commandManager.getCommand(commandId); if (!command.isDefined()) { command.setHandler(HandlerServiceImpl.getHandler(commandId)); } return new CommandLegacyWrapper(command, bindingManager); }
@Override public Command defineCommand(String id, String name, String description, Category category, IParameter[] parameters) { Command cmd = commandManager.getCommand(id); if (!cmd.isDefined()) { cmd.define(name, description, category, parameters); cmd.setHandler(HandlerServiceImpl.getHandler(id)); } return cmd; }
@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); } }
gotoCommand.setHandler(fGoToAddressHandler);
command.setHandler(HandlerServiceImpl.getHandler(commandId));
@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$ } } } } };