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;
}
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()]);
}
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;
}
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()]);
}
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));
}
Aggregations