Exemplo n.º 1
0
  protected ContentProvider(Object parent, IConfigurationElement origin) {
    _origin = origin;
    _parent = parent;
    classifierName = origin.getAttribute("classifierName");
    if (classifierName == null || classifierName.length() == 0)
      throw new RuntimeException("ClassifierName is required");
    packageURI = origin.getAttribute("packageURI");
    if (packageURI == null || packageURI.length() == 0)
      throw new RuntimeException("PackageURI is required");

    IConfigurationElement[] configurationElements = origin.getChildren();
    for (IConfigurationElement element : configurationElements) {
      System.out.println("Initializing " + element.getName());
    }
  }
Exemplo n.º 2
0
  /**
   * {@inheritDoc} The <code>WorkbenchPart</code> implementation of this <code>IExecutableExtension
   * </code> records the configuration element in and internal state variable (accessible via <code>
   * getConfigElement</code>). It also loads the title image, if one is specified in the
   * configuration element. Subclasses may extend.
   *
   * <p>Should not be called by clients. It is called by the core plugin when creating this
   * executable extension.
   */
  public void setInitializationData(IConfigurationElement cfig, String propertyName, Object data) {

    // Save config element.
    configElement = cfig;

    // Part name and title.
    partName = Util.safeString(cfig.getAttribute("name")); // $NON-NLS-1$;
    title = partName;

    // Icon.
    String strIcon = cfig.getAttribute("icon"); // $NON-NLS-1$
    if (strIcon == null) {
      return;
    }

    imageDescriptor =
        AbstractUIPlugin.imageDescriptorFromPlugin(configElement.getNamespace(), strIcon);

    if (imageDescriptor == null) {
      return;
    }

    titleImage = JFaceResources.getResources().createImageWithDefault(imageDescriptor);
  }
  /**
   * Parses registry element to extract mode and selection elements that will be used for
   * verification.
   */
  private void parseClasses(IConfigurationElement config) {
    // Get enables for.
    String enablesFor = config.getAttribute(IWorkbenchRegistryConstants.ATT_ENABLES_FOR);
    if (enablesFor == null) {
      enablesFor = "*"; // $NON-NLS-1$
    }
    if (enablesFor.equals("*")) { // $NON-NLS-1$
      mode = ANY_NUMBER;
    } else if (enablesFor.equals("?")) { // $NON-NLS-1$
      mode = NONE_OR_ONE;
    } else if (enablesFor.equals("!")) { // $NON-NLS-1$
      mode = NONE;
    } else if (enablesFor.equals("+")) { // $NON-NLS-1$
      mode = ONE_OR_MORE;
    } else if (enablesFor.equals("multiple") // $NON-NLS-1$
        || enablesFor.equals("2+")) { // $NON-NLS-1$
      mode = MULTIPLE;
    } else {
      try {
        mode = Integer.parseInt(enablesFor);
      } catch (NumberFormatException e) {
        mode = UNKNOWN;
      }
    }

    // Get enablement block.
    IConfigurationElement[] children =
        config.getChildren(IWorkbenchRegistryConstants.TAG_ENABLEMENT);
    if (children.length > 0) {
      enablementExpression = new ActionExpression(children[0]);
      return;
    }

    // Get selection block.
    children = config.getChildren(IWorkbenchRegistryConstants.TAG_SELECTION);
    if (children.length > 0) {
      classes = new ArrayList();
      for (int i = 0; i < children.length; i++) {
        IConfigurationElement sel = children[i];
        String cname = sel.getAttribute(IWorkbenchRegistryConstants.ATT_CLASS);
        String name = sel.getAttribute(IWorkbenchRegistryConstants.ATT_NAME);
        SelectionClass sclass = new SelectionClass();
        sclass.className = cname;
        sclass.nameFilter = name;
        classes.add(sclass);
      }
    }
  }