Search in sources :

Example 16 with NavigatorContentExtension

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

the class NavigatorContentService method findRootContentExtensions.

/**
 * Search for extensions that declare the given element in their
 * <b>triggerPoints</b> expression.
 *
 * @param anElement
 *            The element to use in the query
 * @param toRespectViewerRoots
 *            True respect the <b>viewerContentBinding</b>s, False will look
 *            only for matching <b>triggerPoints</b> expressions.
 * @return The set of {@link INavigatorContentExtension}s that are
 *         <i>visible</i> and <i>active</i> for this content service and
 *         either declared through a
 *         <b>org.eclipse.ui.navigator.viewer/viewerContentBinding</b> to be
 *         a root element or have a <b>triggerPoints</b> expression that is
 *         <i>enabled</i> for the given element.
 */
public Set findRootContentExtensions(Object anElement, boolean toRespectViewerRoots) {
    SortedSet rootExtensions = new TreeSet(ExtensionSequenceNumberComparator.INSTANCE);
    if (toRespectViewerRoots) /*&& viewerDescriptor.hasOverriddenRootExtensions()*/
    {
        NavigatorContentDescriptor[] descriptors = CONTENT_DESCRIPTOR_REGISTRY.getAllContentDescriptors();
        NavigatorContentExtension extension = null;
        for (int i = 0; i < descriptors.length; i++) {
            if (isActive(descriptors[i].getId()) && isRootExtension(descriptors[i].getId())) {
                extension = getExtension(descriptors[i]);
                if (!extension.hasLoadingFailed()) {
                    rootExtensions.add(extension);
                }
            }
        }
    }
    if (rootExtensions.isEmpty()) {
        return findContentExtensionsByTriggerPoint(anElement);
    }
    return rootExtensions;
}
Also used : NavigatorContentExtension(org.eclipse.ui.internal.navigator.extensions.NavigatorContentExtension) INavigatorContentExtension(org.eclipse.ui.navigator.INavigatorContentExtension) TreeSet(java.util.TreeSet) INavigatorContentDescriptor(org.eclipse.ui.navigator.INavigatorContentDescriptor) NavigatorContentDescriptor(org.eclipse.ui.internal.navigator.extensions.NavigatorContentDescriptor) SortedSet(java.util.SortedSet)

Example 17 with NavigatorContentExtension

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

the class NavigatorContentService method saveState.

/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * org.eclipse.ui.internal.navigator.INavigatorContentService#saveState(
	 * org.eclipse.ui.IMemento)
	 */
public void saveState(final IMemento aMemento) {
    synchronized (this) {
        for (Iterator extensionItr = getExtensions().iterator(); extensionItr.hasNext(); ) {
            final NavigatorContentExtension element = (NavigatorContentExtension) extensionItr.next();
            SafeRunner.run(new NavigatorSafeRunnable(((NavigatorContentDescriptor) element.getDescriptor()).getConfigElement()) {

                public void run() throws Exception {
                    element.saveState(aMemento);
                }
            });
        }
    }
}
Also used : NavigatorContentExtension(org.eclipse.ui.internal.navigator.extensions.NavigatorContentExtension) INavigatorContentExtension(org.eclipse.ui.navigator.INavigatorContentExtension) ListIterator(java.util.ListIterator) Iterator(java.util.Iterator) INavigatorContentDescriptor(org.eclipse.ui.navigator.INavigatorContentDescriptor) NavigatorContentDescriptor(org.eclipse.ui.internal.navigator.extensions.NavigatorContentDescriptor) BackingStoreException(org.osgi.service.prefs.BackingStoreException)

Example 18 with NavigatorContentExtension

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

the class NavigatorContentServiceContentProvider method getParent.

public Object getParent(final Object anElement) {
    final Set extensions = contentService.findContentExtensionsWithPossibleChild(anElement);
    final Object[] parent = new Object[1];
    for (Iterator itr = extensions.iterator(); itr.hasNext(); ) {
        final NavigatorContentExtension foundExtension = (NavigatorContentExtension) itr.next();
        SafeRunner.run(new NavigatorSafeRunnable() {

            NavigatorContentExtension[] overridingExtensions;

            public void run() throws Exception {
                if (!isOverridingExtensionInSet(foundExtension.getDescriptor(), extensions)) {
                    parent[0] = foundExtension.internalGetContentProvider().getParent(anElement);
                    overridingExtensions = foundExtension.getOverridingExtensionsForPossibleChild(anElement);
                    if (overridingExtensions.length > 0) {
                        parent[0] = pipelineParent(anElement, overridingExtensions, parent);
                    }
                    if (parent[0] != null) {
                        return;
                    }
                }
            }

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

Example 19 with NavigatorContentExtension

use of org.eclipse.ui.internal.navigator.extensions.NavigatorContentExtension 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)

Example 20 with NavigatorContentExtension

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

the class NavigatorContentServiceContentProvider method pipelineParent.

/**
 * Query each of <code>theOverridingExtensions</code> for elements, and then
 * pipe them through the Pipeline content provider.
 *
 * @param anInputElement
 *            The input element in the tree
 * @param theOverridingExtensions
 *            The set of overriding extensions that should participate in
 *            the pipeline chain
 * @param theCurrentParent
 *            The current elements to return to the viewer (should be
 *            modifiable)
 * @return The set of elements to return to the viewer
 */
private Object pipelineParent(Object anInputElement, NavigatorContentExtension[] theOverridingExtensions, Object theCurrentParent) {
    IPipelinedTreeContentProvider pipelinedContentProvider;
    NavigatorContentExtension[] overridingExtensions;
    Object aSuggestedParent = null;
    for (int i = 0; i < theOverridingExtensions.length; i++) {
        if (theOverridingExtensions[i].internalGetContentProvider().isPipelined()) {
            pipelinedContentProvider = (IPipelinedTreeContentProvider) theOverridingExtensions[i].internalGetContentProvider();
            aSuggestedParent = pipelinedContentProvider.getPipelinedParent(anInputElement, aSuggestedParent);
            overridingExtensions = theOverridingExtensions[i].getOverridingExtensionsForTriggerPoint(anInputElement);
            if (overridingExtensions.length > 0) {
                aSuggestedParent = pipelineParent(anInputElement, overridingExtensions, aSuggestedParent);
            }
        }
    }
    return aSuggestedParent != null ? aSuggestedParent : theCurrentParent;
}
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