Search in sources :

Example 16 with NavigatorSafeRunnable

use of org.eclipse.ui.internal.navigator.NavigatorSafeRunnable in project polymap4-core by Polymap4.

the class NavigatorActionService method fillActionBars.

/**
 * Request that the service invoke extensions to fill the given IActionBars with retargetable
 * actions or view menu contributions from Action Providers that are interested in the given
 * selection.
 *
 * @param theActionBars
 *            The action bars in use by the current view site.
 * @see ActionGroup#fillActionBars(IActionBars)
 */
public void fillActionBars(final IActionBars theActionBars) {
    Assert.isTrue(!disposed);
    theActionBars.clearGlobalActionHandlers();
    ActionContext context = getContext();
    if (context == null) {
        context = new ActionContext(StructuredSelection.EMPTY);
    }
    final CommonActionProviderDescriptor[] providerDescriptors = CommonActionDescriptorManager.getInstance().findRelevantActionDescriptors(contentService, context);
    if (providerDescriptors.length > 0) {
        for (int i = 0; i < providerDescriptors.length; i++) {
            final CommonActionProviderDescriptor providerDesciptorLocal = providerDescriptors[i];
            final ActionContext actionContextLocal = context;
            SafeRunner.run(new NavigatorSafeRunnable() {

                public void run() throws Exception {
                    if (!filterActionProvider(providerDesciptorLocal)) {
                        CommonActionProvider provider = null;
                        provider = getActionProviderInstance(providerDesciptorLocal);
                        provider.setContext(actionContextLocal);
                        provider.fillActionBars(theActionBars);
                        provider.updateActionBars();
                    }
                }
            });
        }
    }
    theActionBars.updateActionBars();
    theActionBars.getMenuManager().update();
}
Also used : NavigatorSafeRunnable(org.eclipse.ui.internal.navigator.NavigatorSafeRunnable) CommonActionProviderDescriptor(org.eclipse.ui.internal.navigator.actions.CommonActionProviderDescriptor) ActionContext(org.eclipse.ui.actions.ActionContext)

Example 17 with NavigatorSafeRunnable

use of org.eclipse.ui.internal.navigator.NavigatorSafeRunnable in project polymap4-core by Polymap4.

the class NavigatorContentExtension method dispose.

/**
 * Dispose of any resources acquired during the lifecycle of the extension.
 */
public void dispose() {
    try {
        synchronized (this) {
            SafeRunner.run(new NavigatorSafeRunnable() {

                public void run() throws Exception {
                    if (contentProvider != null) {
                        contentProvider.dispose();
                    }
                }
            });
            SafeRunner.run(new NavigatorSafeRunnable() {

                public void run() throws Exception {
                    if (labelProvider != null) {
                        labelProvider.removeListener((ILabelProviderListener) contentService.createCommonLabelProvider());
                        labelProvider.dispose();
                    }
                }
            });
        }
    } finally {
        isDisposed = true;
    }
}
Also used : ILabelProviderListener(org.eclipse.jface.viewers.ILabelProviderListener) NavigatorSafeRunnable(org.eclipse.ui.internal.navigator.NavigatorSafeRunnable)

Aggregations

NavigatorSafeRunnable (org.eclipse.ui.internal.navigator.NavigatorSafeRunnable)17 IStatus (org.eclipse.core.runtime.IStatus)2 CommonActionProviderDescriptor (org.eclipse.ui.internal.navigator.actions.CommonActionProviderDescriptor)2 Iterator (java.util.Iterator)1 CoreException (org.eclipse.core.runtime.CoreException)1 LocalSelectionTransfer (org.eclipse.jface.util.LocalSelectionTransfer)1 ILabelProviderListener (org.eclipse.jface.viewers.ILabelProviderListener)1 ISelection (org.eclipse.jface.viewers.ISelection)1 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)1 StructuredViewer (org.eclipse.jface.viewers.StructuredViewer)1 Viewer (org.eclipse.jface.viewers.Viewer)1 ViewerFilter (org.eclipse.jface.viewers.ViewerFilter)1 ViewerSorter (org.eclipse.jface.viewers.ViewerSorter)1 DropTargetEvent (org.eclipse.swt.dnd.DropTargetEvent)1 Transfer (org.eclipse.swt.dnd.Transfer)1 Display (org.eclipse.swt.widgets.Display)1 ActionContext (org.eclipse.ui.actions.ActionContext)1 CommonActionProvider (org.eclipse.ui.navigator.CommonActionProvider)1 CommonDragAdapterAssistant (org.eclipse.ui.navigator.CommonDragAdapterAssistant)1 CommonDropAdapterAssistant (org.eclipse.ui.navigator.CommonDropAdapterAssistant)1