use of org.eclipse.ui.navigator.INavigatorContentDescriptor in project polymap4-core by Polymap4.
the class NavigatorActivationService method revertExtensionActivations.
private void revertExtensionActivations() {
IEclipsePreferences prefs = NavigatorContentService.getPreferencesRoot();
String activatedExtensionsString = prefs.get(getPreferenceKey(), null);
if (activatedExtensionsString != null && activatedExtensionsString.length() > 0) {
String[] contentExtensionIds = activatedExtensionsString.split(DELIM);
String id = null;
String booleanString = null;
int indx = 0;
for (int i = 0; i < contentExtensionIds.length; i++) {
if ((indx = contentExtensionIds[i].indexOf(EQUALS)) > -1) {
// up to but not including the equals
id = contentExtensionIds[i].substring(0, indx);
booleanString = contentExtensionIds[i].substring(indx + 1, contentExtensionIds[i].length());
activatedExtensionsMap.put(id, Boolean.valueOf(booleanString));
} else {
// IS THIS THE RIGHT WAY TO HANDLE THIS CASE?
NavigatorContentDescriptor descriptor = CONTENT_DESCRIPTOR_REGISTRY.getContentDescriptor(contentExtensionIds[i]);
if (descriptor != null)
activatedExtensionsMap.put(id, Boolean.valueOf(descriptor.isActiveByDefault()));
}
}
} else {
/*
* We add the default activation of every known extension, even
* though some may not be bound to the associated content service;
* this is because they could be bound at a later time through the
* programmatic binding mechanism in INavigatorContentService.
*/
INavigatorContentDescriptor[] contentDescriptors = CONTENT_DESCRIPTOR_REGISTRY.getAllContentDescriptors();
for (int i = 0; i < contentDescriptors.length; i++) {
if (contentDescriptors[i].isActiveByDefault()) {
activatedExtensionsMap.put(contentDescriptors[i].getId(), Boolean.TRUE);
}
}
}
}
use of org.eclipse.ui.navigator.INavigatorContentDescriptor in project polymap4-core by Polymap4.
the class NavigatorActivationService method deactivateExtensions.
public INavigatorContentDescriptor[] deactivateExtensions(String[] extensionIds, boolean toEnableAllOthers) {
Set activatedDescriptors = new HashSet();
setActive(extensionIds, false);
if (toEnableAllOthers) {
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[] activatedExtensions = new String[descriptorList.size()];
for (int i = 0; i < descriptorList.size(); i++) {
NavigatorContentDescriptor descriptor = (NavigatorContentDescriptor) descriptorList.get(i);
activatedExtensions[i] = descriptor.getId();
activatedDescriptors.add(descriptor);
}
setActive(activatedExtensions, true);
}
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 getExtension.
/**
* @param aDescriptorKey
* @param toLoadIfNecessary
* True if the extension should be loaded if it is not already.
* @return The instance of the extension for the given descriptor key.
*/
public final NavigatorContentExtension getExtension(INavigatorContentDescriptor aDescriptorKey, boolean toLoadIfNecessary) {
/* Query and return the relevant descriptor instance */
NavigatorContentExtension extension = (NavigatorContentExtension) contentExtensions.get(aDescriptorKey);
if (extension != null || !toLoadIfNecessary) {
return extension;
}
/*
* If the descriptor instance hasn't been created yet, then we need to
* (1) verify that it wasn't added by another thread, (2) create and add
* the result into the map
*/
synchronized (this) {
extension = (NavigatorContentExtension) contentExtensions.get(aDescriptorKey);
if (extension == null) {
contentExtensions.put(aDescriptorKey, (extension = new NavigatorContentExtension((NavigatorContentDescriptor) aDescriptorKey, this, structuredViewerManager)));
notifyListeners(extension);
}
}
return extension;
}
use of org.eclipse.ui.navigator.INavigatorContentDescriptor in project polymap4-core by Polymap4.
the class NavigatorContentService method getVisibleExtensions.
public INavigatorContentDescriptor[] getVisibleExtensions() {
List visibleDescriptors = new ArrayList();
NavigatorContentDescriptor[] descriptors = CONTENT_DESCRIPTOR_REGISTRY.getAllContentDescriptors();
for (int i = 0; i < descriptors.length; i++) {
if (assistant.isVisible(descriptors[i].getId())) {
visibleDescriptors.add(descriptors[i]);
}
}
if (visibleDescriptors.isEmpty()) {
return NO_DESCRIPTORS;
}
return (INavigatorContentDescriptor[]) visibleDescriptors.toArray(new INavigatorContentDescriptor[visibleDescriptors.size()]);
}
use of org.eclipse.ui.navigator.INavigatorContentDescriptor in project polymap4-core by Polymap4.
the class NavigatorContentServiceContentProvider method internalGetChildren.
private Object[] internalGetChildren(final Object aParentElement, final Object aParentElementOrPath, final Set enabledExtensions, final boolean elements) {
if (enabledExtensions.size() == 0) {
return NO_CHILDREN;
}
final Set finalSet = new LinkedHashSet();
final ContributorTrackingSet localSet = new ContributorTrackingSet(contentService);
for (final Iterator itr = enabledExtensions.iterator(); itr.hasNext(); ) {
SafeRunner.run(new NavigatorSafeRunnable() {
NavigatorContentExtension foundExtension = (NavigatorContentExtension) itr.next();
Object[] contributedChildren = null;
NavigatorContentExtension[] overridingExtensions;
public void run() throws Exception {
if (!isOverridingExtensionInSet(foundExtension.getDescriptor(), enabledExtensions)) {
if (elements)
contributedChildren = foundExtension.internalGetContentProvider().getElements(aParentElementOrPath);
else
contributedChildren = foundExtension.internalGetContentProvider().getChildren(aParentElementOrPath);
overridingExtensions = foundExtension.getOverridingExtensionsForTriggerPoint(aParentElement);
INavigatorContentDescriptor foundDescriptor = foundExtension.getDescriptor();
localSet.setContributor(foundDescriptor, foundDescriptor);
localSet.setContents(contributedChildren);
if (overridingExtensions.length > 0) {
pipelineChildren(aParentElement, overridingExtensions, foundDescriptor, localSet, elements);
}
finalSet.addAll(localSet);
}
}
public void handleException(Throwable e) {
NavigatorPlugin.logError(0, NLS.bind(CommonNavigatorMessages.Exception_Invoking_Extension, new Object[] { foundExtension.getDescriptor().getId(), aParentElement }), e);
}
});
}
return finalSet.toArray();
}
Aggregations