You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pivot.apache.org by no...@apache.org on 2011/04/05 15:05:07 UTC
svn commit: r1089018 -
/pivot/trunk/wtk/src/org/apache/pivot/wtk/content/TreeBranch.java
Author: noelgrandin
Date: Tue Apr 5 13:05:07 2011
New Revision: 1089018
URL: http://svn.apache.org/viewvc?rev=1089018&view=rev
Log:
PIVOT-724 Problem with TreeView and Comparator
Modified:
pivot/trunk/wtk/src/org/apache/pivot/wtk/content/TreeBranch.java
Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/content/TreeBranch.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/content/TreeBranch.java?rev=1089018&r1=1089017&r2=1089018&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/content/TreeBranch.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/content/TreeBranch.java Tue Apr 5 13:05:07 2011
@@ -212,7 +212,30 @@ public class TreeBranch extends TreeNode
@Override
public int indexOf(TreeNode treeNode) {
- return treeNodes.indexOf(treeNode);
+ // We can't use the ArrayList indexOf method, because if we have a comparator, it
+ // might return the wrong answer.
+ int index = 0;
+ int length = treeNodes.getLength();
+ while (index < length) {
+ TreeNode node = treeNodes.get(index);
+ if (treeNode == null) {
+ if (node == null) {
+ break;
+ }
+ } else {
+ if (treeNode.equals(node)) {
+ break;
+ }
+ }
+
+ index++;
+ }
+
+ if (index == length) {
+ index = -1;
+ }
+
+ return index;
}
@Override
@@ -260,4 +283,5 @@ public class TreeBranch extends TreeNode
public ListenerList<ListListener<TreeNode>> getListListeners() {
return listListeners;
}
+
}