Search in sources :

Example 16 with SafeRunnable

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]));
}
Also used : Status(org.eclipse.core.runtime.Status) IStatus(org.eclipse.core.runtime.IStatus) IHyperlinkDetector(org.eclipse.jface.text.hyperlink.IHyperlinkDetector) CoreException(org.eclipse.core.runtime.CoreException) ISafeRunnable(org.eclipse.core.runtime.ISafeRunnable) SafeRunnable(org.eclipse.jface.util.SafeRunnable) ISafeRunnable(org.eclipse.core.runtime.ISafeRunnable)

Example 17 with SafeRunnable

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];
}
Also used : SafeRunnable(org.eclipse.jface.util.SafeRunnable) TextSearchQueryProvider(org.eclipse.search.ui.text.TextSearchQueryProvider) IConfigurationElement(org.eclipse.core.runtime.IConfigurationElement)

Example 18 with SafeRunnable

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);
            }
        });
    }
}
Also used : ICheckStateListener(org.eclipse.jface.viewers.ICheckStateListener) SafeRunnable(org.eclipse.jface.util.SafeRunnable)

Example 19 with SafeRunnable

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);
            }
        });
    }
}
Also used : IPageChangedListener(org.eclipse.jface.dialogs.IPageChangedListener) SafeRunnable(org.eclipse.jface.util.SafeRunnable) Point(org.eclipse.swt.graphics.Point)

Example 20 with SafeRunnable

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);
            }
        });
    }
}
Also used : ILabelProviderListener(org.eclipse.jface.viewers.ILabelProviderListener) SafeRunnable(org.eclipse.jface.util.SafeRunnable)

Aggregations

SafeRunnable (org.eclipse.jface.util.SafeRunnable)31 ISafeRunnable (org.eclipse.core.runtime.ISafeRunnable)6 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)5 Point (org.eclipse.swt.graphics.Point)5 IConfigurationElement (org.eclipse.core.runtime.IConfigurationElement)4 ICheckStateListener (org.eclipse.jface.viewers.ICheckStateListener)3 ILabelProviderListener (org.eclipse.jface.viewers.ILabelProviderListener)3 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)3 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)3 DropTargetEvent (org.eclipse.swt.dnd.DropTargetEvent)3 Rectangle (org.eclipse.swt.graphics.Rectangle)3 Control (org.eclipse.swt.widgets.Control)3 TableItem (org.eclipse.swt.widgets.TableItem)3 TreeItem (org.eclipse.swt.widgets.TreeItem)3 IHyperlinkDetector (org.eclipse.jface.text.hyperlink.IHyperlinkDetector)2 LocalSelectionTransfer (org.eclipse.jface.util.LocalSelectionTransfer)2 TransferDropTargetListener (org.eclipse.jface.util.TransferDropTargetListener)2 ViewerFilter (org.eclipse.jface.viewers.ViewerFilter)2 Transfer (org.eclipse.swt.dnd.Transfer)2 DragNodeCommand (org.eclipse.wst.xml.ui.internal.dnd.DragNodeCommand)2