diff options
author | Matti Tahvonen <matti.tahvonen@itmill.com> | 2010-03-09 10:20:01 +0000 |
---|---|---|
committer | Matti Tahvonen <matti.tahvonen@itmill.com> | 2010-03-09 10:20:01 +0000 |
commit | 680617832d13b0e738f99d61ed675e380407cac5 (patch) | |
tree | 5ab3d112d78116d753ff2c31a092207b4dde0d50 /src/com/vaadin/data/util | |
parent | 8d9850db3f9554b965f8d0a2ba4aa518f847b73c (diff) | |
download | vaadin-framework-680617832d13b0e738f99d61ed675e380407cac5.tar.gz vaadin-framework-680617832d13b0e738f99d61ed675e380407cac5.zip |
fixes #3949
svn changeset:11705/svn branch:6.3
Diffstat (limited to 'src/com/vaadin/data/util')
-rw-r--r-- | src/com/vaadin/data/util/ContainerHierarchicalWrapper.java | 14 | ||||
-rw-r--r-- | src/com/vaadin/data/util/HierarchicalContainer.java | 31 |
2 files changed, 36 insertions, 9 deletions
diff --git a/src/com/vaadin/data/util/ContainerHierarchicalWrapper.java b/src/com/vaadin/data/util/ContainerHierarchicalWrapper.java index 8b6fedb8e4..e692f11498 100644 --- a/src/com/vaadin/data/util/ContainerHierarchicalWrapper.java +++ b/src/com/vaadin/data/util/ContainerHierarchicalWrapper.java @@ -518,7 +518,7 @@ public class ContainerHierarchicalWrapper implements Container.Hierarchical, /** * Removes an Item specified by the itemId from the underlying container and - * from the hierarcy. + * from the hierarchy. * * @param itemId * the ID of the Item to be removed. @@ -540,6 +540,18 @@ public class ContainerHierarchicalWrapper implements Container.Hierarchical, } /** + * Removes the Item identified by given itemId and all its children. + * + * @see #removeItem(Object) + * @param itemId + * the identifier of the Item to be removed + * @return true if the operation succeeded + */ + public boolean removeItemRecursively(Object itemId) { + return HierarchicalContainer.removeItemRecursively(this, itemId); + } + + /** * Adds a new Property to all Items in the Container. * * @param propertyId diff --git a/src/com/vaadin/data/util/HierarchicalContainer.java b/src/com/vaadin/data/util/HierarchicalContainer.java index a404d83eb1..5d29283bcb 100644 --- a/src/com/vaadin/data/util/HierarchicalContainer.java +++ b/src/com/vaadin/data/util/HierarchicalContainer.java @@ -492,29 +492,44 @@ public class HierarchicalContainer extends IndexedContainer implements } /** - * Removes the Item identified by ItemId from the Container and all its - * children. + * Removes the Item identified by given itemId and all its children. * * @see #removeItem(Object) * @param itemId - * the identifier of the Item to remove + * the identifier of the Item to be removed * @return true if the operation succeeded */ public boolean removeItemRecursively(Object itemId) { + return removeItemRecursively(this, itemId); + } + + /** + * Removes the Item identified by given itemId and all its children from the + * given Container. + * + * @param container + * the container where the item is to be removed + * @param itemId + * the identifier of the Item to be removed + * @return true if the operation succeeded + */ + public static boolean removeItemRecursively( + Container.Hierarchical container, Object itemId) { boolean success = true; - Collection<Object> children2 = getChildren(itemId); + Collection<?> children2 = container.getChildren(itemId); if (children2 != null) { Object[] array = children2.toArray(); for (int i = 0; i < array.length; i++) { - boolean removeItemRecursively = removeItemRecursively(array[i]); + boolean removeItemRecursively = removeItemRecursively( + container, array[i]); if (!removeItemRecursively) { success = false; } } } - boolean removeItem = removeItem(itemId); - if (!removeItem) { - success = false; + // remove the root of subtree if children where succesfully removed + if (success) { + success = container.removeItem(itemId); } return success; |