Search in sources :

Example 6 with NavigatorContentExtension

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

the class NavigatorContentServiceContentProvider method pipelineChildren.

/**
 * Query each of <code>theOverridingExtensions</code> for children, and then
 * pipe them through the Pipeline content provider.
 *
 * @param aParent
 *            The parent element in the tree
 * @param theOverridingExtensions
 *            The set of overriding extensions that should participate in
 *            the pipeline chain
 * @param pipelinedChildren
 *            The current children to return to the viewer (should be
 *            modifiable)
 */
private void pipelineChildren(Object aParent, NavigatorContentExtension[] theOverridingExtensions, INavigatorContentDescriptor firstClassDescriptor, ContributorTrackingSet pipelinedChildren, boolean elements) {
    IPipelinedTreeContentProvider pipelinedContentProvider;
    NavigatorContentExtension[] overridingExtensions;
    for (int i = 0; i < theOverridingExtensions.length; i++) {
        if (theOverridingExtensions[i].internalGetContentProvider().isPipelined()) {
            pipelinedContentProvider = (IPipelinedTreeContentProvider) theOverridingExtensions[i].internalGetContentProvider();
            pipelinedChildren.setContributor(theOverridingExtensions[i].getDescriptor(), firstClassDescriptor);
            if (elements) {
                pipelinedContentProvider.getPipelinedElements(aParent, pipelinedChildren);
            } else {
                pipelinedContentProvider.getPipelinedChildren(aParent, pipelinedChildren);
            }
            overridingExtensions = theOverridingExtensions[i].getOverridingExtensionsForTriggerPoint(aParent);
            if (overridingExtensions.length > 0) {
                pipelineChildren(aParent, overridingExtensions, firstClassDescriptor, pipelinedChildren, elements);
            }
        }
    }
}
Also used : IPipelinedTreeContentProvider(org.eclipse.ui.navigator.IPipelinedTreeContentProvider) NavigatorContentExtension(org.eclipse.ui.internal.navigator.extensions.NavigatorContentExtension)

Example 7 with NavigatorContentExtension

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

the class NavigatorContentServiceContentProvider method hasChildren.

/**
 * Calculate hasChildren for both an element or a path.
 *
 *  If any of the first class NCEs don't implement the IPipelinedTreeContentProviderHasChildren
 *  and they return true, then we have to use that as the value, as we are obliged to take
 *  the union of the non-pipelined calls. This may result in a false positive hasChildren
 *  indication if the pipeline mechanism does not actually contribute children later.
 *  For pipelined calls, we simply ask the pipelined content provider about the children
 *  and they can override this as they would in the case where they are providing the objects.
 */
public boolean hasChildren(final Object anElementOrPath) {
    final Object anElement = internalAsElement(anElementOrPath);
    final Set enabledExtensions = contentService.findContentExtensionsByTriggerPoint(anElement);
    final boolean[] suggestedHasChildren = new boolean[1];
    for (final Iterator itr = enabledExtensions.iterator(); itr.hasNext(); ) {
        SafeRunner.run(new NavigatorSafeRunnable() {

            NavigatorContentExtension ext;

            public void run() throws Exception {
                ext = (NavigatorContentExtension) itr.next();
                if (!ext.isLoaded() && !enforceHasChildren) {
                    suggestedHasChildren[0] = true;
                    return;
                }
                NavigatorContentExtension[] overridingExtensions;
                if (!isOverridingExtensionInSet(ext.getDescriptor(), enabledExtensions)) {
                    SafeDelegateTreeContentProvider cp = ext.internalGetContentProvider();
                    suggestedHasChildren[0] |= callNormalHasChildren(anElementOrPath, anElement, cp);
                    overridingExtensions = ext.getOverridingExtensionsForTriggerPoint(anElement);
                    if (overridingExtensions.length > 0) {
                        suggestedHasChildren[0] = pipelineHasChildren(anElementOrPath, anElement, overridingExtensions, suggestedHasChildren[0]);
                    }
                    if (suggestedHasChildren[0]) {
                        return;
                    }
                }
            }

            public void handleException(Throwable e) {
                NavigatorPlugin.logError(0, NLS.bind(CommonNavigatorMessages.Exception_Invoking_Extension, new Object[] { ext.getDescriptor().getId(), anElementOrPath }), e);
            }
        });
    }
    return suggestedHasChildren[0];
}
Also used : Set(java.util.Set) LinkedHashSet(java.util.LinkedHashSet) NavigatorContentExtension(org.eclipse.ui.internal.navigator.extensions.NavigatorContentExtension) SafeDelegateTreeContentProvider(org.eclipse.ui.internal.navigator.extensions.SafeDelegateTreeContentProvider) Iterator(java.util.Iterator)

Example 8 with NavigatorContentExtension

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

the class NavigatorContentServiceContentProvider method findParent.

private Object findParent(NavigatorContentExtension anExtension, Object anElement, Object aSuggestedParent) {
    /* the last valid (non-null) parent for the anElement */
    Object lastValidParent = aSuggestedParent;
    /* used to keep track of new suggestions */
    Object suggestedOverriddenParent = null;
    IPipelinedTreeContentProvider piplineContentProvider;
    NavigatorContentExtension[] overridingExtensions = anExtension.getOverridingExtensionsForPossibleChild(anElement);
    for (int i = 0; i < overridingExtensions.length; i++) {
        if (overridingExtensions[i].internalGetContentProvider().isPipelined()) {
            piplineContentProvider = (IPipelinedTreeContentProvider) overridingExtensions[i].internalGetContentProvider();
            suggestedOverriddenParent = piplineContentProvider.getPipelinedParent(anElement, lastValidParent);
            if (suggestedOverriddenParent != null && !suggestedOverriddenParent.equals(aSuggestedParent))
                lastValidParent = suggestedOverriddenParent;
            // should never return null
            lastValidParent = findParent(overridingExtensions[i], anElement, lastValidParent);
        }
    }
    return lastValidParent;
}
Also used : IPipelinedTreeContentProvider(org.eclipse.ui.navigator.IPipelinedTreeContentProvider) NavigatorContentExtension(org.eclipse.ui.internal.navigator.extensions.NavigatorContentExtension)

Example 9 with NavigatorContentExtension

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

the class NavigatorPipelineService method pipelineInterceptRemove.

private void pipelineInterceptRemove(final PipelinedShapeModification aRemoveModification, final ContributorTrackingSet trackedSet, final NavigatorContentExtension overrideableExtension) {
    final Set overridingExtensions = new LinkedHashSet();
    overridingExtensions.addAll(Arrays.asList(overrideableExtension.getOverridingExtensions()));
    for (Iterator extensionsItr = overridingExtensions.iterator(); extensionsItr.hasNext(); ) {
        final NavigatorContentExtension overridingExtension = (NavigatorContentExtension) extensionsItr.next();
        trackedSet.setContributor((NavigatorContentDescriptor) overridingExtension.getDescriptor(), null);
        if (overridingExtension.internalGetContentProvider().isPipelined()) {
            SafeRunner.run(new NavigatorSafeRunnable() {

                public void run() throws Exception {
                    ((IPipelinedTreeContentProvider) overridingExtension.internalGetContentProvider()).interceptRemove(aRemoveModification);
                }

                public void handleException(Throwable e) {
                    NavigatorPlugin.logError(0, NLS.bind(CommonNavigatorMessages.Exception_Invoking_Extension, new Object[] { overridingExtension.getDescriptor().getId(), null }), e);
                }
            });
        }
        trackedSet.setContributor(null, null);
        if (overridingExtension.getDescriptor().hasOverridingExtensions())
            pipelineInterceptRemove(aRemoveModification, trackedSet, overridingExtension);
    }
}
Also used : LinkedHashSet(java.util.LinkedHashSet) Set(java.util.Set) LinkedHashSet(java.util.LinkedHashSet) NavigatorContentExtension(org.eclipse.ui.internal.navigator.extensions.NavigatorContentExtension) Iterator(java.util.Iterator)

Example 10 with NavigatorContentExtension

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

the class NavigatorPipelineService method pipelineInterceptUpdate.

private boolean pipelineInterceptUpdate(final NavigatorContentExtension overrideableExtension, final PipelinedViewerUpdate anUpdateSynchronization, final Object refreshable) {
    final boolean[] intercepted = new boolean[1];
    final NavigatorContentExtension[] overridingExtensions = overrideableExtension.getOverridingExtensions();
    for (int i = 0; i < overridingExtensions.length; i++) {
        if (overridingExtensions[i].internalGetContentProvider().isPipelined()) {
            final NavigatorContentExtension nceLocal = overridingExtensions[i];
            SafeRunner.run(new NavigatorSafeRunnable() {

                public void run() throws Exception {
                    intercepted[0] |= ((IPipelinedTreeContentProvider) nceLocal.internalGetContentProvider()).interceptUpdate(anUpdateSynchronization);
                    if (nceLocal.getDescriptor().hasOverridingExtensions())
                        intercepted[0] |= pipelineInterceptUpdate(nceLocal, anUpdateSynchronization, refreshable);
                }

                public void handleException(Throwable e) {
                    NavigatorPlugin.logError(0, NLS.bind(CommonNavigatorMessages.Exception_Invoking_Extension, new Object[] { nceLocal.getDescriptor().getId(), refreshable }), e);
                }
            });
        }
    }
    return intercepted[0];
}
Also used : IPipelinedTreeContentProvider(org.eclipse.ui.navigator.IPipelinedTreeContentProvider) NavigatorContentExtension(org.eclipse.ui.internal.navigator.extensions.NavigatorContentExtension)

Aggregations

NavigatorContentExtension (org.eclipse.ui.internal.navigator.extensions.NavigatorContentExtension)24 Iterator (java.util.Iterator)14 LinkedHashSet (java.util.LinkedHashSet)9 Set (java.util.Set)9 INavigatorContentDescriptor (org.eclipse.ui.navigator.INavigatorContentDescriptor)7 INavigatorContentExtension (org.eclipse.ui.navigator.INavigatorContentExtension)6 NavigatorContentDescriptor (org.eclipse.ui.internal.navigator.extensions.NavigatorContentDescriptor)5 IPipelinedTreeContentProvider (org.eclipse.ui.navigator.IPipelinedTreeContentProvider)5 ListIterator (java.util.ListIterator)4 SafeDelegateTreeContentProvider (org.eclipse.ui.internal.navigator.extensions.SafeDelegateTreeContentProvider)2 BackingStoreException (org.osgi.service.prefs.BackingStoreException)2 Collection (java.util.Collection)1 SortedSet (java.util.SortedSet)1 TreeSet (java.util.TreeSet)1 CellLabelProvider (org.eclipse.jface.viewers.CellLabelProvider)1 ITreeContentProvider (org.eclipse.jface.viewers.ITreeContentProvider)1 StructuredViewer (org.eclipse.jface.viewers.StructuredViewer)1 TreePath (org.eclipse.jface.viewers.TreePath)1 Image (org.eclipse.swt.graphics.Image)1 NavigatorContentService (org.eclipse.ui.internal.navigator.NavigatorContentService)1