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;
+ }
+
}
/**
VerticalDropLocation dropLocation = details
.getDropLocation();
- Object itemIdAfter = itemIdOver;
- if (dropLocation == VerticalDropLocation.MIDDLE) {
+ Object itemIdAfter = details.getItemIdAfter();
+
+ if (itemIdOver.equals(itemIdInto)) { // directly on a node
t.setParent(itemId, itemIdOver);
return;
- } else if (VerticalDropLocation.TOP == dropLocation) {
- // if on top of the caption area, add before
- Collection children;
- if (itemIdInto != null) {
- // seek the previous from child list
- children = idx.getChildren(itemIdInto);
- } else {
- children = idx.rootItemIds();
- }
- Object ref = null;
- for (Object object : children) {
- if (object.equals(itemIdOver)) {
- itemIdAfter = ref;
- break;
- }
- ref = object;
- }
}
+
idx.setParent(itemId, itemIdInto);
if (dropLocation == null) {