org.eclipse.core.runtime.ISafeRunnable Java Examples
The following examples show how to use
org.eclipse.core.runtime.ISafeRunnable.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TbMatcher.java From translationstudio8 with GNU General Public License v2.0 | 6 votes |
/** * 加载记忆库匹配实现 ; */ 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); } }
Example #2
Source File: ContributedCleanUpTabPage.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
@Override protected void doCreatePreferences(Composite composite, int numColumns) { final Composite parent= new Composite(composite, SWT.NONE); GridData layoutData= new GridData(SWT.FILL, SWT.FILL, true, true); layoutData.horizontalSpan= numColumns; parent.setLayoutData(layoutData); GridLayout layout= new GridLayout(1, false); layout.marginHeight= 0; layout.marginWidth= 0; parent.setLayout(layout); SafeRunner.run(new ISafeRunnable() { public void handleException(Throwable exception) { ContributedCleanUpTabPage.this.handleException(exception); Label label= new Label(parent, SWT.NONE); label.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false)); label.setText(CleanUpMessages.ContributedCleanUpTabPage_ErrorPage_message); } public void run() throws Exception { fContribution.createContents(parent); } }); }
Example #3
Source File: ContributedCleanUpTabPage.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
@Override public int getSelectedCleanUpCount() { final int[] result= new int[] { 0 }; SafeRunner.run(new ISafeRunnable() { public void handleException(Throwable exception) { ContributedCleanUpTabPage.this.handleException(exception); } public void run() throws Exception { int count= fContribution.getSelectedCleanUpCount(); Assert.isTrue(count >= 0 && count <= getCleanUpCount()); result[0]= count; } }); return result[0]; }
Example #4
Source File: ClasspathAttributeConfigurationDescriptors.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
public ClasspathAttributeConfiguration get(final String attributeKey) { final Descriptor desc= getDescriptors().get(attributeKey); if (desc == null) { return null; } final ClasspathAttributeConfiguration[] res= { null }; SafeRunner.run(new ISafeRunnable() { public void handleException(Throwable exception) { JavaPlugin.log(exception); getDescriptors().remove(attributeKey); // remove from list } public void run() throws Exception { res[0]= desc.getInstance(); } }); return res[0]; }
Example #5
Source File: TypeHierarchy.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
/** * Notifies listeners that this hierarchy has changed and needs * refreshing. Note that listeners can be removed as we iterate * through the list. */ public void fireChange() { ArrayList listeners = getClonedChangeListeners(); // clone so that a listener cannot have a side-effect on this list when being notified if (listeners == null) { return; } if (DEBUG) { System.out.println("FIRING hierarchy change ["+Thread.currentThread()+"]"); //$NON-NLS-1$ //$NON-NLS-2$ if (this.focusType != null) { System.out.println(" for hierarchy focused on " + ((JavaElement)this.focusType).toStringWithAncestors()); //$NON-NLS-1$ } } for (int i= 0; i < listeners.size(); i++) { final ITypeHierarchyChangedListener listener= (ITypeHierarchyChangedListener)listeners.get(i); SafeRunner.run(new ISafeRunnable() { public void handleException(Throwable exception) { Util.log(exception, "Exception occurred in listener of Type hierarchy change notification"); //$NON-NLS-1$ } public void run() throws Exception { listener.typeHierarchyChanged(TypeHierarchy.this); } }); } }
Example #6
Source File: ReconcileWorkingCopyOperation.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
private void notifyParticipants(final CompilationUnit workingCopy) { IJavaProject javaProject = getWorkingCopy().getJavaProject(); CompilationParticipant[] participants = JavaModelManager.getJavaModelManager().compilationParticipants.getCompilationParticipants(javaProject); if (participants == null) return; final ReconcileContext context = new ReconcileContext(this, workingCopy); for (int i = 0, length = participants.length; i < length; i++) { final CompilationParticipant participant = participants[i]; SafeRunner.run(new ISafeRunnable() { public void handleException(Throwable exception) { if (exception instanceof Error) { throw (Error) exception; // errors are not supposed to be caught } else if (exception instanceof OperationCanceledException) throw (OperationCanceledException) exception; else if (exception instanceof UnsupportedOperationException) { // might want to disable participant as it tried to modify the buffer of the working copy being reconciled Util.log(exception, "Reconcile participant attempted to modify the buffer of the working copy being reconciled"); //$NON-NLS-1$ } else Util.log(exception, "Exception occurred in reconcile participant"); //$NON-NLS-1$ } public void run() throws Exception { participant.reconcile(context); } }); } }
Example #7
Source File: Buffer.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
/** * Notify the listeners that this buffer has changed. * To avoid deadlock, this should not be called in a synchronized block. */ protected void notifyChanged(final BufferChangedEvent event) { ArrayList listeners = this.changeListeners; if (listeners != null) { for (int i = 0, size = listeners.size(); i < size; ++i) { final IBufferChangedListener listener = (IBufferChangedListener) listeners.get(i); SafeRunner.run(new ISafeRunnable() { public void handleException(Throwable exception) { Util.log(exception, "Exception occurred in listener of buffer change notification"); //$NON-NLS-1$ } public void run() throws Exception { listener.bufferChanged(event); } }); } } }
Example #8
Source File: SimpleMatcherFactory.java From translationstudio8 with GNU General Public License v2.0 | 6 votes |
/** * 加载记忆库匹配实现 ; */ 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); } }
Example #9
Source File: TmMatcher.java From translationstudio8 with GNU General Public License v2.0 | 6 votes |
/** * 加哉记忆库匹配实现 ; */ 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); } }
Example #10
Source File: ComplexMatcherFactory.java From translationstudio8 with GNU General Public License v2.0 | 6 votes |
/** * 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); } }
Example #11
Source File: TmImporter.java From translationstudio8 with GNU General Public License v2.0 | 6 votes |
/** * 加载记忆库匹配实现 ; */ 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); } }
Example #12
Source File: FilterDescriptor.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
/** * Creates a new <code>ViewerFilter</code>. * This method is only valid for viewer filters. * @return a new <code>ViewerFilter</code> */ public ViewerFilter createViewerFilter() { if (!isCustomFilter()) return null; final ViewerFilter[] result= new ViewerFilter[1]; String message= Messages.format(FilterMessages.FilterDescriptor_filterCreationError_message, getId()); ISafeRunnable code= new SafeRunnable(message) { /* * @see org.eclipse.core.runtime.ISafeRunnable#run() */ public void run() throws Exception { result[0]= (ViewerFilter)fElement.createExecutableExtension(CLASS_ATTRIBUTE); } }; SafeRunner.run(code); return result[0]; }
Example #13
Source File: TbImporter.java From translationstudio8 with GNU General Public License v2.0 | 6 votes |
/** * 加载记忆库匹配实现 ; */ 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); } }
Example #14
Source File: WSO2PluginProjectWizard.java From developer-studio with Apache License 2.0 | 6 votes |
public boolean executeExtension(final Object execClass, final WSO2PluginSampleExt element, final String projectName) { ISafeRunnable runnable = new ISafeRunnable() { @Override public void handleException(Throwable e) { log.error("Exception in client"); } @Override public void run() throws Exception { ((IProjectTemplateManager) execClass).executeSelectedProjectTemplate(element, projectName); } }; SafeRunner.run(runnable); return true; }
Example #15
Source File: SimpleMatcherFactory.java From tmxeditor8 with GNU General Public License v2.0 | 6 votes |
/** * 加载记忆库匹配实现 ; */ 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); } }
Example #16
Source File: TmMatcher.java From tmxeditor8 with GNU General Public License v2.0 | 6 votes |
/** * 加哉记忆库匹配实现 ; */ 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); } }
Example #17
Source File: ComplexMatcherFactory.java From tmxeditor8 with GNU General Public License v2.0 | 6 votes |
/** * 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); } }
Example #18
Source File: TmImporter.java From tmxeditor8 with GNU General Public License v2.0 | 6 votes |
/** * 加载记忆库匹配实现 ; */ 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); } }
Example #19
Source File: TbMatcher.java From tmxeditor8 with GNU General Public License v2.0 | 6 votes |
/** * 加载记忆库匹配实现 ; */ 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); } }
Example #20
Source File: TbImporter.java From tmxeditor8 with GNU General Public License v2.0 | 6 votes |
/** * 加载记忆库匹配实现 ; */ 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); } }
Example #21
Source File: InMemoryEclipsePreferences.java From Pydev with Eclipse Public License 1.0 | 6 votes |
protected void firePreferenceEvent(String key, Object oldValue, Object newValue) { if (preferenceChangeListeners == null) { return; } final PreferenceChangeEvent event = new PreferenceChangeEvent(this, key, oldValue, newValue); for (final IPreferenceChangeListener listener : preferenceChangeListeners) { ISafeRunnable job = new ISafeRunnable() { @Override public void handleException(Throwable exception) { // already logged in Platform#run() } @Override public void run() throws Exception { listener.preferenceChange(event); } }; SafeRunner.run(job); } }
Example #22
Source File: TabContents.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
/** * If controls have been created, refresh all sections on the page. */ public void refresh() { if (controlsCreated) { for (final ISection section : sections) { ISafeRunnable runnable = new SafeRunnable() { @Override public void run() throws Exception { section.refresh(); } }; SafeRunnable.run(runnable); } } }
Example #23
Source File: PreferenceManager.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 6 votes |
private void preferencesChanged(Preferences oldPreferences, Preferences newPreferences) { for (final IPreferencesChangeListener listener : preferencesChangeListeners) { ISafeRunnable job = new ISafeRunnable() { @Override public void handleException(Throwable e) { JavaLanguageServerPlugin.log(new CoreException(StatusFactory.newErrorStatus(e.getMessage(), e))); } @Override public void run() throws Exception { listener.preferencesChange(oldPreferences, newPreferences); } }; SafeRunner.run(job); } }
Example #24
Source File: JaxRSServerContainer.java From JaxRSProviders with Apache License 2.0 | 6 votes |
protected void removeRegistration(RSARemoteServiceRegistration registration) { final HttpService httpService = getHttpService(); if (httpService != null) { final String servletAlias = getServletAlias(registration); if (servletAlias != null) { synchronized (this.registrations) { this.registrations.remove(servletAlias); SafeRunner.run(new ISafeRunnable() { @Override public void run() throws Exception { httpService.unregister(servletAlias); } }); } } } }
Example #25
Source File: StatusCollector.java From APICloud-Studio with GNU General Public License v3.0 | 6 votes |
/** * Notify a status change to the registered listeners. * * @param oldStatus * @param newStatus */ private void notifyChange(final IStatus oldStatus, final IStatus newStatus) { IStatusCollectorListener[] notifyTo = listeners.toArray(new IStatusCollectorListener[listeners.size()]); for (final IStatusCollectorListener listener : notifyTo) { SafeRunner.run(new ISafeRunnable() { public void run() throws Exception { listener.statusChanged(oldStatus, newStatus); } public void handleException(Throwable exception) { IdeLog.logError(CorePlugin.getDefault(), "StatusCollector: Error while notifying a staus change event.", exception); //$NON-NLS-1$ } }); } }
Example #26
Source File: ContributedCleanUpTabPage.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
@Override public void setWorkingValues(Map<String, String> workingValues) { super.setWorkingValues(workingValues); final CleanUpOptions options= new CleanUpOptions(workingValues) { /* * @see org.eclipse.jdt.internal.ui.fix.CleanUpOptions#setOption(java.lang.String, java.lang.String) */ @Override public void setOption(String key, String value) { super.setOption(key, value); doUpdatePreview(); notifyValuesModified(); } }; SafeRunner.run(new ISafeRunnable() { public void handleException(Throwable exception) { ContributedCleanUpTabPage.this.handleException(exception); } public void run() throws Exception { fContribution.setOptions(options); } }); }
Example #27
Source File: AbstractSearchResultTreePage.java From xds-ide with Eclipse Public License 1.0 | 6 votes |
private void showMatch(final Match match, final boolean activateEditor) { ISafeRunnable runnable = new ISafeRunnable() { public void handleException(Throwable exception) { if (exception instanceof PartInitException) { PartInitException pie = (PartInitException) exception; ErrorDialog.openError(getSite().getShell(), "Show match", "Could not find an editor for the current match", pie.getStatus()); } } public void run() throws Exception { IRegion location= getCurrentMatchLocation(match); showMatch(match, location.getOffset(), location.getLength(), activateEditor); } }; SafeRunner.run(runnable); }
Example #28
Source File: ServerManager.java From APICloud-Studio with GNU General Public License v3.0 | 6 votes |
private void notifyListeners(Kind kind, IServer serverConfiguration) { final ServerChangeEvent event = new ServerChangeEvent(kind, serverConfiguration); for (Object i : listeners.getListeners()) { final IServerChangeListener listener = (IServerChangeListener) i; SafeRunner.run(new ISafeRunnable() { public void run() { listener.configurationChanged(event); } public void handleException(Throwable exception) { IdeLog.logError(WebServerCorePlugin.getDefault(), exception); } }); } }
Example #29
Source File: SVNProviderPlugin.java From APICloud-Studio with GNU General Public License v3.0 | 6 votes |
/** * This method is called by SyncFileChangeListener when metafiles have * changed */ public static void broadcastSyncInfoChanges(final IResource[] resources, final boolean initializeListeners) { IResourceStateChangeListener[] toNotify; synchronized(listeners) { toNotify = (IResourceStateChangeListener[])listeners.toArray(new IResourceStateChangeListener[listeners.size()]); } for (int i = 0; i < toNotify.length; ++i) { final IResourceStateChangeListener listener = toNotify[i]; ISafeRunnable code = new ISafeRunnable() { public void run() throws Exception { if (initializeListeners) listener.initialize(); listener.resourceSyncInfoChanged(resources); } public void handleException(Throwable e) { // don't log the exception....it is already being logged in // Platform#run } }; SafeRunner.run(code); } }
Example #30
Source File: SVNProviderPlugin.java From APICloud-Studio with GNU General Public License v3.0 | 6 votes |
/** * This method is called by FileModificationManager when some resources have * changed */ public static void broadcastModificationStateChanges( final IResource[] resources) { IResourceStateChangeListener[] toNotify; synchronized(listeners) { toNotify = (IResourceStateChangeListener[])listeners.toArray(new IResourceStateChangeListener[listeners.size()]); } for (int i = 0; i < toNotify.length; ++i) { final IResourceStateChangeListener listener = toNotify[i]; ISafeRunnable code = new ISafeRunnable() { public void run() throws Exception { listener.resourceModified(resources); } public void handleException(Throwable e) { // don't log the exception....it is already being logged in // Platform#run } }; SafeRunner.run(code); } }