aboutsummaryrefslogtreecommitdiffstats
path: root/src/com/vaadin/ui/Tree.java
diff options
context:
space:
mode:
authorMatti Tahvonen <matti.tahvonen@itmill.com>2010-03-24 15:40:04 +0000
committerMatti Tahvonen <matti.tahvonen@itmill.com>2010-03-24 15:40:04 +0000
commitc8fbcdc7dc02d36ddbcd2cb8ab061d45db04e154 (patch)
tree2cfb86d7434cda8af911c09bd6e94f06c764f74f /src/com/vaadin/ui/Tree.java
parent7f09fcfac4d0bd424427cb59403204863f337e12 (diff)
downloadvaadin-framework-c8fbcdc7dc02d36ddbcd2cb8ab061d45db04e154.tar.gz
vaadin-framework-c8fbcdc7dc02d36ddbcd2cb8ab061d45db04e154.zip
renaming criteria
svn changeset:12074/svn branch:6.3
Diffstat (limited to 'src/com/vaadin/ui/Tree.java')
-rw-r--r--src/com/vaadin/ui/Tree.java48
1 files changed, 24 insertions, 24 deletions
diff --git a/src/com/vaadin/ui/Tree.java b/src/com/vaadin/ui/Tree.java
index ac4222f8ec..670f9d8f2b 100644
--- a/src/com/vaadin/ui/Tree.java
+++ b/src/com/vaadin/ui/Tree.java
@@ -44,7 +44,7 @@ import com.vaadin.terminal.Resource;
import com.vaadin.terminal.gwt.client.MouseEventDetails;
import com.vaadin.terminal.gwt.client.ui.VTree;
import com.vaadin.terminal.gwt.client.ui.dd.VLazyInitItemIdentifiers;
-import com.vaadin.terminal.gwt.client.ui.dd.VTargetNodeIsChildOf;
+import com.vaadin.terminal.gwt.client.ui.dd.VTargetInSubtree;
import com.vaadin.terminal.gwt.client.ui.dd.VerticalDropLocation;
import com.vaadin.tools.ReflectTools;
@@ -1411,41 +1411,41 @@ public class Tree extends AbstractSelect implements Container.Hierarchical,
/**
* An accept criterion that checks the parent node (or parent hierarchy) for
* the item identifier given in constructor. If the parent is found, content
- * is accepted. Criterion can be used to accepts drags on a select sub tree
- * only.
- *
- * TODO consider renaming and starting traversing from "itemIdInto".
+ * is accepted. Criterion can be used to accepts drags on a specific sub
+ * tree only.
+ * <p>
+ * The root items is also consider to be valid target.
*/
- @ClientCriterion(VTargetNodeIsChildOf.class)
- public class TargetNodeIsChildOf extends ClientSideCriterion {
+ @ClientCriterion(VTargetInSubtree.class)
+ public class TargetInSubtree extends ClientSideCriterion {
- private Object parentItemId;
- private int depthToCheck = 1;
+ private Object rootId;
+ private int depthToCheck = -1;
/**
- * Constructs a criteria that accepts the drag if the targeted item is a
- * direct descendant of Item identified by given id
+ * Constructs a criteria that accepts the drag if the targeted Item is a
+ * descendant of Item identified by given id
*
* @param parentItemId
* the item identifier of the parent node
*/
- public TargetNodeIsChildOf(Object parentItemId) {
- this.parentItemId = parentItemId;
+ public TargetInSubtree(Object parentItemId) {
+ rootId = parentItemId;
}
/**
- * Constructs a criteria that accepts drops at any level below the item
- * identified by given id
+ * Constructs a criteria that accepts drops within given level below the
+ * subtree root identified by given id.
*
- * @param parentItemId
+ * @param rootId
* the item identifier to be sought for
* @param depthToCheck
* the depth that tree is traversed upwards to seek for the
* parent, -1 means that the whole structure should be
* checked
*/
- public TargetNodeIsChildOf(Object parentItemId, int depthToCheck) {
- this.parentItemId = parentItemId;
+ public TargetInSubtree(Object rootId, int depthToCheck) {
+ this.rootId = rootId;
this.depthToCheck = depthToCheck;
}
@@ -1455,14 +1455,14 @@ public class Tree extends AbstractSelect implements Container.Hierarchical,
.getDropTargetDetails();
if (eventDetails.getItemIdOver() != null) {
- Object itemIdOver = eventDetails.getItemIdOver();
- Object parent2 = getParent(itemIdOver);
+ Object itemId = eventDetails.getItemIdOver();
int i = 0;
- while (parent2 != null
- && (depthToCheck == -1 || i < depthToCheck)) {
- if (parent2.equals(parentItemId)) {
+ while (itemId != null
+ && (depthToCheck == -1 || i <= depthToCheck)) {
+ if (itemId.equals(rootId)) {
return true;
}
+ itemId = getParent(itemId);
i++;
}
}
@@ -1476,7 +1476,7 @@ public class Tree extends AbstractSelect implements Container.Hierarchical,
public void paintContent(PaintTarget target) throws PaintException {
super.paintContent(target);
target.addAttribute("depth", depthToCheck);
- target.addAttribute("key", key(parentItemId));
+ target.addAttribute("key", key(rootId));
}
}