use of org.eclipse.ui.internal.navigator.extensions.NavigatorContentExtension in project polymap4-core by Polymap4.
the class NavigatorContentServiceContentProvider method pipelineChildren.
/**
* Query each of <code>theOverridingExtensions</code> for children, and then
* pipe them through the Pipeline content provider.
*
* @param aParent
* The parent element in the tree
* @param theOverridingExtensions
* The set of overriding extensions that should participate in
* the pipeline chain
* @param pipelinedChildren
* The current children to return to the viewer (should be
* modifiable)
*/
private void pipelineChildren(Object aParent, NavigatorContentExtension[] theOverridingExtensions, INavigatorContentDescriptor firstClassDescriptor, ContributorTrackingSet pipelinedChildren, boolean elements) {
IPipelinedTreeContentProvider pipelinedContentProvider;
NavigatorContentExtension[] overridingExtensions;
for (int i = 0; i < theOverridingExtensions.length; i++) {
if (theOverridingExtensions[i].internalGetContentProvider().isPipelined()) {
pipelinedContentProvider = (IPipelinedTreeContentProvider) theOverridingExtensions[i].internalGetContentProvider();
pipelinedChildren.setContributor(theOverridingExtensions[i].getDescriptor(), firstClassDescriptor);
if (elements) {
pipelinedContentProvider.getPipelinedElements(aParent, pipelinedChildren);
} else {
pipelinedContentProvider.getPipelinedChildren(aParent, pipelinedChildren);
}
overridingExtensions = theOverridingExtensions[i].getOverridingExtensionsForTriggerPoint(aParent);
if (overridingExtensions.length > 0) {
pipelineChildren(aParent, overridingExtensions, firstClassDescriptor, pipelinedChildren, elements);
}
}
}
}
use of org.eclipse.ui.internal.navigator.extensions.NavigatorContentExtension in project polymap4-core by Polymap4.
the class NavigatorContentServiceContentProvider method hasChildren.
/**
* Calculate hasChildren for both an element or a path.
*
* If any of the first class NCEs don't implement the IPipelinedTreeContentProviderHasChildren
* and they return true, then we have to use that as the value, as we are obliged to take
* the union of the non-pipelined calls. This may result in a false positive hasChildren
* indication if the pipeline mechanism does not actually contribute children later.
* For pipelined calls, we simply ask the pipelined content provider about the children
* and they can override this as they would in the case where they are providing the objects.
*/
public boolean hasChildren(final Object anElementOrPath) {
final Object anElement = internalAsElement(anElementOrPath);
final Set enabledExtensions = contentService.findContentExtensionsByTriggerPoint(anElement);
final boolean[] suggestedHasChildren = new boolean[1];
for (final Iterator itr = enabledExtensions.iterator(); itr.hasNext(); ) {
SafeRunner.run(new NavigatorSafeRunnable() {
NavigatorContentExtension ext;
public void run() throws Exception {
ext = (NavigatorContentExtension) itr.next();
if (!ext.isLoaded() && !enforceHasChildren) {
suggestedHasChildren[0] = true;
return;
}
NavigatorContentExtension[] overridingExtensions;
if (!isOverridingExtensionInSet(ext.getDescriptor(), enabledExtensions)) {
SafeDelegateTreeContentProvider cp = ext.internalGetContentProvider();
suggestedHasChildren[0] |= callNormalHasChildren(anElementOrPath, anElement, cp);
overridingExtensions = ext.getOverridingExtensionsForTriggerPoint(anElement);
if (overridingExtensions.length > 0) {
suggestedHasChildren[0] = pipelineHasChildren(anElementOrPath, anElement, overridingExtensions, suggestedHasChildren[0]);
}
if (suggestedHasChildren[0]) {
return;
}
}
}
public void handleException(Throwable e) {
NavigatorPlugin.logError(0, NLS.bind(CommonNavigatorMessages.Exception_Invoking_Extension, new Object[] { ext.getDescriptor().getId(), anElementOrPath }), e);
}
});
}
return suggestedHasChildren[0];
}
use of org.eclipse.ui.internal.navigator.extensions.NavigatorContentExtension in project polymap4-core by Polymap4.
the class NavigatorContentServiceContentProvider method findParent.
private Object findParent(NavigatorContentExtension anExtension, Object anElement, Object aSuggestedParent) {
/* the last valid (non-null) parent for the anElement */
Object lastValidParent = aSuggestedParent;
/* used to keep track of new suggestions */
Object suggestedOverriddenParent = null;
IPipelinedTreeContentProvider piplineContentProvider;
NavigatorContentExtension[] overridingExtensions = anExtension.getOverridingExtensionsForPossibleChild(anElement);
for (int i = 0; i < overridingExtensions.length; i++) {
if (overridingExtensions[i].internalGetContentProvider().isPipelined()) {
piplineContentProvider = (IPipelinedTreeContentProvider) overridingExtensions[i].internalGetContentProvider();
suggestedOverriddenParent = piplineContentProvider.getPipelinedParent(anElement, lastValidParent);
if (suggestedOverriddenParent != null && !suggestedOverriddenParent.equals(aSuggestedParent))
lastValidParent = suggestedOverriddenParent;
// should never return null
lastValidParent = findParent(overridingExtensions[i], anElement, lastValidParent);
}
}
return lastValidParent;
}
use of org.eclipse.ui.internal.navigator.extensions.NavigatorContentExtension in project polymap4-core by Polymap4.
the class NavigatorPipelineService method pipelineInterceptRemove.
private void pipelineInterceptRemove(final PipelinedShapeModification aRemoveModification, final ContributorTrackingSet trackedSet, final NavigatorContentExtension overrideableExtension) {
final Set overridingExtensions = new LinkedHashSet();
overridingExtensions.addAll(Arrays.asList(overrideableExtension.getOverridingExtensions()));
for (Iterator extensionsItr = overridingExtensions.iterator(); extensionsItr.hasNext(); ) {
final NavigatorContentExtension overridingExtension = (NavigatorContentExtension) extensionsItr.next();
trackedSet.setContributor((NavigatorContentDescriptor) overridingExtension.getDescriptor(), null);
if (overridingExtension.internalGetContentProvider().isPipelined()) {
SafeRunner.run(new NavigatorSafeRunnable() {
public void run() throws Exception {
((IPipelinedTreeContentProvider) overridingExtension.internalGetContentProvider()).interceptRemove(aRemoveModification);
}
public void handleException(Throwable e) {
NavigatorPlugin.logError(0, NLS.bind(CommonNavigatorMessages.Exception_Invoking_Extension, new Object[] { overridingExtension.getDescriptor().getId(), null }), e);
}
});
}
trackedSet.setContributor(null, null);
if (overridingExtension.getDescriptor().hasOverridingExtensions())
pipelineInterceptRemove(aRemoveModification, trackedSet, overridingExtension);
}
}
use of org.eclipse.ui.internal.navigator.extensions.NavigatorContentExtension in project polymap4-core by Polymap4.
the class NavigatorPipelineService method pipelineInterceptUpdate.
private boolean pipelineInterceptUpdate(final NavigatorContentExtension overrideableExtension, final PipelinedViewerUpdate anUpdateSynchronization, final Object refreshable) {
final boolean[] intercepted = new boolean[1];
final NavigatorContentExtension[] overridingExtensions = overrideableExtension.getOverridingExtensions();
for (int i = 0; i < overridingExtensions.length; i++) {
if (overridingExtensions[i].internalGetContentProvider().isPipelined()) {
final NavigatorContentExtension nceLocal = overridingExtensions[i];
SafeRunner.run(new NavigatorSafeRunnable() {
public void run() throws Exception {
intercepted[0] |= ((IPipelinedTreeContentProvider) nceLocal.internalGetContentProvider()).interceptUpdate(anUpdateSynchronization);
if (nceLocal.getDescriptor().hasOverridingExtensions())
intercepted[0] |= pipelineInterceptUpdate(nceLocal, anUpdateSynchronization, refreshable);
}
public void handleException(Throwable e) {
NavigatorPlugin.logError(0, NLS.bind(CommonNavigatorMessages.Exception_Invoking_Extension, new Object[] { nceLocal.getDescriptor().getId(), refreshable }), e);
}
});
}
}
return intercepted[0];
}
Aggregations