summaryrefslogtreecommitdiffstats
path: root/src/com/vaadin/event/dd/acceptcriteria
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/vaadin/event/dd/acceptcriteria')
-rw-r--r--src/com/vaadin/event/dd/acceptcriteria/AcceptAll.java37
-rw-r--r--src/com/vaadin/event/dd/acceptcriteria/AcceptCriterion.java75
-rw-r--r--src/com/vaadin/event/dd/acceptcriteria/And.java54
-rw-r--r--src/com/vaadin/event/dd/acceptcriteria/ClientCriterion.java32
-rw-r--r--src/com/vaadin/event/dd/acceptcriteria/ClientSideCriterion.java58
-rw-r--r--src/com/vaadin/event/dd/acceptcriteria/ContainsDataFlavor.java54
-rw-r--r--src/com/vaadin/event/dd/acceptcriteria/DragSourceIs.java54
-rw-r--r--src/com/vaadin/event/dd/acceptcriteria/DropTargetDetailEquals.java73
-rw-r--r--src/com/vaadin/event/dd/acceptcriteria/IsDataBound.java48
-rw-r--r--src/com/vaadin/event/dd/acceptcriteria/IsSameSourceAndTarget.java52
-rw-r--r--src/com/vaadin/event/dd/acceptcriteria/Not.java40
-rw-r--r--src/com/vaadin/event/dd/acceptcriteria/Or.java53
-rw-r--r--src/com/vaadin/event/dd/acceptcriteria/ServerSideCriterion.java56
13 files changed, 686 insertions, 0 deletions
diff --git a/src/com/vaadin/event/dd/acceptcriteria/AcceptAll.java b/src/com/vaadin/event/dd/acceptcriteria/AcceptAll.java
new file mode 100644
index 0000000000..3916d8e7e6
--- /dev/null
+++ b/src/com/vaadin/event/dd/acceptcriteria/AcceptAll.java
@@ -0,0 +1,37 @@
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+/**
+ *
+ */
+package com.vaadin.event.dd.acceptCriteria;
+
+import com.vaadin.event.dd.DragAndDropEvent;
+import com.vaadin.terminal.gwt.client.ui.dd.VAcceptAll;
+
+/**
+ * Criterion that accepts all drops anywhere on the component.
+ * <p>
+ * Note! Class is singleton, use {@link #get()} method to get the instance.
+ *
+ *
+ * @since 6.3
+ *
+ */
+@ClientCriterion(VAcceptAll.class)
+public final class AcceptAll extends ClientSideCriterion {
+
+ private static final long serialVersionUID = 7406683402153141461L;
+ private static AcceptCriterion singleton = new AcceptAll();
+
+ private AcceptAll() {
+ }
+
+ public static AcceptCriterion get() {
+ return singleton;
+ }
+
+ public boolean accept(DragAndDropEvent dragEvent) {
+ return true;
+ }
+} \ No newline at end of file
diff --git a/src/com/vaadin/event/dd/acceptcriteria/AcceptCriterion.java b/src/com/vaadin/event/dd/acceptcriteria/AcceptCriterion.java
new file mode 100644
index 0000000000..5c2ec6a4a8
--- /dev/null
+++ b/src/com/vaadin/event/dd/acceptcriteria/AcceptCriterion.java
@@ -0,0 +1,75 @@
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+/**
+ *
+ */
+package com.vaadin.event.dd.acceptCriteria;
+
+import java.io.Serializable;
+
+import com.vaadin.event.Transferable;
+import com.vaadin.event.dd.DragAndDropEvent;
+import com.vaadin.event.dd.DropHandler;
+import com.vaadin.terminal.PaintException;
+import com.vaadin.terminal.PaintTarget;
+
+/**
+ * Criterion that can be used create policy to accept/discard dragged content
+ * (presented by {@link Transferable}).
+ *
+ * The drag and drop mechanism will verify the criteria returned by
+ * {@link DropHandler#getAcceptCriterion()} before calling
+ * {@link DropHandler#drop(DragAndDropEvent)}.
+ *
+ * The criteria can be evaluated either on the client (browser - see
+ * {@link ClientSideCriterion}) or on the server (see
+ * {@link ServerSideCriterion}). If no constraints are needed, an
+ * {@link AcceptAll} can be used.
+ *
+ * In addition to accepting or rejecting a possible drop, criteria can provide
+ * additional hints for client side painting.
+ *
+ * @see DropHandler
+ * @see ClientSideCriterion
+ * @see ServerSideCriterion
+ *
+ * @since 6.3
+ */
+public interface AcceptCriterion extends Serializable {
+
+ /**
+ * Returns whether the criteria can be checked on the client or whether a
+ * server request is needed to check the criteria.
+ *
+ * This requirement may depend on the state of the criterion (e.g. logical
+ * operations between criteria), so this cannot be based on a marker
+ * interface.
+ */
+ public boolean isClientSideVerifiable();
+
+ public void paint(PaintTarget target) throws PaintException;
+
+ /**
+ * This needs to be implemented iff criterion does some lazy server side
+ * initialization. The UIDL painted in this method will be passed to client
+ * side drop handler implementation. Implementation can assume that
+ * {@link #accept(DragAndDropEvent)} is called before this method.
+ *
+ * @param target
+ * @throws PaintException
+ */
+ public void paintResponse(PaintTarget target) throws PaintException;
+
+ /**
+ * Validates the data in event to be appropriate for
+ * {@link DropHandler#drop(com.vaadin.event.dd.DropEvent)} method.
+ * <p>
+ * Note that even if your criterion is matched on client side, it is a very
+ * good manner to validate the data on server side too.
+ *
+ * @param dragEvent
+ * @return
+ */
+ public boolean accept(DragAndDropEvent dragEvent);
+} \ 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
new file mode 100644
index 0000000000..3db317c213
--- /dev/null
+++ b/src/com/vaadin/event/dd/acceptcriteria/And.java
@@ -0,0 +1,54 @@
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+/**
+ *
+ */
+package com.vaadin.event.dd.acceptCriteria;
+
+import com.vaadin.event.dd.DragAndDropEvent;
+import com.vaadin.terminal.PaintException;
+import com.vaadin.terminal.PaintTarget;
+
+/**
+ * A compound criterion that accepts the drag if all of its criteria accepts the
+ * drag.
+ *
+ * @see Or
+ *
+ * @since 6.3
+ *
+ */
+@ClientCriterion(com.vaadin.terminal.gwt.client.ui.dd.VAnd.class)
+public class And extends ClientSideCriterion {
+
+ private static final long serialVersionUID = -5242574480825471748L;
+ protected ClientSideCriterion[] criteria;
+
+ /**
+ *
+ * @param criteria
+ * criteria of which the And criterion will be composed
+ */
+ public And(ClientSideCriterion... criteria) {
+ this.criteria = criteria;
+ }
+
+ @Override
+ public void paintContent(PaintTarget target) throws PaintException {
+ super.paintContent(target);
+ for (ClientSideCriterion crit : criteria) {
+ crit.paint(target);
+ }
+ }
+
+ public boolean accept(DragAndDropEvent dragEvent) {
+ for (ClientSideCriterion crit : criteria) {
+ if (!crit.accept(dragEvent)) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+} \ No newline at end of file
diff --git a/src/com/vaadin/event/dd/acceptcriteria/ClientCriterion.java b/src/com/vaadin/event/dd/acceptcriteria/ClientCriterion.java
new file mode 100644
index 0000000000..465637afe7
--- /dev/null
+++ b/src/com/vaadin/event/dd/acceptcriteria/ClientCriterion.java
@@ -0,0 +1,32 @@
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+package com.vaadin.event.dd.acceptCriteria;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import com.vaadin.terminal.gwt.client.ui.dd.VAcceptCriterion;
+import com.vaadin.ui.ClientWidget;
+
+/**
+ * An annotation type used to point the client side counterpart for server side
+ * a {@link AcceptCriterion} class. Usage is pretty similar to
+ * {@link ClientWidget} which is used with Vaadin components that have a
+ * specialized client side counterpart.
+ * <p>
+ * Annotations are used at GWT compilation phase, so remember to rebuild your
+ * widgetset if you do changes for {@link ClientCriterion} mappings.
+ *
+ * @since 6.3
+ */
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.TYPE)
+public @interface ClientCriterion {
+ /**
+ * @return the client side counterpart for the annotated criterion
+ */
+ Class<? extends VAcceptCriterion> value();
+}
diff --git a/src/com/vaadin/event/dd/acceptcriteria/ClientSideCriterion.java b/src/com/vaadin/event/dd/acceptcriteria/ClientSideCriterion.java
new file mode 100644
index 0000000000..e98e3c2719
--- /dev/null
+++ b/src/com/vaadin/event/dd/acceptcriteria/ClientSideCriterion.java
@@ -0,0 +1,58 @@
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+package com.vaadin.event.dd.acceptCriteria;
+
+import java.io.Serializable;
+
+import com.vaadin.terminal.PaintException;
+import com.vaadin.terminal.PaintTarget;
+
+/**
+ * Parent class for criteria that can be completely validated on client side.
+ * All classes that provide criteria that can be completely validated on client
+ * side should extend this class.
+ *
+ * It is recommended that subclasses of ClientSideCriterion re-validate the
+ * condition on the server side in
+ * {@link AcceptCriterion#accept(com.vaadin.event.dd.DragAndDropEvent)} after
+ * the client side validation has accepted a transfer.
+ *
+ * @since 6.3
+ */
+public abstract class ClientSideCriterion implements Serializable,
+ AcceptCriterion {
+
+ /*
+ * All criteria that extend this must be completely validatable on client
+ * side.
+ *
+ * (non-Javadoc)
+ *
+ * @see
+ * com.vaadin.event.dd.acceptCriteria.AcceptCriterion#isClientSideVerifiable
+ * ()
+ */
+ public final boolean isClientSideVerifiable() {
+ return true;
+ }
+
+ public void paint(PaintTarget target) throws PaintException {
+ target.startTag("-ac");
+ target.addAttribute("name", getIdentifier());
+ paintContent(target);
+ target.endTag("-ac");
+ }
+
+ protected void paintContent(PaintTarget target) throws PaintException {
+ }
+
+ protected String getIdentifier() {
+ return getClass().getCanonicalName();
+ }
+
+ public final 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/ContainsDataFlavor.java b/src/com/vaadin/event/dd/acceptcriteria/ContainsDataFlavor.java
new file mode 100644
index 0000000000..806a3b5d2d
--- /dev/null
+++ b/src/com/vaadin/event/dd/acceptcriteria/ContainsDataFlavor.java
@@ -0,0 +1,54 @@
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+/**
+ *
+ */
+package com.vaadin.event.dd.acceptCriteria;
+
+import com.vaadin.event.Transferable;
+import com.vaadin.event.dd.DragAndDropEvent;
+import com.vaadin.terminal.PaintException;
+import com.vaadin.terminal.PaintTarget;
+import com.vaadin.terminal.gwt.client.ui.dd.VContainsDataFlavor;
+
+/**
+ * A Criterion that checks whether {@link Transferable} contains given data
+ * flavor. The developer might for example accept the incoming data only if it
+ * contains "Url" or "Text".
+ *
+ * @since 6.3
+ */
+@ClientCriterion(VContainsDataFlavor.class)
+public class ContainsDataFlavor extends ClientSideCriterion {
+
+ private String dataFlavorId;
+
+ /**
+ * Constructs a new instance of {@link ContainsDataFlavor}.
+ *
+ * @param dataFlawor
+ * the type of data that will be checked from
+ * {@link Transferable}
+ */
+ public ContainsDataFlavor(String dataFlawor) {
+ dataFlavorId = dataFlawor;
+ }
+
+ @Override
+ public void paintContent(PaintTarget target) throws PaintException {
+ super.paintContent(target);
+ target.addAttribute("p", dataFlavorId);
+ }
+
+ public boolean accept(DragAndDropEvent dragEvent) {
+ return dragEvent.getTransferable().getDataFlavors().contains(
+ dataFlavorId);
+ }
+
+ @Override
+ protected String getIdentifier() {
+ // extending classes use client side implementation from this class
+ return ContainsDataFlavor.class.getCanonicalName();
+ }
+} \ No newline at end of file
diff --git a/src/com/vaadin/event/dd/acceptcriteria/DragSourceIs.java b/src/com/vaadin/event/dd/acceptcriteria/DragSourceIs.java
new file mode 100644
index 0000000000..218133815c
--- /dev/null
+++ b/src/com/vaadin/event/dd/acceptcriteria/DragSourceIs.java
@@ -0,0 +1,54 @@
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+/**
+ *
+ */
+package com.vaadin.event.dd.acceptCriteria;
+
+import com.vaadin.event.TransferableImpl;
+import com.vaadin.event.dd.DragAndDropEvent;
+import com.vaadin.terminal.PaintException;
+import com.vaadin.terminal.PaintTarget;
+import com.vaadin.terminal.gwt.client.ui.dd.VDragSourceIs;
+import com.vaadin.ui.Component;
+
+/**
+ * Client side criteria that checks if the drag source is one of the given
+ * components.
+ *
+ * @since 6.3
+ */
+@ClientCriterion(VDragSourceIs.class)
+public class DragSourceIs extends ClientSideCriterion {
+
+ private Component[] component;
+
+ public DragSourceIs(Component... component) {
+ this.component = component;
+ }
+
+ @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 accept(DragAndDropEvent dragEvent) {
+ if (dragEvent.getTransferable() instanceof TransferableImpl) {
+ Component sourceComponent = ((TransferableImpl) dragEvent
+ .getTransferable()).getSourceComponent();
+ for (Component c : component) {
+ if (c == sourceComponent) {
+ return true;
+ }
+ }
+ }
+
+ return false;
+ }
+
+} \ No newline at end of file
diff --git a/src/com/vaadin/event/dd/acceptcriteria/DropTargetDetailEquals.java b/src/com/vaadin/event/dd/acceptcriteria/DropTargetDetailEquals.java
new file mode 100644
index 0000000000..a2b24533b3
--- /dev/null
+++ b/src/com/vaadin/event/dd/acceptcriteria/DropTargetDetailEquals.java
@@ -0,0 +1,73 @@
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+/**
+ *
+ */
+package com.vaadin.event.dd.acceptCriteria;
+
+import com.vaadin.event.dd.DragAndDropEvent;
+import com.vaadin.event.dd.DropTargetDetails;
+import com.vaadin.terminal.PaintException;
+import com.vaadin.terminal.PaintTarget;
+import com.vaadin.terminal.gwt.client.ui.dd.VDropDetailEquals;
+
+/**
+ * Criterion for checking if drop target details contains the specific property
+ * with the specific value. Currently only String values are supported.
+ *
+ * @since 6.3
+ *
+ * TODO add support for other basic data types that we support in UIDL.
+ *
+ */
+@ClientCriterion(VDropDetailEquals.class)
+public class DropTargetDetailEquals extends ClientSideCriterion {
+
+ private static final long serialVersionUID = 763165450054331246L;
+ private String propertyName;
+ private Object value;
+
+ /**
+ * Constructs a criterion which ensures that the value there is a value in
+ * {@link DropTargetDetails} that equals the reference value.
+ *
+ * @param dataFlavor
+ * the type of data to be checked
+ * @param value
+ * the reference value to which the drop target detail will be
+ * compared
+ */
+ public DropTargetDetailEquals(String dataFlavor, String value) {
+ propertyName = dataFlavor;
+ this.value = value;
+ }
+
+ public DropTargetDetailEquals(String dataFlavor, Boolean true1) {
+ propertyName = dataFlavor;
+ value = true1;
+ }
+
+ @Override
+ public void paintContent(PaintTarget target) throws PaintException {
+ super.paintContent(target);
+ target.addAttribute("p", propertyName);
+ if (value instanceof Boolean) {
+ target.addAttribute("v", ((Boolean) value).booleanValue());
+ target.addAttribute("t", "b");
+ } else if (value instanceof String) {
+ target.addAttribute("v", (String) value);
+ }
+ }
+
+ public boolean accept(DragAndDropEvent dragEvent) {
+ Object data = dragEvent.getDropTargetDetails().getData(propertyName);
+ return value.equals(data);
+ }
+
+ @Override
+ protected String getIdentifier() {
+ // sub classes by default use VDropDetailEquals a client implementation
+ return DropTargetDetailEquals.class.getCanonicalName();
+ }
+} \ 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..8615d207ca
--- /dev/null
+++ b/src/com/vaadin/event/dd/acceptcriteria/IsDataBound.java
@@ -0,0 +1,48 @@
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+/**
+ *
+ */
+package com.vaadin.event.dd.acceptCriteria;
+
+import com.vaadin.data.Container;
+import com.vaadin.data.Item;
+import com.vaadin.event.DataBoundTransferable;
+import com.vaadin.event.Transferable;
+import com.vaadin.event.dd.DragAndDropEvent;
+import com.vaadin.ui.Table;
+import com.vaadin.ui.Tree;
+
+/**
+ * A simple accept criterion which ensures that {@link Transferable} contains an
+ * {@link Item} identifiers. In other words the criterion check that drag is
+ * coming from a {@link Container} like {@link Tree} or {@link Table}. TODO
+ * Javadoc
+ * <p>
+ * Note! class is singleton, use {@link #get()} method to get the instance.
+ *
+ * @since 6.3
+ *
+ */
+public final class IsDataBound extends ContainsDataFlavor {
+ private static final long serialVersionUID = 1952366107184656946L;
+ private static IsDataBound singleton = new IsDataBound();
+
+ private IsDataBound() {
+ super("itemId");
+ }
+
+ public static IsDataBound get() {
+ return singleton;
+ }
+
+ @Override
+ public boolean accept(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/IsSameSourceAndTarget.java b/src/com/vaadin/event/dd/acceptcriteria/IsSameSourceAndTarget.java
new file mode 100644
index 0000000000..2637d27a0b
--- /dev/null
+++ b/src/com/vaadin/event/dd/acceptcriteria/IsSameSourceAndTarget.java
@@ -0,0 +1,52 @@
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+/**
+ *
+ */
+package com.vaadin.event.dd.acceptCriteria;
+
+import com.vaadin.event.Transferable;
+import com.vaadin.event.TransferableImpl;
+import com.vaadin.event.dd.DragAndDropEvent;
+import com.vaadin.event.dd.DropTarget;
+import com.vaadin.terminal.gwt.client.ui.dd.VSourceIsSameAsTarget;
+import com.vaadin.ui.Component;
+import com.vaadin.ui.Table;
+import com.vaadin.ui.Tree;
+
+/**
+ *
+ * A criterion that ensures the drag source is the same as drop target. Eg.
+ * {@link Tree} or {@link Table} could support only re-ordering of items, but no
+ * {@link Transferable}s coming outside.
+ * <p>
+ * Note! Class is singleton, use {@link #get()} method to get the instance.
+ *
+ * @since 6.3
+ *
+ */
+@ClientCriterion(VSourceIsSameAsTarget.class)
+public class IsSameSourceAndTarget extends ClientSideCriterion {
+
+ private static final long serialVersionUID = -451399314705532584L;
+ private static IsSameSourceAndTarget instance = new IsSameSourceAndTarget();
+
+ private IsSameSourceAndTarget() {
+ }
+
+ public boolean accept(DragAndDropEvent dragEvent) {
+ if (dragEvent.getTransferable() instanceof TransferableImpl) {
+ Component sourceComponent = ((TransferableImpl) dragEvent
+ .getTransferable()).getSourceComponent();
+ DropTarget target = dragEvent.getDropTargetDetails().getTarget();
+ return sourceComponent == target;
+ }
+ return false;
+ }
+
+ public static synchronized IsSameSourceAndTarget get() {
+ return instance;
+ }
+
+} \ 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
new file mode 100644
index 0000000000..874016c9b7
--- /dev/null
+++ b/src/com/vaadin/event/dd/acceptcriteria/Not.java
@@ -0,0 +1,40 @@
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+/**
+ *
+ */
+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.terminal.gwt.client.ui.dd.VNot;
+
+/**
+ * Criterion that wraps another criterion and inverts its return value.
+ *
+ * @since 6.3
+ *
+ */
+@ClientCriterion(VNot.class)
+public class Not extends ClientSideCriterion {
+
+ private static final long serialVersionUID = 1131422338558613244L;
+ private AcceptCriterion acceptCriterion;
+
+ public Not(ClientSideCriterion acceptCriterion) {
+ this.acceptCriterion = acceptCriterion;
+ }
+
+ @Override
+ public void paintContent(PaintTarget target) throws PaintException {
+ super.paintContent(target);
+ acceptCriterion.paint(target);
+ }
+
+ public boolean accept(DragAndDropEvent dragEvent) {
+ return !acceptCriterion.accept(dragEvent);
+ }
+
+} \ 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
new file mode 100644
index 0000000000..41aef10738
--- /dev/null
+++ b/src/com/vaadin/event/dd/acceptcriteria/Or.java
@@ -0,0 +1,53 @@
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+/**
+ *
+ */
+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.terminal.gwt.client.ui.dd.VOr;
+
+/**
+ * A compound criterion that accepts the drag if any of its criterion accepts
+ * it.
+ *
+ * @see And
+ *
+ * @since 6.3
+ *
+ */
+@ClientCriterion(VOr.class)
+public class Or extends ClientSideCriterion {
+ private static final long serialVersionUID = 1L;
+ private AcceptCriterion criteria[];
+
+ /**
+ * @param criteria
+ * the criteria of which the Or criteria will be composed
+ */
+ public Or(ClientSideCriterion... criteria) {
+ this.criteria = criteria;
+ }
+
+ @Override
+ public void paintContent(PaintTarget target) throws PaintException {
+ super.paintContent(target);
+ for (AcceptCriterion crit : criteria) {
+ crit.paint(target);
+ }
+ }
+
+ public boolean accept(DragAndDropEvent dragEvent) {
+ for (AcceptCriterion crit : criteria) {
+ if (crit.accept(dragEvent)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+} \ No newline at end of file
diff --git a/src/com/vaadin/event/dd/acceptcriteria/ServerSideCriterion.java b/src/com/vaadin/event/dd/acceptcriteria/ServerSideCriterion.java
new file mode 100644
index 0000000000..69405db8ed
--- /dev/null
+++ b/src/com/vaadin/event/dd/acceptcriteria/ServerSideCriterion.java
@@ -0,0 +1,56 @@
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+package com.vaadin.event.dd.acceptCriteria;
+
+import java.io.Serializable;
+
+import com.vaadin.event.Transferable;
+import com.vaadin.terminal.PaintException;
+import com.vaadin.terminal.PaintTarget;
+import com.vaadin.terminal.gwt.client.ui.dd.VServerAccept;
+
+/**
+ * Parent class for criteria which are verified on the server side during a drag
+ * operation to accept/discard dragged content (presented by
+ * {@link Transferable}).
+ * <p>
+ * Subclasses should implement the
+ * {@link AcceptCriterion#accept(com.vaadin.event.dd.DragAndDropEvent)} method.
+ * <p>
+ * As all server side state can be used to make a decision, this is more
+ * flexible than {@link ClientSideCriterion}. However, this does require
+ * additional requests from the browser to the server during a drag operation.
+ *
+ * @see AcceptCriterion
+ * @see ClientSideCriterion
+ *
+ * @since 6.3
+ */
+@ClientCriterion(VServerAccept.class)
+public abstract class ServerSideCriterion implements Serializable,
+ AcceptCriterion {
+
+ private static final long serialVersionUID = 2128510128911628902L;
+
+ public final boolean isClientSideVerifiable() {
+ return false;
+ }
+
+ public void paint(PaintTarget target) throws PaintException {
+ target.startTag("-ac");
+ target.addAttribute("name", getIdentifier());
+ paintContent(target);
+ target.endTag("-ac");
+ }
+
+ public void paintContent(PaintTarget target) {
+ }
+
+ public void paintResponse(PaintTarget target) throws PaintException {
+ }
+
+ protected String getIdentifier() {
+ return ServerSideCriterion.class.getCanonicalName();
+ }
+}