Search in sources :

Example 6 with IConfigurationElement

use of org.eclipse.core.runtime.IConfigurationElement in project translationstudio8 by heartsome.

the class TbMatcher method runExtension.

/**
	 * 加载记忆库匹配实现 ;
	 */
private void runExtension() {
    IConfigurationElement[] config = Platform.getExtensionRegistry().getConfigurationElementsFor(TERMMATCH_EXTENSION_ID);
    try {
        for (IConfigurationElement e : config) {
            final Object o = e.createExecutableExtension("class");
            if (o instanceof ITbMatch) {
                ISafeRunnable runnable = new ISafeRunnable() {

                    public void handleException(Throwable exception) {
                        logger.error(Messages.getString("match.TbMatcher.logger1"), exception);
                    }

                    public void run() throws Exception {
                        termMatch = (ITbMatch) o;
                    }
                };
                SafeRunner.run(runnable);
            }
        }
    } catch (CoreException ex) {
        logger.error(Messages.getString("match.TbMatcher.logger1"), ex);
    }
}
Also used : CoreException(org.eclipse.core.runtime.CoreException) ITbMatch(net.heartsome.cat.ts.tb.match.extension.ITbMatch) ISafeRunnable(org.eclipse.core.runtime.ISafeRunnable) IConfigurationElement(org.eclipse.core.runtime.IConfigurationElement)

Example 7 with IConfigurationElement

use of org.eclipse.core.runtime.IConfigurationElement in project translationstudio8 by heartsome.

the class NewProjectWizard method runWizardPageExtension.

/**
	 * 加载扩展向导页 ;
	 */
private void runWizardPageExtension() {
    // 加载向导扩展
    IConfigurationElement[] config = Platform.getExtensionRegistry().getConfigurationElementsFor(PAGE_EXTENSION_ID);
    try {
        for (IConfigurationElement e : config) {
            final Object o = e.createExecutableExtension("class");
            if (o instanceof AbstractNewProjectWizardPage) {
                ISafeRunnable runnable = new ISafeRunnable() {

                    public void handleException(Throwable exception) {
                        logger.error(Messages.getString("wizard.NewProjectWizard.logger1"), exception);
                    }

                    public void run() throws Exception {
                        extensionPages.add((AbstractNewProjectWizardPage) o);
                    }
                };
                SafeRunner.run(runnable);
            }
        }
    } catch (CoreException ex) {
        logger.error(Messages.getString("wizard.NewProjectWizard.logger1"), ex);
    }
    // 加载转换器扩展
    IConfigurationElement[] config2 = Platform.getExtensionRegistry().getConfigurationElementsFor("net.heartsome.cat.ts.ui.extension.converter");
    try {
        for (IConfigurationElement e : config2) {
            final Object o = e.createExecutableExtension("class");
            if (o instanceof IConverterCaller) {
                ISafeRunnable runnable = new ISafeRunnable() {

                    public void handleException(Throwable exception) {
                        logger.error(Messages.getString("wizard.NewProjectWizard.logger2"), exception);
                    }

                    public void run() throws Exception {
                        convertImpl = (IConverterCaller) o;
                    }
                };
                SafeRunner.run(runnable);
            }
        }
    } catch (CoreException ex) {
        logger.error(Messages.getString("wizard.NewProjectWizard.logger2"), ex);
    }
}
Also used : AbstractNewProjectWizardPage(net.heartsome.cat.ts.ui.extensionpoint.AbstractNewProjectWizardPage) CoreException(org.eclipse.core.runtime.CoreException) ISafeRunnable(org.eclipse.core.runtime.ISafeRunnable) IConverterCaller(net.heartsome.cat.ts.ui.extensionpoint.IConverterCaller) IConfigurationElement(org.eclipse.core.runtime.IConfigurationElement)

Example 8 with IConfigurationElement

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

the class CustomizeJetFilesProviderManager method loadJetsProvidersFromExtension.

private void loadJetsProvidersFromExtension() {
    providers = new ArrayList<AbstractJetFileProvider>();
    IExtensionRegistry extensionRegistry = Platform.getExtensionRegistry();
    //$NON-NLS-1$
    IExtensionPoint extensionPoint = extensionRegistry.getExtensionPoint("org.talend.designer.codegen.additional_jetfile");
    IExtension[] extensions = extensionPoint.getExtensions();
    for (IExtension extension : extensions) {
        IConfigurationElement[] configurationElements = extension.getConfigurationElements();
        for (IConfigurationElement configurationElement : configurationElements) {
            //$NON-NLS-1$               
            String id = configurationElement.getAttribute("id");
            try {
                AbstractJetFileProvider jetProvider = (AbstractJetFileProvider) configurationElement.createExecutableExtension(//$NON-NLS-1$
                "class");
                jetProvider.setId(id);
                providers.add(jetProvider);
            } catch (CoreException e) {
                //$NON-NLS-1$
                log.error(Messages.getString("JetFilesProviderManager.unableLoad", id), e);
            }
        }
    }
}
Also used : IExtensionPoint(org.eclipse.core.runtime.IExtensionPoint) CoreException(org.eclipse.core.runtime.CoreException) IExtension(org.eclipse.core.runtime.IExtension) IConfigurationElement(org.eclipse.core.runtime.IConfigurationElement) IExtensionRegistry(org.eclipse.core.runtime.IExtensionRegistry)

Example 9 with IConfigurationElement

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

the class ComponentsProviderManager method loadComponentsProvidersFromExtension.

private void loadComponentsProvidersFromExtension() {
    if (providers == null) {
        providers = new ArrayList<AbstractComponentsProvider>();
        IExtensionRegistry extensionRegistry = Platform.getExtensionRegistry();
        //$NON-NLS-1$
        IExtensionPoint extensionPoint = extensionRegistry.getExtensionPoint("org.talend.core.components_provider");
        IExtension[] extensions = extensionPoint.getExtensions();
        for (IExtension extension : extensions) {
            IConfigurationElement[] configurationElements = extension.getConfigurationElements();
            for (IConfigurationElement configurationElement : configurationElements) {
                //$NON-NLS-1$
                String id = configurationElement.getAttribute("id");
                //$NON-NLS-1$
                String folderName = configurationElement.getAttribute("folderName");
                String contributerName = configurationElement.getContributor().getName();
                IBrandingService brandingService = (IBrandingService) GlobalServiceRegister.getDefault().getService(IBrandingService.class);
                if (!brandingService.isPoweredOnlyCamel() && id.equals("org.talend.designer.camel.components.localprovider.CamelLocalComponentsProvider")) {
                    folderName = "camel";
                }
                try {
                    AbstractComponentsProvider componentsProvider = (AbstractComponentsProvider) configurationElement.createExecutableExtension(//$NON-NLS-1$
                    "class");
                    componentsProvider.setId(id);
                    componentsProvider.setFolderName(folderName);
                    componentsProvider.setContributer(contributerName);
                    providers.add(componentsProvider);
                } catch (CoreException e) {
                    //$NON-NLS-1$
                    log.error(Messages.getString("ComponentsProviderManager.unableLoad") + id, e);
                }
            }
        }
    }
}
Also used : AbstractComponentsProvider(org.talend.core.model.components.AbstractComponentsProvider) IExtensionPoint(org.eclipse.core.runtime.IExtensionPoint) CoreException(org.eclipse.core.runtime.CoreException) IExtension(org.eclipse.core.runtime.IExtension) IBrandingService(org.talend.core.ui.branding.IBrandingService) IConfigurationElement(org.eclipse.core.runtime.IConfigurationElement) IExtensionRegistry(org.eclipse.core.runtime.IExtensionRegistry)

Example 10 with IConfigurationElement

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

the class ExtendedNodeManager method getExtendedNodeHandler.

public static List<IExtendedNodeHandler> getExtendedNodeHandler() {
    if (extendedNodeHandler == null) {
        extendedNodeHandler = new ArrayList<IExtendedNodeHandler>();
        IExtensionRegistry extensionRegistry = Platform.getExtensionRegistry();
        IExtensionPoint extensionPoint = extensionRegistry.getExtensionPoint(//$NON-NLS-1$
        "org.talend.designer.core.extended_node_handler");
        if (extensionPoint != null) {
            IExtension[] extensions = extensionPoint.getExtensions();
            for (IExtension extension : extensions) {
                IConfigurationElement[] configurationElements = extension.getConfigurationElements();
                for (IConfigurationElement configurationElement : configurationElements) {
                    try {
                        //$NON-NLS-1$
                        Object service = configurationElement.createExecutableExtension("class");
                        if (service instanceof IExtendedNodeHandler) {
                            extendedNodeHandler.add((IExtendedNodeHandler) service);
                        }
                    } catch (CoreException e) {
                        ExceptionHandler.process(e);
                    }
                }
            }
        }
    }
    return extendedNodeHandler;
}
Also used : IExtensionPoint(org.eclipse.core.runtime.IExtensionPoint) CoreException(org.eclipse.core.runtime.CoreException) IExtension(org.eclipse.core.runtime.IExtension) IConfigurationElement(org.eclipse.core.runtime.IConfigurationElement) IExtensionRegistry(org.eclipse.core.runtime.IExtensionRegistry)

Aggregations

IConfigurationElement (org.eclipse.core.runtime.IConfigurationElement)62 CoreException (org.eclipse.core.runtime.CoreException)32 IExtensionRegistry (org.eclipse.core.runtime.IExtensionRegistry)14 IExtension (org.eclipse.core.runtime.IExtension)12 IExtensionPoint (org.eclipse.core.runtime.IExtensionPoint)12 ISafeRunnable (org.eclipse.core.runtime.ISafeRunnable)11 ArrayList (java.util.ArrayList)8 List (java.util.List)5 GridData (org.eclipse.swt.layout.GridData)4 HashSet (java.util.HashSet)3 Set (java.util.Set)3 ImageDescriptor (org.eclipse.jface.resource.ImageDescriptor)3 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)3 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)3 Image (org.eclipse.swt.graphics.Image)3 GridLayout (org.eclipse.swt.layout.GridLayout)3 Composite (org.eclipse.swt.widgets.Composite)3 HeaderClause (aQute.bnd.build.model.clauses.HeaderClause)2 File (java.io.File)2 URL (java.net.URL)2