Search in sources :

Example 91 with IConfigurationElement

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

the class TbImporter method runExtension.

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

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

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

Example 92 with IConfigurationElement

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

the class ComplexMatcherFactory method runExtension.

/**
	 * load implement of complex matcher
	 */
private void runExtension() {
    IConfigurationElement[] config = Platform.getExtensionRegistry().getConfigurationElementsFor(EXTENSION_ID);
    try {
        for (IConfigurationElement e : config) {
            final Object o = e.createExecutableExtension("class");
            if (o instanceof IComplexMatch) {
                ISafeRunnable runnable = new ISafeRunnable() {

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

                    public void run() throws Exception {
                        IComplexMatch simpleMatcher = (IComplexMatch) o;
                        matchers.add(simpleMatcher);
                    }
                };
                SafeRunner.run(runnable);
            }
        }
    } catch (CoreException ex) {
        logger.error(Messages.getString("complexMatch.ComplexMatcherFactory.logger1"), ex);
    }
}
Also used : CoreException(org.eclipse.core.runtime.CoreException) ISafeRunnable(org.eclipse.core.runtime.ISafeRunnable) IConfigurationElement(org.eclipse.core.runtime.IConfigurationElement)

Example 93 with IConfigurationElement

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

the class TmImporter method runExtension.

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

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

                    public void run() throws Exception {
                        tmImporter = (ITmImporter) o;
                    }
                };
                SafeRunner.run(runnable);
            }
        }
    } catch (CoreException ex) {
        logger.error(Messages.getString("importer.TmImporter.logger1"), ex);
    }
}
Also used : ITmImporter(net.heartsome.cat.ts.tm.importer.extension.ITmImporter) CoreException(org.eclipse.core.runtime.CoreException) ISafeRunnable(org.eclipse.core.runtime.ISafeRunnable) IConfigurationElement(org.eclipse.core.runtime.IConfigurationElement)

Example 94 with IConfigurationElement

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

the class TmMatcher method runExtension.

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

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

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

Example 95 with IConfigurationElement

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

the class SimpleMatcherFactory method runExtension.

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

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

                    public void run() throws Exception {
                        ISimpleMatcher simpleMatcher = (ISimpleMatcher) o;
                        matchers.add(simpleMatcher);
                    }
                };
                SafeRunner.run(runnable);
            }
        }
    } catch (CoreException ex) {
        logger.error(Messages.getString("simpleMatch.SimpleMatcherFactory.logger1"), ex);
    }
}
Also used : CoreException(org.eclipse.core.runtime.CoreException) ISafeRunnable(org.eclipse.core.runtime.ISafeRunnable) IConfigurationElement(org.eclipse.core.runtime.IConfigurationElement)

Aggregations

IConfigurationElement (org.eclipse.core.runtime.IConfigurationElement)189 CoreException (org.eclipse.core.runtime.CoreException)75 IExtensionPoint (org.eclipse.core.runtime.IExtensionPoint)64 IExtensionRegistry (org.eclipse.core.runtime.IExtensionRegistry)50 ArrayList (java.util.ArrayList)39 IExtension (org.eclipse.core.runtime.IExtension)30 IStatus (org.eclipse.core.runtime.IStatus)24 Status (org.eclipse.core.runtime.Status)24 HashMap (java.util.HashMap)16 HashSet (java.util.HashSet)16 ISafeRunnable (org.eclipse.core.runtime.ISafeRunnable)11 List (java.util.List)9 Map (java.util.Map)9 Platform (org.eclipse.core.runtime.Platform)9 File (java.io.File)8 Collection (java.util.Collection)8 Stream (java.util.stream.Stream)8 LinkedList (java.util.LinkedList)7 Optional (java.util.Optional)5 IFile (org.eclipse.core.resources.IFile)5