if (!command.isDefined()) { throw new NotDefinedException("The command is not defined. " //$NON-NLS-1$ + command.getId()); final IHandler handler = command.getHandler(); if (handler != null) { final String helpContextId = helpContextIdsByHandler.get(handler); return command.getHelpContextId();
private boolean hasTypedParameterMatch(Command command, Object object) throws CommandException { IParameter[] params = command.getParameters(); if (params != null) { for (IParameter param : params) { ParameterType parameterType = command.getParameterType(param.getId()); if (parameterType != null) { if (parameterType.isCompatible(object)) return true; } } } return false; }
private void replaceWith(IHandler newHandler) { if (command.isHandled()) { handler= command.getHandler(); command.setHandler(newHandler); } } }
public final void commandChanged( final CommandEvent commandEvent) { if (command.isDefined()) { command.removeCommandListener(this); loggedCommandIds.remove(commandId); } } });
final Command command = commandManager.getCommand(commandId); if (!command.isDefined() && (!loggedCommandIds.contains(commandId))) { .translateString(RESOURCE_BUNDLE, "undefinedCommand.WarningMessage", null), //$NON-NLS-1$ command.getId()); IStatus status = new Status(IStatus.ERROR, "org.eclipse.jface", //$NON-NLS-1$ command.addCommandListener(new ICommandListener() { @Override public final void commandChanged(
/** * Returns the command's base identifier. It is possible for more than one * parameterized command to have the same identifier. * * @return The command id; never <code>null</code>. */ public final String getId() { return command.getId(); }
final MCategory categoryModel) throws NotDefinedException { MCommand command = modelService.createModelElement(MCommand.class); command.setElementId(cmd.getId()); command.setCategory(categoryModel); command.setCommandName(cmd.getName()); command.setDescription(cmd.getDescription()); IParameter[] cmdParms = cmd.getParameters(); if (cmdParms != null) { for (IParameter cmdParm : cmdParms) { parmModel.setName(cmdParm.getName()); parmModel.setOptional(cmdParm.isOptional()); ParameterType parmType = cmd.getParameterType(cmdParm.getId()); if (parmType != null) { parmModel.setTypeId(parmType.getId());
@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; }
boolean enabledChanged = isEnabled(); returnType = null; final String[] stateIds = getStateIds(); if (stateIds != null) { if (handler instanceof IObjectWithState) { handlerWithState.removeState(stateId); final State state = getState(stateId); removeState(stateId); state.dispose(); final State state = getState(stateId); removeState(stateId); state.dispose(); fireCommandChanged(new CommandEvent(this, categoryChanged, definedChanged, descriptionChanged, false, nameChanged, parametersChanged, returnTypeChanged, false, enabledChanged));
@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); } } }
@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()); } } }
final MCommand mCommand = commands.get(cmd.getId()); if (mCommand != null) { try { String cmdName = cmd.getName(); if (!cmdName.equals(mCommand.getCommandName())) { mCommand.setCommandName(cmdName); String cmdDesc = cmd.getDescription(); if (cmdDesc != null) mCommand.setDescription(cmdDesc); final MCategory categoryModel = categories.get(cmd.getCategory().getId());
@Override public boolean isDefined() { return command.isDefined(); }
@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); }
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); } }
protected ICommandListener getCommandListener() { if (commandListener == null) { commandListener = commandEvent -> { if (commandEvent.isHandledChanged() || commandEvent.isEnabledChanged()) { if (commandEvent.getCommand().isDefined()) { setEnabled(commandEvent.getCommand().isEnabled()); } } }; } return commandListener; }
public void showDetailsFor(Object object) { if (object instanceof ParameterizedCommand) object = (fPreSel = (ParameterizedCommand) object).getCommand(); if (!(object instanceof Command)) { resetAllFields(); return; } fSelectedCommand = (Command) object; fComIDT.setText(fSelectedCommand.getId()); fParameterToValue.clear(); fObjectParamList.clear(); fValueParamList.clear(); fExecLink.setVisible(fSelectedCommand.isEnabled()); fCopyLink.setVisible(true); try { populateParams(fSelectedCommand, object); } catch (NotDefinedException e) { createNoParamComp(); } updatePreviewText(); }
/** * Returns the {@link ParameterType} for the parameter with the provided id * or <code>null</code> if this command does not have a parameter type * with the id. * * @param parameterId * The id of the parameter to retrieve the {@link ParameterType} * of. * @return The {@link ParameterType} for the parameter with the provided id * or <code>null</code> if this command does not have a parameter * type with the provided id. * @throws NotDefinedException * If the handle is not currently defined. * @since 3.2 */ public ParameterType getParameterType(final String parameterId) throws NotDefinedException { final IParameter parameter = getParameter(parameterId); if (parameter instanceof ITypedParameter) { final ITypedParameter parameterWithType = (ITypedParameter) parameter; return parameterWithType.getParameterType(); } return null; }