use of org.eclipse.jface.viewers.TreePath in project netxms by netxms.
the class GalleryTreeViewer method remove.
/**
* Removes the element at the specified index of the parent. The selection
* is updated if required.
*
* @param parentOrTreePath
* the parent element, the input element, or a tree path to the
* parent element
* @param index
* child index
* @since 3.3
*/
@SuppressWarnings({ "rawtypes", "unchecked" })
public void remove(final Object parentOrTreePath, final int index) {
// if (isBusy())
// return;
final List oldSelection = new LinkedList(Arrays.asList(((TreeSelection) getSelection()).getPaths()));
preservingSelection(new Runnable() {
public void run() {
TreePath removedPath = null;
if (internalIsInputOrEmptyPath(parentOrTreePath)) {
Gallery gallery = (Gallery) getControl();
if (index < gallery.getItemCount()) {
GalleryItem item = gallery.getItem(index);
if (item.getData() != null) {
removedPath = getTreePathFromItem(item);
disassociate(item);
}
item.dispose();
}
} else {
Widget[] parentItems = internalFindItems(parentOrTreePath);
for (int i = 0; i < parentItems.length; i++) {
GalleryItem parentItem = (GalleryItem) parentItems[i];
if (index < parentItem.getItemCount()) {
GalleryItem item = parentItem.getItem(index);
if (item.getData() != null) {
removedPath = getTreePathFromItem(item);
disassociate(item);
}
item.dispose();
}
}
}
if (removedPath != null) {
boolean removed = false;
for (Iterator it = oldSelection.iterator(); it.hasNext(); ) {
TreePath path = (TreePath) it.next();
if (path.startsWith(removedPath, getComparer())) {
it.remove();
removed = true;
}
}
if (removed) {
setSelection(new TreeSelection((TreePath[]) oldSelection.toArray(new TreePath[oldSelection.size()]), getComparer()), false);
}
}
}
});
}
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;
}
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;
}
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;
}
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()]);
}
Aggregations