diff options
Diffstat (limited to 'org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/FilterTransform.java')
-rw-r--r-- | org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/FilterTransform.java | 102 |
1 files changed, 51 insertions, 51 deletions
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/FilterTransform.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/FilterTransform.java index af91ff4ea..5e207da8b 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/FilterTransform.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/FilterTransform.java @@ -34,16 +34,16 @@ import org.eclipse.jface.viewers.TreePath; public class FilterTransform { private Node root = new Node(); - + class Node { private int[] filteredIndexes = null; private Object[] filteredElements = null; private Map<Object, Node> children = null; // only set for parent nodes, // indexed by child - + Node() { } - + boolean addFilter(TreePath path, int childIndex, int pathIndex, Object filtered) { if (pathIndex == path.getSegmentCount()) { if (filteredIndexes == null) { @@ -80,7 +80,7 @@ public class FilterTransform { filteredElements = filt; return true; } - + if (children == null) { children = new HashMap<Object, Node>(); } @@ -92,7 +92,7 @@ public class FilterTransform { } return node.addFilter(path, childIndex, pathIndex + 1, filtered); } - + boolean clear(TreePath path, int pathIndex) { if (pathIndex == path.getSegmentCount()) { return true; @@ -109,7 +109,7 @@ public class FilterTransform { } return children.isEmpty() && (filteredIndexes == null || filteredIndexes.length == 0); } - + boolean clear(TreePath path, int childIndex, int pathIndex) { if (pathIndex == path.getSegmentCount()) { if (filteredIndexes != null) { @@ -158,8 +158,8 @@ public class FilterTransform { } else { return false; } - } - + } + Node find(TreePath path, int pathIndex) { if (pathIndex == path.getSegmentCount()) { return this; @@ -174,7 +174,7 @@ public class FilterTransform { } return null; } - + int viewToModel(int childIndex) { if (filteredIndexes == null) { return childIndex; @@ -185,11 +185,11 @@ public class FilterTransform { // has asked for the model index corresponding to the 4th viewer // index, then we want to find the 5th missing number in the // filtered index sequence. - + int count = -1; // count from 0, 1, 2... int missingNumbers = 0; // how many numbers missing from the filtered index int offset = 0; // offset into the filtered index - + while (missingNumbers < (childIndex + 1)) { count++; if (offset < filteredIndexes.length) { @@ -206,7 +206,7 @@ public class FilterTransform { } return count; } - + int modelToView(int childIndex) { if (filteredIndexes == null) { return childIndex; @@ -222,15 +222,15 @@ public class FilterTransform { } } return childIndex - offset; - } - + } + int modelToViewCount(int childCount) { if (filteredIndexes == null) { return childCount; } return childCount - filteredIndexes.length; } - + boolean isFiltered(int index) { if (filteredIndexes != null) { int location = Arrays.binarySearch(filteredIndexes, index); @@ -238,7 +238,7 @@ public class FilterTransform { } return false; } - + int indexOfFilteredElement(Object element) { if (filteredElements != null) { for (int i = 0; i < filteredElements.length; i++) { @@ -249,11 +249,11 @@ public class FilterTransform { } return -1; } - + /** * Sets the child count for this element, trimming any filtered elements * that were above this count. - * + * * @param childCount new child count */ void setModelChildCount(int childCount) { @@ -263,7 +263,7 @@ public class FilterTransform { // trim if (i == 0) { filteredIndexes = null; - // bug 200325 - filteredElements should have the same length + // bug 200325 - filteredElements should have the same length // as filteredIndexes filteredElements = null; return; @@ -271,7 +271,7 @@ public class FilterTransform { int[] temp = new int[i + 1]; System.arraycopy(filteredIndexes, 0, temp, 0, temp.length); filteredIndexes = temp; - // bug 200325 - filteredElements should have the same length + // bug 200325 - filteredElements should have the same length // as filteredIndexes Object[] temp2 = new Object[i + 1]; System.arraycopy(filteredElements, 0, temp2, 0, temp2.length); @@ -281,10 +281,10 @@ public class FilterTransform { } } } - + /** * Updates filter index for a removed element at the given index - * + * * @param index index at which an element was removed */ void removeElementFromFilters(int index) { @@ -333,7 +333,7 @@ public class FilterTransform { /** * Filters the specified child of the given parent and returns * whether the filter was added. - * + * * @param parentPath path to parent element * @param childIndex index of filtered child relative to parent (in model coordinates) * @param element the filtered element @@ -343,46 +343,46 @@ public class FilterTransform { public boolean addFilteredIndex(TreePath parentPath, int childIndex, Object element) { return root.addFilter(parentPath, childIndex, 0, element); } - + /** * Clears all filtered elements. */ public void clear() { root = new Node(); } - + /** * Clears all filters in the subtree of the given element. - * + * * @param path element path */ public void clear(TreePath path) { root.clear(path, 0); } - + /** * Clears the given filtered index of the specified parent. I.e. * the child still exists, but is no longer filtered. - * + * * @param parentPath parent path * @param index index to clear */ public void clear(TreePath parentPath, int index) { root.clear(parentPath, index, 0); - } - + } + public int indexOfFilteredElement(TreePath parentPath, Object element) { Node parentNode = root.find(parentPath, 0); if (parentNode == null) { return -1; } - return parentNode.indexOfFilteredElement(element); + return parentNode.indexOfFilteredElement(element); } - + /** * Translates and returns the given model index (raw index) into * a view index (filtered index), or -1 if filtered. - * + * * @param parentPath path to parent element * @param childIndex index of child element in model space * @return the given index in view coordinates, or -1 if filtered. @@ -394,11 +394,11 @@ public class FilterTransform { } return parentNode.modelToView(childIndex); } - + /** * Translates and returns the given view index (filtered) into * a model index (raw index). - * + * * @param parentPath path to parent element * @param childIndex index of child element in view space * @return the given index in model coordinates @@ -410,10 +410,10 @@ public class FilterTransform { } return parentNode.viewToModel(childIndex); } - + /** * Returns the number of children for the given parent, in the model. - * + * * @param parentPath path to parent element * @param viewCount number of children in the view * @return number of children in the model @@ -427,11 +427,11 @@ public class FilterTransform { } return viewCount; } - + /** * Translates and returns the given model child count (raw) into * a view count (filtered). - * + * * @param parentPath path to parent element * @param count child count in model space * @return the given count in view coordinates @@ -442,11 +442,11 @@ public class FilterTransform { return count; } return parentNode.modelToViewCount(count); - } - + } + /** * Returns whether the given index of the specified parent is currently filtered. - * + * * @param parentPath path to parent element * @param index index of child element * @return whether the child is currently filtered @@ -458,10 +458,10 @@ public class FilterTransform { } return parentNode.isFiltered(index); } - + /** * Returns filtered children of the given parent, or <code>null</code> if none. - * + * * @param parentPath Path of parent element * @return filtered children or <code>null</code> */ @@ -472,10 +472,10 @@ public class FilterTransform { } return parentNode.filteredIndexes; } - + /** * Clears any filters for the given parent above the given count. - * + * * @param parentPath path to parent element * @param childCount child count */ @@ -485,11 +485,11 @@ public class FilterTransform { parentNode.setModelChildCount(childCount); } } - + /** * The element at the given index has been removed from the parent. Update * indexes. - * + * * @param parentPath path to parent element * @param index index of child element in model coordinates */ @@ -499,11 +499,11 @@ public class FilterTransform { parentNode.removeElementFromFilters(index); } } - + /** * The element has been removed from the parent. Update * filtered indexes, in case it was a filtered object. - * + * * @param parentPath path to parent element * @param element removed element * @return true if element was removed @@ -518,5 +518,5 @@ public class FilterTransform { } } return false; - } + } } |