org.eclipse.core.runtime.SafeRunner Java Examples

The following examples show how to use org.eclipse.core.runtime.SafeRunner. 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: SVNProviderPlugin.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
/**
 * This method is called by SVNTeamProvider.configureProject which is
 * invoked when a project is mapped
 */
protected static void broadcastProjectConfigured(final IProject project) {
	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.projectConfigured(project);
			}
			public void handleException(Throwable e) {
				// don't log the exception....it is already being logged in
				// Platform#run
			}
		};
		SafeRunner.run(code);
	}
}
 
Example #2
Source File: CasEditorViewPage.java    From uima-uimaj with Apache License 2.0 6 votes vote down vote up
/**
 * Selection changed.
 *
 * @param event the event
 */
public void selectionChanged(final SelectionChangedEvent event) {
  
  for (Object listener : selectionChangedListeners.getListeners()) {
    
    final ISelectionChangedListener selectionChangedListener = 
            (ISelectionChangedListener) listener;
    
    SafeRunner.run(new SafeRunnable() {
      @Override
      public void run() {
        selectionChangedListener.selectionChanged(event);
      }
    });
  }
}
 
Example #3
Source File: ReportResourceSynchronizer.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
protected void notifyListeners( final IReportResourceChangeEvent event )
{
	log.log( Level.FINE, event.toString( ) );
	
	//Object[] list = listeners.getListeners( );
	List<IReportResourceChangeListener> list = listeners.get( event.getType( ) );
	if (list == null)
	{
		return;
	}

	for ( int i = 0; i < list.size( ); i++ )
	{
		final IReportResourceChangeListener rcl = list.get( i );

		SafeRunner.run( new SafeRunnable( ) {

			public void run( ) throws Exception
			{
				rcl.resourceChanged( event );
			}
		} );
	}

}
 
Example #4
Source File: AbstractVisibilityProvider.java    From neoscada with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Fire visibility change
 * <p>
 * The change will only be fired if the state really changed.
 * </p>
 * 
 * @param state
 *            the new state
 */
protected void fireChange ( final boolean state )
{
    if ( this.state == state )
    {
        return;
    }

    this.state = state;
    for ( final Listener listener : this.listeners )
    {
        SafeRunner.run ( new SafeRunnable () {

            @Override
            public void run () throws Exception
            {
                listener.visibilityChanged ( state );
            }
        } );
    }
}
 
Example #5
Source File: TbImporter.java    From tmxeditor8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 加载记忆库匹配实现 ;
 */
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 #6
Source File: TbMatcher.java    From tmxeditor8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 加载记忆库匹配实现 ;
 */
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 #7
Source File: PreferenceManager.java    From eclipse.jdt.ls with Eclipse Public License 2.0 6 votes vote down vote up
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 #8
Source File: ComboFieldEditor2.java    From neoscada with Eclipse Public License 1.0 6 votes vote down vote up
@Override
protected void fireValueChanged ( final String property, final Object oldValue, final Object newValue )
{
    if ( VALUE.equals ( property ) )
    {
        if ( this.callback != null )
        {
            SafeRunner.run ( new SafeRunnable () {

                @Override
                public void run () throws Exception
                {
                    ComboFieldEditor2.this.callback.valueChange ( newValue );
                }
            } );
        }
    }
    super.fireValueChanged ( property, oldValue, newValue );
}
 
Example #9
Source File: JaxRSServerContainer.java    From JaxRSProviders with Apache License 2.0 6 votes vote down vote up
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 #10
Source File: DeleteResourceAction.java    From gama with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Tries to find opened editors matching given resource roots. The editors will be closed without confirmation and
 * only if the editor resource does not exists anymore.
 *
 * @param resourceRoots
 *            non null array with deleted resource tree roots
 * @param deletedOnly
 *            true to close only editors on resources which do not exist
 */
static void closeMatchingEditors(final List<? extends IResource> resourceRoots, final boolean deletedOnly) {
	if (resourceRoots.isEmpty()) { return; }
	final Runnable runnable = () -> SafeRunner.run(new SafeRunnable(IDEWorkbenchMessages.ErrorOnCloseEditors) {
		@Override
		public void run() {
			final IWorkbenchWindow w = WorkbenchHelper.getWindow();
			if (w != null) {
				final List<IEditorReference> toClose = getMatchingEditors(resourceRoots, w, deletedOnly);
				if (toClose.isEmpty()) { return; }
				closeEditors(toClose, w);
			}
		}
	});
	BusyIndicator.showWhile(PlatformUI.getWorkbench().getDisplay(), runnable);
}
 
Example #11
Source File: CloseResourceAction.java    From gama with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Tries to find opened editors matching given resource roots. The editors will be closed without confirmation and
 * only if the editor resource does not exists anymore.
 *
 * @param resourceRoots
 *            non null array with deleted resource tree roots
 * @param deletedOnly
 *            true to close only editors on resources which do not exist
 */
static void closeMatchingEditors(final List<? extends IResource> resourceRoots, final boolean deletedOnly) {
	if (resourceRoots.isEmpty()) { return; }
	final Runnable runnable = () -> SafeRunner.run(new SafeRunnable(IDEWorkbenchMessages.ErrorOnCloseEditors) {
		@Override
		public void run() {
			final IWorkbenchWindow w = getActiveWindow();
			if (w != null) {
				final List<IEditorReference> toClose = getMatchingEditors(resourceRoots, w, deletedOnly);
				if (toClose.isEmpty()) { return; }
				closeEditors(toClose, w);
			}
		}
	});
	BusyIndicator.showWhile(PlatformUI.getWorkbench().getDisplay(), runnable);
}
 
Example #12
Source File: AutoConfigMaker.java    From Pydev with Eclipse Public License 1.0 6 votes vote down vote up
private List<IInterpreterProvider> getAllProviders() {
    final List<IInterpreterProvider> providers = new ArrayList<IInterpreterProvider>();
    @SuppressWarnings("unchecked")
    List<IInterpreterProviderFactory> participants = ExtensionHelper
            .getParticipants(ExtensionHelper.PYDEV_INTERPRETER_PROVIDER);
    for (final IInterpreterProviderFactory providerFactory : participants) {
        SafeRunner.run(new SafeRunnable() {
            @Override
            public void run() throws Exception {
                IInterpreterProvider[] ips = providerFactory.getInterpreterProviders(interpreterType);
                if (ips != null) {
                    providers.addAll(Arrays.asList(ips));
                }
            }
        });
    }
    return providers;
}
 
Example #13
Source File: ServerManager.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
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 #14
Source File: TbImporter.java    From translationstudio8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 加载记忆库匹配实现 ;
 */
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 #15
Source File: SVNProviderPlugin.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
/**
 * 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);
	}
}
 
Example #16
Source File: InMemoryEclipsePreferences.java    From Pydev with Eclipse Public License 1.0 6 votes vote down vote up
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 #17
Source File: TbMatcher.java    From translationstudio8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 加载记忆库匹配实现 ;
 */
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 #18
Source File: TmImporter.java    From translationstudio8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 加载记忆库匹配实现 ;
 */
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: ComplexMatcherFactory.java    From translationstudio8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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 #20
Source File: TmMatcher.java    From translationstudio8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 加哉记忆库匹配实现 ;
 */
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 #21
Source File: SimpleMatcherFactory.java    From translationstudio8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 加载记忆库匹配实现 ;
 */
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 #22
Source File: Buffer.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * 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 #23
Source File: ReconcileWorkingCopyOperation.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
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 #24
Source File: TypeHierarchy.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * 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 #25
Source File: FilterDescriptor.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Creates the filter descriptors.
 * @param elements the configuration elements
 * @return new filter descriptors
 */
private static FilterDescriptor[] createFilterDescriptors(IConfigurationElement[] elements) {
	List<FilterDescriptor> result= new ArrayList<FilterDescriptor>(5);
	Set<String> descIds= new HashSet<String>(5);
	for (int i= 0; i < elements.length; i++) {
		final IConfigurationElement element= elements[i];
		if (FILTER_TAG.equals(element.getName())) {

			final FilterDescriptor[] desc= new FilterDescriptor[1];
			SafeRunner.run(new SafeRunnable(FilterMessages.FilterDescriptor_filterDescriptionCreationError_message) {
				public void run() throws Exception {
					desc[0]= new FilterDescriptor(element);
				}
			});

			if (desc[0] != null && !descIds.contains(desc[0].getId())) {
				result.add(desc[0]);
				descIds.add(desc[0].getId());
			}
		}
	}
	return result.toArray(new FilterDescriptor[result.size()]);
}
 
Example #26
Source File: FilterDescriptor.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * 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 #27
Source File: ContributedCleanUpTabPage.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
@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 #28
Source File: ContributedCleanUpTabPage.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
@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 #29
Source File: ClasspathAttributeConfigurationDescriptors.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
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 #30
Source File: ContributedCleanUpTabPage.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
@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];
}