Package org.eclipse.core.commands

Examples of org.eclipse.core.commands.Command


        if (input == null || !input.isSingleFile())
          return;

        ICommandService srv = CommonUtils.getService(site, ICommandService.class);
        IHandlerService hsrv = CommonUtils.getService(site, IHandlerService.class);
        Command cmd = srv.getCommand(HistoryViewCommands.SHOWVERSIONS);
        Parameterization[] parms;
        if (Activator.getDefault().getPreferenceStore().getBoolean(
            UIPreferences.RESOURCEHISTORY_COMPARE_MODE))
          try {
            IParameter parm = cmd
                .getParameter(HistoryViewCommands.COMPARE_MODE_PARAM);
            parms = new Parameterization[] { new Parameterization(
                parm, Boolean.TRUE.toString()) };
          } catch (NotDefinedException e) {
            Activator.handleError(e.getMessage(), e, true);
View Full Code Here


   */
  public static boolean runCommand(String commandId,
      IStructuredSelection selection) {
    ICommandService commandService = CommonUtils.getService(PlatformUI
        .getWorkbench(), ICommandService.class);
    Command cmd = commandService.getCommand(commandId);
    if (!cmd.isDefined())
      return false;

    IHandlerService handlerService = CommonUtils.getService(PlatformUI
        .getWorkbench(), IHandlerService.class);
    EvaluationContext c = null;
View Full Code Here

public class HighlightLayerActionHandler extends MapEditorActionHandler {

  @Override
  public void executeForEditor(ExecutionEvent event, MapEditor activeEditor) {
    Command command = event.getCommand();
    State state = command.getState("STYLE");
    state.setValue(!(Boolean) state.getValue());
    activeEditor.setHighlightCurrentLayer((Boolean) state.getValue());
  }
View Full Code Here

* Implements "Link With Selection" toggle
*/
public class LinkWithSelectionCommand extends
    RepositoriesViewCommandHandler<RepositoryTreeNode> {
  public Object execute(final ExecutionEvent event) throws ExecutionException {
    Command command = event.getCommand();
    HandlerUtil.toggleCommandState(command);
    @SuppressWarnings("boxing")
    boolean test = (Boolean) command.getState(RegistryToggleState.STATE_ID).getValue();
    getView(event).setReactOnSelection(test);
    return null;
  }
View Full Code Here

    if (commandService == null)
      return;

    /* Define Command For Each Label */
    for (final ILabel label : labels) {
      Command command = commandService.getCommand(LABEL_ACTION_PREFIX + label.getOrder());
      command.define(NLS.bind(Messages.Controller_LABEL, label.getName()), NLS.bind(Messages.Controller_LABEL_MSG, label.getName()), commandService.getCategory(RSSOWL_KEYBINDING_CATEGORY));
      command.setHandler(new LabelNewsHandler(label));
    }
  }
View Full Code Here

    if (commandService == null)
      return;

    /* Define Command For Each Share Provider */
    for (final ShareProvider provider : shareProviders) {
      Command command = commandService.getCommand(provider.getId());
      command.define(NLS.bind(Messages.Controller_SHARE, provider.getName()), NLS.bind(Messages.Controller_SHARE_MSG, provider.getName()), commandService.getCategory(RSSOWL_KEYBINDING_CATEGORY));
      command.setHandler(new ShareNewsHandler(provider));
    }
  }
View Full Code Here

    private void executeCommand(String command, String... parameters)
    {
        try
        {
            Command cmd = commandService.getCommand(command);

            List<Parameterization> parameterizations = new ArrayList<Parameterization>();
            if (parameters != null)
            {
                for (int ii = 0; ii < parameters.length; ii++)
                {
                    IParameter p = cmd.getParameter(parameters[ii]);
                    parameterizations.add(new Parameterization(p, parameters[++ii]));
                }
            }

            ParameterizedCommand pCmd = new ParameterizedCommand(cmd,
View Full Code Here

        return null;
    }

    private void executeCommand(String command)
    {
        Command cmd = commandService.getCommand(command);
        ParameterizedCommand pCmd = new ParameterizedCommand(cmd, null);
        if (handlerService.canExecute(pCmd))
        {
            handlerService.executeHandler(pCmd);
        }
View Full Code Here

        final Iterator listenerItr = registeredListeners.entrySet()
            .iterator();
        while (listenerItr.hasNext()) {
          final Map.Entry entry = (Map.Entry) listenerItr.next();
          final String commandId = (String) entry.getKey();
          final Command command = commandManager
              .getCommand(commandId);
          final ParameterizedCommand parameterizedCommand = new ParameterizedCommand(
              command, null);
          if (event.isActiveBindingsChangedFor(parameterizedCommand)) {
            final IPropertyChangeListener listener = (IPropertyChangeListener) entry
View Full Code Here

     * Calling this method with an undefined command id will generate a log
     * message.
     */
    public final boolean isActive(final String commandId) {
      if (commandId != null) {
        final Command command = commandManager.getCommand(commandId);

        if (!command.isDefined()
            && (!loggedCommandIds.contains(commandId))) {
          // The command is not yet defined, so we should log this.
          final String message = MessageFormat.format(Util
              .translateString(RESOURCE_BUNDLE,
                  "undefinedCommand.WarningMessage", null), //$NON-NLS-1$
              new String[] { command.getId() });
          IStatus status = new Status(IStatus.ERROR,
              "org.eclipse.jface", //$NON-NLS-1$
              0, message, new Exception());
          Policy.getLog().log(status);

          // And remember this item so we don't log it again.
          loggedCommandIds.add(commandId);
          command.addCommandListener(new ICommandListener() {
            /*
             * (non-Javadoc)
             *
             * @see org.eclipse.ui.commands.ICommandListener#commandChanged(org.eclipse.ui.commands.CommandEvent)
             */
            public final void commandChanged(
                final CommandEvent commandEvent) {
              if (command.isDefined()) {
                command.removeCommandListener(this);
                loggedCommandIds.remove(commandId);
              }
            }
          });

View Full Code Here

TOP

Related Classes of org.eclipse.core.commands.Command

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.