use of org.eclipse.ui.internal.navigator.extensions.NavigatorContentExtension in project polymap4-core by Polymap4.
the class NavigatorContentService method findRootContentExtensions.
/**
* Search for extensions that declare the given element in their
* <b>triggerPoints</b> expression.
*
* @param anElement
* The element to use in the query
* @param toRespectViewerRoots
* True respect the <b>viewerContentBinding</b>s, False will look
* only for matching <b>triggerPoints</b> expressions.
* @return The set of {@link INavigatorContentExtension}s that are
* <i>visible</i> and <i>active</i> for this content service and
* either declared through a
* <b>org.eclipse.ui.navigator.viewer/viewerContentBinding</b> to be
* a root element or have a <b>triggerPoints</b> expression that is
* <i>enabled</i> for the given element.
*/
public Set findRootContentExtensions(Object anElement, boolean toRespectViewerRoots) {
SortedSet rootExtensions = new TreeSet(ExtensionSequenceNumberComparator.INSTANCE);
if (toRespectViewerRoots) /*&& viewerDescriptor.hasOverriddenRootExtensions()*/
{
NavigatorContentDescriptor[] descriptors = CONTENT_DESCRIPTOR_REGISTRY.getAllContentDescriptors();
NavigatorContentExtension extension = null;
for (int i = 0; i < descriptors.length; i++) {
if (isActive(descriptors[i].getId()) && isRootExtension(descriptors[i].getId())) {
extension = getExtension(descriptors[i]);
if (!extension.hasLoadingFailed()) {
rootExtensions.add(extension);
}
}
}
}
if (rootExtensions.isEmpty()) {
return findContentExtensionsByTriggerPoint(anElement);
}
return rootExtensions;
}
use of org.eclipse.ui.internal.navigator.extensions.NavigatorContentExtension in project polymap4-core by Polymap4.
the class NavigatorContentService method saveState.
/*
* (non-Javadoc)
*
* @see
* org.eclipse.ui.internal.navigator.INavigatorContentService#saveState(
* org.eclipse.ui.IMemento)
*/
public void saveState(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.saveState(aMemento);
}
});
}
}
}
use of org.eclipse.ui.internal.navigator.extensions.NavigatorContentExtension in project polymap4-core by Polymap4.
the class NavigatorContentServiceContentProvider method getParent.
public Object getParent(final Object anElement) {
final Set extensions = contentService.findContentExtensionsWithPossibleChild(anElement);
final Object[] parent = new Object[1];
for (Iterator itr = extensions.iterator(); itr.hasNext(); ) {
final NavigatorContentExtension foundExtension = (NavigatorContentExtension) itr.next();
SafeRunner.run(new NavigatorSafeRunnable() {
NavigatorContentExtension[] overridingExtensions;
public void run() throws Exception {
if (!isOverridingExtensionInSet(foundExtension.getDescriptor(), extensions)) {
parent[0] = foundExtension.internalGetContentProvider().getParent(anElement);
overridingExtensions = foundExtension.getOverridingExtensionsForPossibleChild(anElement);
if (overridingExtensions.length > 0) {
parent[0] = pipelineParent(anElement, overridingExtensions, parent);
}
if (parent[0] != null) {
return;
}
}
}
public void handleException(Throwable e) {
NavigatorPlugin.logError(0, NLS.bind(CommonNavigatorMessages.Exception_Invoking_Extension, new Object[] { foundExtension.getDescriptor().getId(), anElement }), e);
}
});
}
return parent[0];
}
use of org.eclipse.ui.internal.navigator.extensions.NavigatorContentExtension in project polymap4-core by Polymap4.
the class NavigatorContentServiceContentProvider method pipelineHasChildren.
private boolean pipelineHasChildren(Object anElementOrPath, Object anElement, NavigatorContentExtension[] theOverridingExtensions, boolean suggestedHasChildren) {
NavigatorContentExtension[] overridingExtensions;
for (int i = 0; i < theOverridingExtensions.length; i++) {
SafeDelegateTreeContentProvider cp = theOverridingExtensions[i].internalGetContentProvider();
if (cp.isPipelinedHasChildren()) {
suggestedHasChildren = cp.hasPipelinedChildren(anElement, suggestedHasChildren);
overridingExtensions = theOverridingExtensions[i].getOverridingExtensionsForTriggerPoint(anElement);
if (overridingExtensions.length > 0) {
suggestedHasChildren = pipelineHasChildren(anElementOrPath, anElement, overridingExtensions, suggestedHasChildren);
}
} else {
suggestedHasChildren |= callNormalHasChildren(anElementOrPath, anElement, cp);
}
}
return suggestedHasChildren;
}
use of org.eclipse.ui.internal.navigator.extensions.NavigatorContentExtension in project polymap4-core by Polymap4.
the class NavigatorContentServiceContentProvider method pipelineParent.
/**
* Query each of <code>theOverridingExtensions</code> for elements, and then
* pipe them through the Pipeline content provider.
*
* @param anInputElement
* The input element in the tree
* @param theOverridingExtensions
* The set of overriding extensions that should participate in
* the pipeline chain
* @param theCurrentParent
* The current elements to return to the viewer (should be
* modifiable)
* @return The set of elements to return to the viewer
*/
private Object pipelineParent(Object anInputElement, NavigatorContentExtension[] theOverridingExtensions, Object theCurrentParent) {
IPipelinedTreeContentProvider pipelinedContentProvider;
NavigatorContentExtension[] overridingExtensions;
Object aSuggestedParent = null;
for (int i = 0; i < theOverridingExtensions.length; i++) {
if (theOverridingExtensions[i].internalGetContentProvider().isPipelined()) {
pipelinedContentProvider = (IPipelinedTreeContentProvider) theOverridingExtensions[i].internalGetContentProvider();
aSuggestedParent = pipelinedContentProvider.getPipelinedParent(anInputElement, aSuggestedParent);
overridingExtensions = theOverridingExtensions[i].getOverridingExtensionsForTriggerPoint(anInputElement);
if (overridingExtensions.length > 0) {
aSuggestedParent = pipelineParent(anInputElement, overridingExtensions, aSuggestedParent);
}
}
}
return aSuggestedParent != null ? aSuggestedParent : theCurrentParent;
}
Aggregations