Search in sources :

Example 1 with Saveable

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

the class NavigatorSaveablesService method getSaveable.

/**
 * @param element
 * @return the saveable associated with the given element
 */
private Saveable getSaveable(Object element) {
    if (saveablesProviderMap == null) {
        // has the side effect of recomputing saveablesProviderMap:
        getSaveablesProviders();
    }
    for (Iterator sItr = saveablesProviderMap.keySet().iterator(); sItr.hasNext(); ) {
        NavigatorContentDescriptor descriptor = (NavigatorContentDescriptor) sItr.next();
        if (descriptor.isTriggerPoint(element) || descriptor.isPossibleChild(element)) {
            SaveablesProvider provider = (SaveablesProvider) saveablesProviderMap.get(descriptor);
            Saveable saveable = provider.getSaveable(element);
            if (saveable != null) {
                return saveable;
            }
        }
    }
    return null;
}
Also used : Saveable(org.eclipse.ui.Saveable) Iterator(java.util.Iterator) NavigatorContentDescriptor(org.eclipse.ui.internal.navigator.extensions.NavigatorContentDescriptor) INavigatorContentDescriptor(org.eclipse.ui.navigator.INavigatorContentDescriptor) SaveablesProvider(org.eclipse.ui.navigator.SaveablesProvider)

Example 2 with Saveable

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

the class NavigatorSaveablesService method findSaveable.

/**
 * @param path
 * @return a saveable, or null
 */
private Saveable findSaveable(TreePath path) {
    int count = path.getSegmentCount();
    for (int j = count - 1; j >= 0; j--) {
        Object parent = path.getSegment(j);
        Saveable saveable = getSaveable(parent);
        if (saveable != null) {
            return saveable;
        }
    }
    return null;
}
Also used : Saveable(org.eclipse.ui.Saveable)

Example 3 with Saveable

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

the class NavigatorSaveablesService method getActiveSaveablesFromTreeProvider.

/**
 * @param selection
 * @param contentProvider
 * @return the active saveables
 */
private Saveable[] getActiveSaveablesFromTreeProvider(IStructuredSelection selection, ITreeContentProvider contentProvider) {
    Set result = new HashSet();
    for (Iterator it = selection.iterator(); it.hasNext(); ) {
        Object element = it.next();
        Saveable saveable = findSaveable(element, contentProvider);
        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) Iterator(java.util.Iterator) HashSet(java.util.HashSet)

Example 4 with Saveable

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

the class NavigatorSaveablesService method findSaveable.

/**
 * @param element
 * @param contentProvider
 * @return the saveable, or null
 */
private Saveable findSaveable(Object element, ITreeContentProvider contentProvider) {
    while (element != null) {
        Saveable saveable = getSaveable(element);
        if (saveable != null) {
            return saveable;
        }
        element = contentProvider.getParent(element);
    }
    return null;
}
Also used : Saveable(org.eclipse.ui.Saveable)

Example 5 with Saveable

use of org.eclipse.ui.Saveable 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)

Aggregations

Saveable (org.eclipse.ui.Saveable)8 HashSet (java.util.HashSet)5 Set (java.util.Set)5 Iterator (java.util.Iterator)3 TreePath (org.eclipse.jface.viewers.TreePath)3 SaveablesProvider (org.eclipse.ui.navigator.SaveablesProvider)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 ITreeContentProvider (org.eclipse.jface.viewers.ITreeContentProvider)1 ITreePathContentProvider (org.eclipse.jface.viewers.ITreePathContentProvider)1 SaveablesLifecycleEvent (org.eclipse.ui.SaveablesLifecycleEvent)1 NavigatorContentDescriptor (org.eclipse.ui.internal.navigator.extensions.NavigatorContentDescriptor)1 INavigatorContentDescriptor (org.eclipse.ui.navigator.INavigatorContentDescriptor)1