Search in sources :

Example 11 with NavigatorContentDescriptor

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

the class NavigatorContentService method findDescriptorsByTriggerPoint.

/**
 * Search for extensions that declare the given element in their
 * <b>triggerPoints</b> expression.
 *
 * @param anElement
 *            The element to use in the query
 * @param considerOverrides
 *
 * @return The set of {@link INavigatorContentDescriptor}s that are
 *         <i>visible</i> and <i>active</i> for this content service and
 *         have a <b>triggerPoints</b> expression that is <i>enabled</i> for
 *         the given element.
 */
public Set findDescriptorsByTriggerPoint(Object anElement, boolean considerOverrides) {
    // Here we use the cache, since objects are inserted into the
    // cache in response to the trigger point
    NavigatorContentDescriptor descriptor = getSourceOfContribution(anElement);
    Set result = new TreeSet(ExtensionSequenceNumberComparator.INSTANCE);
    if (descriptor != null) {
        result.add(descriptor);
    }
    result.addAll(CONTENT_DESCRIPTOR_REGISTRY.findDescriptorsForTriggerPoint(anElement, assistant, considerOverrides));
    return result;
}
Also used : SortedSet(java.util.SortedSet) Set(java.util.Set) TreeSet(java.util.TreeSet) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet) TreeSet(java.util.TreeSet) INavigatorContentDescriptor(org.eclipse.ui.navigator.INavigatorContentDescriptor) NavigatorContentDescriptor(org.eclipse.ui.internal.navigator.extensions.NavigatorContentDescriptor)

Example 12 with NavigatorContentDescriptor

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

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

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

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

Aggregations

NavigatorContentDescriptor (org.eclipse.ui.internal.navigator.extensions.NavigatorContentDescriptor)17 INavigatorContentDescriptor (org.eclipse.ui.navigator.INavigatorContentDescriptor)17 ArrayList (java.util.ArrayList)7 List (java.util.List)7 Iterator (java.util.Iterator)6 Set (java.util.Set)5 NavigatorContentExtension (org.eclipse.ui.internal.navigator.extensions.NavigatorContentExtension)5 HashSet (java.util.HashSet)4 ListIterator (java.util.ListIterator)4 INavigatorContentExtension (org.eclipse.ui.navigator.INavigatorContentExtension)4 LinkedHashSet (java.util.LinkedHashSet)3 SortedSet (java.util.SortedSet)3 TreeSet (java.util.TreeSet)3 SaveablesProvider (org.eclipse.ui.navigator.SaveablesProvider)3 ListenerList (org.eclipse.core.runtime.ListenerList)2 BackingStoreException (org.osgi.service.prefs.BackingStoreException)2 HashMap (java.util.HashMap)1 TreeMap (java.util.TreeMap)1 IEclipsePreferences (org.eclipse.core.runtime.preferences.IEclipsePreferences)1 Saveable (org.eclipse.ui.Saveable)1