Java Code Examples for org.eclipse.core.runtime.IExtensionRegistry#getConfigurationElementsFor()

The following examples show how to use org.eclipse.core.runtime.IExtensionRegistry#getConfigurationElementsFor() . 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
Source File: TesterRegistry.java    From n4js with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Reads information from extensions defined in plugin.xml files.
 */
private void initialize() {
	if (isInitialized)
		throw new IllegalStateException("may invoke method initialize() only once");
	isInitialized = true;

	final IExtensionRegistry registry = RegistryFactory.getRegistry();
	if (registry != null) {
		final IConfigurationElement[] configElems = registry
				.getConfigurationElementsFor(TESTERS_EXTENSION_POINT_ID);

		for (IConfigurationElement elem : configElems) {
			try {
				final EclipseTesterDescriptor descriptor = new EclipseTesterDescriptor(elem);
				injector.injectMembers(descriptor);
				register(descriptor);
			} catch (Exception ex) {
				log.error("Error while reading extensions for extension point " + TESTERS_EXTENSION_POINT_ID, ex);
			}
		}
	}
}
 
Example 2
Source File: SVNUIPlugin.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
public static ISVNRepositorySourceProvider[] getRepositorySourceProviders() throws Exception {
	if (repositorySourceProviders == null) {
		List<ISVNRepositorySourceProvider> repositorySourceProviderList = new ArrayList<ISVNRepositorySourceProvider>();
		IExtensionRegistry extensionRegistry = Platform.getExtensionRegistry();
		IConfigurationElement[] configurationElements = extensionRegistry.getConfigurationElementsFor(REPOSITORY_SOURCE_PROVIDERS);
		for (int i = 0; i < configurationElements.length; i++) {
			IConfigurationElement configurationElement = configurationElements[i];
			ISVNRepositorySourceProvider repositorySourceProvider = (ISVNRepositorySourceProvider)configurationElement.createExecutableExtension("class"); //$NON-NLS-1$
			repositorySourceProvider.setId(configurationElement.getAttribute("id")); //$NON-NLS-1$
			repositorySourceProviderList.add(repositorySourceProvider);
		}
		repositorySourceProviders = new ISVNRepositorySourceProvider[repositorySourceProviderList.size()];
		repositorySourceProviderList.toArray(repositorySourceProviders);
		Arrays.sort(repositorySourceProviders, new Comparator<ISVNRepositorySourceProvider>() {
			public int compare(ISVNRepositorySourceProvider o1, ISVNRepositorySourceProvider o2) {
				return o1.getName().compareTo(o2.getName());
			}		
		});
	}
	return repositorySourceProviders;
}
 
Example 3
Source File: LegacyJavadocCompletionProposalComputer.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
private IJavadocCompletionProcessor[] getContributedProcessors() {
	if (fSubProcessors == null) {
		try {
			IExtensionRegistry registry= Platform.getExtensionRegistry();
			IConfigurationElement[] elements=	registry.getConfigurationElementsFor(JavaUI.ID_PLUGIN, PROCESSOR_CONTRIBUTION_ID);
			IJavadocCompletionProcessor[] result= new IJavadocCompletionProcessor[elements.length];
			for (int i= 0; i < elements.length; i++) {
				result[i]= (IJavadocCompletionProcessor) elements[i].createExecutableExtension("class"); //$NON-NLS-1$
			}
			fSubProcessors= result;
		} catch (CoreException e) {
			JavaPlugin.log(e);
			fSubProcessors= new IJavadocCompletionProcessor[0];
		}
	}
	return fSubProcessors;
}
 
Example 4
Source File: CodeGenerators.java    From JReFrameworker with MIT License 6 votes vote down vote up
/**
 * Registers the contributed plugin code generator definitions
 */
public static void loadCodeGeneratorContributions() {
	IExtensionRegistry registry = Platform.getExtensionRegistry();
	IConfigurationElement[] config = registry.getConfigurationElementsFor(Activator.PLUGIN_CODE_GENERATOR_EXTENSION_ID);
	try {
		for (IConfigurationElement element : config) {
			final Object o = element.createExecutableExtension("class");
			if (o instanceof CodeGenerator) {
				CodeGenerator codeGenerator = (CodeGenerator) o;
				registerCodeGenerator(codeGenerator);
			}
		}
	} catch (CoreException e) {
		Log.error("Error loading code generators.", e);
	}
}
 
Example 5
Source File: NodejsInstallManager.java    From typescript.java with MIT License 6 votes vote down vote up
/**
 * Load the Nodejs installs.
 */
private synchronized void loadNodejsInstalls() {
	if (nodeJSInstalls != null)
		return;

	Trace.trace(Trace.EXTENSION_POINT, "->- Loading .nodeJSInstalls extension point ->-");

	IExtensionRegistry registry = Platform.getExtensionRegistry();
	IConfigurationElement[] cf = registry.getConfigurationElementsFor(TypeScriptCorePlugin.PLUGIN_ID,
			EXTENSION_NODEJS_INSTALLS);
	List<IEmbeddedNodejs> list = new ArrayList<IEmbeddedNodejs>(cf.length);
	addNodejsInstalls(cf, list);
	addRegistryListenerIfNeeded();
	nodeJSInstalls = list;

	Trace.trace(Trace.EXTENSION_POINT, "-<- Done loading .nodeJSInstalls extension point -<-");
}
 
Example 6
Source File: TypeScriptConsoleConnectorManager.java    From typescript.java with MIT License 6 votes vote down vote up
/**
 * Load the TypeScript console connectors.
 */
private synchronized void loadTypeScriptConsoleConnectors() {
	if (typeScriptConsoleConnectors != null)
		return;

	Trace.trace(Trace.EXTENSION_POINT, "->- Loading .typeScriptConsoleConnectors extension point ->-");

	IExtensionRegistry registry = Platform.getExtensionRegistry();
	IConfigurationElement[] cf = registry.getConfigurationElementsFor(TypeScriptCorePlugin.PLUGIN_ID,
			EXTENSION_TYPESCRIPT_CONSOLE_CONNECTORS);
	List<ITypeScriptConsoleConnector> list = new ArrayList<ITypeScriptConsoleConnector>(cf.length);
	addTypeScriptConsoleConnectors(cf, list);
	addRegistryListenerIfNeeded();
	typeScriptConsoleConnectors = list;

	Trace.trace(Trace.EXTENSION_POINT, "-<- Done loading .typeScriptConsoleConnectors extension point -<-");
}
 
Example 7
Source File: CheckCfgUtil.java    From dsl-devkit with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Retrieves all property contributions from the checkcfg property extension point.
 *
 * @return the collection of all available property contributions, never {@code null}
 */
public static Collection<ICheckCfgPropertySpecification> getAllPropertyContributions() {
  Set<ICheckCfgPropertySpecification> contributions = Sets.newHashSet();
  IExtensionRegistry registry = Platform.getExtensionRegistry();
  if (registry != null) { // registry is null in the standalone builder...
    IConfigurationElement[] elements = registry.getConfigurationElementsFor(PROPERTY_EXTENSION_POINT);
    for (IConfigurationElement element : elements) {
      try {
        contributions.add((ICheckCfgPropertySpecification) element.createExecutableExtension(PROPERTY_EXECUTABLE_EXTENSION_ATTRIBUTE));
      } catch (CoreException e) {
        LOGGER.log(Level.WARN, "Failed to instantiate property from " + element.getContributor(), e);
      }
    }
  }
  return contributions;
}
 
Example 8
Source File: UIHelper.java    From tlaplus with MIT License 5 votes vote down vote up
/**
 * @return Returns the {@link IEditorPart} for the given editor id without
 *         opening the editor or null if no editor with the given id exists.
 *         Contrary to the Eclipse facilities to find and editor, this method
 *         does not initialize/render/configure the editor instance. It is left
 *         to the callee to properly initialize the editor instance by e.g.
 *         adding it to a MultipageEditor.
 * @throws CoreException
 */
public static IEditorPart findEditor(final String editorId) throws CoreException {
	final IExtensionRegistry registry = Platform.getExtensionRegistry();
	final IConfigurationElement[] elements = registry.getConfigurationElementsFor(PlatformUI.PLUGIN_ID, "editors");
	for (IConfigurationElement ice : elements) {
		if (editorId.equals(ice.getAttribute("id"))) {
			return (IEditorPart) ice.createExecutableExtension("class");
		}
	}
	return null;
}
 
Example 9
Source File: ESBService.java    From tesb-studio-se with Apache License 2.0 5 votes vote down vote up
private void addExtensionRepositoryNodes(List<ERepositoryObjectType> arraysList) {
    IExtensionRegistry registry = Platform.getExtensionRegistry();
    IConfigurationElement[] configurationElements = registry
            .getConfigurationElementsFor("org.talend.core.repository.repository_node_provider");
    for (IConfigurationElement element : configurationElements) {
        String type = element.getAttribute("type");
        ERepositoryObjectType repositoryNodeType = ERepositoryObjectType.valueOf(ERepositoryObjectType.class, type);
        if (repositoryNodeType != null) {
            arraysList.add(repositoryNodeType);
        }
    }
}
 
Example 10
Source File: DetectorsExtensionHelper.java    From spotbugs with GNU Lesser General Public License v2.1 5 votes vote down vote up
/** key is the plugin id, value is the plugin library path */
public static synchronized SortedMap<String, String> getContributedDetectors() {
    if (contributedDetectors != null) {
        return new TreeMap<>(contributedDetectors);
    }
    TreeMap<String, String> set = new TreeMap<>();

    IExtensionRegistry registry = Platform.getExtensionRegistry();
    for (IConfigurationElement configElt : registry.getConfigurationElementsFor(EXTENSION_POINT_ID)) {
        addContribution(set, configElt);
    }
    contributedDetectors = set;
    return new TreeMap<>(contributedDetectors);
}
 
Example 11
Source File: TmfAnalysisParameterProviders.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Return the analysis parameter providers advertised in the extension
 * point, and associated with an analysis ID.
 *
 * @param analysisId
 *            Get the parameter providers for an analysis identified by its
 *            ID
 * @return Map of analysis ID mapped to parameter provider classes
 */
public static Set<IAnalysisParameterProvider> getParameterProvidersFor(String analysisId) {
    Set<IAnalysisParameterProvider> providers = new HashSet<>();
    // Get the parameter provider elements from the extension point
    IExtensionRegistry extensionRegistry = Platform.getExtensionRegistry();
    if (extensionRegistry == null) {
        return Collections.emptySet();
    }
    IConfigurationElement[] config = extensionRegistry.getConfigurationElementsFor(TMF_ANALYSIS_TYPE_ID);
    for (IConfigurationElement ce : config) {
        String elementName = ce.getName();
        if (elementName.equals(PARAMETER_PROVIDER_ELEM)) {
            try {
                IConfigurationElement[] children = ce.getChildren(ANALYSIS_ID_ELEM);
                if (children.length == 0) {
                    throw new IllegalStateException();
                }
                String id = children[0].getAttribute(ID_ATTR);
                String className = ce.getAttribute(CLASS_ATTR);
                if (id == null || className == null) {
                    continue;
                }
                if (analysisId.equals(id)) {
                    IAnalysisParameterProvider provider = fParamProviderInstances.get(className);
                    if (provider == null) {
                        provider = checkNotNull((IAnalysisParameterProvider) ce.createExecutableExtension(CLASS_ATTR));
                        fParamProviderInstances.put(className, provider);
                    }
                    providers.add(provider);
                }
            } catch (InvalidRegistryObjectException | CoreException e) {
                Activator.logError("Error creating module parameter provider", e); //$NON-NLS-1$
            }
        }
    }
    return providers;
}
 
Example 12
Source File: JavaFoldingStructureProviderRegistry.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Reads all extensions.
 * <p>
 * This method can be called more than once in
 * order to reload from a changed extension registry.
 * </p>
 */
public void reloadExtensions() {
	IExtensionRegistry registry= Platform.getExtensionRegistry();
	Map<String, JavaFoldingStructureProviderDescriptor> map= new HashMap<String, JavaFoldingStructureProviderDescriptor>();

	IConfigurationElement[] elements= registry.getConfigurationElementsFor(JavaPlugin.getPluginId(), EXTENSION_POINT);
	for (int i= 0; i < elements.length; i++) {
		JavaFoldingStructureProviderDescriptor desc= new JavaFoldingStructureProviderDescriptor(elements[i]);
		map.put(desc.getId(), desc);
	}

	synchronized(this) {
		fDescriptors= Collections.unmodifiableMap(map);
	}
}
 
Example 13
Source File: EvaluateExtentionHandler.java    From developer-studio with Apache License 2.0 5 votes vote down vote up
public void execute(IExtensionRegistry registry) {
	IConfigurationElement[] config = registry.getConfigurationElementsFor(ExtentionPoint_ID);
	try {
		for (IConfigurationElement e : config) {
			final Object o = e.createExecutableExtension("class");
			if (o instanceof IResourceManager) {
				executeExtension(o);
			}
		}
	} catch (CoreException ex) {
		log.error("Error while finding " + ExtentionPoint_ID, ex);
	}
}
 
Example 14
Source File: FilterDescriptor.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Returns all contributed Java element filters.
 * @return all contributed Java element filters
 */
public static FilterDescriptor[] getFilterDescriptors() {
	if (fgFilterDescriptors == null) {
		IExtensionRegistry registry= Platform.getExtensionRegistry();
		IConfigurationElement[] elements= registry.getConfigurationElementsFor(JavaUI.ID_PLUGIN, EXTENSION_POINT_NAME);
		fgFilterDescriptors= createFilterDescriptors(elements);
	}
	return fgFilterDescriptors;
}
 
Example 15
Source File: SVNProviderPlugin.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
public static IMessageHandler[] getMessageHandlers() throws Exception {
	if (messageHandlers == null) {
		ArrayList<IMessageHandler> messageHandlerList = new ArrayList<IMessageHandler>();
		IExtensionRegistry extensionRegistry = Platform.getExtensionRegistry();
		IConfigurationElement[] configurationElements = extensionRegistry.getConfigurationElementsFor(MESSAGE_HANDLERS);
		for (int i = 0; i < configurationElements.length; i++) {
			IConfigurationElement configurationElement = configurationElements[i];
			IMessageHandler messageHandler = (IMessageHandler)configurationElement.createExecutableExtension("class"); //$NON-NLS-1$
			messageHandlerList.add(messageHandler);
		}
		messageHandlers = new IMessageHandler[messageHandlerList.size()];
		messageHandlerList.toArray(messageHandlers);	
	}
	return messageHandlers;
}
 
Example 16
Source File: PyEditorTextHoverDescriptor.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Returns all PyDev editor text hovers contributed to the workbench.
 *
 * @return an array with the contributed text hovers
 */
public static PyEditorTextHoverDescriptor[] getContributedHovers() {
    IExtensionRegistry registry = Platform.getExtensionRegistry();
    IConfigurationElement[] elements = registry
            .getConfigurationElementsFor(ExtensionHelper.PYDEV_HOVER2);
    PyEditorTextHoverDescriptor[] hoverDescs = createDescriptors(elements);
    initializeDefaultHoverPreferences(elements);
    initializeHoversFromPreferences(hoverDescs);
    return hoverDescs;
}
 
Example 17
Source File: DeveloperStudioProviderUtils.java    From developer-studio with Apache License 2.0 4 votes vote down vote up
/**
 * This method will return an array of IConfigurationElements of all the instances that extends a given extension point
 * @param extensionID - the id of the extension point
 * @return the IConfigurationElements array of data of all extended instances
 */
public IConfigurationElement[] getExtensionPointmembers(String extensionID){
	IExtensionRegistry reg = Platform.getExtensionRegistry();
    IConfigurationElement[] elements = reg.getConfigurationElementsFor(extensionID);
    return elements;
}
 
Example 18
Source File: E4PreferenceRegistry.java    From e4Preferences with Eclipse Public License 1.0 4 votes vote down vote up
/** 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);
	}
}
 
Example 19
Source File: WebAppProjectCreator.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 4 votes vote down vote up
@Inject
public void doSomething(IExtensionRegistry registry) {
  registry.getConfigurationElementsFor("com.gwtplugins.gdt.eclipse.suite.webAppCreatorParticipant");
}
 
Example 20
Source File: CheckConfigurationFactory.java    From eclipse-cs with GNU Lesser General Public License v2.1 4 votes vote down vote up
/**
 * Loads the built-in check configurations defined in plugin.xml or custom fragments.
 */
private static void loadBuiltinConfigurations() {

  IExtensionRegistry pluginRegistry = Platform.getExtensionRegistry();

  IConfigurationElement[] elements = pluginRegistry
          .getConfigurationElementsFor(CONFIGS_EXTENSION_POINT);

  int currentMaxDefaultWeight = -1;

  ICheckConfiguration defaultBuiltInCheckConfig = null;

  for (int i = 0; i < elements.length; i++) {
    String name = elements[i].getAttribute(XMLTags.NAME_TAG);
    String description = elements[i].getAttribute(XMLTags.DESCRIPTION_TAG);
    String location = elements[i].getAttribute(XMLTags.LOCATION_TAG);

    String defaultWeightAsString = elements[i].getAttribute(XMLTags.DEFAULT_WEIGHT);
    final int defaultWeight = defaultWeightAsString != null
            ? Integer.parseInt(defaultWeightAsString)
            : 0;

    IConfigurationType configType = ConfigurationTypes.getByInternalName("builtin");

    Map<String, String> additionalData = new HashMap<>();
    additionalData.put(BuiltInConfigurationType.CONTRIBUTOR_KEY,
            elements[i].getContributor().getName());

    List<ResolvableProperty> props = new ArrayList<>();
    IConfigurationElement[] propEls = elements[i].getChildren(XMLTags.PROPERTY_TAG);
    for (IConfigurationElement propEl : propEls) {
      props.add(new ResolvableProperty(propEl.getAttribute(XMLTags.NAME_TAG),
              propEl.getAttribute(XMLTags.VALUE_TAG)));
    }

    ICheckConfiguration checkConfig = new CheckConfiguration(name, location, description,
            configType, true, props, additionalData);
    sConfigurations.add(checkConfig);

    if (defaultWeight > currentMaxDefaultWeight) {
      currentMaxDefaultWeight = defaultWeight;
      defaultBuiltInCheckConfig = checkConfig;
    }
  }

  sDefaultBuiltInConfig = defaultBuiltInCheckConfig;
}