diff options
author | Matti Tahvonen <matti.tahvonen@itmill.com> | 2010-03-05 15:12:46 +0000 |
---|---|---|
committer | Matti Tahvonen <matti.tahvonen@itmill.com> | 2010-03-05 15:12:46 +0000 |
commit | bc2514699433c8166053ee635e999dd8506b13cf (patch) | |
tree | 98f889450cd2c54eb70b418da7a4fc2724cfa60c /src/com/vaadin/ui/Tree.java | |
parent | 077b37ac8dd6b03c927edba95dd7ddec5ff37ba7 (diff) | |
download | vaadin-framework-bc2514699433c8166053ee635e999dd8506b13cf.tar.gz vaadin-framework-bc2514699433c8166053ee635e999dd8506b13cf.zip |
extracted helper to detect previous itemId (in children list) of the actual target to Tree
svn changeset:11671/svn branch:6.3
Diffstat (limited to 'src/com/vaadin/ui/Tree.java')
-rw-r--r-- | src/com/vaadin/ui/Tree.java | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/src/com/vaadin/ui/Tree.java b/src/com/vaadin/ui/Tree.java index d28d02216c..4c1c7136fb 100644 --- a/src/com/vaadin/ui/Tree.java +++ b/src/com/vaadin/ui/Tree.java @@ -1154,6 +1154,41 @@ public class Tree extends AbstractSelect implements Container.Hierarchical, return getParent(itemIdOver); } + /** + * If drop is targeted into "folder node" (see {@link #getItemIdInto()} + * ), this method returns the item id after the drag was targeted. TODO + * could this be said any more difficult :-) + * + * @return + */ + public Object getItemIdAfter() { + Object itemIdOver = getItemIdOver(); + Object itemIdInto2 = getItemIdInto(); + if (itemIdOver.equals(itemIdInto2)) { + return null; + } + VerticalDropLocation dropLocation = getDropLocation(); + if (VerticalDropLocation.TOP == dropLocation) { + // if on top of the caption area, add before + Collection children; + Object itemIdInto = getItemIdInto(); + if (itemIdInto != null) { + // seek the previous from child list + children = getChildren(itemIdInto); + } else { + children = rootItemIds(); + } + Object ref = null; + for (Object object : children) { + if (object.equals(itemIdOver)) { + return ref; + } + ref = object; + } + } + return itemIdOver; + } + } /** |