Search in sources :

Example 1 with IConfigurationElement

use of org.eclipse.core.runtime.IConfigurationElement in project che by eclipse.

the class ContributionContextTypeRegistry method createContextType.

/**
	 * Tries to create a context type given an id. Contributions to the
	 * <code>org.eclipse.ui.editors.templates</code> extension point are
	 * searched for the given identifier and the specified context type
	 * instantiated if it is found. Any contributed
	 * {@link org.eclipse.jface.text.templates.TemplateVariableResolver}s
	 * are also instantiated and added to the context type.
	 *
	 * @param id the id for the context type as specified in XML
	 * @return the instantiated and configured context type, or
	 *         <code>null</code> if it is not found or cannot be instantiated
	 */
public static TemplateContextType createContextType(String id) {
    Assert.isNotNull(id);
    IConfigurationElement[] extensions = getTemplateExtensions();
    TemplateContextType type;
    try {
        type = createContextType(extensions, id);
        if (type != null) {
            TemplateVariableResolver[] resolvers = createResolvers(extensions, id);
            for (int i = 0; i < resolvers.length; i++) type.addResolver(resolvers[i]);
        }
    } catch (CoreException e) {
        JavaPlugin.log(e);
        type = null;
    }
    return type;
}
Also used : CoreException(org.eclipse.core.runtime.CoreException) IConfigurationElement(org.eclipse.core.runtime.IConfigurationElement) TemplateContextType(org.eclipse.jface.text.templates.TemplateContextType) TemplateVariableResolver(org.eclipse.jface.text.templates.TemplateVariableResolver)

Example 2 with IConfigurationElement

use of org.eclipse.core.runtime.IConfigurationElement in project che by eclipse.

the class ExtensionsRegistry method doGetDocumentFactory.

/**
	 * Returns a sharable document factory for the given content types.
	 *
	 * @param contentTypes the content types used to find the factory
	 * @return the sharable document factory or <code>null</code>
	 * @deprecated As of 3.5
	 */
protected org.eclipse.core.filebuffers.IDocumentFactory doGetDocumentFactory(IContentType[] contentTypes) {
    Set set = null;
    int i = 0;
    while (i < contentTypes.length && set == null) {
        set = (Set) fFactoryDescriptors.get(new ContentTypeAdapter(contentTypes[i++]));
    }
    if (set != null) {
        IConfigurationElement entry = selectConfigurationElement(set);
        return (org.eclipse.core.filebuffers.IDocumentFactory) getExtension(entry, fFactories, org.eclipse.core.filebuffers.IDocumentFactory.class);
    }
    return null;
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) IConfigurationElement(org.eclipse.core.runtime.IConfigurationElement)

Example 3 with IConfigurationElement

use of org.eclipse.core.runtime.IConfigurationElement in project che by eclipse.

the class ExtensionsRegistry method doGetDocumentSetupParticipants.

/**
	 * Returns the set of setup participants for the given content types.
	 *
	 * @param contentTypes the contentTypes to be used for lookup
	 * @return the sharable set of document setup participants
	 */
private List doGetDocumentSetupParticipants(IContentType[] contentTypes) {
    Set resultSet = new HashSet();
    int i = 0;
    while (i < contentTypes.length) {
        Set set = (Set) fSetupParticipantDescriptors.get(new ContentTypeAdapter(contentTypes[i++]));
        if (set != null)
            resultSet.addAll(set);
    }
    List participants = new ArrayList();
    Iterator e = resultSet.iterator();
    while (e.hasNext()) {
        IConfigurationElement entry = (IConfigurationElement) e.next();
        Object participant = getExtension(entry, fSetupParticipants, IDocumentSetupParticipant.class);
        if (participant != null)
            participants.add(participant);
    }
    return participants.isEmpty() ? null : participants;
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) List(java.util.List) IConfigurationElement(org.eclipse.core.runtime.IConfigurationElement) HashSet(java.util.HashSet)

Example 4 with IConfigurationElement

use of org.eclipse.core.runtime.IConfigurationElement in project tdi-studio-se by Talend.

the class SchemaNode method addExtensionNodes.

/**
     * Add Extension nodes.
     */
//$NON-NLS-1$
@SuppressWarnings("unchecked")
private void addExtensionNodes() {
    String databaseProductName = getSession().getRoot().getDatabaseProductName().toLowerCase().trim();
    IExtensionRegistry registry = Platform.getExtensionRegistry();
    //$NON-NLS-1$ //$NON-NLS-2$
    IExtensionPoint point = registry.getExtensionPoint("net.sourceforge.sqlexplorer", "node");
    IExtension[] extensions = point.getExtensions();
    for (int i = 0; i < extensions.length; i++) {
        IExtension e = extensions[i];
        IConfigurationElement[] ces = e.getConfigurationElements();
        for (int j = 0; j < ces.length; j++) {
            try {
                // include only nodes that are attachted to the schema
                // node..
                //$NON-NLS-1$
                String parent = ces[j].getAttribute("parent-node");
                if (parent.indexOf("schema") == -1) {
                    //$NON-NLS-1$
                    continue;
                }
                boolean isValidProduct = false;
                //$NON-NLS-1$ //$NON-NLS-2$
                String[] validProducts = ces[j].getAttribute("database-product-name").split(",");
                // include only nodes valid for this database
                for (int k = 0; k < validProducts.length; k++) {
                    String product = validProducts[k].toLowerCase().trim();
                    if (product.length() == 0) {
                        continue;
                    }
                    if (product.equals("*")) {
                        //$NON-NLS-1$
                        isValidProduct = true;
                        break;
                    }
                    //$NON-NLS-1$
                    String regex = TextUtil.replaceChar(product, '*', ".*");
                    if (databaseProductName.matches(regex)) {
                        isValidProduct = true;
                        break;
                    }
                }
                if (!isValidProduct) {
                    continue;
                }
                //$NON-NLS-1$
                String imagePath = ces[j].getAttribute("icon");
                //$NON-NLS-1$
                String id = ces[j].getAttribute("id");
                //$NON-NLS-1$
                String type = ces[j].getAttribute("table-type").trim();
                //$NON-NLS-1$
                AbstractNode childNode = (AbstractNode) ces[j].createExecutableExtension("class");
                childNode.setParent(this);
                childNode.setSession(psessionNode);
                childNode.setType(type);
                String fragmentId = id.substring(0, id.indexOf('.', END_INDEX));
                if (imagePath != null && imagePath.trim().length() != 0) {
                    childNode.setImage(ImageUtil.getFragmentImage(fragmentId, imagePath));
                }
                pchildNames.add(childNode.getLabelText());
                if (!isExcludedByFilter(childNode.getLabelText())) {
                    addChildNode(childNode);
                }
            } catch (Throwable ex) {
                //$NON-NLS-1$
                SqlBuilderPlugin.log(Messages.getString("SchemaNode.logMessage1"), ex);
            }
        }
    }
}
Also used : IExtensionPoint(org.eclipse.core.runtime.IExtensionPoint) IExtension(org.eclipse.core.runtime.IExtension) IConfigurationElement(org.eclipse.core.runtime.IConfigurationElement) IExtensionPoint(org.eclipse.core.runtime.IExtensionPoint) IExtensionRegistry(org.eclipse.core.runtime.IExtensionRegistry)

Example 5 with IConfigurationElement

use of org.eclipse.core.runtime.IConfigurationElement in project tdi-studio-se by Talend.

the class JavaJobScriptsExportWSWizardPagePresenter method initExtraCheckersFromExtensionPoint.

/**
	 * Inits the extra checkers from plugin extension
	 * <code>org.talend.repository.ui.wizards.exportjob.extraBuildChecker</code>
	 */
private void initExtraCheckersFromExtensionPoint() {
    IExtension[] extensions = Platform.getExtensionRegistry().getExtensionPoint(EXTENSION_EXTRA_BUILD_CHECKER).getExtensions();
    for (IExtension extension : extensions) {
        IConfigurationElement[] eles = extension.getConfigurationElements();
        for (IConfigurationElement ele : eles) {
            try {
                ExtraBuildChecker checker = (ExtraBuildChecker) ele.createExecutableExtension(EXTRA_BUILD_CHECKER);
                addExtraChecker(checker);
            } catch (CoreException e) {
                ExceptionHandler.process(new RuntimeException("Can't load extra Job Build checker - " + ele, e));
            }
        }
    }
}
Also used : CoreException(org.eclipse.core.runtime.CoreException) IExtension(org.eclipse.core.runtime.IExtension) ExtraBuildChecker(org.talend.repository.ui.wizards.exportjob.extrachecker.ExtraBuildChecker) IConfigurationElement(org.eclipse.core.runtime.IConfigurationElement)

Aggregations

IConfigurationElement (org.eclipse.core.runtime.IConfigurationElement)530 CoreException (org.eclipse.core.runtime.CoreException)196 IExtensionRegistry (org.eclipse.core.runtime.IExtensionRegistry)182 IExtensionPoint (org.eclipse.core.runtime.IExtensionPoint)175 ArrayList (java.util.ArrayList)124 IExtension (org.eclipse.core.runtime.IExtension)100 HashMap (java.util.HashMap)36 IStatus (org.eclipse.core.runtime.IStatus)35 List (java.util.List)34 Status (org.eclipse.core.runtime.Status)34 Bundle (org.osgi.framework.Bundle)24 HashSet (java.util.HashSet)22 Map (java.util.Map)18 ISafeRunnable (org.eclipse.core.runtime.ISafeRunnable)16 IOException (java.io.IOException)15 Iterator (java.util.Iterator)14 Platform (org.eclipse.core.runtime.Platform)14 URL (java.net.URL)13 Collection (java.util.Collection)12 Stream (java.util.stream.Stream)11