Search in sources :

Example 6 with NavigatorSafeRunnable

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

the class LinkHelperDescriptor method createLinkHelper.

/**
 * Create a link helper instance from this descriptors class attribute.
 *
 * @return An instance of the helper that is defined by the extension, or a
 *         Skeleton Link Helper.
 */
public ILinkHelper createLinkHelper() {
    if (hasLinkHelperFailedCreation)
        return SkeletonLinkHelper.INSTANCE;
    final ILinkHelper[] helper = new ILinkHelper[1];
    SafeRunner.run(new NavigatorSafeRunnable(configElement) {

        public void run() throws Exception {
            helper[0] = (ILinkHelper) configElement.createExecutableExtension(ATT_CLASS);
        }
    });
    if (helper[0] != null)
        return helper[0];
    hasLinkHelperFailedCreation = true;
    return SkeletonLinkHelper.INSTANCE;
}
Also used : ILinkHelper(org.eclipse.ui.navigator.ILinkHelper) NavigatorSafeRunnable(org.eclipse.ui.internal.navigator.NavigatorSafeRunnable)

Example 7 with NavigatorSafeRunnable

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

the class NavigatorActionService method getActionProviderInstance.

/**
 * @param aProviderDescriptor
 * @return a CommonActionProvider
 * @noreference This method is not intended to be referenced by clients.
 */
public CommonActionProvider getActionProviderInstance(final CommonActionProviderDescriptor aProviderDescriptor) {
    CommonActionProvider provider = null;
    provider = (CommonActionProvider) actionProviderInstances.get(aProviderDescriptor);
    if (provider != null) {
        return provider;
    }
    synchronized (actionProviderInstances) {
        provider = (CommonActionProvider) actionProviderInstances.get(aProviderDescriptor);
        if (provider == null) {
            final CommonActionProvider[] retProvider = new CommonActionProvider[1];
            SafeRunner.run(new NavigatorSafeRunnable() {

                public void run() throws Exception {
                    retProvider[0] = aProviderDescriptor.createActionProvider();
                    if (retProvider[0] != null) {
                        initialize(aProviderDescriptor.getId(), aProviderDescriptor.getPluginId(), retProvider[0]);
                    }
                }
            });
            // This could happen in the exception case
            if (retProvider[0] == null)
                retProvider[0] = SkeletonActionProvider.INSTANCE;
            actionProviderInstances.put(aProviderDescriptor, retProvider[0]);
            provider = retProvider[0];
        }
    }
    return provider;
}
Also used : NavigatorSafeRunnable(org.eclipse.ui.internal.navigator.NavigatorSafeRunnable)

Example 8 with NavigatorSafeRunnable

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

the class CommonActionProviderDescriptor method createActionProvider.

/**
 * @return The instantiated CommonActionProvider for this descriptor as
 *         declared in the ATT_CLASS attribute or
 *         {@link SkeletonActionProvider} if a problem occurs while loading
 *         the instance.
 */
public CommonActionProvider createActionProvider() {
    if (hasLoadingFailed) {
        return SkeletonActionProvider.INSTANCE;
    }
    final CommonActionProvider[] provider = new CommonActionProvider[1];
    SafeRunner.run(new NavigatorSafeRunnable(configurationElement) {

        public void run() throws Exception {
            provider[0] = (CommonActionProvider) configurationElement.createExecutableExtension(ATT_CLASS);
        }
    });
    if (provider[0] != null)
        return provider[0];
    hasLoadingFailed = true;
    return SkeletonActionProvider.INSTANCE;
}
Also used : NavigatorSafeRunnable(org.eclipse.ui.internal.navigator.NavigatorSafeRunnable) CommonActionProvider(org.eclipse.ui.navigator.CommonActionProvider) CoreException(org.eclipse.core.runtime.CoreException)

Example 9 with NavigatorSafeRunnable

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

the class CommonDropAdapterDescriptor method createDropAssistant.

/**
 * @return An instance of {@link CommonDropAdapterAssistant} from the
 *         descriptor or {@link SkeletonCommonDropAssistant}.
 */
public CommonDropAdapterAssistant createDropAssistant() {
    final CommonDropAdapterAssistant[] retValue = new CommonDropAdapterAssistant[1];
    SafeRunner.run(new NavigatorSafeRunnable(element) {

        public void run() throws Exception {
            retValue[0] = (CommonDropAdapterAssistant) element.createExecutableExtension(ATT_CLASS);
        }
    });
    if (retValue[0] != null)
        return retValue[0];
    return SkeletonCommonDropAssistant.INSTANCE;
}
Also used : NavigatorSafeRunnable(org.eclipse.ui.internal.navigator.NavigatorSafeRunnable) CommonDropAdapterAssistant(org.eclipse.ui.navigator.CommonDropAdapterAssistant)

Example 10 with NavigatorSafeRunnable

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

the class CommonDropAdapter method performDrop.

public boolean performDrop(Object data) {
    final DropTargetEvent event = getCurrentEvent();
    if (Policy.DEBUG_DND) {
        // $NON-NLS-1$
        System.out.println("CommonDropAdapter.drop (begin): " + event);
    }
    final Object target = getCurrentTarget() != null ? getCurrentTarget() : getViewer().getInput();
    // Must validate the drop here because on some platforms (Linux, Mac) the event
    // is not populated with the correct currentDataType until the drop actually
    // happens, and validateDrop sets the currentTransfer based on that.  The
    // call to validateDrop in dragAccept is too early.
    validateDrop(target, getCurrentOperation(), event.currentDataType);
    if (PluginTransfer.getInstance().isSupportedType(event.currentDataType)) {
        super.drop(event);
        return true;
    }
    if (Policy.DEBUG_DND) {
        // $NON-NLS-1$ //$NON-NLS-2$
        System.out.println("CommonDropAdapter.drop target: " + target + " op: " + getCurrentOperation());
    }
    final CommonDropAdapterAssistant[] assistants = dndService.findCommonDropAdapterAssistants(target, getCurrentTransfer());
    final boolean[] retValue = new boolean[1];
    for (int i = 0; i < assistants.length; i++) {
        final CommonDropAdapterAssistant localAssistant = assistants[i];
        SafeRunner.run(new NavigatorSafeRunnable() {

            public void run() throws Exception {
                localAssistant.setCurrentEvent(event);
                IStatus valid = localAssistant.validateDrop(target, getCurrentOperation(), getCurrentTransfer());
                if (valid != null && valid.isOK()) {
                    if (Policy.DEBUG_DND) {
                        System.out.println(// $NON-NLS-1$ //$NON-NLS-2$
                        "CommonDropAdapter.drop assistant selected: " + localAssistant + " op: " + event.detail);
                    }
                    localAssistant.handleDrop(CommonDropAdapter.this, event, target);
                    retValue[0] = true;
                }
            }
        });
        if (retValue[0])
            return true;
    }
    return false;
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) NavigatorSafeRunnable(org.eclipse.ui.internal.navigator.NavigatorSafeRunnable) DropTargetEvent(org.eclipse.swt.dnd.DropTargetEvent)

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