Search in sources :

Example 6 with SafeRunnable

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

Example 7 with SafeRunnable

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

Example 8 with SafeRunnable

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

Example 9 with SafeRunnable

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

Example 10 with SafeRunnable

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

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