Package org.eclipse.core.runtime

Examples of org.eclipse.core.runtime.IConfigurationElement


      }
    }

    // The registry.
    for (int i = configurationElementCount - 1; i >= 0; i--) {
      final IConfigurationElement configurationElement = configurationElements[i];

      String id = configurationElement
          .getAttribute(ATT_KEY_CONFIGURATION_ID);
      if (id != null) {
        try {
          bindingManager
              .setActiveScheme(bindingManager.getScheme(id));
          return;
        } catch (final NotDefinedException e) {
          // Let's keep looking....
        }
      }

      id = configurationElement.getAttribute(ATT_VALUE);
      if (id != null) {
        try {
          bindingManager
              .setActiveScheme(bindingManager.getScheme(id));
          return;
View Full Code Here


      final ICommandService commandService) {
    final Collection bindings = new ArrayList(configurationElementCount);
    final List warningsToLog = new ArrayList(1);

    for (int i = 0; i < configurationElementCount; i++) {
      final IConfigurationElement configurationElement = configurationElements[i];

      /*
       * Read out the command id. Doing this before determining if the key
       * binding is actually valid is a bit wasteful. However, it is
       * helpful to have the command identifier when logging syntax
       * errors.
       */
      String commandId = configurationElement
          .getAttribute(ATT_COMMAND_ID);
      if ((commandId == null) || (commandId.length() == 0)) {
        commandId = configurationElement.getAttribute(ATT_COMMAND);
      }
      if ((commandId != null) && (commandId.length() == 0)) {
        commandId = null;
      }
      final Command command;
      if (commandId != null) {
        command = commandService.getCommand(commandId);
        if (!command.isDefined()) {
          // Reference to an undefined command. This is invalid.
          addWarning(warningsToLog,
              "Cannot bind to an undefined command", //$NON-NLS-1$
              configurationElement, commandId);
          continue;
        }
      } else {
        command = null;
      }

      // Read out the scheme id.
      String schemeId = configurationElement.getAttribute(ATT_SCHEME_ID);
      if ((schemeId == null) || (schemeId.length() == 0)) {
        schemeId = configurationElement
            .getAttribute(ATT_KEY_CONFIGURATION_ID);
        if ((schemeId == null) || (schemeId.length() == 0)) {
          schemeId = configurationElement
              .getAttribute(ATT_CONFIGURATION);
          if ((schemeId == null) || (schemeId.length() == 0)) {
            // The scheme id should never be null. This is invalid.
            addWarning(warningsToLog, "Key bindings need a scheme", //$NON-NLS-1$
                configurationElement, commandId);
            continue;
          }
        }
      }

      // Read out the context id.
      String contextId = configurationElement
          .getAttribute(ATT_CONTEXT_ID);
      if (LEGACY_DEFAULT_SCOPE.equals(contextId)) {
        contextId = null;
      } else if ((contextId == null) || (contextId.length() == 0)) {
        contextId = configurationElement.getAttribute(ATT_SCOPE);
        if (LEGACY_DEFAULT_SCOPE.equals(contextId)) {
          contextId = null;
        }
      }
      if ((contextId == null) || (contextId.length() == 0)) {
        contextId = IContextIds.CONTEXT_ID_WINDOW;
      }

      // Read out the key sequence.
      KeySequence keySequence = null;
      String keySequenceText = configurationElement
          .getAttribute(ATT_SEQUENCE);
      if ((keySequenceText == null) || (keySequenceText.length() == 0)) {
        keySequenceText = configurationElement
            .getAttribute(ATT_KEY_SEQUENCE);
      }
      if ((keySequenceText == null) || (keySequenceText.length() == 0)) {
        keySequenceText = configurationElement.getAttribute(ATT_STRING);
        if ((keySequenceText == null)
            || (keySequenceText.length() == 0)) {
          // The key sequence should never be null. This is pointless
          addWarning(
              warningsToLog,
              "Defining a key binding with no key sequence has no effect", //$NON-NLS-1$
              configurationElement, commandId);
          continue;
        }

        // The key sequence is in the old-style format.
        try {
          keySequence = convert2_1Sequence(parse2_1Sequence(keySequenceText));
        } catch (final IllegalArgumentException e) {
          addWarning(warningsToLog, "Could not parse key sequence", //$NON-NLS-1$
              configurationElement, commandId, "keySequence", //$NON-NLS-1$
              keySequenceText);
          continue;
        }

      } else {
        // The key sequence is in the new-style format.
        try {
          keySequence = KeySequence.getInstance(keySequenceText);
        } catch (final ParseException e) {
          addWarning(warningsToLog, "Could not parse key sequence", //$NON-NLS-1$
              configurationElement, commandId, "keySequence", //$NON-NLS-1$
              keySequenceText);
          continue;
        }
        if (keySequence.isEmpty() || !keySequence.isComplete()) {
          addWarning(
              warningsToLog,
              "Key bindings should not have an empty or incomplete key sequence", //$NON-NLS-1$
              configurationElement, commandId, "keySequence", //$NON-NLS-1$
              keySequence.toString());
          continue;
        }

      }

      // Read out the locale and platform.
      String locale = configurationElement.getAttribute(ATT_LOCALE);
      if ((locale != null) && (locale.length() == 0)) {
        locale = null;
      }
      String platform = configurationElement.getAttribute(ATT_PLATFORM);
      if ((platform != null) && (platform.length() == 0)) {
        platform = null;
      }

      // Read out the parameters, if any.
View Full Code Here

    }

    final List warningsToLog = new ArrayList(1);

    for (int i = 0; i < configurationElementCount; i++) {
      final IConfigurationElement configurationElement = configurationElements[i];

      // Read out the attributes.
      final String id = readRequired(configurationElement, ATT_ID,
          warningsToLog, "Schemes need an id"); //$NON-NLS-1$
      if (id == null) {
        continue;
      }
      final String name = readRequired(configurationElement, ATT_NAME,
          warningsToLog, "A scheme needs a name", id); //$NON-NLS-1$
      if (name == null) {
        continue;
      }
      final String description = readOptional(configurationElement,
          ATT_DESCRIPTION);

      String parentId = configurationElement.getAttribute(ATT_PARENT_ID);
      if ((parentId != null) && (parentId.length() == 0)) {
        parentId = configurationElement.getAttribute(ATT_PARENT);
        if ((parentId != null) && (parentId.length() == 0)) {
          parentId = null;
        }
      }
View Full Code Here

    // Sort the bindings extension point based on element name.
    final IConfigurationElement[] bindingsExtensionPoint = registry
        .getConfigurationElementsFor(EXTENSION_BINDINGS);
    for (int i = 0; i < bindingsExtensionPoint.length; i++) {
      final IConfigurationElement configurationElement = bindingsExtensionPoint[i];
      final String name = configurationElement.getName();

      // Check if it is a binding definition.
      if (TAG_KEY.equals(name)) {
        addElementToIndexedArray(configurationElement,
            indexedConfigurationElements,
            INDEX_BINDING_DEFINITIONS, bindingDefinitionCount++);
      } else
      // Check to see if it is a scheme definition.
      if (TAG_SCHEME.equals(name)) {
        addElementToIndexedArray(configurationElement,
            indexedConfigurationElements, INDEX_SCHEME_DEFINITIONS,
            schemeDefinitionCount++);
      }

    }

    // Sort the commands extension point based on element name.
    final IConfigurationElement[] commandsExtensionPoint = registry
        .getConfigurationElementsFor(EXTENSION_COMMANDS);
    for (int i = 0; i < commandsExtensionPoint.length; i++) {
      final IConfigurationElement configurationElement = commandsExtensionPoint[i];
      final String name = configurationElement.getName();

      // Check if it is a binding definition.
      if (TAG_KEY_BINDING.equals(name)) {
        addElementToIndexedArray(configurationElement,
            indexedConfigurationElements,
            INDEX_BINDING_DEFINITIONS, bindingDefinitionCount++);

        // Check if it is a scheme defintion.
      } else if (TAG_KEY_CONFIGURATION.equals(name)) {
        addElementToIndexedArray(configurationElement,
            indexedConfigurationElements, INDEX_SCHEME_DEFINITIONS,
            schemeDefinitionCount++);

        // Check if it is an active scheme identifier.
      } else if (TAG_ACTIVE_KEY_CONFIGURATION.equals(name)) {
        addElementToIndexedArray(configurationElement,
            indexedConfigurationElements, INDEX_ACTIVE_SCHEME,
            activeSchemeElementCount++);
      }
    }

    /*
     * Sort the accelerator configuration extension point into the scheme
     * definitions.
     */
    final IConfigurationElement[] acceleratorConfigurationsExtensionPoint = registry
        .getConfigurationElementsFor(EXTENSION_ACCELERATOR_CONFIGURATIONS);
    for (int i = 0; i < acceleratorConfigurationsExtensionPoint.length; i++) {
      final IConfigurationElement configurationElement = acceleratorConfigurationsExtensionPoint[i];
      final String name = configurationElement.getName();

      // Check if the name matches the accelerator configuration element
      if (TAG_ACCELERATOR_CONFIGURATION.equals(name)) {
        addElementToIndexedArray(configurationElement,
            indexedConfigurationElements, INDEX_SCHEME_DEFINITIONS,
View Full Code Here

                .getConfigurationElements();

        // look for the startup tag in each element and run the extension
        boolean foundAtLeastOne = false;
        for (int i = 0; i < configElements.length; ++i) {
            IConfigurationElement element = configElements[i];
            if (element != null
                    && element.getName()
                            .equals(IWorkbenchConstants.TAG_STARTUP)) {
                runEarlyStartup(getExecutableExtension(element));
                foundAtLeastOne = true;
            }
        }
View Full Code Here

    commandImageManager.clear();

    final List warningsToLog = new ArrayList(1);

    for (int i = 0; i < configurationElementCount; i++) {
      final IConfigurationElement configurationElement = configurationElements[i];

      // Read out the command identifier.
      final String commandId = readRequired(configurationElement,
          ATT_COMMAND_ID, warningsToLog, "Image needs an id"); //$NON-NLS-1$
      if (commandId == null) {
        continue;
      }

      if (!commandService.getCommand(commandId).isDefined()) {
        // Reference to an undefined command. This is invalid.
        addWarning(warningsToLog,
            "Cannot bind to an undefined command", //$NON-NLS-1$
            configurationElement, commandId);
        continue;
      }

      // Read out the style.
      final String style = readOptional(configurationElement, ATT_STYLE);

      // Read out the default icon.
      final String icon = readRequired(configurationElement, ATT_ICON,
          warningsToLog, commandId);
      if (icon == null) {
        continue;
      }

      final String disabledIcon = readOptional(configurationElement,
          ATT_DISABLEDICON);
      final String hoverIcon = readOptional(configurationElement,
          ATT_HOVERICON);

      final URL iconURL = BundleUtility.find(configurationElement
          .getNamespace(), icon);
      commandImageManager.bind(commandId,
          CommandImageManager.TYPE_DEFAULT, style, iconURL);
      if (disabledIcon != null) {
        final URL disabledIconURL = BundleUtility.find(
            configurationElement.getNamespace(), disabledIcon);
        commandImageManager.bind(commandId,
            CommandImageManager.TYPE_DISABLED, style,
            disabledIconURL);
      }
      if (hoverIcon != null) {
        final URL hoverIconURL = BundleUtility.find(
            configurationElement.getNamespace(), hoverIcon);
        commandImageManager.bind(commandId,
            CommandImageManager.TYPE_HOVER, style, hoverIconURL);
      }
    }
View Full Code Here

    // Sort the commands extension point based on element name.
    final IConfigurationElement[] commandImagesExtensionPoint = registry
        .getConfigurationElementsFor(EXTENSION_COMMAND_IMAGES);
    for (int i = 0; i < commandImagesExtensionPoint.length; i++) {
      final IConfigurationElement configurationElement = commandImagesExtensionPoint[i];
      final String name = configurationElement.getName();

      // Check if it is a binding definition.
      if (TAG_IMAGE.equals(name)) {
        addElementToIndexedArray(configurationElement,
            indexedConfigurationElements, INDEX_IMAGES,
View Full Code Here

            WorkbenchMessages.CommandService_AutogeneratedCategoryDescription);

    final List warningsToLog = new ArrayList(1);

    for (int i = 0; i < configurationElementCount; i++) {
      final IConfigurationElement configurationElement = configurationElements[i];

      // Read out the category identifier.
      final String categoryId = readRequired(configurationElement,
          ATT_ID, warningsToLog, "Categories need an id"); //$NON-NLS-1$
      if (categoryId == null) {
View Full Code Here

    }

    final List warningsToLog = new ArrayList(1);

    for (int i = 0; i < configurationElementCount; i++) {
      final IConfigurationElement configurationElement = configurationElements[i];

      // Read out the command identifier.
      final String commandId = readRequired(configurationElement, ATT_ID,
          warningsToLog, "Commands need an id"); //$NON-NLS-1$
      if (commandId == null) {
        continue;
      }

      // Read out the name.
      final String name = readRequired(configurationElement, ATT_NAME,
          warningsToLog, "Commands need a name"); //$NON-NLS-1$
      if (name == null) {
        continue;
      }

      // Read out the description.
      final String description = readOptional(configurationElement,
          ATT_DESCRIPTION);

      // Read out the category id.
      String categoryId = configurationElement
          .getAttribute(ATT_CATEGORY_ID);
      if ((categoryId == null) || (categoryId.length() == 0)) {
        categoryId = configurationElement.getAttribute(ATT_CATEGORY);
        if ((categoryId != null) && (categoryId.length() == 0)) {
          categoryId = null;
        }
      }
View Full Code Here

    }

    int insertionIndex = 0;
    Parameter[] parameters = new Parameter[parameterElements.length];
    for (int i = 0; i < parameterElements.length; i++) {
      final IConfigurationElement parameterElement = parameterElements[i];
      // Read out the id
      final String id = readRequired(parameterElement, ATT_ID,
          warningsToLog, "Parameters need an id"); //$NON-NLS-1$
      if (id == null) {
        continue;
View Full Code Here

TOP

Related Classes of org.eclipse.core.runtime.IConfigurationElement

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.