Search in sources :

Example 16 with INavigatorContentDescriptor

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

the class NavigatorContentService method findPossibleLabelExtensions.

/**
 * Returns the list of extensions that should be considered as possible
 * contributors of CNF artifacts (labels, sorters, ...). The algorithm
 * first considers the source of contribution and its overrides, and then
 * any possibleChildren and their overrides in order.
 *
 * @param anElement
 *            An element from the tree (any element contributed to the
 *            tree).
 * @return A Collection of NCEs sorted in the correct order for label provider application
 */
public Collection findPossibleLabelExtensions(Object anElement) {
    LinkedHashSet contributors = new LinkedHashSet();
    INavigatorContentDescriptor sourceDescriptor = getSourceOfContribution(anElement);
    // This is a TreeSet sorted ascending
    Set possibleChildDescriptors = findDescriptorsWithPossibleChild(anElement, false);
    // Add the source so that it gets sorted into the right place
    if (sourceDescriptor != null) {
        possibleChildDescriptors.add(sourceDescriptor);
    }
    for (Iterator iter = possibleChildDescriptors.iterator(); iter.hasNext(); ) {
        NavigatorContentDescriptor ncd = (NavigatorContentDescriptor) iter.next();
        findOverridingLabelExtensions(anElement, ncd, contributors);
    }
    return contributors;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) INavigatorContentDescriptor(org.eclipse.ui.navigator.INavigatorContentDescriptor) SortedSet(java.util.SortedSet) Set(java.util.Set) TreeSet(java.util.TreeSet) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet) ListIterator(java.util.ListIterator) Iterator(java.util.Iterator) INavigatorContentDescriptor(org.eclipse.ui.navigator.INavigatorContentDescriptor) NavigatorContentDescriptor(org.eclipse.ui.internal.navigator.extensions.NavigatorContentDescriptor)

Example 17 with INavigatorContentDescriptor

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

the class NavigatorContentService method findOverrideableContentExtensionsForPossibleChild.

/**
 * Search for extensions that declare the given element in their
 * <b>possibleChildren</b> expression.
 *
 * @param anElement
 *            The element to use in the query
 * @return The set of {@link INavigatorContentExtension}s that are
 *         <i>visible</i> and <i>active</i> for this content service and
 *         have a <b>possibleChildren</b> expression that is <i>enabled</i>
 *         for the given element.
 */
public Set findOverrideableContentExtensionsForPossibleChild(Object anElement) {
    Set overrideableExtensions = new TreeSet(ExtensionSequenceNumberComparator.INSTANCE);
    Set descriptors = findDescriptorsWithPossibleChild(anElement, false);
    for (Iterator iter = descriptors.iterator(); iter.hasNext(); ) {
        INavigatorContentDescriptor descriptor = (INavigatorContentDescriptor) iter.next();
        if (descriptor.hasOverridingExtensions()) {
            overrideableExtensions.add(getExtension(descriptor));
        }
    }
    return overrideableExtensions;
}
Also used : INavigatorContentDescriptor(org.eclipse.ui.navigator.INavigatorContentDescriptor) SortedSet(java.util.SortedSet) Set(java.util.Set) TreeSet(java.util.TreeSet) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet) TreeSet(java.util.TreeSet) ListIterator(java.util.ListIterator) Iterator(java.util.Iterator)

Example 18 with INavigatorContentDescriptor

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

the class NavigatorContentService method findStateModel.

public IExtensionStateModel findStateModel(String anExtensionId) {
    if (anExtensionId == null) {
        return null;
    }
    INavigatorContentDescriptor desc = CONTENT_DESCRIPTOR_REGISTRY.getContentDescriptor(anExtensionId);
    if (desc == null) {
        return null;
    }
    INavigatorContentExtension ext = getExtension(desc);
    if (ext == null) {
        return null;
    }
    return ext.getStateModel();
}
Also used : INavigatorContentDescriptor(org.eclipse.ui.navigator.INavigatorContentDescriptor) INavigatorContentExtension(org.eclipse.ui.navigator.INavigatorContentExtension)

Example 19 with INavigatorContentDescriptor

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

the class NavigatorContentService method getActiveDescriptorsWithSaveables.

/* package */
INavigatorContentDescriptor[] getActiveDescriptorsWithSaveables() {
    List result = new ArrayList();
    NavigatorContentDescriptor[] descriptors = CONTENT_DESCRIPTOR_REGISTRY.getContentDescriptorsWithSaveables();
    for (int i = 0; i < descriptors.length; i++) {
        if (assistant.isVisible(descriptors[i].getId()) && assistant.isActive(descriptors[i])) {
            result.add(descriptors[i]);
        }
    }
    if (result.isEmpty()) {
        return NO_DESCRIPTORS;
    }
    return (INavigatorContentDescriptor[]) result.toArray(new INavigatorContentDescriptor[result.size()]);
}
Also used : INavigatorContentDescriptor(org.eclipse.ui.navigator.INavigatorContentDescriptor) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) INavigatorContentDescriptor(org.eclipse.ui.navigator.INavigatorContentDescriptor) NavigatorContentDescriptor(org.eclipse.ui.internal.navigator.extensions.NavigatorContentDescriptor)

Example 20 with INavigatorContentDescriptor

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

the class NavigatorPipelineService method pipelineInterceptAdd.

private void pipelineInterceptAdd(final PipelinedShapeModification anAddModification, final ContributorTrackingSet trackedSet, final INavigatorContentDescriptor descriptor) {
    if (descriptor.hasOverridingExtensions()) {
        Set overridingDescriptors = descriptor.getOverriddingExtensions();
        for (Iterator overridingDescriptorsItr = overridingDescriptors.iterator(); overridingDescriptorsItr.hasNext(); ) {
            INavigatorContentDescriptor overridingDescriptor = (INavigatorContentDescriptor) overridingDescriptorsItr.next();
            if (contentService.isVisible(overridingDescriptor.getId()) && contentService.isActive(overridingDescriptor.getId())) {
                trackedSet.setContributor((NavigatorContentDescriptor) overridingDescriptor, (NavigatorContentDescriptor) descriptor);
                final NavigatorContentExtension extension = contentService.getExtension(overridingDescriptor);
                if (extension.internalGetContentProvider().isPipelined()) {
                    SafeRunner.run(new NavigatorSafeRunnable() {

                        public void run() throws Exception {
                            ((IPipelinedTreeContentProvider) extension.internalGetContentProvider()).interceptAdd(anAddModification);
                        }

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

Aggregations

INavigatorContentDescriptor (org.eclipse.ui.navigator.INavigatorContentDescriptor)23 Set (java.util.Set)10 NavigatorContentDescriptor (org.eclipse.ui.internal.navigator.extensions.NavigatorContentDescriptor)10 ArrayList (java.util.ArrayList)7 LinkedHashSet (java.util.LinkedHashSet)7 List (java.util.List)7 HashSet (java.util.HashSet)6 Iterator (java.util.Iterator)6 SortedSet (java.util.SortedSet)4 TreeSet (java.util.TreeSet)4 ListIterator (java.util.ListIterator)3 NavigatorContentExtension (org.eclipse.ui.internal.navigator.extensions.NavigatorContentExtension)3 INavigatorContentExtension (org.eclipse.ui.navigator.INavigatorContentExtension)3 ListenerList (org.eclipse.core.runtime.ListenerList)2 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)2 TableItem (org.eclipse.swt.widgets.TableItem)2 ICommonFilterDescriptor (org.eclipse.ui.navigator.ICommonFilterDescriptor)2 HashMap (java.util.HashMap)1 TreeMap (java.util.TreeMap)1 IEclipsePreferences (org.eclipse.core.runtime.preferences.IEclipsePreferences)1