use of org.eclipse.ui.internal.navigator.extensions.NavigatorContentDescriptor 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.internal.navigator.extensions.NavigatorContentDescriptor 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.internal.navigator.extensions.NavigatorContentDescriptor 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.internal.navigator.extensions.NavigatorContentDescriptor 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.internal.navigator.extensions.NavigatorContentDescriptor in project polymap4-core by Polymap4.
the class NavigatorContentService method restoreState.
/*
* (non-Javadoc)
*
* @see
* org.eclipse.ui.internal.navigator.INavigatorContentService#restoreState
* (org.eclipse.ui.IMemento)
*/
public void restoreState(final IMemento aMemento) {
synchronized (this) {
for (Iterator extensionItr = getExtensions().iterator(); extensionItr.hasNext(); ) {
final NavigatorContentExtension element = (NavigatorContentExtension) extensionItr.next();
SafeRunner.run(new NavigatorSafeRunnable(((NavigatorContentDescriptor) element.getDescriptor()).getConfigElement()) {
public void run() throws Exception {
element.restoreState(aMemento);
}
});
}
}
}
Aggregations