use of org.eclipse.jface.util.SafeRunnable in project erlide_eclipse by erlang.
the class FilterDescriptor method createFilterDescriptors.
// ---- initialization ---------------------------------------------------
/**
* Creates the filter descriptors.
*
* @param elements
* the configuration elements
* @param extensionPointID
* @return new filter descriptors
*/
private static Collection<FilterDescriptor> createFilterDescriptors(final IConfigurationElement[] elements, final String extensionPointID) {
final List<FilterDescriptor> result = Lists.newArrayList();
final Set<String> descIds = Sets.newHashSet();
for (final IConfigurationElement element : elements) {
if (FilterDescriptor.FILTER_TAG.equals(element.getName())) {
final FilterDescriptor[] desc = new FilterDescriptor[1];
SafeRunner.run(new SafeRunnable(" One of the extensions for extension-point " + extensionPointID + " is incorrect.") {
@Override
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;
}
use of org.eclipse.jface.util.SafeRunnable in project erlide_eclipse by erlang.
the class FilterDescriptor method getViewerFilter.
/**
* Creates a new <code>ViewerFilter</code>. This method is only valid for
* viewer filters.
*
* @return a new <code>ViewerFilter</code>
*/
public ViewerFilter getViewerFilter() {
if (!isClassFilter()) {
return null;
}
if (fCachedInstance == null) {
final ViewerFilter[] result = new ViewerFilter[1];
final String message = String.format("The org.erlide.ui.erlangElementFilters plug-in extension \"%s\" specifies a viewer filter class which does not exist.", getId());
final ISafeRunnable code = new SafeRunnable(message) {
/*
* @see org.eclipse.core.runtime.ISafeRunnable#run()
*/
@Override
public void run() throws Exception {
result[0] = (ViewerFilter) fElement.createExecutableExtension(FilterDescriptor.CLASS_ATTRIBUTE);
}
};
SafeRunner.run(code);
fCachedInstance = result[0];
}
return fCachedInstance;
}
use of org.eclipse.jface.util.SafeRunnable in project tmdm-studio-se by Talend.
the class CompositeSelectionProvider method setSelection.
public void setSelection(ISelection selection) {
this.selection = selection;
final SelectionChangedEvent e = new SelectionChangedEvent(this, selection);
for (final ISelectionChangedListener eachListener : listeners.toArray(new ISelectionChangedListener[0])) {
SafeRunner.run(new SafeRunnable() {
public void run() {
eachListener.selectionChanged(e);
}
});
}
}
use of org.eclipse.jface.util.SafeRunnable in project eclipse-cs by checkstyle.
the class EnhancedCheckBoxTableViewer method fireCheckStateChanged.
/**
* Notifies any check state listeners that a check state changed has been received. Only listeners
* registered at the time this method is called are notified.
*
* @param event
* a check state changed event
* @see ICheckStateListener#checkStateChanged
*/
private void fireCheckStateChanged(final CheckStateChangedEvent event) {
Object[] array = checkStateListeners.getListeners();
for (int i = 0; i < array.length; i++) {
final ICheckStateListener l = (ICheckStateListener) array[i];
SafeRunnable.run(new SafeRunnable() {
@Override
public void run() {
l.checkStateChanged(event);
}
});
}
}
use of org.eclipse.jface.util.SafeRunnable in project ecf by eclipse.
the class WizardNode method getWizard.
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.wizard.IWizardNode#getWizard()
*/
public IWizard getWizard() {
if (wizard != null)
// we've already created it
return wizard;
final IWizard[] newWizard = new IWizard[1];
final IStatus[] statuses = new IStatus[1];
// Start busy indicator.
BusyIndicator.showWhile(parentWizardPage.getShell().getDisplay(), new Runnable() {
public void run() {
SafeRunner.run(new SafeRunnable() {
/**
* Add the exception details to status is one
* happens.
*/
public void handleException(Throwable e) {
IPluginContribution contribution = (IPluginContribution) wizardElement.getAdapter(IPluginContribution.class);
statuses[0] = new // $NON-NLS-1$,
Status(// $NON-NLS-1$,
IStatus.ERROR, // $NON-NLS-1$,
contribution != null ? contribution.getPluginId() : Activator.PLUGIN_ID, // $NON-NLS-1$,
IStatus.OK, // $NON-NLS-1$,
e.getMessage() == null ? "" : e.getMessage(), e);
}
public void run() {
try {
newWizard[0] = createWizard();
// create instance of target wizard
} catch (CoreException e) {
statuses[0] = e.getStatus();
}
}
});
}
});
if (statuses[0] != null) {
// $NON-NLS-1$
parentWizardPage.setErrorMessage("The selected wizard could not be started.");
// $NON-NLS-1$
ErrorDialog.openError(// $NON-NLS-1$
parentWizardPage.getShell(), // $NON-NLS-1$
"Problem Opening Wizard", "The selected wizard could not be started.", // $NON-NLS-1$
statuses[0]);
return null;
}
wizard = newWizard[0];
return wizard;
}
Aggregations