Search in sources :

Example 11 with INavigatorContentDescriptor

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

the class NavigatorSaveablesService method getSaveablesProviders.

/**
 * @return all SaveablesProvider objects
 */
private SaveablesProvider[] getSaveablesProviders() {
    // TODO optimize this
    if (saveablesProviders == null) {
        inactivePluginsWithSaveablesProviders = new HashMap();
        saveablesProviderMap = new TreeMap(ExtensionSequenceNumberComparator.INSTANCE);
        INavigatorContentDescriptor[] descriptors = contentService.getActiveDescriptorsWithSaveables();
        List result = new ArrayList();
        for (int i = 0; i < descriptors.length; i++) {
            NavigatorContentDescriptor descriptor = (NavigatorContentDescriptor) descriptors[i];
            String pluginId = ((NavigatorContentDescriptor) descriptor).getContribution().getPluginId();
            if (Platform.getBundle(pluginId).getState() != Bundle.ACTIVE) {
                List inactiveDescriptors = (List) inactivePluginsWithSaveablesProviders.get(pluginId);
                if (inactiveDescriptors == null) {
                    inactiveDescriptors = new ArrayList();
                    inactivePluginsWithSaveablesProviders.put(pluginId, inactiveDescriptors);
                }
                inactiveDescriptors.add(descriptor);
            } else {
                SaveablesProvider saveablesProvider = createSaveablesProvider(descriptor);
                if (saveablesProvider != null) {
                    saveablesProvider.init(saveablesLifecycleListener);
                    result.add(saveablesProvider);
                    saveablesProviderMap.put(descriptor, saveablesProvider);
                }
            }
        }
        saveablesProviders = (SaveablesProvider[]) result.toArray(new SaveablesProvider[result.size()]);
    }
    return saveablesProviders;
}
Also used : INavigatorContentDescriptor(org.eclipse.ui.navigator.INavigatorContentDescriptor) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) TreeMap(java.util.TreeMap) NavigatorContentDescriptor(org.eclipse.ui.internal.navigator.extensions.NavigatorContentDescriptor) INavigatorContentDescriptor(org.eclipse.ui.navigator.INavigatorContentDescriptor) SaveablesProvider(org.eclipse.ui.navigator.SaveablesProvider)

Example 12 with INavigatorContentDescriptor

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

the class NavigatorActivationService method activateExtensions.

public INavigatorContentDescriptor[] activateExtensions(String[] extensionIds, boolean toDeactivateAllOthers) {
    Set activatedDescriptors = new HashSet();
    setActive(extensionIds, true);
    for (int extId = 0; extId < extensionIds.length; extId++) {
        activatedDescriptors.add(CONTENT_DESCRIPTOR_REGISTRY.getContentDescriptor(extensionIds[extId]));
    }
    if (toDeactivateAllOthers) {
        NavigatorContentDescriptor[] descriptors = CONTENT_DESCRIPTOR_REGISTRY.getAllContentDescriptors();
        List descriptorList = new ArrayList(Arrays.asList(descriptors));
        for (int descriptorIndx = 0; descriptorIndx < descriptors.length; descriptorIndx++) {
            for (int extId = 0; extId < extensionIds.length; extId++) {
                if (descriptors[descriptorIndx].getId().equals(extensionIds[extId])) {
                    descriptorList.remove(descriptors[descriptorIndx]);
                }
            }
        }
        String[] deactivatedExtensions = new String[descriptorList.size()];
        for (int i = 0; i < descriptorList.size(); i++) {
            INavigatorContentDescriptor descriptor = (INavigatorContentDescriptor) descriptorList.get(i);
            deactivatedExtensions[i] = descriptor.getId();
        }
        setActive(deactivatedExtensions, false);
    }
    if (activatedDescriptors.size() == 0) {
        return NO_DESCRIPTORS;
    }
    return (INavigatorContentDescriptor[]) activatedDescriptors.toArray(new NavigatorContentDescriptor[activatedDescriptors.size()]);
}
Also used : INavigatorContentDescriptor(org.eclipse.ui.navigator.INavigatorContentDescriptor) Set(java.util.Set) HashSet(java.util.HashSet) ArrayList(java.util.ArrayList) ListenerList(org.eclipse.core.runtime.ListenerList) ArrayList(java.util.ArrayList) List(java.util.List) NavigatorContentDescriptor(org.eclipse.ui.internal.navigator.extensions.NavigatorContentDescriptor) INavigatorContentDescriptor(org.eclipse.ui.navigator.INavigatorContentDescriptor) HashSet(java.util.HashSet)

Example 13 with INavigatorContentDescriptor

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

the class NavigatorContentService method findOverridingLabelExtensions.

private void findOverridingLabelExtensions(Object anElement, INavigatorContentDescriptor descriptor, LinkedHashSet contributors) {
    ListIterator iter = ((NavigatorContentDescriptor) descriptor).getOverridingExtensionsListIterator(false);
    while (iter.hasPrevious()) {
        INavigatorContentDescriptor child = (INavigatorContentDescriptor) iter.previous();
        if (assistant.isVisibleAndActive(child) && child.isPossibleChild(anElement)) {
            findOverridingLabelExtensions(anElement, child, contributors);
        }
    }
    contributors.add(getExtension(descriptor));
}
Also used : INavigatorContentDescriptor(org.eclipse.ui.navigator.INavigatorContentDescriptor) ListIterator(java.util.ListIterator) INavigatorContentDescriptor(org.eclipse.ui.navigator.INavigatorContentDescriptor) NavigatorContentDescriptor(org.eclipse.ui.internal.navigator.extensions.NavigatorContentDescriptor)

Example 14 with INavigatorContentDescriptor

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

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

the class NavigatorContentService method bindExtensions.

/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * org.eclipse.ui.navigator.INavigatorContentService#bindExtensions(java
	 * .lang.String[], boolean)
	 */
public INavigatorContentDescriptor[] bindExtensions(String[] extensionIds, boolean isRoot) {
    if (extensionIds == null || extensionIds.length == 0) {
        return NO_DESCRIPTORS;
    }
    for (int i = 0; i < extensionIds.length; i++) {
        assistant.bindExtensions(extensionIds, isRoot);
    }
    Set boundDescriptors = new HashSet();
    INavigatorContentDescriptor descriptor;
    for (int i = 0; i < extensionIds.length; i++) {
        descriptor = CONTENT_DESCRIPTOR_REGISTRY.getContentDescriptor(extensionIds[i]);
        if (descriptor != null) {
            boundDescriptors.add(descriptor);
        }
    }
    if (boundDescriptors.size() == 0) {
        return NO_DESCRIPTORS;
    }
    if (Policy.DEBUG_EXTENSION_SETUP) {
        System.out.println(// $NON-NLS-1$
        "bindExtensions: " + boundDescriptors);
    }
    return (INavigatorContentDescriptor[]) boundDescriptors.toArray(new INavigatorContentDescriptor[boundDescriptors.size()]);
}
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) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet)

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