Search in sources :

Example 51 with IExtensionPoint

use of org.eclipse.core.runtime.IExtensionPoint in project webtools.servertools by eclipse.

the class ExtensionPointUtil method getExtensionPoint.

private static IExtensionPoint getExtensionPoint(String id) {
    IExtensionRegistry registry = Platform.getExtensionRegistry();
    IExtensionPoint extensionPoint = registry.getExtensionPoint(id);
    return extensionPoint;
}
Also used : IExtensionPoint(org.eclipse.core.runtime.IExtensionPoint) IExtensionRegistry(org.eclipse.core.runtime.IExtensionRegistry)

Example 52 with IExtensionPoint

use of org.eclipse.core.runtime.IExtensionPoint in project webtools.servertools by eclipse.

the class ExtensionPointUtil method getExtensions.

private static IExtension[] getExtensions(String extensionId) {
    IExtensionPoint extensionPoint = getExtensionPoint(extensionId);
    IExtension[] extensions = extensionPoint.getExtensions();
    return extensions;
}
Also used : IExtensionPoint(org.eclipse.core.runtime.IExtensionPoint) IExtension(org.eclipse.core.runtime.IExtension)

Example 53 with IExtensionPoint

use of org.eclipse.core.runtime.IExtensionPoint in project eclipse.platform.runtime by eclipse.

the class EclipseTestHarnessApplication method findTestFor.

/**
 * Finds, creates and returns a prototypical test object for the test with
 * the given name/id.  Returns <code>null</code> if no such test is found
 * or the class defined by the test extension could not be found.
 * In either failure case a message is output on the System console.
 */
protected Object findTestFor(String testName) {
    IExtensionPoint point = Platform.getExtensionRegistry().getExtensionPoint(PI_TESTHARNESS, PT_TESTS);
    IConfigurationElement[] elements = point.getConfigurationElements();
    for (IConfigurationElement element : elements) {
        if (element.getName().equals("test")) {
            String id = element.getAttribute("id");
            if (id != null && id.equals(testName)) {
                try {
                    return element.createExecutableExtension("run");
                } catch (CoreException e) {
                    System.err.println("Could not instantiate test: " + testName);
                    e.printStackTrace();
                    return null;
                }
            }
        }
    }
    System.out.println("Could not find test: " + testName);
    return null;
}
Also used : IExtensionPoint(org.eclipse.core.runtime.IExtensionPoint) CoreException(org.eclipse.core.runtime.CoreException) IConfigurationElement(org.eclipse.core.runtime.IConfigurationElement)

Example 54 with IExtensionPoint

use of org.eclipse.core.runtime.IExtensionPoint in project eclipse.platform.runtime by eclipse.

the class ContributorsTest method testByContributor.

/**
 * bundleA, bundleB, and fragment on bundleA all use the same namespace. Verify that getting
 * elements by contributor returns all elements from the contributor and only from that
 * contributor.
 *
 * @throws IOException
 * @throws BundleException
 */
public void testByContributor() throws IOException, BundleException {
    Bundle bundleA = null;
    Bundle bundleB = null;
    Bundle fragment = null;
    try {
        bundleA = BundleTestingHelper.installBundle("0.1", RuntimeTestsPlugin.getContext(), RuntimeTestsPlugin.TEST_FILES_ROOT + "registry/elementsByContributor/A");
        bundleB = BundleTestingHelper.installBundle("0.2", RuntimeTestsPlugin.getContext(), RuntimeTestsPlugin.TEST_FILES_ROOT + "registry/elementsByContributor/B");
        fragment = BundleTestingHelper.installBundle("0.2", RuntimeTestsPlugin.getContext(), RuntimeTestsPlugin.TEST_FILES_ROOT + "registry/elementsByContributor/Afragment");
        BundleTestingHelper.refreshPackages(RuntimeTestsPlugin.getContext(), new Bundle[] { bundleA, bundleB, fragment });
        IExtensionRegistry registry = RegistryFactory.getRegistry();
        // verify bundleA (bundle B is the same - will work if this works)
        IContributor contributorA = ContributorFactoryOSGi.createContributor(bundleA);
        IExtensionPoint[] extPointsA = registry.getExtensionPoints(contributorA);
        assertNotNull(extPointsA);
        assertTrue(extPointsA.length == 1);
        assertTrue(extPointsA[0].getUniqueIdentifier().equals("org.eclipse.test.registryByContrib.PointA"));
        IExtension[] extsA = registry.getExtensions(contributorA);
        assertNotNull(extsA);
        assertTrue(extsA.length == 1);
        assertTrue(extsA[0].getUniqueIdentifier().equals("org.eclipse.test.registryByContrib.ExtensionA"));
        // verify fragment
        IContributor contributorAF = ContributorFactoryOSGi.createContributor(fragment);
        IExtensionPoint[] extPointsFragmentA = registry.getExtensionPoints(contributorAF);
        assertNotNull(extPointsFragmentA);
        assertTrue(extPointsFragmentA.length == 1);
        assertTrue(extPointsFragmentA[0].getUniqueIdentifier().equals("org.eclipse.test.registryByContrib.PointFA"));
        IExtension[] extsFragmentA = registry.getExtensions(contributorAF);
        assertNotNull(extsFragmentA);
        assertTrue(extsFragmentA.length == 1);
        assertTrue(extsFragmentA[0].getUniqueIdentifier().equals("org.eclipse.test.registryByContrib.ExtensionFA"));
    } finally {
        if (bundleA != null)
            bundleA.uninstall();
        if (bundleB != null)
            bundleB.uninstall();
        if (fragment != null)
            fragment.uninstall();
    }
}
Also used : IExtensionPoint(org.eclipse.core.runtime.IExtensionPoint) Bundle(org.osgi.framework.Bundle) IExtension(org.eclipse.core.runtime.IExtension) IContributor(org.eclipse.core.runtime.IContributor) IExtensionRegistry(org.eclipse.core.runtime.IExtensionRegistry)

Example 55 with IExtensionPoint

use of org.eclipse.core.runtime.IExtensionPoint in project mdw-designer by CenturyLinkCloud.

the class WorkflowProjectManager method getAllExtensions.

private List<ExtensionModule> getAllExtensions() {
    if (allExtensions == null) {
        allExtensions = new ArrayList<ExtensionModule>();
        // read the plug-in extensions
        IExtensionRegistry registry = Platform.getExtensionRegistry();
        IExtensionPoint extensionPoint = registry.getExtensionPoint("com.centurylink.mdw.designer.ui.extensionModules");
        IExtension[] extensions = extensionPoint.getExtensions();
        for (IExtension extension : extensions) {
            for (IConfigurationElement element : extension.getConfigurationElements()) {
                try {
                    ExtensionModule module = (ExtensionModule) element.createExecutableExtension("class");
                    module.setId(element.getAttribute("id"));
                    module.setName(element.getAttribute("name"));
                    module.setDescription(element.getAttribute("description"));
                    // null
                    module.setVersion(element.getAttribute("version"));
                    // means
                    // MDW
                    // version
                    String requiredMdwVersion = element.getAttribute("requiredMdwVersion");
                    if (requiredMdwVersion != null)
                        // null
                        module.setRequiredMdwVersion(requiredMdwVersion);
                    // means
                    // any
                    // >=
                    // 5.1
                    allExtensions.add(module);
                } catch (Exception ex) {
                    PluginMessages.log("Unable to load MDW Extension for element: " + element);
                    PluginMessages.log(ex);
                }
            }
        }
    }
    Collections.sort(allExtensions);
    return allExtensions;
}
Also used : IExtensionPoint(org.eclipse.core.runtime.IExtensionPoint) IExtension(org.eclipse.core.runtime.IExtension) ExtensionModule(com.centurylink.mdw.plugin.project.extensions.ExtensionModule) IConfigurationElement(org.eclipse.core.runtime.IConfigurationElement) ResourceException(org.eclipse.core.internal.resources.ResourceException) CoreException(org.eclipse.core.runtime.CoreException) JavaModelException(org.eclipse.jdt.core.JavaModelException) MdwSecurityException(com.centurylink.mdw.auth.MdwSecurityException) DiscoveryException(com.centurylink.mdw.plugin.designer.DiscoveryException) XmlException(org.apache.xmlbeans.XmlException) IExtensionRegistry(org.eclipse.core.runtime.IExtensionRegistry)

Aggregations

IExtensionPoint (org.eclipse.core.runtime.IExtensionPoint)187 IConfigurationElement (org.eclipse.core.runtime.IConfigurationElement)160 IExtensionRegistry (org.eclipse.core.runtime.IExtensionRegistry)107 IExtension (org.eclipse.core.runtime.IExtension)92 CoreException (org.eclipse.core.runtime.CoreException)70 ArrayList (java.util.ArrayList)29 HashMap (java.util.HashMap)17 Platform (org.eclipse.core.runtime.Platform)17 Stream (java.util.stream.Stream)16 List (java.util.List)15 NodeLogger (org.knime.core.node.NodeLogger)15 Map (java.util.Map)14 Optional (java.util.Optional)14 Collection (java.util.Collection)9 Bundle (org.osgi.framework.Bundle)9 Collectors (java.util.stream.Collectors)8 IOException (java.io.IOException)6 Collections (java.util.Collections)6 LinkedList (java.util.LinkedList)6 Objects (java.util.Objects)6