summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/com/vaadin/event/DataBoundTransferable.java (renamed from src/com/vaadin/event/DataBindedTransferable.java)2
-rw-r--r--src/com/vaadin/event/dd/acceptCriteria/AcceptAll.java19
-rw-r--r--src/com/vaadin/event/dd/acceptCriteria/And.java40
-rw-r--r--src/com/vaadin/event/dd/acceptCriteria/ClientSideCriterion.java8
-rw-r--r--src/com/vaadin/event/dd/acceptCriteria/ComponentFilter.java39
-rw-r--r--src/com/vaadin/event/dd/acceptCriteria/IsDataBinded.java43
-rw-r--r--src/com/vaadin/event/dd/acceptCriteria/IsDatabound.java26
-rw-r--r--src/com/vaadin/event/dd/acceptCriteria/Not.java22
-rw-r--r--src/com/vaadin/event/dd/acceptCriteria/Or.java29
-rw-r--r--src/com/vaadin/event/dd/acceptCriteria/OverTreeNode.java37
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/dd/And.java2
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/dd/ComponentCriteria.java16
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/dd/HasItemId.java2
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/dd/Not.java48
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/dd/Or.java59
-rw-r--r--src/com/vaadin/ui/DragDropPane.java6
-rw-r--r--src/com/vaadin/ui/Table.java4
-rw-r--r--src/com/vaadin/ui/Tree.java9
-rw-r--r--tests/src/com/vaadin/tests/dd/DDTest1.java10
-rw-r--r--tests/src/com/vaadin/tests/dd/DDTest2.java52
20 files changed, 281 insertions, 192 deletions
diff --git a/src/com/vaadin/event/DataBindedTransferable.java b/src/com/vaadin/event/DataBoundTransferable.java
index 6e7675691d..fd259f0481 100644
--- a/src/com/vaadin/event/DataBindedTransferable.java
+++ b/src/com/vaadin/event/DataBoundTransferable.java
@@ -1,6 +1,6 @@
package com.vaadin.event;
-public interface DataBindedTransferable extends ComponentTransferable {
+public interface DataBoundTransferable extends ComponentTransferable {
public Object getItemId();
diff --git a/src/com/vaadin/event/dd/acceptCriteria/AcceptAll.java b/src/com/vaadin/event/dd/acceptCriteria/AcceptAll.java
index 8a6129130c..4424447d97 100644
--- a/src/com/vaadin/event/dd/acceptCriteria/AcceptAll.java
+++ b/src/com/vaadin/event/dd/acceptCriteria/AcceptAll.java
@@ -4,26 +4,14 @@
package com.vaadin.event.dd.acceptCriteria;
import com.vaadin.event.dd.DragAndDropEvent;
-import com.vaadin.terminal.PaintException;
-import com.vaadin.terminal.PaintTarget;
-public final class AcceptAll implements AcceptCriterion {
+public final class AcceptAll extends ClientSideCriterion {
private static AcceptCriterion singleton = new AcceptAll();
private AcceptAll() {
}
- public boolean isClientSideVerifiable() {
- return true;
- }
-
- public void paint(PaintTarget target) throws PaintException {
- target.startTag("-ac");
- target.addAttribute("name", getClass().getCanonicalName());
- target.endTag("-ac");
- }
-
public static AcceptCriterion get() {
return singleton;
}
@@ -31,9 +19,4 @@ public final class AcceptAll implements AcceptCriterion {
public boolean accepts(DragAndDropEvent dragEvent) {
return true;
}
-
- public void paintResponse(PaintTarget target) throws PaintException {
- // TODO Auto-generated method stub
-
- }
} \ No newline at end of file
diff --git a/src/com/vaadin/event/dd/acceptCriteria/And.java b/src/com/vaadin/event/dd/acceptCriteria/And.java
index 9517688f35..29a4a6aa2e 100644
--- a/src/com/vaadin/event/dd/acceptCriteria/And.java
+++ b/src/com/vaadin/event/dd/acceptCriteria/And.java
@@ -7,37 +7,41 @@ import com.vaadin.event.dd.DragAndDropEvent;
import com.vaadin.terminal.PaintException;
import com.vaadin.terminal.PaintTarget;
-public class And implements AcceptCriterion {
+/**
+ * TODO consider replacing this with Union
+ *
+ */
+public class And extends ClientSideCriterion {
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
private AcceptCriterion f1;
private AcceptCriterion f2;
- public And(AcceptCriterion f1, AcceptCriterion f2) {
+ public And(ClientSideCriterion f1, ClientSideCriterion f2) {
this.f1 = f1;
this.f2 = f2;
}
- public boolean isClientSideVerifiable() {
- boolean a1 = f1 instanceof AcceptCriterion ? (f1)
- .isClientSideVerifiable() : false;
- boolean a2 = f2 instanceof AcceptCriterion ? (f2)
- .isClientSideVerifiable() : false;
- return a1 && a2;
- }
-
- public void paint(PaintTarget target) throws PaintException {
- target.startTag("-ac");
- target.addAttribute("name", getClass().getCanonicalName());
+ // @Override
+ // public boolean isClientSideVerifiable() {
+ // boolean a1 = f1 instanceof AcceptCriterion ? (f1)
+ // .isClientSideVerifiable() : false;
+ // boolean a2 = f2 instanceof AcceptCriterion ? (f2)
+ // .isClientSideVerifiable() : false;
+ // return a1 && a2;
+ // }
+
+ @Override
+ public void paintContent(PaintTarget target) throws PaintException {
+ super.paintContent(target);
(f1).paint(target);
(f2).paint(target);
- target.endTag("-ac");
}
public boolean accepts(DragAndDropEvent dragEvent) {
return f1.accepts(dragEvent) && f2.accepts(dragEvent);
}
- public void paintResponse(PaintTarget target) throws PaintException {
- // TODO Auto-generated method stub
-
- }
} \ No newline at end of file
diff --git a/src/com/vaadin/event/dd/acceptCriteria/ClientSideCriterion.java b/src/com/vaadin/event/dd/acceptCriteria/ClientSideCriterion.java
index b221fb69cd..eaba934c10 100644
--- a/src/com/vaadin/event/dd/acceptCriteria/ClientSideCriterion.java
+++ b/src/com/vaadin/event/dd/acceptCriteria/ClientSideCriterion.java
@@ -13,7 +13,7 @@ public abstract class ClientSideCriterion implements Serializable,
*/
private static final long serialVersionUID = 1L;
- public final boolean isClientSideVerifiable() {
+ public boolean isClientSideVerifiable() {
return true;
}
@@ -24,10 +24,12 @@ public abstract class ClientSideCriterion implements Serializable,
target.endTag("-ac");
}
- public void paintContent(PaintTarget target) {
+ public void paintContent(PaintTarget target) throws PaintException {
}
- abstract protected String getIdentifier();
+ protected String getIdentifier() {
+ return getClass().getCanonicalName();
+ }
public void paintResponse(PaintTarget target) throws PaintException {
// NOP, nothing to do as this is client side verified criterion
diff --git a/src/com/vaadin/event/dd/acceptCriteria/ComponentFilter.java b/src/com/vaadin/event/dd/acceptCriteria/ComponentFilter.java
index dbaaac6ac8..85b0a953e3 100644
--- a/src/com/vaadin/event/dd/acceptCriteria/ComponentFilter.java
+++ b/src/com/vaadin/event/dd/acceptCriteria/ComponentFilter.java
@@ -9,35 +9,34 @@ import com.vaadin.terminal.PaintException;
import com.vaadin.terminal.PaintTarget;
import com.vaadin.ui.Component;
-public class ComponentFilter implements AcceptCriterion {
- private Component component;
+public class ComponentFilter extends ClientSideCriterion {
+ private Component[] component;
- public ComponentFilter(Component component) {
+ public ComponentFilter(Component... component) {
this.component = component;
}
- public boolean isClientSideVerifiable() {
- return true;
- }
-
- public void paint(PaintTarget target) throws PaintException {
- target.startTag("-ac");
- target.addAttribute("name", getClass().getCanonicalName());
- target.addAttribute("component", component);
- target.endTag("-ac");
+ @Override
+ public void paintContent(PaintTarget target) throws PaintException {
+ super.paintContent(target);
+ target.addAttribute("c", component.length);
+ for (int i = 0; i < component.length; i++) {
+ target.addAttribute("component" + i, component[i]);
+ }
}
public boolean accepts(DragAndDropEvent dragEvent) {
if (dragEvent.getTransferable() instanceof ComponentTransferable) {
- return ((ComponentTransferable) dragEvent.getTransferable())
- .getSourceComponent() == component;
- } else {
- return false;
+ Component sourceComponent = ((ComponentTransferable) dragEvent
+ .getTransferable()).getSourceComponent();
+ for (Component c : component) {
+ if (c == sourceComponent) {
+ return true;
+ }
+ }
}
- }
-
- public void paintResponse(PaintTarget target) throws PaintException {
- // TODO Auto-generated method stub
+ return false;
}
+
} \ No newline at end of file
diff --git a/src/com/vaadin/event/dd/acceptCriteria/IsDataBinded.java b/src/com/vaadin/event/dd/acceptCriteria/IsDataBinded.java
deleted file mode 100644
index bbda232786..0000000000
--- a/src/com/vaadin/event/dd/acceptCriteria/IsDataBinded.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/**
- *
- */
-package com.vaadin.event.dd.acceptCriteria;
-
-import com.vaadin.event.DataBindedTransferable;
-import com.vaadin.event.dd.DragAndDropEvent;
-import com.vaadin.terminal.PaintException;
-import com.vaadin.terminal.PaintTarget;
-
-public final class IsDataBinded implements AcceptCriterion {
- private static IsDataBinded singleton = new IsDataBinded();
-
- private IsDataBinded() {
- }
-
- public boolean isClientSideVerifiable() {
- return true;
- }
-
- public void paint(PaintTarget target) throws PaintException {
- target.startTag("-ac");
- target.addAttribute("name", getClass().getCanonicalName());
- target.endTag("-ac");
- }
-
- public static IsDataBinded get() {
- return singleton;
- }
-
- public boolean accepts(DragAndDropEvent dragEvent) {
- if (dragEvent.getTransferable() instanceof DataBindedTransferable) {
- return ((DataBindedTransferable) dragEvent.getTransferable())
- .getItemId() != null;
- }
- return false;
- }
-
- public void paintResponse(PaintTarget target) throws PaintException {
- // TODO Auto-generated method stub
-
- }
-} \ No newline at end of file
diff --git a/src/com/vaadin/event/dd/acceptCriteria/IsDatabound.java b/src/com/vaadin/event/dd/acceptCriteria/IsDatabound.java
new file mode 100644
index 0000000000..4b40296e3b
--- /dev/null
+++ b/src/com/vaadin/event/dd/acceptCriteria/IsDatabound.java
@@ -0,0 +1,26 @@
+/**
+ *
+ */
+package com.vaadin.event.dd.acceptCriteria;
+
+import com.vaadin.event.DataBoundTransferable;
+import com.vaadin.event.dd.DragAndDropEvent;
+
+public final class IsDatabound extends ClientSideCriterion {
+ private static IsDatabound singleton = new IsDatabound();
+
+ private IsDatabound() {
+ }
+
+ public static IsDatabound get() {
+ return singleton;
+ }
+
+ public boolean accepts(DragAndDropEvent dragEvent) {
+ if (dragEvent.getTransferable() instanceof DataBoundTransferable) {
+ return ((DataBoundTransferable) dragEvent.getTransferable())
+ .getItemId() != null;
+ }
+ return false;
+ }
+} \ No newline at end of file
diff --git a/src/com/vaadin/event/dd/acceptCriteria/Not.java b/src/com/vaadin/event/dd/acceptCriteria/Not.java
index 2408d6b6a3..58d1aed5df 100644
--- a/src/com/vaadin/event/dd/acceptCriteria/Not.java
+++ b/src/com/vaadin/event/dd/acceptCriteria/Not.java
@@ -4,33 +4,17 @@
package com.vaadin.event.dd.acceptCriteria;
import com.vaadin.event.dd.DragAndDropEvent;
-import com.vaadin.terminal.PaintException;
-import com.vaadin.terminal.PaintTarget;
-public class Not implements AcceptCriterion {
+public class Not extends ClientSideCriterion {
+
private AcceptCriterion acceptCriterion;
- public Not(AcceptCriterion acceptCriterion) {
+ public Not(ClientSideCriterion acceptCriterion) {
this.acceptCriterion = acceptCriterion;
}
- public boolean isClientSideVerifiable() {
- // TODO Auto-generated method stub
- return false;
- }
-
- public void paint(PaintTarget target) throws PaintException {
- // TODO Auto-generated method stub
-
- }
-
public boolean accepts(DragAndDropEvent dragEvent) {
return !acceptCriterion.accepts(dragEvent);
}
- public void paintResponse(PaintTarget target) throws PaintException {
- // TODO Auto-generated method stub
-
- }
-
} \ No newline at end of file
diff --git a/src/com/vaadin/event/dd/acceptCriteria/Or.java b/src/com/vaadin/event/dd/acceptCriteria/Or.java
index 6537f86b30..59f4de90f2 100644
--- a/src/com/vaadin/event/dd/acceptCriteria/Or.java
+++ b/src/com/vaadin/event/dd/acceptCriteria/Or.java
@@ -7,31 +7,32 @@ import com.vaadin.event.dd.DragAndDropEvent;
import com.vaadin.terminal.PaintException;
import com.vaadin.terminal.PaintTarget;
-public class Or implements AcceptCriterion {
+/**
+ * TODO consider replacing this with intersection
+ *
+ */
+public class Or extends ClientSideCriterion {
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
private AcceptCriterion f1;
private AcceptCriterion f2;
- Or(AcceptCriterion f1, AcceptCriterion f2) {
+ public Or(ClientSideCriterion f1, ClientSideCriterion f2) {
this.f1 = f1;
this.f2 = f2;
}
- public boolean isClientSideVerifiable() {
- // TODO Auto-generated method stub
- return false;
- }
-
- public void paint(PaintTarget target) throws PaintException {
- // TODO Auto-generated method stub
-
+ @Override
+ public void paintContent(PaintTarget target) throws PaintException {
+ super.paintContent(target);
+ f1.paint(target);
+ f2.paint(target);
}
public boolean accepts(DragAndDropEvent dragEvent) {
return f1.accepts(dragEvent) || f2.accepts(dragEvent);
}
- public void paintResponse(PaintTarget target) throws PaintException {
- // TODO Auto-generated method stub
-
- }
} \ No newline at end of file
diff --git a/src/com/vaadin/event/dd/acceptCriteria/OverTreeNode.java b/src/com/vaadin/event/dd/acceptCriteria/OverTreeNode.java
index 1241bf6cb3..e1bcf506b8 100644
--- a/src/com/vaadin/event/dd/acceptCriteria/OverTreeNode.java
+++ b/src/com/vaadin/event/dd/acceptCriteria/OverTreeNode.java
@@ -4,36 +4,39 @@
package com.vaadin.event.dd.acceptCriteria;
import com.vaadin.event.dd.DragAndDropEvent;
-import com.vaadin.terminal.PaintException;
-import com.vaadin.terminal.PaintTarget;
+import com.vaadin.ui.Tree;
import com.vaadin.ui.Tree.Location;
import com.vaadin.ui.Tree.TreeDropDetails;
-public class OverTreeNode implements AcceptCriterion {
-
- public boolean isClientSideVerifiable() {
- return true;
- }
+/**
+ * Accepts transferable only on tree Node (middle of the node + can has child)
+ *
+ * TODO relocate close to {@link Tree} as this is tree specifif
+ *
+ */
+public class OverTreeNode extends ClientSideCriterion {
- public void paint(PaintTarget target) throws PaintException {
- target.startTag("-ac");
- target.addAttribute("name", getClass().getCanonicalName());
- target.endTag("-ac");
- }
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
public boolean accepts(DragAndDropEvent dragEvent) {
try {
+ // must be over tree node and in the middle of it (not top or bottom
+ // part)
TreeDropDetails eventDetails = (TreeDropDetails) dragEvent
.getDropTargetData();
+
+ Object itemIdOver = eventDetails.getItemIdOver();
+ if (!eventDetails.getTarget().areChildrenAllowed(itemIdOver)) {
+ return false;
+ }
+
return eventDetails.getDropLocation() == Location.MIDDLE;
} catch (Exception e) {
return false;
}
}
- public void paintResponse(PaintTarget target) throws PaintException {
- // TODO Auto-generated method stub
-
- }
-
} \ No newline at end of file
diff --git a/src/com/vaadin/terminal/gwt/client/ui/dd/And.java b/src/com/vaadin/terminal/gwt/client/ui/dd/And.java
index 6eea108a42..42a341d7e3 100644
--- a/src/com/vaadin/terminal/gwt/client/ui/dd/And.java
+++ b/src/com/vaadin/terminal/gwt/client/ui/dd/And.java
@@ -40,7 +40,7 @@ final class And implements VAcceptCriteria {
};
crit1.accept(drag, configuration.getChildUIDL(0), accept1cb);
- crit2.accept(drag, configuration.getChildUIDL(0), accept2cb);
+ crit2.accept(drag, configuration.getChildUIDL(1), accept2cb);
if (b1 && b2) {
callback.accepted(drag);
}
diff --git a/src/com/vaadin/terminal/gwt/client/ui/dd/ComponentCriteria.java b/src/com/vaadin/terminal/gwt/client/ui/dd/ComponentCriteria.java
index 198e58018e..860653b67a 100644
--- a/src/com/vaadin/terminal/gwt/client/ui/dd/ComponentCriteria.java
+++ b/src/com/vaadin/terminal/gwt/client/ui/dd/ComponentCriteria.java
@@ -12,12 +12,16 @@ final class ComponentCriteria implements VAcceptCriteria {
VAcceptCallback callback) {
try {
Paintable component = drag.getTransferable().getComponent();
- String requiredPid = configuration.getStringAttribute("component");
- Paintable paintable = VDragAndDropManager.get()
- .getCurrentDropHandler().getApplicationConnection()
- .getPaintable(requiredPid);
- if (paintable == component) {
- callback.accepted(drag);
+ int c = configuration.getIntAttribute("c");
+ for (int i = 0; i < c; i++) {
+ String requiredPid = configuration
+ .getStringAttribute("component" + i);
+ Paintable paintable = VDragAndDropManager.get()
+ .getCurrentDropHandler().getApplicationConnection()
+ .getPaintable(requiredPid);
+ if (paintable == component) {
+ callback.accepted(drag);
+ }
}
} catch (Exception e) {
}
diff --git a/src/com/vaadin/terminal/gwt/client/ui/dd/HasItemId.java b/src/com/vaadin/terminal/gwt/client/ui/dd/HasItemId.java
index 8c2bbee46f..30716b43a5 100644
--- a/src/com/vaadin/terminal/gwt/client/ui/dd/HasItemId.java
+++ b/src/com/vaadin/terminal/gwt/client/ui/dd/HasItemId.java
@@ -5,7 +5,7 @@ package com.vaadin.terminal.gwt.client.ui.dd;
import com.vaadin.terminal.gwt.client.UIDL;
-@ServerCriterion("com.vaadin.event.dd.acceptCriteria.IsDataBinded")
+@ServerCriterion("com.vaadin.event.dd.acceptCriteria.IsDatabound")
final class HasItemId implements VAcceptCriteria {
public void accept(VDragEvent drag, UIDL configuration,
VAcceptCallback callback) {
diff --git a/src/com/vaadin/terminal/gwt/client/ui/dd/Not.java b/src/com/vaadin/terminal/gwt/client/ui/dd/Not.java
new file mode 100644
index 0000000000..3b5915c73b
--- /dev/null
+++ b/src/com/vaadin/terminal/gwt/client/ui/dd/Not.java
@@ -0,0 +1,48 @@
+/**
+ *
+ */
+package com.vaadin.terminal.gwt.client.ui.dd;
+
+import com.vaadin.terminal.gwt.client.ApplicationConnection;
+import com.vaadin.terminal.gwt.client.UIDL;
+
+@ServerCriterion("com.vaadin.event.dd.acceptCriteria.Or")
+final class Not implements VAcceptCriteria {
+ private boolean b1;
+ private VAcceptCriteria crit1;
+
+ public void accept(VDragEvent drag, UIDL configuration,
+ VAcceptCallback callback) {
+ if (crit1 == null) {
+ crit1 = getCriteria(drag, configuration, 0);
+ if (crit1 == null) {
+ ApplicationConnection.getConsole().log(
+ "Not criteria didn't found a child criteria");
+ return;
+ }
+ }
+
+ b1 = false;
+
+ VAcceptCallback accept1cb = new VAcceptCallback() {
+ public void accepted(VDragEvent event) {
+ b1 = true;
+ }
+ };
+
+ crit1.accept(drag, configuration.getChildUIDL(0), accept1cb);
+ if (!b1) {
+ callback.accepted(drag);
+ }
+ }
+
+ private VAcceptCriteria getCriteria(VDragEvent drag, UIDL configuration,
+ int i) {
+ UIDL childUIDL = configuration.getChildUIDL(i);
+ return VAcceptCriterion.get(childUIDL.getStringAttribute("name"));
+ }
+
+ public boolean needsServerSideCheck(VDragEvent drag, UIDL criterioUIDL) {
+ return false; // TODO enforce on server side
+ }
+} \ No newline at end of file
diff --git a/src/com/vaadin/terminal/gwt/client/ui/dd/Or.java b/src/com/vaadin/terminal/gwt/client/ui/dd/Or.java
new file mode 100644
index 0000000000..ea79edcd4e
--- /dev/null
+++ b/src/com/vaadin/terminal/gwt/client/ui/dd/Or.java
@@ -0,0 +1,59 @@
+/**
+ *
+ */
+package com.vaadin.terminal.gwt.client.ui.dd;
+
+import com.vaadin.terminal.gwt.client.ApplicationConnection;
+import com.vaadin.terminal.gwt.client.UIDL;
+
+@ServerCriterion("com.vaadin.event.dd.acceptCriteria.Or")
+final class Or implements VAcceptCriteria {
+ private boolean b1;
+ private boolean b2;
+ private VAcceptCriteria crit1;
+ private VAcceptCriteria crit2;
+
+ public void accept(VDragEvent drag, UIDL configuration,
+ VAcceptCallback callback) {
+ if (crit1 == null) {
+ crit1 = getCriteria(drag, configuration, 0);
+ crit2 = getCriteria(drag, configuration, 1);
+ if (crit1 == null || crit2 == null) {
+ ApplicationConnection.getConsole().log(
+ "Or criteria didn't found a chidl criteria");
+ return;
+ }
+ }
+
+ b1 = false;
+ b2 = false;
+
+ VAcceptCallback accept1cb = new VAcceptCallback() {
+ public void accepted(VDragEvent event) {
+ b1 = true;
+ }
+ };
+ VAcceptCallback accept2cb = new VAcceptCallback() {
+ public void accepted(VDragEvent event) {
+ b2 = true;
+ }
+ };
+
+ crit1.accept(drag, configuration.getChildUIDL(0), accept1cb);
+ crit2.accept(drag, configuration.getChildUIDL(1), accept2cb);
+ if (b1 || b2) {
+ callback.accepted(drag);
+ }
+ }
+
+ private VAcceptCriteria getCriteria(VDragEvent drag, UIDL configuration,
+ int i) {
+ UIDL childUIDL = configuration.getChildUIDL(i);
+ return VAcceptCriterion.get(childUIDL.getStringAttribute("name"));
+ }
+
+ public boolean needsServerSideCheck(VDragEvent drag, UIDL criterioUIDL) {
+ return false; // TODO enforce on server side
+ }
+
+} \ No newline at end of file
diff --git a/src/com/vaadin/ui/DragDropPane.java b/src/com/vaadin/ui/DragDropPane.java
index ec8443e237..24c366156c 100644
--- a/src/com/vaadin/ui/DragDropPane.java
+++ b/src/com/vaadin/ui/DragDropPane.java
@@ -3,7 +3,7 @@ package com.vaadin.ui;
import java.util.Map;
import com.vaadin.event.ComponentTransferable;
-import com.vaadin.event.DataBindedTransferable;
+import com.vaadin.event.DataBoundTransferable;
import com.vaadin.event.Transferable;
import com.vaadin.event.dd.DropEvent;
import com.vaadin.event.dd.DropHandler;
@@ -81,13 +81,13 @@ public class DragDropPane extends AbsoluteLayout implements DropTarget {
Component component = ctr.getSourceComponent();
if (component.getParent() != pane) {
- if (transferable instanceof DataBindedTransferable) {
+ if (transferable instanceof DataBoundTransferable) {
// Item has been dragged, construct a Label from
// Item id
Label l = new Label();
l.setSizeUndefined();
l.setValue("ItemId : "
- + ((DataBindedTransferable) transferable)
+ + ((DataBoundTransferable) transferable)
.getItemId());
pane.addComponent(l);
component = l;
diff --git a/src/com/vaadin/ui/Table.java b/src/com/vaadin/ui/Table.java
index 0ef6950936..afc91d7bcf 100644
--- a/src/com/vaadin/ui/Table.java
+++ b/src/com/vaadin/ui/Table.java
@@ -23,7 +23,7 @@ import com.vaadin.data.Property;
import com.vaadin.data.util.ContainerOrderedWrapper;
import com.vaadin.data.util.IndexedContainer;
import com.vaadin.event.Action;
-import com.vaadin.event.DataBindedTransferable;
+import com.vaadin.event.DataBoundTransferable;
import com.vaadin.event.ItemClickEvent;
import com.vaadin.event.Transferable;
import com.vaadin.event.Action.Handler;
@@ -3321,7 +3321,7 @@ public class Table extends AbstractSelect implements Action.Container,
requestRepaint();
}
- class TableTransferable implements DataBindedTransferable {
+ class TableTransferable implements DataBoundTransferable {
private final HashMap<String, Object> data = new HashMap<String, Object>();
diff --git a/src/com/vaadin/ui/Tree.java b/src/com/vaadin/ui/Tree.java
index c235405b36..15990500d6 100644
--- a/src/com/vaadin/ui/Tree.java
+++ b/src/com/vaadin/ui/Tree.java
@@ -23,7 +23,7 @@ import com.vaadin.data.Item;
import com.vaadin.data.util.ContainerHierarchicalWrapper;
import com.vaadin.data.util.IndexedContainer;
import com.vaadin.event.Action;
-import com.vaadin.event.DataBindedTransferable;
+import com.vaadin.event.DataBoundTransferable;
import com.vaadin.event.ItemClickEvent;
import com.vaadin.event.Transferable;
import com.vaadin.event.ItemClickEvent.ItemClickListener;
@@ -117,7 +117,7 @@ public class Tree extends AbstractSelect implements Container.Hierarchical,
private int itemDragModes = DRAG_OUT;
- class TreeTransferable implements DataBindedTransferable {
+ class TreeTransferable implements DataBoundTransferable {
private final HashMap<String, Object> data = new HashMap<String, Object>();
@@ -1188,6 +1188,11 @@ public class Tree extends AbstractSelect implements Container.Hierarchical,
}
}
+ @Override
+ public Tree getTarget() {
+ return (Tree) super.getTarget();
+ }
+
}
public TreeDropDetails translateDragDropDetails(
diff --git a/tests/src/com/vaadin/tests/dd/DDTest1.java b/tests/src/com/vaadin/tests/dd/DDTest1.java
index 33b2af641b..49f47da436 100644
--- a/tests/src/com/vaadin/tests/dd/DDTest1.java
+++ b/tests/src/com/vaadin/tests/dd/DDTest1.java
@@ -5,13 +5,13 @@ import java.util.Collection;
import com.vaadin.data.Item;
import com.vaadin.data.util.HierarchicalContainer;
import com.vaadin.event.ComponentTransferable;
-import com.vaadin.event.DataBindedTransferable;
+import com.vaadin.event.DataBoundTransferable;
import com.vaadin.event.Transferable;
import com.vaadin.event.dd.DragAndDropEvent;
import com.vaadin.event.dd.DropEvent;
import com.vaadin.event.dd.DropHandler;
import com.vaadin.event.dd.acceptCriteria.AcceptCriterion;
-import com.vaadin.event.dd.acceptCriteria.IsDataBinded;
+import com.vaadin.event.dd.acceptCriteria.IsDatabound;
import com.vaadin.event.dd.acceptCriteria.ServerSideCriterion;
import com.vaadin.terminal.ExternalResource;
import com.vaadin.tests.components.TestBase;
@@ -191,8 +191,8 @@ public class DDTest1 extends TestBase {
.getDropTargetData();
// TODO set properties, so same sorter could be used in Table
Transferable transferable = event.getTransferable();
- if (transferable instanceof DataBindedTransferable) {
- DataBindedTransferable transferrable2 = (DataBindedTransferable) transferable;
+ if (transferable instanceof DataBoundTransferable) {
+ DataBoundTransferable transferrable2 = (DataBoundTransferable) transferable;
Object itemId = transferrable2.getItemId();
@@ -237,7 +237,7 @@ public class DDTest1 extends TestBase {
public AcceptCriterion getAcceptCriterion() {
// TODO should actually check that source is same as target
- return IsDataBinded.get();
+ return IsDatabound.get();
}
};
diff --git a/tests/src/com/vaadin/tests/dd/DDTest2.java b/tests/src/com/vaadin/tests/dd/DDTest2.java
index 49ba8780e8..ab24955f2e 100644
--- a/tests/src/com/vaadin/tests/dd/DDTest2.java
+++ b/tests/src/com/vaadin/tests/dd/DDTest2.java
@@ -4,11 +4,12 @@ import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
+import com.vaadin.data.Container;
import com.vaadin.data.Item;
import com.vaadin.data.util.HierarchicalContainer;
import com.vaadin.demo.tutorial.addressbook.data.Person;
import com.vaadin.demo.tutorial.addressbook.data.PersonContainer;
-import com.vaadin.event.DataBindedTransferable;
+import com.vaadin.event.DataBoundTransferable;
import com.vaadin.event.Transferable;
import com.vaadin.event.dd.DragAndDropEvent;
import com.vaadin.event.dd.DropEvent;
@@ -16,7 +17,8 @@ import com.vaadin.event.dd.DropHandler;
import com.vaadin.event.dd.acceptCriteria.AcceptCriterion;
import com.vaadin.event.dd.acceptCriteria.And;
import com.vaadin.event.dd.acceptCriteria.ComponentFilter;
-import com.vaadin.event.dd.acceptCriteria.IsDataBinded;
+import com.vaadin.event.dd.acceptCriteria.IsDatabound;
+import com.vaadin.event.dd.acceptCriteria.Or;
import com.vaadin.event.dd.acceptCriteria.OverTreeNode;
import com.vaadin.terminal.Resource;
import com.vaadin.terminal.ThemeResource;
@@ -105,9 +107,12 @@ public class DDTest2 extends TestBase {
*/
table.setDragMode(Table.DragModes.ROWS);
- AcceptCriterion onNode = new OverTreeNode();
- AcceptCriterion fromTree = new ComponentFilter(table);
- final And and = new And(fromTree, onNode);
+ OverTreeNode onNode = new OverTreeNode();
+ ComponentFilter fromTable = new ComponentFilter(table);
+
+ ComponentFilter fromTree = new ComponentFilter(tree1);
+ final Or fromTree1OrTable = new Or(fromTable, fromTree);
+ final And and = new And(fromTree1OrTable, onNode);
DropHandler dropHandler = new DropHandler() {
@@ -116,15 +121,28 @@ public class DDTest2 extends TestBase {
* We know transferrable is from table, so it is of type
* DataBindedTransferrable
*/
- DataBindedTransferable tr = (DataBindedTransferable) event
+ DataBoundTransferable tr = (DataBoundTransferable) event
.getTransferable();
Object itemId = tr.getItemId();
- Table fromTable = (Table) tr.getSourceComponent();
- String name = fromTable.getItem(itemId).getItemProperty("Name")
- .toString();
+ Container sourceContainer = (Container) tr.getSourceComponent();
+ if (sourceContainer != tree1) {
+ // if the source is from table (not from tree1 itself),
+ // transfer Name property and use it as an indentifier in
+ // tree1
+ String name = sourceContainer.getItem(itemId)
+ .getItemProperty("Name").toString();
+
+ tree1.addItem(name);
+ tree1.setChildrenAllowed(name, false);
- tree1.addItem(name);
- tree1.setChildrenAllowed(name, false);
+ /*
+ * Remove the item from table
+ */
+ sourceContainer.removeItem(itemId);
+
+ itemId = name;
+
+ }
/*
* As we also accept only drops on folders, we know dropDetails
@@ -133,12 +151,8 @@ public class DDTest2 extends TestBase {
TreeDropDetails details = (TreeDropDetails) event
.getDropTargetData();
Object idOver = details.getItemIdOver();
- tree1.setParent(name, idOver);
+ tree1.setParent(itemId, idOver);
- /*
- * Remove the item from table
- */
- table.removeItem(itemId);
}
public AcceptCriterion getAcceptCriterion() {
@@ -163,8 +177,8 @@ public class DDTest2 extends TestBase {
.getDropTargetData();
Transferable transferable = event.getTransferable();
- if (transferable instanceof DataBindedTransferable) {
- DataBindedTransferable tr = (DataBindedTransferable) transferable;
+ if (transferable instanceof DataBoundTransferable) {
+ DataBoundTransferable tr = (DataBoundTransferable) transferable;
Object itemId = tree2.addItem();
tree2.setParent(itemId, details.getItemIdOver());
@@ -198,7 +212,7 @@ public class DDTest2 extends TestBase {
}
public AcceptCriterion getAcceptCriterion() {
- return IsDataBinded.get();
+ return IsDatabound.get();
}
};