Search in sources :

Example 16 with NavigatorContentDescriptor

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

the class NavigatorContentService method getVisibleExtensionIds.

public String[] getVisibleExtensionIds() {
    List visibleExtensionIds = new ArrayList();
    NavigatorContentDescriptor[] descriptors = CONTENT_DESCRIPTOR_REGISTRY.getAllContentDescriptors();
    for (int i = 0; i < descriptors.length; i++) {
        if (assistant.isVisible(descriptors[i].getId())) {
            visibleExtensionIds.add(descriptors[i].getId());
        }
    }
    if (visibleExtensionIds.isEmpty()) {
        return NO_EXTENSION_IDS;
    }
    return (String[]) visibleExtensionIds.toArray(new String[visibleExtensionIds.size()]);
}
Also used : 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 17 with NavigatorContentDescriptor

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

the class NavigatorContentServiceContentProvider method findParents.

private Set findParents(final Object anElement) {
    final Set descriptors = contentService.findDescriptorsWithPossibleChild(anElement, false);
    final Set parents = new LinkedHashSet();
    for (final Iterator itr = descriptors.iterator(); itr.hasNext(); ) {
        SafeRunner.run(new NavigatorSafeRunnable() {

            NavigatorContentDescriptor foundDescriptor;

            NavigatorContentExtension foundExtension;

            Object parent = null;

            public void run() throws Exception {
                foundDescriptor = (NavigatorContentDescriptor) itr.next();
                foundExtension = contentService.getExtension(foundDescriptor);
                if (!isOverridingDescriptorInSet(foundExtension.getDescriptor(), descriptors)) {
                    if (foundExtension.internalGetContentProvider().isTreePath()) {
                        TreePath[] parentTreePaths = ((ITreePathContentProvider) foundExtension.internalGetContentProvider()).getParents(anElement);
                        for (int i = 0; i < parentTreePaths.length; i++) {
                            parent = parentTreePaths[i].getLastSegment();
                            if ((parent = findParent(foundExtension, anElement, parent)) != null)
                                parents.add(parent);
                        }
                    } else {
                        parent = foundExtension.internalGetContentProvider().getParent(anElement);
                        if ((parent = findParent(foundExtension, anElement, parent)) != null)
                            parents.add(parent);
                    }
                }
            }

            public void handleException(Throwable e) {
                NavigatorPlugin.logError(0, NLS.bind(CommonNavigatorMessages.Exception_Invoking_Extension, new Object[] { foundExtension.getDescriptor().getId(), anElement }), e);
            }
        });
    }
    return parents;
}
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) NavigatorContentDescriptor(org.eclipse.ui.internal.navigator.extensions.NavigatorContentDescriptor) INavigatorContentDescriptor(org.eclipse.ui.navigator.INavigatorContentDescriptor)

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