summaryrefslogtreecommitdiffstats
path: root/src/com/vaadin/event
diff options
context:
space:
mode:
authorMatti Tahvonen <matti.tahvonen@itmill.com>2010-02-15 12:00:39 +0000
committerMatti Tahvonen <matti.tahvonen@itmill.com>2010-02-15 12:00:39 +0000
commitb3b04325f1b4bb84962752d466fd54e1b176dea3 (patch)
treea5ebd6edd6893f893820a0c09c96324321837402 /src/com/vaadin/event
parent269bd9adf61590cd4b76fb357491fc2974843fd1 (diff)
downloadvaadin-framework-b3b04325f1b4bb84962752d466fd54e1b176dea3.tar.gz
vaadin-framework-b3b04325f1b4bb84962752d466fd54e1b176dea3.zip
small changes
svn changeset:11321/svn branch:6.3_dd
Diffstat (limited to 'src/com/vaadin/event')
-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
10 files changed, 112 insertions, 153 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