Search in sources :

Example 11 with NavigatorSafeRunnable

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

the class StructuredViewerManager method initialize.

/**
 * @param aContentProvider
 * @return True if all is well.
 */
public boolean initialize(final IStructuredContentProvider aContentProvider) {
    final boolean[] result = new boolean[1];
    SafeRunner.run(new NavigatorSafeRunnable() {

        public void run() throws Exception {
            if (aContentProvider != null) {
                aContentProvider.inputChanged(viewer, cachedOldInput, cachedNewInput);
            }
            result[0] = true;
        }
    });
    return result[0];
}
Also used : NavigatorSafeRunnable(org.eclipse.ui.internal.navigator.NavigatorSafeRunnable)

Example 12 with NavigatorSafeRunnable

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

the class CommonFilterDescriptor method createFilter.

/**
 * @return An instance of the ViewerFilter defined by the extension. Callers
 *         of this method are responsible for managing the instantiated
 *         filter.
 */
public ViewerFilter createFilter() {
    final ViewerFilter[] filter = new ViewerFilter[1];
    SafeRunner.run(new NavigatorSafeRunnable() {

        public void run() throws Exception {
            if (filterExpression != null) {
                if (element.getAttribute(ATT_CLASS) != null) {
                    NavigatorPlugin.log(IStatus.WARNING, 0, // $NON-NLS-1$
                    "A \"commonFilter\" was specified in " + element.getDeclaringExtension().getNamespaceIdentifier() + // $NON-NLS-1$
                    " which specifies a \"class\" attribute and an Core Expression.\n" + // $NON-NLS-1$
                    "Only the Core Expression will be respected.", null);
                }
                filter[0] = new CoreExpressionFilter(filterExpression);
                return;
            }
            filter[0] = (ViewerFilter) element.createExecutableExtension(ATT_CLASS);
        }
    });
    if (filter[0] != null)
        return filter[0];
    return SkeletonViewerFilter.INSTANCE;
}
Also used : ViewerFilter(org.eclipse.jface.viewers.ViewerFilter) NavigatorSafeRunnable(org.eclipse.ui.internal.navigator.NavigatorSafeRunnable)

Example 13 with NavigatorSafeRunnable

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

the class SafeDelegateTreeContentProvider method inputChanged.

public void inputChanged(final Viewer aViewer, final Object anOldInput, final Object aNewInput) {
    viewer = (StructuredViewer) aViewer;
    SafeRunner.run(new NavigatorSafeRunnable() {

        public void run() throws Exception {
            contentProvider.inputChanged(aViewer, anOldInput, aNewInput);
        }
    });
}
Also used : NavigatorSafeRunnable(org.eclipse.ui.internal.navigator.NavigatorSafeRunnable)

Example 14 with NavigatorSafeRunnable

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

the class NavigatorActionService method addCommonActionProviderMenu.

/**
 * @param aMenu
 */
private void addCommonActionProviderMenu(final IMenuManager aMenu) {
    final CommonActionProviderDescriptor[] providerDescriptors = CommonActionDescriptorManager.getInstance().findRelevantActionDescriptors(contentService, getContext());
    if (providerDescriptors.length > 0) {
        for (int i = 0; i < providerDescriptors.length; i++) {
            final CommonActionProviderDescriptor providerDescriptorLocal = providerDescriptors[i];
            SafeRunner.run(new NavigatorSafeRunnable() {

                public void run() throws Exception {
                    if (!filterActionProvider(providerDescriptorLocal)) {
                        CommonActionProvider provider = getActionProviderInstance(providerDescriptorLocal);
                        provider.setContext(getContext());
                        provider.fillContextMenu(aMenu);
                    }
                }
            });
        }
    }
}
Also used : NavigatorSafeRunnable(org.eclipse.ui.internal.navigator.NavigatorSafeRunnable) CommonActionProviderDescriptor(org.eclipse.ui.internal.navigator.actions.CommonActionProviderDescriptor)

Example 15 with NavigatorSafeRunnable

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

the class NavigatorActionService method restoreState.

/**
 * Use the given memento to restore the state of each Action Provider as it is initialized.
 *
 * @param aMemento
 *            The memento retrieved from the dialog settings
 */
public void restoreState(IMemento aMemento) {
    Assert.isTrue(!disposed);
    memento = aMemento;
    synchronized (actionProviderInstances) {
        for (Iterator actionProviderIterator = actionProviderInstances.values().iterator(); actionProviderIterator.hasNext(); ) {
            final CommonActionProvider provider = (CommonActionProvider) actionProviderIterator.next();
            SafeRunner.run(new NavigatorSafeRunnable() {

                public void run() throws Exception {
                    provider.restoreState(memento);
                }
            });
        }
    }
}
Also used : NavigatorSafeRunnable(org.eclipse.ui.internal.navigator.NavigatorSafeRunnable) Iterator(java.util.Iterator)

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