Search in sources :

Example 26 with ISafeRunnable

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

the class DeltaProcessor method notifyTypeHierarchies.

private void notifyTypeHierarchies(IElementChangedListener[] listeners, int listenerCount) {
    for (int i = 0; i < listenerCount; i++) {
        final IElementChangedListener listener = listeners[i];
        if (!(listener instanceof TypeHierarchy))
            continue;
        // wrap callbacks with Safe runnable for subsequent listeners to be called when some are causing grief
        SafeRunner.run(new ISafeRunnable() {

            public void handleException(Throwable exception) {
                //$NON-NLS-1$
                Util.log(exception, "Exception occurred in listener of Java element change notification");
            }

            public void run() throws Exception {
                TypeHierarchy typeHierarchy = (TypeHierarchy) listener;
                if (typeHierarchy.hasFineGrainChanges()) {
                    // case of changes in primary working copies
                    typeHierarchy.needsRefresh = true;
                    typeHierarchy.fireChange();
                }
            }
        });
    }
}
Also used : IElementChangedListener(org.eclipse.jdt.core.IElementChangedListener) ISafeRunnable(org.eclipse.core.runtime.ISafeRunnable) TypeHierarchy(org.eclipse.jdt.internal.core.hierarchy.TypeHierarchy) JavaModelException(org.eclipse.jdt.core.JavaModelException) CoreException(org.eclipse.core.runtime.CoreException)

Example 27 with ISafeRunnable

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

the class AutomaticQATrigger method runExtension.

/**
	 * 加载自动品质检查的扩展
	 */
private void runExtension() {
    IConfigurationElement[] config = Platform.getExtensionRegistry().getConfigurationElementsFor(CONSTANT_automaticQA_EXTENSION_ID);
    try {
        for (IConfigurationElement e : config) {
            final Object o = e.createExecutableExtension("class");
            if (o instanceof IAutomaticQA) {
                ISafeRunnable runnable = new ISafeRunnable() {

                    public void handleException(Throwable exception) {
                        exception.printStackTrace();
                    }

                    public void run() throws Exception {
                        autoQA = (IAutomaticQA) o;
                    }
                };
                SafeRunner.run(runnable);
            }
        }
    } catch (CoreException e) {
        LOGGER.error("", e);
        e.printStackTrace();
    }
}
Also used : CoreException(org.eclipse.core.runtime.CoreException) ISafeRunnable(org.eclipse.core.runtime.ISafeRunnable) IConfigurationElement(org.eclipse.core.runtime.IConfigurationElement)

Example 28 with ISafeRunnable

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

the class RealTimeSpellCheckTrigger method runExtension.

/**
	 * 加哉实时拼写检查 ;
	 */
private void runExtension() {
    IConfigurationElement[] config = Platform.getExtensionRegistry().getConfigurationElementsFor(CONSTANT_realTimeSpell_extentionId);
    try {
        for (IConfigurationElement e : config) {
            final Object o = e.createExecutableExtension("class");
            if (o instanceof IRealTimeSpellCheck) {
                ISafeRunnable runnable = new ISafeRunnable() {

                    public void handleException(Throwable exception) {
                        exception.printStackTrace();
                    }

                    public void run() throws Exception {
                        realTimeSpell = (IRealTimeSpellCheck) o;
                    }
                };
                SafeRunner.run(runnable);
            }
        }
    } catch (CoreException e) {
        LOGGER.error("", e);
        e.printStackTrace();
    }
}
Also used : CoreException(org.eclipse.core.runtime.CoreException) ISafeRunnable(org.eclipse.core.runtime.ISafeRunnable) IConfigurationElement(org.eclipse.core.runtime.IConfigurationElement)

Example 29 with ISafeRunnable

use of org.eclipse.core.runtime.ISafeRunnable 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 30 with ISafeRunnable

use of org.eclipse.core.runtime.ISafeRunnable 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)

Aggregations

ISafeRunnable (org.eclipse.core.runtime.ISafeRunnable)44 CoreException (org.eclipse.core.runtime.CoreException)28 IConfigurationElement (org.eclipse.core.runtime.IConfigurationElement)11 IStatus (org.eclipse.core.runtime.IStatus)11 Status (org.eclipse.core.runtime.Status)11 OperationCanceledException (org.eclipse.core.runtime.OperationCanceledException)6 ISpellingPreferenceBlock (org.eclipse.ui.texteditor.spelling.ISpellingPreferenceBlock)5 ExecutionException (org.eclipse.core.commands.ExecutionException)4 CompilationUnit (org.eclipse.jdt.core.dom.CompilationUnit)4 SpellingEngineDescriptor (org.eclipse.ui.texteditor.spelling.SpellingEngineDescriptor)4 ArrayList (java.util.ArrayList)3 SubProgressMonitor (org.eclipse.core.runtime.SubProgressMonitor)3 ASTParser (org.eclipse.jdt.core.dom.ASTParser)3 IDocument (org.eclipse.jface.text.IDocument)3 IUndoManagerListener (org.eclipse.ltk.core.refactoring.IUndoManagerListener)3 IOException (java.io.IOException)2 Iterator (java.util.Iterator)2 IDocumentSetupParticipant (org.eclipse.core.filebuffers.IDocumentSetupParticipant)2 IDocumentSetupParticipantExtension (org.eclipse.core.filebuffers.IDocumentSetupParticipantExtension)2 IFile (org.eclipse.core.resources.IFile)2