Search in sources :

Example 1 with INavigatorContentExtension

use of org.eclipse.ui.navigator.INavigatorContentExtension in project polymap4-core by Polymap4.

the class ExtensionSequenceNumberComparator method compare.

/*
	 * (non-Javadoc)
	 * 
	 * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
	 */
public int compare(Object o1, Object o2) {
    INavigatorContentDescriptor lvalue = null;
    INavigatorContentDescriptor rvalue = null;
    if (o1 instanceof INavigatorContentDescriptor) {
        lvalue = (INavigatorContentDescriptor) o1;
    } else if (o1 instanceof NavigatorContentExtension) {
        lvalue = ((NavigatorContentExtension) o1).getDescriptor();
    }
    if (o2 instanceof INavigatorContentDescriptor) {
        rvalue = (INavigatorContentDescriptor) o2;
    } else if (o2 instanceof INavigatorContentExtension) {
        rvalue = ((NavigatorContentExtension) o2).getDescriptor();
    }
    if (lvalue == null || rvalue == null) {
        return -1 * sortAscending;
    }
    int c = lvalue.getSequenceNumber() - rvalue.getSequenceNumber();
    if (c != 0) {
        return c * sortAscending;
    }
    return 0;
}
Also used : INavigatorContentDescriptor(org.eclipse.ui.navigator.INavigatorContentDescriptor) INavigatorContentExtension(org.eclipse.ui.navigator.INavigatorContentExtension) INavigatorContentExtension(org.eclipse.ui.navigator.INavigatorContentExtension)

Example 2 with INavigatorContentExtension

use of org.eclipse.ui.navigator.INavigatorContentExtension in project polymap4-core by Polymap4.

the class NavigatorContentService method findStateModel.

public IExtensionStateModel findStateModel(String anExtensionId) {
    if (anExtensionId == null) {
        return null;
    }
    INavigatorContentDescriptor desc = CONTENT_DESCRIPTOR_REGISTRY.getContentDescriptor(anExtensionId);
    if (desc == null) {
        return null;
    }
    INavigatorContentExtension ext = getExtension(desc);
    if (ext == null) {
        return null;
    }
    return ext.getStateModel();
}
Also used : INavigatorContentDescriptor(org.eclipse.ui.navigator.INavigatorContentDescriptor) INavigatorContentExtension(org.eclipse.ui.navigator.INavigatorContentExtension)

Example 3 with INavigatorContentExtension

use of org.eclipse.ui.navigator.INavigatorContentExtension 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;
}
Also used : NavigatorContentExtension(org.eclipse.ui.internal.navigator.extensions.NavigatorContentExtension) INavigatorContentExtension(org.eclipse.ui.navigator.INavigatorContentExtension) TreeSet(java.util.TreeSet) INavigatorContentDescriptor(org.eclipse.ui.navigator.INavigatorContentDescriptor) NavigatorContentDescriptor(org.eclipse.ui.internal.navigator.extensions.NavigatorContentDescriptor) SortedSet(java.util.SortedSet)

Aggregations

INavigatorContentDescriptor (org.eclipse.ui.navigator.INavigatorContentDescriptor)3 INavigatorContentExtension (org.eclipse.ui.navigator.INavigatorContentExtension)3 SortedSet (java.util.SortedSet)1 TreeSet (java.util.TreeSet)1 NavigatorContentDescriptor (org.eclipse.ui.internal.navigator.extensions.NavigatorContentDescriptor)1 NavigatorContentExtension (org.eclipse.ui.internal.navigator.extensions.NavigatorContentExtension)1