use of org.eclipse.jface.util.SafeRunnable in project eclipse.platform.text by eclipse.
the class HyperlinkDetectorDescriptor method createHyperlinkDetectorImplementation.
/**
* Creates a new {@link IHyperlinkDetector}.
*
* @return the hyperlink detector or <code>null</code> if the plug-in isn't loaded yet
* @throws CoreException if a failure occurred during creation
* @since 3.9
*/
public IHyperlinkDetector createHyperlinkDetectorImplementation() throws CoreException {
final Throwable[] exception = new Throwable[1];
final IHyperlinkDetector[] result = new IHyperlinkDetector[1];
String message = NLSUtility.format(EditorMessages.Editor_error_HyperlinkDetector_couldNotCreate_message, new String[] { getId(), fElement.getContributor().getName() });
ISafeRunnable code = new SafeRunnable(message) {
@Override
public void run() throws Exception {
String pluginId = fElement.getContributor().getName();
boolean isPlugInActivated = Platform.getBundle(pluginId).getState() == Bundle.ACTIVE;
if (isPlugInActivated || canActivatePlugIn())
result[0] = (IHyperlinkDetector) fElement.createExecutableExtension(CLASS_ATTRIBUTE);
}
@Override
public void handleException(Throwable ex) {
super.handleException(ex);
exception[0] = ex;
}
};
SafeRunner.run(code);
if (exception[0] == null)
return result[0];
throw new CoreException(new Status(IStatus.ERROR, TextEditorPlugin.PLUGIN_ID, IStatus.OK, message, exception[0]));
}
use of org.eclipse.jface.util.SafeRunnable in project eclipse.platform.text by eclipse.
the class TextSearchQueryProviderRegistry method createFromExtension.
private TextSearchQueryProvider createFromExtension(final String id) {
final TextSearchQueryProvider[] res = new TextSearchQueryProvider[] { null };
SafeRunnable safe = new SafeRunnable() {
@Override
public void run() throws Exception {
IConfigurationElement[] extensions = Platform.getExtensionRegistry().getConfigurationElementsFor(EXTENSION_POINT_ID);
for (IConfigurationElement curr : extensions) {
if (PROVIDER_NODE_NAME.equals(curr.getName()) && id.equals(curr.getAttribute(ATTRIB_ID))) {
res[0] = (TextSearchQueryProvider) curr.createExecutableExtension(ATTRIB_CLASS);
return;
}
}
}
@Override
public void handleException(Throwable e) {
SearchPlugin.log(e);
}
};
SafeRunnable.run(safe);
return res[0];
}
use of org.eclipse.jface.util.SafeRunnable in project linuxtools by eclipse.
the class CheckboxTreeAndListGroup method notifyCheckStateChangeListeners.
/**
* Notify all checked state listeners that the passed element has had its
* checked state changed to the passed state
*/
protected void notifyCheckStateChangeListeners(final CheckStateChangedEvent event) {
Object[] array = getListeners();
for (int i = 0; i < array.length; i++) {
final ICheckStateListener l = (ICheckStateListener) array[i];
SafeRunner.run(new SafeRunnable() {
@Override
public void run() {
l.checkStateChanged(event);
}
});
}
}
use of org.eclipse.jface.util.SafeRunnable in project translationstudio8 by heartsome.
the class TSWizardDialog method firePageChanged.
/**
* Notifies any selection changed listeners that the selected page has
* changed. Only listeners registered at the time this method is called are
* notified.
*
* @param event
* a selection changed event
*
* @see IPageChangedListener#pageChanged
*
* @since 3.1
*/
protected void firePageChanged(final PageChangedEvent event) {
Object[] listeners = pageChangedListeners.getListeners();
for (int i = 0; i < listeners.length; ++i) {
final IPageChangedListener l = (IPageChangedListener) listeners[i];
SafeRunnable.run(new SafeRunnable() {
public void run() {
l.pageChanged(event);
}
});
}
}
use of org.eclipse.jface.util.SafeRunnable in project erlide_eclipse by erlang.
the class ErlangLabelProvider method fireLabelProviderChanged.
/**
* Fires a label provider changed event to all registered listeners Only
* listeners registered at the time this method is called are notified.
*
* @param event
* a label provider changed event
*
* @see ILabelProviderListener#labelProviderChanged
*/
protected void fireLabelProviderChanged(final LabelProviderChangedEvent event) {
final Object[] listeners = fListeners.getListeners();
for (final Object element : listeners) {
final ILabelProviderListener l = (ILabelProviderListener) element;
SafeRunner.run(new SafeRunnable() {
@Override
public void run() {
l.labelProviderChanged(event);
}
});
}
}
Aggregations