Search in sources :

Example 1 with SafeDelegateTreeContentProvider

use of org.eclipse.ui.internal.navigator.extensions.SafeDelegateTreeContentProvider 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 2 with SafeDelegateTreeContentProvider

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

the class NavigatorContentServiceContentProvider method pipelineHasChildren.

private boolean pipelineHasChildren(Object anElementOrPath, Object anElement, NavigatorContentExtension[] theOverridingExtensions, boolean suggestedHasChildren) {
    NavigatorContentExtension[] overridingExtensions;
    for (int i = 0; i < theOverridingExtensions.length; i++) {
        SafeDelegateTreeContentProvider cp = theOverridingExtensions[i].internalGetContentProvider();
        if (cp.isPipelinedHasChildren()) {
            suggestedHasChildren = cp.hasPipelinedChildren(anElement, suggestedHasChildren);
            overridingExtensions = theOverridingExtensions[i].getOverridingExtensionsForTriggerPoint(anElement);
            if (overridingExtensions.length > 0) {
                suggestedHasChildren = pipelineHasChildren(anElementOrPath, anElement, overridingExtensions, suggestedHasChildren);
            }
        } else {
            suggestedHasChildren |= callNormalHasChildren(anElementOrPath, anElement, cp);
        }
    }
    return suggestedHasChildren;
}
Also used : NavigatorContentExtension(org.eclipse.ui.internal.navigator.extensions.NavigatorContentExtension) SafeDelegateTreeContentProvider(org.eclipse.ui.internal.navigator.extensions.SafeDelegateTreeContentProvider)

Aggregations

NavigatorContentExtension (org.eclipse.ui.internal.navigator.extensions.NavigatorContentExtension)2 SafeDelegateTreeContentProvider (org.eclipse.ui.internal.navigator.extensions.SafeDelegateTreeContentProvider)2 Iterator (java.util.Iterator)1 LinkedHashSet (java.util.LinkedHashSet)1 Set (java.util.Set)1