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