use of org.eclipse.ui.internal.navigator.extensions.NavigatorContentExtension in project polymap4-core by Polymap4.
the class NavigatorContentService method updateService.
protected void updateService(Viewer aViewer, Object anOldInput, Object aNewInput) {
// NavigatorContentServiceContentProvider, which gets us here
if (isDisposed)
return;
synchronized (this) {
if (structuredViewerManager == null) {
structuredViewerManager = new StructuredViewerManager((StructuredViewer) aViewer, this);
structuredViewerManager.inputChanged(anOldInput, aNewInput);
} else {
structuredViewerManager.inputChanged(aViewer, anOldInput, aNewInput);
}
for (Iterator contentItr = contentExtensions.values().iterator(); contentItr.hasNext(); ) {
NavigatorContentExtension ext = (NavigatorContentExtension) contentItr.next();
if (ext.isLoaded()) {
structuredViewerManager.initialize(ext.internalGetContentProvider());
}
}
rootContentProviders = extractContentProviders(findRootContentExtensions(aNewInput));
}
}
use of org.eclipse.ui.internal.navigator.extensions.NavigatorContentExtension 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.NavigatorContentExtension 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);
}
});
}
}
}
use of org.eclipse.ui.internal.navigator.extensions.NavigatorContentExtension in project polymap4-core by Polymap4.
the class NavigatorContentService method dispose.
/*
* (non-Javadoc)
*
* @see org.eclipse.ui.internal.navigator.INavigatorContentService#dispose()
*/
public void dispose() {
if (navigatorSaveablesService != null) {
assistant.removeListener(navigatorSaveablesService);
}
if (navigatorSorterService != null) {
assistant.removeListener(navigatorSorterService);
}
synchronized (this) {
for (Iterator contentItr = contentExtensions.values().iterator(); contentItr.hasNext(); ) {
((NavigatorContentExtension) contentItr.next()).dispose();
}
}
getActivationService().removeExtensionActivationListener(this);
assistant.dispose();
isDisposed = true;
}
use of org.eclipse.ui.internal.navigator.extensions.NavigatorContentExtension 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