summaryrefslogtreecommitdiffstats
path: root/server/src/com/vaadin
diff options
context:
space:
mode:
Diffstat (limited to 'server/src/com/vaadin')
-rw-r--r--server/src/com/vaadin/ui/Tree.java24
1 files changed, 18 insertions, 6 deletions
diff --git a/server/src/com/vaadin/ui/Tree.java b/server/src/com/vaadin/ui/Tree.java
index 32c5712f0f..2c16a36a6c 100644
--- a/server/src/com/vaadin/ui/Tree.java
+++ b/server/src/com/vaadin/ui/Tree.java
@@ -75,7 +75,7 @@ public class Tree extends AbstractSelect implements Container.Hierarchical,
/**
* Set of expanded nodes.
*/
- private final HashSet<Object> expanded = new HashSet<Object>();
+ private HashSet<Object> expanded = new HashSet<Object>();
/**
* List of action handlers.
@@ -845,9 +845,20 @@ public class Tree extends AbstractSelect implements Container.Hierarchical,
newDataSource));
}
- // Ensure previous expanded items are cleaned up if they don't exist in
- // the new container
- cleanupExpandedItems();
+ /*
+ * Ensure previous expanded items are cleaned up if they don't exist in
+ * the new container
+ */
+ if (expanded != null) {
+ /*
+ * We need to check that the expanded-field is not null since
+ * setContainerDataSource() is called from the parent constructor
+ * (AbstractSelect()) and at that time the expanded field is not yet
+ * initialized.
+ */
+ cleanupExpandedItems();
+ }
+
}
/* Expand event and listener */
@@ -1652,7 +1663,6 @@ public class Tree extends AbstractSelect implements Container.Hierarchical,
target.addAttribute("depth", depthToCheck);
target.addAttribute("key", key(rootId));
}
-
}
/**
@@ -1688,13 +1698,15 @@ public class Tree extends AbstractSelect implements Container.Hierarchical,
}
private void cleanupExpandedItems() {
+ Set<Object> removedItemIds = new HashSet<Object>();
for (Object expandedItemId : expanded) {
if (getItem(expandedItemId) == null) {
- expanded.remove(expandedItemId);
+ removedItemIds.add(expandedItemId);
if (this.expandedItemId == expandedItemId) {
this.expandedItemId = null;
}
}
}
+ expanded.removeAll(removedItemIds);
}
}