Java Code Examples for org.eclipse.core.runtime.IConfigurationElement#getNamespaceIdentifier()

The following examples show how to use org.eclipse.core.runtime.IConfigurationElement#getNamespaceIdentifier() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
@Override
public void setInitializationData(IConfigurationElement config, String propertyName, Object data)
    throws CoreException {
    if (data == null || !(data instanceof String)) {
      throw new CoreException(StatusUtil.error(getClass(), "Data must be a class name"));
    }
    String className = (String) data;
    String bundleSymbolicName = config.getNamespaceIdentifier();
    Bundle bundle = Platform.getBundle(bundleSymbolicName);
    if (bundle == null) {
      throw new CoreException(StatusUtil.error(this, "Missing bundle " + bundleSymbolicName));
    }
    try {
      clazz = bundle.loadClass(className);
    } catch (ClassNotFoundException ex) {
      throw new CoreException(StatusUtil.error(this,
                                               "Could not load class " + className
                                               + " from bundle " + bundle.getSymbolicName(),
                                               ex));
    }
}
 
Example 2
@Override
public void setInitializationData(IConfigurationElement configElement, String propertyName,
    Object data) throws CoreException {
  if (configElement.getAttribute(ExtensionBuilder.ATTR_ID) == null) {
    throw new CoreException(new Status(IStatus.ERROR, configElement.getNamespaceIdentifier(),
        "Missing " + ExtensionBuilder.ATTR_HOST_PAGE_ID));
  }
  pageId = configElement.getAttribute(ExtensionBuilder.ATTR_ID);
  new ExtensionBuilder().build();
}
 
Example 3
Source Project: tm4e   File: TMResource.java    License: Eclipse Public License 1.0 4 votes vote down vote up
public TMResource(IConfigurationElement ce) {
	this(ce.getAttribute(XMLConstants.PATH_ATTR));
	this.pluginId = ce.getNamespaceIdentifier();
}
 
Example 4
Source Project: tm4e   File: ThemeAssociation.java    License: Eclipse Public License 1.0 4 votes vote down vote up
public ThemeAssociation(IConfigurationElement ce) {
	this(ce.getAttribute(THEME_ID_ATTR), ce.getAttribute(SCOPE_NAME_ATTR),
			"true".equals(ce.getAttribute(WHEN_DARK_ATTR)));
	this.pluginId = ce.getNamespaceIdentifier();
}
 
Example 5
public static String createId(IConfigurationElement element) {
	return element.getNamespaceIdentifier() + "#" + element.getAttribute(CLASS);
}
 
Example 6
/** Read the e4PreferenceStoreProvider extension point */
private void initialisePreferenceStoreProviders(IEclipseContext context)
{
	if (psProviders == null)
	{
		IContributionFactory factory = context.get(IContributionFactory.class);

		psProviders = new HashMap<String, Object>();
		IExtensionRegistry registry = context.get(IExtensionRegistry.class);

		// Read extensions and fill the map...
		for (IConfigurationElement elmt : registry.getConfigurationElementsFor(PREF_STORE_PROVIDER))
		{
			String declaringBundle = elmt.getNamespaceIdentifier();
			String pluginId = elmt.getAttribute(ATTR_PLUGIN_ID);
			if (isEmpty(pluginId))
			{
				logger.warn("missing plugin Id in extension " + PREF_STORE_PROVIDER + " check the plugin " + declaringBundle);
				continue;
			}

			String classname = elmt.getAttribute(ATTR_CLASS);
			String objectId = elmt.getAttribute(ATTR_ID_IN_WBCONTEXT);

			if ((isEmpty(classname) && isEmpty(objectId)) || (((classname != null) && classname.length() > 0) && ((objectId != null) && objectId.length() > 0)))
			{
				logger.warn("In extension " + PREF_STORE_PROVIDER + " only one of the two attributes (pluginId or idInWorkbenchContext) must be set. Check the plugin "
						+ declaringBundle);
				continue;
			}

			// Ok can now work with data...
			Object data = objectId;
			if (classname != null)
			{
				data = factory.create(classname, context);
				if (!(data instanceof IPreferenceStoreProvider))
				{
					logger.warn("In extension " + PREF_STORE_PROVIDER + " the class must implements IPreferenceStoreProvider. Check the plugin " + declaringBundle);
					continue;
				}
			}

			psProviders.put(pluginId, data);

		}
		
		context.set(KEY_PREF_STORE_PROVIDERS, psProviders);
	}
}