Package org.eclipse.core.commands

Examples of org.eclipse.core.commands.ParameterizedCommand


        final int columnIndex) {
      final Object value = element;
      if (value instanceof Binding) {
        switch (columnIndex) {
        case COLUMN_COMMAND:
          final ParameterizedCommand parameterizedCommand = ((Binding) value)
              .getParameterizedCommand();
          if (parameterizedCommand != null) {
            final String commandId = parameterizedCommand.getId();
            final ImageDescriptor imageDescriptor = commandImageService
                .getImageDescriptor(commandId);
            if (imageDescriptor == null) {
              return null;
            }
            try {
              return localResourceManager
                  .createImage(imageDescriptor);
            } catch (final DeviceResourceException e) {
              final String message = "Problem retrieving image for a command '" //$NON-NLS-1$
                  + commandId + '\'';
              final IStatus status = new Status(IStatus.ERROR,
                  WorkbenchPlugin.PI_WORKBENCH, 0, message, e);
              WorkbenchPlugin.log(message, status);
            }
          }
          return null;

        case COLUMN_USER:
          if (((Binding) value).getType() == Binding.USER)
            return ImageFactory.getImage("change"); //$NON-NLS-1$
          return ImageFactory.getImage("blank"); //$NON-NLS-1$
        }

      } else if (value instanceof ParameterizedCommand) {
        switch (columnIndex) {
        case COLUMN_COMMAND:
          final ParameterizedCommand parameterizedCommand = (ParameterizedCommand) value;
          final String commandId = parameterizedCommand.getId();
          final ImageDescriptor imageDescriptor = commandImageService
              .getImageDescriptor(commandId);
          if (imageDescriptor == null) {
            return null;
          }
View Full Code Here


    public final int category(final Object element) {
      switch (grouping) {
      case GROUPING_CATEGORY:
        // TODO This has to be done with something other than the hash.
        try {
          final ParameterizedCommand command = (element instanceof ParameterizedCommand) ? (ParameterizedCommand) element
              : ((Binding) element).getParameterizedCommand();
          return command.getCommand().getCategory().hashCode();
        } catch (final NotDefinedException e) {
          return 0;
        }
      case GROUPING_CONTEXT:
        // TODO This has to be done with something other than the hash.
View Full Code Here

  }

  private void createDefaultPageLabel(Composite composite, int h_span) {
      final ICommandService commandSvc= (ICommandService) PlatformUI.getWorkbench().getAdapter(ICommandService.class);
    final Command command= commandSvc.getCommand(ITextEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS);
    ParameterizedCommand pCmd= new ParameterizedCommand(command, null);
    String key= getKeyboardShortcut(pCmd);
    if (key == null) {
      key= SSEUIMessages.CodeAssistAdvancedConfigurationBlock_no_shortcut;
    }
View Full Code Here

            Command command = commandService.getCommand("org.eclipse.ui.perspectives.showPerspective");


            Map parameters = new HashMap();
            parameters.put("org.eclipse.ui.perspectives.showPerspective.perspectiveId", perspectiveDescriptor.getId());
            ParameterizedCommand parameterizedCommand = ParameterizedCommand.generateCommand(command, parameters);

            IHandlerService handlerService = (IHandlerService) PlatformUI.getWorkbench()
                    .getService(IHandlerService.class);
            try {
                handlerService.executeCommand(parameterizedCommand, null);
View Full Code Here

        WorkbenchPlugin.log("Command " + commandId + " is undefined"); //$NON-NLS-1$//$NON-NLS-2$
        return;
      }

      if (parameterMap == null) {
        parameterizedCommand = new ParameterizedCommand(cmd, null);
        return;
      }

      ArrayList parameters = new ArrayList();
      Iterator i = parameterMap.keySet().iterator();
      while (i.hasNext()) {
        String parmName = (String) i.next();
        IParameter parm = cmd.getParameter(parmName);
        if (parm == null) {
          WorkbenchPlugin.log("Invalid parameter \'" + parmName //$NON-NLS-1$
              + "\' for command " + commandId); //$NON-NLS-1$
          return;
        }
        parameters.add(new Parameterization(parm, (String) parameterMap
            .get(parmName)));
      }
      parameterizedCommand = new ParameterizedCommand(cmd,
          (Parameterization[]) parameters
              .toArray(new Parameterization[parameters.size()]));
    } catch (NotDefinedException e) {
      WorkbenchPlugin.log(e);
    }
View Full Code Here

    if (commandId == null) {
      return null;
    }

    final Command command = commandService.getCommand(commandId);
    final ParameterizedCommand parameterizedCommand = readParameters(
        configurationElement, warningsToLog, command);

    return parameterizedCommand;
  }
View Full Code Here

      final IConfigurationElement configurationElement,
      final List warningsToLog, final Command command) {
    final IConfigurationElement[] parameterElements = configurationElement
        .getChildren(TAG_PARAMETER);
    if ((parameterElements == null) || (parameterElements.length == 0)) {
      return new ParameterizedCommand(command, null);
    }

    final Collection parameters = new ArrayList();
    for (int i = 0; i < parameterElements.length; i++) {
      final IConfigurationElement parameterElement = parameterElements[i];

      // Read out the id.
      final String id = parameterElement.getAttribute(ATT_ID);
      if ((id == null) || (id.length() == 0)) {
        // The name should never be null. This is invalid.
        addWarning(warningsToLog, "Parameters need a name", //$NON-NLS-1$
            configurationElement);
        continue;
      }

      // Find the parameter on the command.
      IParameter parameter = null;
      try {
        final IParameter[] commandParameters = command.getParameters();
        if (parameters != null) {
          for (int j = 0; j < commandParameters.length; j++) {
            final IParameter currentParameter = commandParameters[j];
            if (Util.equals(currentParameter.getId(), id)) {
              parameter = currentParameter;
              break;
            }
          }

        }
      } catch (final NotDefinedException e) {
        // This should not happen.
      }
      if (parameter == null) {
        // The name should never be null. This is invalid.
        addWarning(warningsToLog,
            "Could not find a matching parameter", //$NON-NLS-1$
            configurationElement, id);
        continue;
      }

      // Read out the value.
      final String value = parameterElement.getAttribute(ATT_VALUE);
      if ((value == null) || (value.length() == 0)) {
        // The name should never be null. This is invalid.
        addWarning(warningsToLog, "Parameters need a value", //$NON-NLS-1$
            configurationElement, id);
        continue;
      }

      parameters.add(new Parameterization(parameter, value));
    }

    if (parameters.isEmpty()) {
      return new ParameterizedCommand(command, null);
    }

    return new ParameterizedCommand(command,
        (Parameterization[]) parameters
            .toArray(new Parameterization[parameters.size()]));
  }
View Full Code Here

    if (commandId == null) {
      return null;
    }

    final Command command = commandService.getCommand(commandId);
    final ParameterizedCommand parameterizedCommand = readParameters(
        memento, warningsToLog, command);

    return parameterizedCommand;
  }
View Full Code Here

      final IMemento memento, final List warningsToLog,
      final Command command) {
    final IMemento[] parameterMementos = memento
        .getChildren(TAG_PARAMETER);
    if ((parameterMementos == null) || (parameterMementos.length == 0)) {
      return new ParameterizedCommand(command, null);
    }

    final Collection parameters = new ArrayList();
    for (int i = 0; i < parameterMementos.length; i++) {
      final IMemento parameterMemento = parameterMementos[i];

      // Read out the id.
      final String id = parameterMemento.getString(ATT_ID);
      if ((id == null) || (id.length() == 0)) {
        // The name should never be null. This is invalid.
        addWarning(warningsToLog, "Parameters need a name"); //$NON-NLS-1$
        continue;
      }

      // Find the parameter on the command.
      IParameter parameter = null;
      try {
        final IParameter[] commandParameters = command.getParameters();
        if (parameters != null) {
          for (int j = 0; j < commandParameters.length; j++) {
            final IParameter currentParameter = commandParameters[j];
            if (Util.equals(currentParameter.getId(), id)) {
              parameter = currentParameter;
              break;
            }
          }

        }
      } catch (final NotDefinedException e) {
        // This should not happen.
      }
      if (parameter == null) {
        // The name should never be null. This is invalid.
        addWarning(warningsToLog,
            "Could not find a matching parameter", id); //$NON-NLS-1$
        continue;
      }

      // Read out the value.
      final String value = parameterMemento.getString(ATT_VALUE);
      if ((value == null) || (value.length() == 0)) {
        // The name should never be null. This is invalid.
        addWarning(warningsToLog, "Parameters need a value", id); //$NON-NLS-1$
        continue;
      }

      parameters.add(new Parameterization(parameter, value));
    }

    if (parameters.isEmpty()) {
      return new ParameterizedCommand(command, null);
    }

    return new ParameterizedCommand(command,
        (Parameterization[]) parameters
            .toArray(new Parameterization[parameters.size()]));
  }
View Full Code Here

   */
  protected ParameterizedCommand getBackwardCommand() {
    // TODO Auto-generated method stub
    final ICommandService commandService = (ICommandService) window.getWorkbench().getService(ICommandService.class);
    final Command command = commandService.getCommand("org.eclipse.ui.window.previousView"); //$NON-NLS-1$
    ParameterizedCommand commandBack = new ParameterizedCommand(command, null);
    return commandBack;
  }
View Full Code Here

TOP

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

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.