|
Lines 50-55
Link Here
|
| 50 |
*/ |
50 |
*/ |
| 51 |
public abstract class AbstractTreeViewer extends StructuredViewer { |
51 |
public abstract class AbstractTreeViewer extends StructuredViewer { |
| 52 |
|
52 |
|
|
|
53 |
private static Widget[] NO_WIDGETS_ARRAY = new Widget[0]; |
| 54 |
|
| 53 |
/** |
55 |
/** |
| 54 |
* Constant indicating that all levels of the tree should be expanded or |
56 |
* Constant indicating that all levels of the tree should be expanded or |
| 55 |
* collapsed. |
57 |
* collapsed. |
|
Lines 131-136
Link Here
|
| 131 |
} |
133 |
} |
| 132 |
} |
134 |
} |
| 133 |
|
135 |
|
|
|
136 |
/* (non-Javadoc) |
| 137 |
* @see org.eclipse.jface.viewers.StructuredViewer#doFindItems(java.lang.Object) |
| 138 |
*/ |
| 139 |
protected Widget[] doFindItems(Object element) { |
| 140 |
// compare with root |
| 141 |
Object root = getRoot(); |
| 142 |
if (root == null) { |
| 143 |
return NO_WIDGETS_ARRAY; |
| 144 |
} |
| 145 |
|
| 146 |
ArrayList result = new ArrayList(); |
| 147 |
Item[] items = getChildren(getControl()); |
| 148 |
if (items != null) { |
| 149 |
for (int i = 0; i < items.length; i++) { |
| 150 |
internalFindItems(result, items[i], element); |
| 151 |
} |
| 152 |
} |
| 153 |
return (Widget[]) result.toArray(new Widget[result.size()]); |
| 154 |
} |
| 155 |
|
| 134 |
/** |
156 |
/** |
| 135 |
* Find the items for the given element of tree path |
157 |
* Find the items for the given element of tree path |
| 136 |
* @param parentElementOrTreePath the element or tree path |
158 |
* @param parentElementOrTreePath the element or tree path |
|
Lines 785-806
Link Here
|
| 785 |
|
807 |
|
| 786 |
/* (non-Javadoc) Method declared on StructuredViewer. */ |
808 |
/* (non-Javadoc) Method declared on StructuredViewer. */ |
| 787 |
protected Widget doFindItem(Object element) { |
809 |
protected Widget doFindItem(Object element) { |
| 788 |
// compare with root |
810 |
Widget[] items = doFindItems(element); |
| 789 |
Object root = getRoot(); |
811 |
if (items.length > 0) { |
| 790 |
if (root == null) { |
812 |
return items[0]; |
| 791 |
return null; |
813 |
} |
| 792 |
} |
814 |
return null; |
| 793 |
|
|
|
| 794 |
Item[] items = getChildren(getControl()); |
| 795 |
if (items != null) { |
| 796 |
for (int i = 0; i < items.length; i++) { |
| 797 |
Widget o = internalFindItem(items[i], element); |
| 798 |
if (o != null) { |
| 799 |
return o; |
| 800 |
} |
| 801 |
} |
| 802 |
} |
| 803 |
return null; |
| 804 |
} |
815 |
} |
| 805 |
|
816 |
|
| 806 |
/** |
817 |
/** |
|
Lines 1525-1549
Link Here
|
| 1525 |
* the element |
1536 |
* the element |
| 1526 |
* @return Widget |
1537 |
* @return Widget |
| 1527 |
*/ |
1538 |
*/ |
| 1528 |
private Widget internalFindItem(Item parent, Object element) { |
1539 |
private void internalFindItems(List result, Item parent, Object element) { |
| 1529 |
|
1540 |
|
| 1530 |
// compare with node |
1541 |
// compare with node |
| 1531 |
Object data = parent.getData(); |
1542 |
Object data = parent.getData(); |
| 1532 |
if (data != null) { |
1543 |
if (data != null) { |
| 1533 |
if (equals(data, element)) { |
1544 |
if (equals(data, element)) { |
| 1534 |
return parent; |
1545 |
result.add(parent); |
| 1535 |
} |
1546 |
} |
| 1536 |
} |
1547 |
} |
| 1537 |
// recurse over children |
1548 |
// recurse over children |
| 1538 |
Item[] items = getChildren(parent); |
1549 |
Item[] items = getChildren(parent); |
| 1539 |
for (int i = 0; i < items.length; i++) { |
1550 |
for (int i = 0; i < items.length; i++) { |
| 1540 |
Item item = items[i]; |
1551 |
Item item = items[i]; |
| 1541 |
Widget o = internalFindItem(item, element); |
1552 |
internalFindItems(result, item, element); |
| 1542 |
if (o != null) { |
|
|
| 1543 |
return o; |
| 1544 |
} |
| 1545 |
} |
1553 |
} |
| 1546 |
return null; |
|
|
| 1547 |
} |
1554 |
} |
| 1548 |
|
1555 |
|
| 1549 |
/* (non-Javadoc) Method declared on StructuredViewer. */ |
1556 |
/* (non-Javadoc) Method declared on StructuredViewer. */ |