Search in sources :

Example 41 with TreePath

use of org.eclipse.jface.viewers.TreePath in project polymap4-core by Polymap4.

the class CommonViewerSorter method isSorterProperty.

/* (non-Javadoc)
     * @see org.eclipse.jface.viewers.ViewerComparator#isSorterProperty(java.lang.Object, java.lang.String)
     */
public boolean isSorterProperty(Object element, String property) {
    // Have to get the parent path from the content provider
    NavigatorContentServiceContentProvider cp = (NavigatorContentServiceContentProvider) contentService.createCommonContentProvider();
    TreePath[] parentPaths = cp.getParents(element);
    for (int i = 0; i < parentPaths.length; i++) {
        if (isSorterProperty(parentPaths[i], element, property))
            return true;
    }
    return false;
}
Also used : TreePath(org.eclipse.jface.viewers.TreePath) NavigatorContentServiceContentProvider(org.eclipse.ui.internal.navigator.NavigatorContentServiceContentProvider)

Example 42 with TreePath

use of org.eclipse.jface.viewers.TreePath in project polymap4-core by Polymap4.

the class SafeDelegateTreeContentProvider method getParents.

/* (non-Javadoc)
	 * @see org.eclipse.jface.viewers.ITreePathContentProvider#getParents(java.lang.Object)
	 */
public TreePath[] getParents(Object element) {
    if (contentProvider instanceof ITreePathContentProvider) {
        ITreePathContentProvider tpcp = (ITreePathContentProvider) contentProvider;
        return tpcp.getParents(element);
    }
    ArrayList segments = new ArrayList();
    Object parent = element;
    do {
        parent = contentProvider.getParent(parent);
        if (parent != null && parent != viewer.getInput())
            segments.add(0, parent);
    } while (parent != null && parent != viewer.getInput());
    if (!segments.isEmpty()) {
        // Loop backwards over the array to create the path.
        return new TreePath[] { new TreePath(segments.toArray()) };
    }
    return NO_PATHS;
}
Also used : TreePath(org.eclipse.jface.viewers.TreePath) ArrayList(java.util.ArrayList) ITreePathContentProvider(org.eclipse.jface.viewers.ITreePathContentProvider)

Example 43 with TreePath

use of org.eclipse.jface.viewers.TreePath in project polymap4-core by Polymap4.

the class NavigatorPipelineService method interceptRemove.

public PipelinedShapeModification interceptRemove(PipelinedShapeModification aRemoveModification) {
    ContributorTrackingSet trackedSet = (ContributorTrackingSet) aRemoveModification.getChildren();
    Set interestedExtensions = new LinkedHashSet();
    for (Iterator iter = trackedSet.iterator(); iter.hasNext(); ) {
        Object element = (Object) iter.next();
        if (element instanceof TreePath) {
            interestedExtensions.addAll(contentService.findOverrideableContentExtensionsForPossibleChild(((TreePath) element).getLastSegment()));
        } else {
            interestedExtensions = contentService.findOverrideableContentExtensionsForPossibleChild(element);
        }
    }
    for (Iterator overridingExtensionsIter = interestedExtensions.iterator(); overridingExtensionsIter.hasNext(); ) pipelineInterceptRemove(aRemoveModification, trackedSet, (NavigatorContentExtension) overridingExtensionsIter.next());
    return aRemoveModification;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) Set(java.util.Set) LinkedHashSet(java.util.LinkedHashSet) TreePath(org.eclipse.jface.viewers.TreePath) NavigatorContentExtension(org.eclipse.ui.internal.navigator.extensions.NavigatorContentExtension) Iterator(java.util.Iterator)

Example 44 with TreePath

use of org.eclipse.jface.viewers.TreePath in project polymap4-core by Polymap4.

the class NavigatorSaveablesService method getActiveSaveablesFromTreeSelection.

/**
 * @param selection
 * @return the active saveables
 */
private Saveable[] getActiveSaveablesFromTreeSelection(ITreeSelection selection) {
    Set result = new HashSet();
    TreePath[] paths = selection.getPaths();
    for (int i = 0; i < paths.length; i++) {
        TreePath path = paths[i];
        Saveable saveable = findSaveable(path);
        if (saveable != null) {
            result.add(saveable);
        }
    }
    return (Saveable[]) result.toArray(new Saveable[result.size()]);
}
Also used : Saveable(org.eclipse.ui.Saveable) HashSet(java.util.HashSet) Set(java.util.Set) TreePath(org.eclipse.jface.viewers.TreePath) HashSet(java.util.HashSet)

Example 45 with TreePath

use of org.eclipse.jface.viewers.TreePath in project polymap4-core by Polymap4.

the class NavigatorSaveablesService method getActiveSaveablesFromTreePathProvider.

/**
 * @param selection
 * @param provider
 * @return the active saveables
 */
private Saveable[] getActiveSaveablesFromTreePathProvider(IStructuredSelection selection, ITreePathContentProvider provider) {
    Set result = new HashSet();
    for (Iterator it = selection.iterator(); it.hasNext(); ) {
        Object element = it.next();
        Saveable saveable = getSaveable(element);
        if (saveable != null) {
            result.add(saveable);
        } else {
            TreePath[] paths = provider.getParents(element);
            saveable = findSaveable(paths);
            if (saveable != null) {
                result.add(saveable);
            }
        }
    }
    return (Saveable[]) result.toArray(new Saveable[result.size()]);
}
Also used : Saveable(org.eclipse.ui.Saveable) HashSet(java.util.HashSet) Set(java.util.Set) TreePath(org.eclipse.jface.viewers.TreePath) Iterator(java.util.Iterator) HashSet(java.util.HashSet)

Aggregations

TreePath (org.eclipse.jface.viewers.TreePath)104 TreeSelection (org.eclipse.jface.viewers.TreeSelection)55 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)22 ArrayList (java.util.ArrayList)20 ITreeSelection (org.eclipse.jface.viewers.ITreeSelection)18 XSDComponent (org.eclipse.xsd.XSDComponent)14 Test (org.junit.Test)14 Iterator (java.util.Iterator)13 XSDAnnotation (org.eclipse.xsd.XSDAnnotation)13 Element (org.w3c.dom.Element)13 XSDAnnotationsStructure (com.amalto.workbench.utils.XSDAnnotationsStructure)12 HashSet (java.util.HashSet)10 Set (java.util.Set)10 ConsoleConfiguration (org.hibernate.console.ConsoleConfiguration)10 List (java.util.List)7 TreeViewer (org.eclipse.jface.viewers.TreeViewer)7 EntityDefinition (eu.esdihumboldt.hale.common.align.model.EntityDefinition)6 ILaunchConfiguration (org.eclipse.debug.core.ILaunchConfiguration)6 IProject (org.eclipse.core.resources.IProject)5 DoubleClickEvent (org.eclipse.jface.viewers.DoubleClickEvent)5