]> source.dussan.org Git - vaadin-framework.git/commitdiff
renaming criteria
authorMatti Tahvonen <matti.tahvonen@itmill.com>
Wed, 24 Mar 2010 15:13:24 +0000 (15:13 +0000)
committerMatti Tahvonen <matti.tahvonen@itmill.com>
Wed, 24 Mar 2010 15:13:24 +0000 (15:13 +0000)
svn changeset:12072/svn branch:6.3

src/com/vaadin/event/dd/acceptcriteria/DropTargetDetailEquals.java [deleted file]
src/com/vaadin/event/dd/acceptcriteria/TargetDetailIs.java [new file with mode: 0644]
src/com/vaadin/terminal/gwt/client/ui/dd/VDropDetailEquals.java [deleted file]
src/com/vaadin/terminal/gwt/client/ui/dd/VTargetDetailIs.java [new file with mode: 0644]
src/com/vaadin/ui/Tree.java
tests/src/com/vaadin/tests/dd/DDTest2.java
tests/src/com/vaadin/tests/dd/HorizontalLayoutSortableWithWrappers.java

diff --git a/src/com/vaadin/event/dd/acceptcriteria/DropTargetDetailEquals.java b/src/com/vaadin/event/dd/acceptcriteria/DropTargetDetailEquals.java
deleted file mode 100644 (file)
index ceb98bb..0000000
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
-@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/TargetDetailIs.java b/src/com/vaadin/event/dd/acceptcriteria/TargetDetailIs.java
new file mode 100644 (file)
index 0000000..c20f106
--- /dev/null
@@ -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.VTargetDetailIs;
+
+/**
+ * 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(VTargetDetailIs.class)
+public class TargetDetailIs 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 TargetDetailIs(String dataFlavor, String value) {
+        propertyName = dataFlavor;
+        this.value = value;
+    }
+
+    public TargetDetailIs(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 TargetDetailIs.class.getCanonicalName();
+    }
+}
\ No newline at end of file
diff --git a/src/com/vaadin/terminal/gwt/client/ui/dd/VDropDetailEquals.java b/src/com/vaadin/terminal/gwt/client/ui/dd/VDropDetailEquals.java
deleted file mode 100644 (file)
index 6d04e4c..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
-@ITMillApache2LicenseForJavaFiles@
- */
-/**
- * 
- */
-package com.vaadin.terminal.gwt.client.ui.dd;
-
-import com.vaadin.terminal.gwt.client.UIDL;
-
-final public class VDropDetailEquals extends VAcceptCriterion {
-
-    @Override
-    protected boolean accept(VDragEvent drag, UIDL configuration) {
-        String name = configuration.getStringAttribute("p");
-        String t = configuration.hasAttribute("t") ? configuration
-                .getStringAttribute("t").intern() : "s";
-        Object value = null;
-        if (t == "s") {
-            value = configuration.getStringAttribute("v");
-        } else if (t == "b") {
-            value = configuration.getBooleanAttribute("v");
-        }
-        if (value != null) {
-            Object object = drag.getDropDetails().get(name);
-            return value.equals(object);
-        } else {
-            return false;
-        }
-
-    }
-}
\ No newline at end of file
diff --git a/src/com/vaadin/terminal/gwt/client/ui/dd/VTargetDetailIs.java b/src/com/vaadin/terminal/gwt/client/ui/dd/VTargetDetailIs.java
new file mode 100644 (file)
index 0000000..4e838fb
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+/**
+ * 
+ */
+package com.vaadin.terminal.gwt.client.ui.dd;
+
+import com.vaadin.terminal.gwt.client.UIDL;
+
+final public class VTargetDetailIs extends VAcceptCriterion {
+
+    @Override
+    protected boolean accept(VDragEvent drag, UIDL configuration) {
+        String name = configuration.getStringAttribute("p");
+        String t = configuration.hasAttribute("t") ? configuration
+                .getStringAttribute("t").intern() : "s";
+        Object value = null;
+        if (t == "s") {
+            value = configuration.getStringAttribute("v");
+        } else if (t == "b") {
+            value = configuration.getBooleanAttribute("v");
+        }
+        if (value != null) {
+            Object object = drag.getDropDetails().get(name);
+            return value.equals(object);
+        } else {
+            return false;
+        }
+
+    }
+}
\ No newline at end of file
index 2ce6fe2341db0f2b0e6047e3214ac68c9c8f81dd..ac4222f8ec09e667891af94faf82ac224f49f07d 100644 (file)
@@ -35,8 +35,8 @@ import com.vaadin.event.dd.DropTarget;
 import com.vaadin.event.dd.DropTargetDetails;
 import com.vaadin.event.dd.acceptcriteria.ClientCriterion;
 import com.vaadin.event.dd.acceptcriteria.ClientSideCriterion;
-import com.vaadin.event.dd.acceptcriteria.DropTargetDetailEquals;
 import com.vaadin.event.dd.acceptcriteria.ServerSideCriterion;
+import com.vaadin.event.dd.acceptcriteria.TargetDetailIs;
 import com.vaadin.terminal.KeyMapper;
 import com.vaadin.terminal.PaintException;
 import com.vaadin.terminal.PaintTarget;
@@ -1361,16 +1361,25 @@ public class Tree extends AbstractSelect implements Container.Hierarchical,
     }
 
     /**
-     * A criterion that accepts transferable only directly on a tree node that
-     * can have children.
+     * A criterion that accepts {@link Transferable} only directly on a tree
+     * node that can have children.
+     * <p>
+     * Class is singleton, use {@link TargetItemAllowsChildren#get()} to get the
+     * instance.
      * 
      * @see Tree#setChildrenAllowed(Object, boolean)
      * 
      * @since 6.3
      */
-    public static class OverFolderNode extends DropTargetDetailEquals {
+    public static class TargetItemAllowsChildren extends TargetDetailIs {
+
+        private static TargetItemAllowsChildren instance = new TargetItemAllowsChildren();
+
+        public static TargetItemAllowsChildren get() {
+            return instance;
+        }
 
-        public OverFolderNode() {
+        private TargetItemAllowsChildren() {
             super("itemIdOverIsNode", Boolean.TRUE);
         }
 
index 7efdf0b23d5e3bea872b3c6c0bfcd74b37d25a39..45552d9c791b823d8aba884677bc1e7ea66f33a0 100644 (file)
@@ -15,8 +15,8 @@ import com.vaadin.event.dd.DragAndDropEvent;
 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.SourceIs;
 import com.vaadin.event.dd.acceptcriteria.Or;
+import com.vaadin.event.dd.acceptcriteria.SourceIs;
 import com.vaadin.terminal.Resource;
 import com.vaadin.terminal.ThemeResource;
 import com.vaadin.tests.components.TestBase;
@@ -28,7 +28,7 @@ import com.vaadin.ui.Window;
 import com.vaadin.ui.AbstractSelect.AbstractSelectDropTargetDetails;
 import com.vaadin.ui.AbstractSelect.AcceptItem;
 import com.vaadin.ui.Table.TableTransferable;
-import com.vaadin.ui.Tree.OverFolderNode;
+import com.vaadin.ui.Tree.TargetItemAllowsChildren;
 import com.vaadin.ui.Tree.TreeDragMode;
 
 public class DDTest2 extends TestBase {
@@ -120,7 +120,7 @@ public class DDTest2 extends TestBase {
          */
         table.setDragMode(Table.TableDragMode.ROW);
 
-        OverFolderNode onNode = new OverFolderNode();
+        TargetItemAllowsChildren onNode = TargetItemAllowsChildren.get();
         SourceIs fromTable = new SourceIs(table);
 
         SourceIs fromTree = new SourceIs(tree1);
index 4837934cade02680ebc33e007e0f8a12d90fdd5d..2f2baa581c643e37bb67772cd994531e4aefd0cd 100644 (file)
@@ -10,7 +10,7 @@ import com.vaadin.event.dd.DropTarget;
 import com.vaadin.event.dd.DropTargetDetails;
 import com.vaadin.event.dd.acceptcriteria.AcceptCriterion;
 import com.vaadin.event.dd.acceptcriteria.And;
-import com.vaadin.event.dd.acceptcriteria.DropTargetDetailEquals;
+import com.vaadin.event.dd.acceptcriteria.TargetDetailIs;
 import com.vaadin.event.dd.acceptcriteria.IsSameSourceAndTarget;
 import com.vaadin.event.dd.acceptcriteria.Not;
 import com.vaadin.ui.Component;
@@ -51,7 +51,7 @@ public class HorizontalLayoutSortableWithWrappers extends Window {
     }
 
     private DropHandler dh = new DropHandler() {
-        AcceptCriterion crit = new And(new DropTargetDetailEquals(
+        AcceptCriterion crit = new And(new TargetDetailIs(
                 "horizontalLocation", "LEFT"), new Not(IsSameSourceAndTarget
                 .get()));