コード例 #1
0
 @Override
 public void addExtension(IExtensionTracker tracker, IExtension extension) {
   IConfigurationElement[] elements = extension.getConfigurationElements();
   for (int i = 0; i < elements.length; i++) {
     IConfigurationElement element = elements[i];
     if (element.getName().equals(tag)) {
       String id = element.getAttribute(IWorkbenchRegistryConstants.ATT_ID);
       String file = element.getAttribute(IWorkbenchRegistryConstants.ATT_ICON);
       if (file == null || id == null) {
         Persistence.log(
             element,
             Persistence.ACTIVITY_IMAGE_BINDING_DESC,
             "definition must contain icon and ID"); //$NON-NLS-1$
         continue; // ignore - malformed
       }
       if (registry.getDescriptor(id) == null) { // first come, first serve
         ImageDescriptor descriptor =
             AbstractUIPlugin.imageDescriptorFromPlugin(element.getNamespace(), file);
         if (descriptor != null) {
           registry.put(id, descriptor);
           tracker.registerObject(extension, id, IExtensionTracker.REF_WEAK);
         }
       }
     }
   }
 }
コード例 #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);
  }
コード例 #3
0
  /**
   * The <code>IntroPart</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.
   */
  @Override
  public void setInitializationData(IConfigurationElement cfig, String propertyName, Object data) {

    // Save config element.
    configElement = cfig;

    titleLabel = cfig.getAttribute(IWorkbenchRegistryConstants.ATT_LABEL);

    // Icon.
    String strIcon = cfig.getAttribute(IWorkbenchRegistryConstants.ATT_ICON);
    if (strIcon == null) {
      return;
    }

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

    if (imageDescriptor == null) {
      return;
    }

    Image image = JFaceResources.getResources().createImageWithDefault(imageDescriptor);
    titleImage = image;
  }
コード例 #4
0
 /**
  * @return
  * @throws org.eclipse.core.runtime.InvalidRegistryObjectException
  */
 public String getNamespace() throws InvalidRegistryObjectException {
   if (delegateElement == null) return DELEGATE_NAMESPACE;
   return delegateElement.getNamespace();
 }