Search in sources :

Example 6 with NavigatorContentDescriptor

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

the class NavigatorSaveablesService method getSaveable.

/**
 * @param element
 * @return the saveable associated with the given element
 */
private Saveable getSaveable(Object element) {
    if (saveablesProviderMap == null) {
        // has the side effect of recomputing saveablesProviderMap:
        getSaveablesProviders();
    }
    for (Iterator sItr = saveablesProviderMap.keySet().iterator(); sItr.hasNext(); ) {
        NavigatorContentDescriptor descriptor = (NavigatorContentDescriptor) sItr.next();
        if (descriptor.isTriggerPoint(element) || descriptor.isPossibleChild(element)) {
            SaveablesProvider provider = (SaveablesProvider) saveablesProviderMap.get(descriptor);
            Saveable saveable = provider.getSaveable(element);
            if (saveable != null) {
                return saveable;
            }
        }
    }
    return null;
}
Also used : Saveable(org.eclipse.ui.Saveable) Iterator(java.util.Iterator) NavigatorContentDescriptor(org.eclipse.ui.internal.navigator.extensions.NavigatorContentDescriptor) INavigatorContentDescriptor(org.eclipse.ui.navigator.INavigatorContentDescriptor) SaveablesProvider(org.eclipse.ui.navigator.SaveablesProvider)

Example 7 with NavigatorContentDescriptor

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

the class NavigatorSaveablesService method updateSaveablesProviders.

/**
 * @param startedBundleId
 */
private void updateSaveablesProviders(String startedBundleId) {
    List result = new ArrayList(Arrays.asList(saveablesProviders));
    List descriptors = (List) inactivePluginsWithSaveablesProviders.get(startedBundleId);
    for (Iterator it = descriptors.iterator(); it.hasNext(); ) {
        NavigatorContentDescriptor descriptor = (NavigatorContentDescriptor) it.next();
        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()]);
}
Also used : ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) List(java.util.List) NavigatorContentDescriptor(org.eclipse.ui.internal.navigator.extensions.NavigatorContentDescriptor) INavigatorContentDescriptor(org.eclipse.ui.navigator.INavigatorContentDescriptor) SaveablesProvider(org.eclipse.ui.navigator.SaveablesProvider)

Example 8 with NavigatorContentDescriptor

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

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

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

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