private void processComponent(IConfigurationElement element) {
   if (!"component".equals(element.getName())) { // $NON-NLS-1$
     Activator.getDefault()
         .getLog()
         .log(
             new Status(
                 Status.ERROR,
                 Activator.PLUGIN_ID,
                 Messages.SwitchYardComponentExtensionManager_InvalidElementStatus
                     + element.getName()
                     + ", plugin="
                     + element.getContributor().getName())); // $NON-NLS-1$
     return;
   }
   String id = element.getAttribute("id"); // $NON-NLS-1$
   String name = element.getAttribute("name"); // $NON-NLS-1$
   Category category = parseCategory(element);
   String description = parseDescription(element);
   String bundleId = parseBundleId(element);
   List<Dependency> dependencies = parseDependencies(element);
   if (id == null) {
     Activator.getDefault()
         .getLog()
         .log(
             new Status(
                 Status.ERROR,
                 Activator.PLUGIN_ID,
                 Messages.SwitchYardComponentExtensionManager_InvalidIDStatus
                     + element.getContributor().getName()));
     return;
   } else if (_extensions.containsKey(id)) {
     Activator.getDefault()
         .getLog()
         .log(
             new Status(
                 Status.ERROR,
                 Activator.PLUGIN_ID,
                 Messages.SwitchYardComponentExtensionManager_DuplicateIDStatus
                     + element.getContributor().getName()));
     return;
   } else if (name == null || name.length() == 0) {
     name = id;
   }
   ISwitchYardComponentExtension extension =
       new SwitchYardComponentExtension(
           id,
           name,
           category,
           element.getAttribute("scannerClass"),
           description,
           bundleId,
           dependencies); //$NON-NLS-1$
   _extensions.put(id, extension);
   _extensionsByCategory.get(category).add(extension);
 }
  private Object invokeGetter(final Method method) {
    final Class<?> resultType = method.getReturnType();

    if (IConfigurationElement.class == resultType) {
      return config;
    } else if (Bundle.class == resultType) {
      return ContributorFactoryOSGi.resolve(config.getContributor());
    }

    // map bean name to an XML attribute
    final String key = mapName(method, findPropertyName(method));
    final String value = mapContent(config, key);

    if (null != value) {

      if (String.class == resultType) {
        return value;
      } else if (Class.class == resultType) {
        return loadExtensionClass(config, value);
      } else if (resultType.isPrimitive()) {
        return valueOf(resultType, value);
      }

      try {
        return config.createExecutableExtension(key);
      } catch (final CoreException e) {
        /* try nested getter */
      } // NOPMD
    }

    return invokeNestedGetter(resultType, key);
  }
 private List<Dependency> parseDependencies(IConfigurationElement element) {
   IConfigurationElement[] dependencyElements = element.getChildren("dependency"); // $NON-NLS-1$
   if (dependencyElements == null) {
     return Collections.emptyList();
   }
   List<Dependency> dependencies = new ArrayList<Dependency>(dependencyElements.length);
   for (IConfigurationElement dependencyElement : dependencyElements) {
     String artifactId = parseArtifactId(dependencyElement);
     String groupId = parseGroupId(dependencyElement);
     String scope = parseScope(dependencyElement);
     if (artifactId == null
         || artifactId.length() == 0
         || groupId == null
         || groupId.length() == 0) {
       Activator.getDefault()
           .getLog()
           .log(
               new Status(
                   Status.ERROR,
                   Activator.PLUGIN_ID,
                   Messages.SwitchYardComponentExtensionManager_InvalidDependencyStatus
                       + element.getContributor().getName()));
       continue;
     }
     dependencies.add(M2EUtils.createSwitchYardDependency(groupId, artifactId, scope));
   }
   return dependencies;
 }
Example #4
0
 /**
  * Creates an extension. If the extension plugin has not been loaded, a busy cursor will be
  * activated during the duration of the load.
  *
  * @param element the config element defining the extension
  * @param classAttribute the name of the attribute carrying the class
  * @return the extension object
  */
 public static Object createExtension(
     final IConfigurationElement element, final String classAttribute) throws CoreException {
   // If plugin has been loaded, create extension.
   // Otherwise, show busy cursor then create extension.
   String id = element.getContributor().getName();
   Bundle bundle = Platform.getBundle(id);
   if (bundle.getState() == org.osgi.framework.Bundle.ACTIVE) {
     return element.createExecutableExtension(classAttribute);
   }
   final Object[] ret = new Object[1];
   final CoreException[] exc = new CoreException[1];
   BusyIndicator.showWhile(
       null,
       new Runnable() {
         @Override
         public void run() {
           try {
             ret[0] = element.createExecutableExtension(classAttribute);
           } catch (CoreException e) {
             exc[0] = e;
           }
         }
       });
   if (exc[0] != null) throw exc[0];
   return ret[0];
 }
 @Override
 public void setInitializationData(
     final IConfigurationElement config, final String propertyName, final Object data)
     throws CoreException {
   if (data instanceof Map) {
     try {
       final Map<String, String> parameters = (Map<String, String>) data;
       {
         final String s = parameters.get(ActionUtil.CONTENT_TYPE_PAR_NAME);
         if (s != null) {
           this.util.setContentType(Platform.getContentTypeManager().getContentType(s));
         }
       }
       {
         final String s = parameters.get(ActionUtil.LAUNCH_FLAGS_PAR_NAME);
         if (s != null) {
           this.launchFlags = CollectionUtils.toIdentifierSet(s.split(";")); // $NON-NLS-1$
         }
       }
     } catch (final IllegalArgumentException e) {
       throw new CoreException(
           new Status(
               IStatus.ERROR,
               DocBaseUI.PLUGIN_ID,
               0,
               NLS.bind(
                   "Invalid declaration of contribution by ''{0}''.", //$NON-NLS-1$
                   config.getContributor().getName()),
               e));
     }
   }
 }
  @Override
  protected boolean readElement(IConfigurationElement element, boolean add) {
    if (element.getName().equals(TAG_RESOURCE)) {
      String packageURI = element.getAttribute(ATT_URI);
      if (packageURI == null) {
        logMissingAttribute(element, ATT_URI);
      } else if (element.getAttribute(ATT_LOCATION) == null) {
        logMissingAttribute(element, ATT_LOCATION);
      } else if (add) {
        Object previous =
            EPackage.Registry.INSTANCE.put(
                packageURI, new EPackageDescriptor.Dynamic(element, ATT_LOCATION));
        if (previous instanceof PluginClassDescriptor) {
          PluginClassDescriptor descriptor = (PluginClassDescriptor) previous;
          EcorePlugin.INSTANCE.log(
              "Both '"
                  + descriptor.element.getContributor().getName()
                  + "' and '"
                  + element.getContributor().getName()
                  + "' register a package for '"
                  + packageURI
                  + "'");
        }

        return true;
      } else {
        EPackage.Registry.INSTANCE.remove(packageURI);
        return true;
      }
    }

    return false;
  }
 /**
  * Returns the contributor of the described extension.
  *
  * @return the contributor of the described extension
  */
 IContributor getContributor() {
   try {
     return fElement.getContributor();
   } catch (InvalidRegistryObjectException e) {
     return null;
   }
 }
  /** @return a list of uris of all xmi files registered */
  public static Map<URI, Map<String, String>> getExtensionURIS() {
    final Map<URI, Map<String, String>> ret = new LinkedHashMap<URI, Map<String, String>>();
    final IConfigurationElement[] files =
        Platform.getExtensionRegistry().getConfigurationElementsFor(FILE_EXTENSION);
    final URIConverter converter = new ResourceSetImpl().getURIConverter();
    for (final IConfigurationElement file : files) {
      final String filePath = file.getAttribute(FILEPATH_ATTRIBUTE);

      final IConfigurationElement[] children = file.getChildren(FILTER_ELEMENT);
      final Map<String, String> keyValuePairs = new LinkedHashMap<String, String>();
      for (final IConfigurationElement child : children) {
        final String key = child.getAttribute(FILTER_KEY_ATTRIBUTE);
        final String value = child.getAttribute(FILTER_VALUE_ATTRIBUTE);
        keyValuePairs.put(key, value);
      }

      URI uri;
      final String bundleName = file.getContributor().getName();
      final String path = bundleName + '/' + filePath;
      uri = URI.createPlatformPluginURI(path, false);
      if (converter.exists(uri, null)) {
        ret.put(uri, keyValuePairs);
      } else {
        uri = URI.createPlatformResourceURI(filePath, false);
        if (converter.exists(uri, null)) {
          ret.put(uri, keyValuePairs);
        }
      }
    }
    return ret;
  }
 /**
  * Initialize the filter descriptor from the specified configuration element.
  *
  * @param descriptor The new descriptor to be initialized.
  * @param configuration The configuration element to initialize the filter.
  * @throws CoreException Thrown during parsing.
  */
 void initFilter(FilterDescriptor descriptor, IConfigurationElement configuration)
     throws CoreException {
   String attribute = configuration.getAttribute("name"); // $NON-NLS-1$
   Assert.isNotNull(attribute);
   descriptor.setName(attribute);
   attribute = configuration.getAttribute("description"); // $NON-NLS-1$
   if (attribute != null) {
     descriptor.setDescription(attribute);
   }
   attribute = configuration.getAttribute("image"); // $NON-NLS-1$
   if (attribute != null) {
     String symbolicName = configuration.getContributor().getName();
     URL resource = Platform.getBundle(symbolicName).getResource(attribute);
     Image image = ImageDescriptor.createFromURL(resource).createImage();
     descriptor.setImage(image);
   }
   attribute = configuration.getAttribute("enabled"); // $NON-NLS-1$
   if (attribute != null) {
     descriptor.setEnabled(Boolean.valueOf(attribute).booleanValue());
   }
   attribute = configuration.getAttribute("class"); // $NON-NLS-1$
   Assert.isNotNull(attribute);
   ViewerFilter filter =
       (ViewerFilter) configuration.createExecutableExtension("class"); // $NON-NLS-1$
   Assert.isNotNull(filter);
   descriptor.setFilter(filter);
   attribute = configuration.getAttribute("visibleInUI"); // $NON-NLS-1$
   if (attribute != null) {
     descriptor.setVisible(Boolean.valueOf(attribute).booleanValue());
   }
 }
 /**
  * Initialize the column descriptor by reading the attributes from the configuration element.
  *
  * @param column The column descriptor to be initialized.
  * @param configuration The configuration element.
  * @throws CoreException Thrown during parsing.
  */
 @SuppressWarnings("rawtypes")
 void initColumn(ColumnDescriptor column, IConfigurationElement configuration)
     throws CoreException {
   String name = configuration.getAttribute("name"); // $NON-NLS-1$
   Assert.isNotNull(name);
   column.setName(name);
   column.setDescription(configuration.getAttribute("description")); // $NON-NLS-1$
   String attribute = configuration.getAttribute("moveable"); // $NON-NLS-1$
   if (attribute != null) {
     column.setMoveable(Boolean.valueOf(attribute).booleanValue());
   }
   attribute = configuration.getAttribute("resizable"); // $NON-NLS-1$
   if (attribute != null) {
     column.setResizable(Boolean.valueOf(attribute).booleanValue());
   }
   attribute = configuration.getAttribute("visible"); // $NON-NLS-1$
   if (attribute != null) {
     column.setVisible(Boolean.valueOf(attribute).booleanValue());
   }
   attribute = configuration.getAttribute("style"); // $NON-NLS-1$
   if (attribute != null) {
     column.setStyle(parseAlignment(attribute));
   }
   attribute = configuration.getAttribute("alignment"); // $NON-NLS-1$
   if (attribute != null) {
     column.setAlignment(parseAlignment(attribute));
   }
   attribute = configuration.getAttribute("width"); // $NON-NLS-1$
   if (attribute != null) {
     try {
       column.setWidth(Integer.parseInt(attribute));
     } catch (NumberFormatException e) {
     }
   }
   attribute = configuration.getAttribute("image"); // $NON-NLS-1$
   if (attribute != null) {
     String symbolicName = configuration.getContributor().getName();
     URL resource = Platform.getBundle(symbolicName).getResource(attribute);
     Image image = ImageDescriptor.createFromURL(resource).createImage();
     column.setImage(image);
   }
   attribute = configuration.getAttribute("labelProvider"); // $NON-NLS-1$
   if (attribute != null) {
     ILabelProvider labelProvider =
         (ILabelProvider) configuration.createExecutableExtension("labelProvider"); // $NON-NLS-1$
     if (labelProvider != null) {
       column.setLabelProvider(labelProvider);
     }
   }
   attribute = configuration.getAttribute("comparator"); // $NON-NLS-1$
   if (attribute != null) {
     Comparator comparator =
         (Comparator) configuration.createExecutableExtension("comparator"); // $NON-NLS-1$
     if (comparator != null) {
       column.setComparator(comparator);
     }
   }
 }
  private void init(IConfigurationElement element) throws CoreException {
    Object executable = element.createExecutableExtension(CLASS_ATTRIBUTE);
    if (executable instanceof IValidationRule) {
      rule = (IValidationRule) executable;
    }
    id =
        element.getContributor().getName()
            + "."
            + element.getAttribute(ID_ATTRIBUTE)
            + "-"
            + validatorId;
    name = element.getAttribute(NAME_ATTRIBUTE);
    description = element.getAttribute(DESCRIPTION_ATTRIBUTE);
    String enabledByDefault = element.getAttribute(ENABLED_BY_DEFAULT_ATTRIBUTE);
    if (enabledByDefault != null) {
      setEnabledByDefault(Boolean.valueOf(enabledByDefault));
    } else {
      setEnabledByDefault(true);
    }

    // get configuration data
    propertyValues = new HashMap<String, String>();
    propertyDescriptions = new HashMap<String, String>();
    IConfigurationElement[] configurationDataElements = element.getChildren(PROPERTY_ELEMENT);
    for (IConfigurationElement configurationDataElement : configurationDataElements) {
      String propertyName = configurationDataElement.getAttribute(NAME_ATTRIBUTE);
      propertyValues.put(propertyName, configurationDataElement.getAttribute(VALUE_ATTRIBUTE));
      String desc = configurationDataElement.getAttribute(DESCRIPTION_ATTRIBUTE);
      if (StringUtils.hasText(desc)) {
        propertyDescriptions.put(propertyName, desc);
      }
    }
    originalPropertyValues = new HashMap<String, String>(propertyValues);
    rulePropertiesInitialized = false;

    // get severity data
    messageSeverities = new HashMap<String, Integer>();
    messageDescriptions = new HashMap<String, String>();
    IConfigurationElement[] messageDataElements = element.getChildren(MESSAGE_ELEMENT);
    for (IConfigurationElement messageDataElement : messageDataElements) {
      String messageId = messageDataElement.getAttribute(ID_ATTRIBUTE);
      String label = messageDataElement.getAttribute(LABEL_ATTRIBUTE);
      String severity = messageDataElement.getAttribute(SEVERITY_ATTRIBUTE);
      if ("ERROR".equals(severity)) {
        messageSeverities.put(messageId, IValidationProblemMarker.SEVERITY_ERROR);
      } else if ("WARNING".equals(severity)) {
        messageSeverities.put(messageId, IValidationProblemMarker.SEVERITY_WARNING);
      } else if ("INFO".equals(severity)) {
        messageSeverities.put(messageId, IValidationProblemMarker.SEVERITY_INFO);
      } else {
        messageSeverities.put(messageId, IValidationProblemMarker.SEVERITY_UNKOWN);
      }
      messageDescriptions.put(messageId, label);
    }
    originalMessageSeverities = new HashMap<String, Integer>(messageSeverities);
  }
 public static ImageDescriptor getWizardBanner(String serverTypeId) {
   IConfigurationElement config =
       CloudFoundryBrandingExtensionPoint.getConfigurationElement(serverTypeId);
   String wizBanner = CloudFoundryBrandingExtensionPoint.getWizardBannerPath(serverTypeId);
   if (config != null && wizBanner != null && wizBanner.trim().length() > 0) {
     String bundle = config.getContributor().getName();
     return AbstractUIPlugin.imageDescriptorFromPlugin(bundle, wizBanner);
   }
   return null;
 }
Example #13
0
 private static void log(
     final int severity, final String message, final IConfigurationElement element) {
   final StringBuilder info = new StringBuilder(message);
   if (element != null) {
     info.append(" (contributed by '");
     info.append(element.getContributor().getName());
     info.append("').");
   }
   LOGGER.log(new Status(IStatus.WARNING, PLUGIN_ID, info.toString()));
 }
  /**
   * Returns the image descriptor for the icon path specified by the given configuration element.
   *
   * @param iconPath the icon path
   * @param element the configuration element
   * @return the image descriptor
   * @since 3.0
   */
  private ImageDescriptor getImageDescriptor(String iconPath, IConfigurationElement element) {
    String pluginId = element.getContributor().getName();
    Bundle bundle = Platform.getBundle(pluginId);
    if (bundle == null) return null;

    URL url = FileLocator.find(bundle, new Path(iconPath), null);
    if (url != null) return ImageDescriptor.createFromURL(url);

    return ImageDescriptor.getMissingImageDescriptor();
  }
 /**
  * Creates a new locator proxy based on the given configuration element. Returns the new proxy, or
  * null if the element could not be created.
  */
 public static ProjectMetadataLocatorProxy createProxy(IConfigurationElement element) {
   ProjectMetadataLocatorProxy result = new ProjectMetadataLocatorProxy();
   result.fElement = element;
   if ("metadataLocator".equals(element.getName())) // $NON-NLS-1$
   return result;
   TapestryCore.log(
       EclipseMessages.projectMetaDataUnexpectedElement(
           element.getContributor().getName(), element.getName()));
   return null;
 }
  /** key is the plugin id, value is the plugin library path */
  public static synchronized SortedMap<String, String> getContributedDetectors() {
    if (contributedDetectors != null) {
      return contributedDetectors;
    }
    TreeMap<String, String> set = new TreeMap<String, String>();

    IExtensionRegistry registry = Platform.getExtensionRegistry();
    IExtensionPoint point = registry.getExtensionPoint(EXTENSION_POINT_ID);
    if (point == null) {
      return set;
    }
    IExtension[] extensions = point.getExtensions();
    for (IExtension extension : extensions) {
      IConfigurationElement[] elements = extension.getConfigurationElements();
      for (IConfigurationElement configElt : elements) {
        String libPathAsString;
        String pluginId;
        IContributor contributor = null;
        try {
          contributor = configElt.getContributor();
          if (contributor == null) {
            throw new IllegalArgumentException("Null contributor");
          }
          pluginId = configElt.getAttribute(PLUGIN_ID);
          if (pluginId == null) {
            throw new IllegalArgumentException("Missing '" + PLUGIN_ID + "'");
          }
          libPathAsString = configElt.getAttribute(LIBRARY_PATH);
          if (libPathAsString == null) {
            throw new IllegalArgumentException("Missing '" + LIBRARY_PATH + "'");
          }
          libPathAsString = resolveRelativePath(contributor, libPathAsString);
          if (libPathAsString == null) {
            throw new IllegalArgumentException("Failed to resolve library path for: " + pluginId);
          }
          if (set.containsKey(pluginId)) {
            throw new IllegalArgumentException("Duplicated '" + pluginId + "' contribution.");
          }
          set.put(pluginId, libPathAsString);
        } catch (Throwable e) {
          String cName = contributor != null ? contributor.getName() : "unknown contributor";
          String message =
              "Failed to read contribution for '"
                  + EXTENSION_POINT_ID
                  + "' extension point from "
                  + cName;
          FindbugsPlugin.getDefault().logException(e, message);
          continue;
        }
      }
    }
    contributedDetectors = set;
    return contributedDetectors;
  }
Example #17
0
 public CleanUpInitializerDescriptor(IConfigurationElement element) {
   fElement = element;
   String kind = fElement.getAttribute(ATTRIBUTE_NAME_KIND);
   fKind = getCleanUpKind(kind);
   if (fKind == -1) {
     DartToolsPlugin.logErrorMessage(
         Messages.format(
             FixMessages.CleanUpRegistry_UnknownInitializerKind_errorMessage,
             new String[] {element.getContributor().getName(), kind}));
   }
 }
Example #18
0
 /** @param element the configuration element */
 public CleanUpTabPageDescriptor(IConfigurationElement element) {
   fElement = element;
   fName = element.getAttribute(ATTRIBUTE_ID_NAME);
   String kind = fElement.getAttribute(ATTRIBUTE_NAME_KIND);
   fKind = getCleanUpKind(kind);
   if (fKind == -1) {
     DartToolsPlugin.logErrorMessage(
         Messages.format(
             FixMessages.CleanUpRegistry_WrongKindForConfigurationUI_error,
             new String[] {fName, element.getContributor().getName(), kind}));
   }
 }
 public AbstractContextDescriptor(IConfigurationElement config) {
   super(config == null ? DBeaverCore.PLUGIN_ID : config.getContributor().getName());
   if (config != null) {
     String objectType = config.getAttribute(OBJECT_TYPE);
     if (objectType != null) {
       objectTypes.add(new ObjectType(objectType));
     }
     for (IConfigurationElement typeCfg : config.getChildren(OBJECT_TYPE)) {
       objectTypes.add(new ObjectType(typeCfg));
     }
   }
 }
 /**
  * Checks an element that must be defined according to the extension point schema. Throws an
  * <code>InvalidRegistryObjectException</code> if <code>obj</code> is <code>null</code>.
  */
 private void checkNotNull(Object obj, String attribute) throws InvalidRegistryObjectException {
   if (obj == null) {
     Object[] args = {getId(), fElement.getContributor().getName(), attribute};
     String message =
         Messages.format(
             RubyTextMessages.CompletionProposalComputerDescriptor_illegal_attribute_message,
             args);
     IStatus status =
         new Status(IStatus.WARNING, RubyPlugin.getPluginId(), IStatus.OK, message, null);
     RubyPlugin.log(status);
     throw new InvalidRegistryObjectException();
   }
 }
Example #21
0
 /** @return the clean up or <code>null</code> if the clean up could not be instantiated */
 public ICleanUp createCleanUp() {
   try {
     return (ICleanUp) fElement.createExecutableExtension(ATTRIBUTE_ID_CLASS);
   } catch (CoreException e) {
     String msg =
         Messages.format(
             FixMessages.CleanUpRegistry_cleanUpCreation_error,
             new String[] {
               fElement.getAttribute(ATTRIBUTE_ID_ID), fElement.getContributor().getName()
             });
     DartToolsPlugin.logErrorStatus(msg, e.getStatus());
     return null;
   }
 }
Example #22
0
 public PluginListEditor(
     String name, String labelText, String serviceId, String serviceName, Composite parent) {
   super(name, labelText, parent);
   this.serviceName = serviceName;
   systems = new HashMap<String, String>();
   for (IConfigurationElement e :
       Platform.getExtensionRegistry().getConfigurationElementsFor(serviceId)) {
     String contributorName = e.getContributor().getName();
     systems.put(
         Character.toUpperCase(contributorName.toCharArray()[contributorName.lastIndexOf('.') + 1])
             + contributorName.substring(
                 contributorName.lastIndexOf('.') + 2, contributorName.indexOf(serviceName)),
         contributorName);
   }
 }
Example #23
0
 /**
  * Returns the object for the holder object.
  *
  * @return the object or <code>null</code>
  */
 public Class<X> getObjectClass() {
   final String name = myCE.getContributor().getName();
   final String className = myCE.getAttribute(myAttrName);
   final Bundle bundle = Activator.getDefault().getBundle(name);
   if (bundle == null) {
     LogUtils.error(myCE, myAttrName + ": cannot find bundle configuration element");
     return null;
   }
   try {
     return (Class<X>) bundle.loadClass(className);
   } catch (final ClassNotFoundException ex) {
     LogUtils.error(myCE, myAttrName + ": class cannot be loaded: " + className, ex);
     return null;
   }
 }
Example #24
0
 @SuppressWarnings("unchecked")
 public VerificationViewer(IConfigurationElement element) throws CoreException {
   String typeId = getVal(element, ATTR_TYPE);
   type = VerificationTypeManager.getInstance().getTypeById(typeId);
   if (type == null) {
     throw new IllegalArgumentException(
         Messages.bind(Messages.ContextViewer_InvalidTypeErrorMsg, typeId));
   }
   viewer = (IQ7Viewer<Verification>) element.createExecutableExtension(ATTR_CLASS);
   String iconPath = element.getAttribute(ATTR_ICON);
   if (iconPath != null && iconPath.length() > 0) {
     String plugin = element.getContributor().getName();
     icon = AbstractUIPlugin.imageDescriptorFromPlugin(plugin, iconPath);
   }
 }
 private String parseArtifactId(IConfigurationElement element) {
   IConfigurationElement[] artifactIds = element.getChildren("artifactId"); // $NON-NLS-1$
   if (artifactIds.length != 1) {
     Activator.getDefault()
         .getLog()
         .log(
             new Status(
                 Status.ERROR,
                 Activator.PLUGIN_ID,
                 Messages.SwitchYardComponentExtensionManager_MultipleArtifactIDsStatus
                     + element.getContributor().getName()));
     return null;
   }
   return artifactIds[0].getValue().trim();
 }
 /**
  * Gets the icon.
  *
  * @param e IConfigurationElement
  * @param attribute name of icon
  * @return icon of algorithm
  */
 private static Image getIcon(IConfigurationElement e, String attribute) {
   try {
     Bundle bundle = Platform.getBundle(e.getContributor().getName());
     if (bundle != null) {
       URL resource = bundle.getResource(attribute);
       if (resource != null) {
         return new Image(Display.getDefault(), resource.openStream());
       }
     }
   } catch (InvalidRegistryObjectException e1) {
     e1.printStackTrace();
   } catch (IOException e1) {
     e1.printStackTrace();
   }
   return null;
 }
  /** readElement() */
  protected void readElement(IConfigurationElement element) {
    if (element.getName().equals(ELEMENT_ADAPTER_FACTORY)) {
      String namespace = element.getAttribute(ATT_NAMESPACE);

      if (namespace != null) {
        AdapterFactoryExtension adapterFactoryExtension = new AdapterFactoryExtension(namespace);
        adapterFactoryExtension.setAdapterFactoryClassName(
            element.getAttribute(ATT_ADAPTER_FACTORY_CLASS));
        try {
          Bundle contributorBundle = Platform.getBundle(element.getContributor().getName());
          adapterFactoryExtension.setBundleContributor(contributorBundle);
          registry.add(adapterFactoryExtension);
        } catch (Exception e) {
        }
      }
    }
  }
 public String[] getPrefix() {
   if (fPrefix == null) {
     if (fElement != null) {
       if (isCustom()) { // custom
         IConfigurationElement[] prefixes = fElement.getChildren("startwith"); // $NON-NLS-1$
         if (prefixes != null) {
           List prefixValues = new ArrayList(prefixes.length);
           for (int i = 0; i < prefixes.length; i++) {
             String prefix = prefixes[i].getAttribute("prefix"); // $NON-NLS-1$
             if (prefix != null) {
               prefixValues.add(prefix);
             } else {
               try {
                 Logger.log(
                     Logger.WARNING,
                     "misconfigured comment element in" + fElement.getContributor().getName(),
                     new IllegalArgumentException("startwith")); // $NON-NLS-1$ //$NON-NLS-2$
               } catch (InvalidRegistryObjectException e) {
                 // stale bundle?
               }
             }
           }
           if (!prefixValues.isEmpty()) {
             fPrefix = (String[]) prefixValues.toArray(new String[prefixValues.size()]);
           }
         }
       } else { // basic
         String name = getProperty("elementname"); // $NON-NLS-1$
         if (name != null) {
           if (isEmpty()) {
             fPrefix = new String[1];
             fPrefix[0] = name;
           } else {
             fPrefix = new String[2];
             fPrefix[0] = name;
             fPrefix[1] = '/' + name;
           }
         }
       }
     }
   }
   if (fPrefix == null) {
     fPrefix = new String[0];
   }
   return fPrefix;
 }
 /**
  * Create an executable instance from the given configuration element, with the tree viewer as the
  * constructor parameter.
  *
  * @param aInterface The interface of the element should implement.
  * @param viewer The tree viewer to be passed
  * @param configuration The configuration element.
  * @return The object created.
  * @throws Exception
  */
 Object createExecutableExtension(
     Class<?> aInterface, TreeViewer viewer, IConfigurationElement configuration)
     throws Exception {
   String classname = configuration.getAttribute("class"); // $NON-NLS-1$
   Assert.isNotNull(classname);
   String contributorId = configuration.getContributor().getName();
   Bundle bundle = Platform.getBundle(contributorId);
   Assert.isNotNull(bundle);
   Class<?> clazz = bundle.loadClass(classname);
   Assert.isTrue(aInterface.isAssignableFrom(clazz));
   try {
     Constructor<?> constructor = clazz.getConstructor(TreeViewer.class);
     return constructor.newInstance(viewer);
   } catch (NoSuchMethodException e) {
     Constructor<?> constructor = clazz.getConstructor();
     return constructor.newInstance();
   }
 }
 private String parseScope(IConfigurationElement element) {
   IConfigurationElement[] scopes = element.getChildren("scope"); // $NON-NLS-1$
   if (scopes.length == 0) {
     return null;
   } else if (scopes.length != 1) {
     Activator.getDefault()
         .getLog()
         .log(
             new Status(
                 Status.ERROR,
                 Activator.PLUGIN_ID,
                 Messages.SwitchYardComponentExtensionManager_MultipleScopesStatus
                     + element.getContributor().getName()));
     // we'll fall through and return the first element's value
   }
   String scope = scopes[0].getValue().trim();
   return scope.length() == 0 ? null : scope;
 }