Examples of IActionCommandMappingService


Examples of org.eclipse.ui.internal.handlers.IActionCommandMappingService

    Command command = null;
    if (commandId != null) {
      command = commandService.getCommand(commandId);
    }

    final IActionCommandMappingService mappingService = (IActionCommandMappingService) window
        .getService(IActionCommandMappingService.class);
   
    String label = null;
    if ((commandId == null) || (!command.isDefined())) {
      // Add a mapping from this action id to the command id.
      if (commandId == null && mappingService != null) {
        commandId = mappingService.getGeneratedCommandId(primaryId,
            secondaryId);
      }
      if (commandId == null) {
        WorkbenchPlugin.log("MappingService unavailable"); //$NON-NLS-1$
        return null;
      }

      // Read the label attribute.
      label = readRequired(element, ATT_LABEL, warningsToLog,
          "Actions require a non-empty label or definitionId", //$NON-NLS-1$
          commandId);
      if (label == null) {
        label = WorkbenchMessages.LegacyActionPersistence_AutogeneratedCommandName;
      }

      /*
       * Read the tooltip attribute. The tooltip is really the description
       * of the command.
       */
      final String tooltip = readOptional(element, ATT_TOOLTIP);

      // Define the command.
      command = commandService.getCommand(commandId);
      final Category category = commandService.getCategory(null);
      final String name = LegacyActionTools.removeAcceleratorText(Action
          .removeMnemonics(label));
      command.define(name, tooltip, category, null);

      // TODO Decide the command state.
      final String style = readOptional(element, ATT_STYLE);
      if (STYLE_RADIO.equals(style)) {
        final State state = new RadioState();
        // TODO How to set the id?
        final boolean checked = readBoolean(element, ATT_STATE, false);
        state.setValue((checked) ? Boolean.TRUE : Boolean.FALSE);
        command.addState(IMenuStateIds.STYLE, state);

      } else if (STYLE_TOGGLE.equals(style)) {
        final State state = new ToggleState();
        final boolean checked = readBoolean(element, ATT_STATE, false);
        state.setValue((checked) ? Boolean.TRUE : Boolean.FALSE);
        command.addState(IMenuStateIds.STYLE, state);
      }
    }
    // this allows us to look up a "commandId" give the contributionId
    // and the actionId
    if (mappingService != null && commandId != null) {
      mappingService.map(mappingService.getGeneratedCommandId(primaryId,
          secondaryId), commandId);
    }

    return new ParameterizedCommand(command, null);
  }
View Full Code Here

Examples of org.eclipse.ui.internal.handlers.IActionCommandMappingService

            "The class was not null but retarget was set to true", //$NON-NLS-1$
            element, actionId, ATT_CLASS, classString);
      }

      // Add a mapping from this action id to the command id.
      final IActionCommandMappingService mappingService = (IActionCommandMappingService) window
          .getService(IActionCommandMappingService.class);
      if (mappingService != null) {
        mappingService.map(actionId, command.getId());
      } else {
        // this is probably the shutdown case where the service has
        // already disposed.
        addWarning(
            warningsToLog,
View Full Code Here

Examples of org.eclipse.ui.internal.handlers.IActionCommandMappingService

          throw new CommandNotMappedException("Action " //$NON-NLS-1$
              + actionId + " configuration element invalid"); //$NON-NLS-1$
        }
      }
      // legacy bridge part
      IActionCommandMappingService mapping = (IActionCommandMappingService) locator
          .getService(IActionCommandMappingService.class);
      if (mapping == null) {
        throw new CommandNotMappedException(
            "No action mapping service available"); //$NON-NLS-1$
      }

      commandId = mapping.getCommandId(mapping.getGeneratedCommandId(
          contributionId, actionId));
    }
    // what, still no command?
    if (commandId == null) {
      throw new CommandNotMappedException("Action " + actionId //$NON-NLS-1$
View Full Code Here

Examples of org.eclipse.ui.internal.handlers.IActionCommandMappingService

      }
      actionHandlers.put(actionID, handler);

      // Add a mapping from this action id to the command id.
      if (serviceLocator != null) {
        final IActionCommandMappingService mappingService = (IActionCommandMappingService) serviceLocator
            .getService(IActionCommandMappingService.class);
        final String commandId = mappingService.getCommandId(actionID);

        // Update the handler activations.
        final IHandlerService service = (IHandlerService) serviceLocator
            .getService(IHandlerService.class);
        Map activationsByActionId = null;
View Full Code Here

Examples of org.eclipse.ui.internal.handlers.IActionCommandMappingService

      }

      if (globalAction instanceof CommandAction) {
        final String actionId = globalAction.getId();
        if (actionId != null) {
          final IActionCommandMappingService mappingService = (IActionCommandMappingService) serviceLocator
              .getService(IActionCommandMappingService.class);
          mappingService.map(actionId, commandId);
        }
      } else {
        globalActionHandlersByCommandId.put(commandId,
            new ActionHandler(globalAction));
      }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.