summaryrefslogtreecommitdiffstats
path: root/uitest/src/com/vaadin/tests/dd/CustomDDImplementation.java
diff options
context:
space:
mode:
authorArtur Signell <artur@vaadin.com>2012-08-30 17:24:36 +0300
committerArtur Signell <artur@vaadin.com>2012-08-30 17:24:36 +0300
commit7b25b3886ea95bc6495506fbe9472e45fcbde684 (patch)
tree0b93cb65dab437feb46720659a63b8f1ef48f7f4 /uitest/src/com/vaadin/tests/dd/CustomDDImplementation.java
parent8941056349e302e687e40e94c13709e75f256d73 (diff)
downloadvaadin-framework-7b25b3886ea95bc6495506fbe9472e45fcbde684.tar.gz
vaadin-framework-7b25b3886ea95bc6495506fbe9472e45fcbde684.zip
Renamed tests -> uitest and tests/testbench -> uitest/src (#9299)
Diffstat (limited to 'uitest/src/com/vaadin/tests/dd/CustomDDImplementation.java')
-rw-r--r--uitest/src/com/vaadin/tests/dd/CustomDDImplementation.java85
1 files changed, 85 insertions, 0 deletions
diff --git a/uitest/src/com/vaadin/tests/dd/CustomDDImplementation.java b/uitest/src/com/vaadin/tests/dd/CustomDDImplementation.java
new file mode 100644
index 0000000000..f6e196761e
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/dd/CustomDDImplementation.java
@@ -0,0 +1,85 @@
+package com.vaadin.tests.dd;
+
+import java.util.Map;
+
+import com.vaadin.event.dd.DragAndDropEvent;
+import com.vaadin.event.dd.DropHandler;
+import com.vaadin.event.dd.DropTarget;
+import com.vaadin.event.dd.TargetDetails;
+import com.vaadin.event.dd.acceptcriteria.AcceptAll;
+import com.vaadin.event.dd.acceptcriteria.AcceptCriterion;
+import com.vaadin.ui.AbstractComponent;
+import com.vaadin.ui.Component;
+import com.vaadin.ui.CssLayout;
+import com.vaadin.ui.CustomComponent;
+import com.vaadin.ui.Layout;
+
+/**
+ * Test/Example/Draft code how to build custom DD implementation using the thing
+ * framework provided by Vaadin.
+ *
+ */
+public class CustomDDImplementation extends CustomComponent {
+
+ public CustomDDImplementation() {
+ Layout l = new CssLayout();
+ l.addComponent(new MyDropTarget());
+ l.addComponent(new MyDragSource());
+ }
+
+ /**
+ * Server side component that accepts drags must implement HasDropHandler
+ * that have one method to get reference of DropHandler.
+ *
+ * DropHandler may be implemented directly or probably most commonly using a
+ * half baked implementation {@link AbstractDropHandler}.
+ *
+ * Check the @ClientWidget
+ *
+ */
+ class MyDropTarget extends AbstractComponent implements DropTarget {
+ @Override
+ public DropHandler getDropHandler() {
+ return new DropHandler() {
+
+ @Override
+ public void drop(DragAndDropEvent event) {
+ // Do something with data
+ return;
+ }
+
+ @Override
+ public AcceptCriterion getAcceptCriterion() {
+ return AcceptAll.get();
+ }
+
+ };
+ }
+
+ @Override
+ public TargetDetails translateDropTargetDetails(
+ Map<String, Object> clientVariables) {
+ // If component has some special drop details that it needs to
+ // translate for server side use, developer must return a
+ // DragDropDetails here. If details does not exist or raw client
+ // side data is ok, it is safe to return null here.
+ return null;
+ }
+
+ }
+
+ /**
+ * Server side implementation of source does not necessary need to contain
+ * anything.
+ *
+ * Check the @ClientWidget
+ *
+ * However component might have different modes to support starting drag
+ * operations that are controlled via server side api.
+ *
+ */
+ public class MyDragSource extends AbstractComponent implements Component {
+
+ }
+
+}