summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatti Tahvonen <matti.tahvonen@itmill.com>2010-02-17 09:10:43 +0000
committerMatti Tahvonen <matti.tahvonen@itmill.com>2010-02-17 09:10:43 +0000
commit8d2ace1645c029eafc2de9dd7704980709692819 (patch)
tree2fc8369656e4522581f915c60f50047673f29d8e
parent3b012b40d19c9b9b3acb7b675e82e07aad309cbe (diff)
downloadvaadin-framework-8d2ace1645c029eafc2de9dd7704980709692819.tar.gz
vaadin-framework-8d2ace1645c029eafc2de9dd7704980709692819.zip
criterion map now generated from annotations from server side counterpart
svn changeset:11350/svn branch:6.3_dd
-rw-r--r--src/com/vaadin/event/dd/acceptCriteria/AcceptAll.java2
-rw-r--r--src/com/vaadin/event/dd/acceptCriteria/AcceptCriterion.java4
-rw-r--r--src/com/vaadin/event/dd/acceptCriteria/And.java1
-rw-r--r--src/com/vaadin/event/dd/acceptCriteria/ClientCriterion.java22
-rw-r--r--src/com/vaadin/event/dd/acceptCriteria/ComponentFilter.java2
-rw-r--r--src/com/vaadin/event/dd/acceptCriteria/IsDatabound.java2
-rw-r--r--src/com/vaadin/event/dd/acceptCriteria/Not.java2
-rw-r--r--src/com/vaadin/event/dd/acceptCriteria/Or.java2
-rw-r--r--src/com/vaadin/event/dd/acceptCriteria/OverTreeNode.java2
-rw-r--r--src/com/vaadin/event/dd/acceptCriteria/ServerSideCriterion.java2
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/dd/ServerCriterion.java18
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/dd/VAbstractDropHandler.java2
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/dd/VAcceptAll.java (renamed from src/com/vaadin/terminal/gwt/client/ui/dd/AcceptAll.java)3
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/dd/VAnd.java (renamed from src/com/vaadin/terminal/gwt/client/ui/dd/And.java)3
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/dd/VComponentFilter.java (renamed from src/com/vaadin/terminal/gwt/client/ui/dd/ComponentCriteria.java)3
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/dd/VDataBound.java (renamed from src/com/vaadin/terminal/gwt/client/ui/dd/HasItemId.java)3
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/dd/VLazyInitItemIdentifiers.java (renamed from src/com/vaadin/terminal/gwt/client/ui/dd/LazyInitItemIdentifiers.java)8
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/dd/VNot.java (renamed from src/com/vaadin/terminal/gwt/client/ui/dd/Not.java)3
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/dd/VOr.java (renamed from src/com/vaadin/terminal/gwt/client/ui/dd/Or.java)3
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/dd/VOverTreeNode.java (renamed from src/com/vaadin/terminal/gwt/client/ui/dd/OverTreeNode.java)3
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/dd/VServerAccept.java (renamed from src/com/vaadin/terminal/gwt/client/ui/dd/ServerAccept.java)3
-rw-r--r--src/com/vaadin/terminal/gwt/widgetsetutils/AcceptCriterionGenerator.java53
-rw-r--r--src/com/vaadin/terminal/gwt/widgetsetutils/ClassPathExplorer.java16
-rw-r--r--src/com/vaadin/ui/Tree.java3
24 files changed, 86 insertions, 79 deletions
diff --git a/src/com/vaadin/event/dd/acceptCriteria/AcceptAll.java b/src/com/vaadin/event/dd/acceptCriteria/AcceptAll.java
index 4424447d97..93a28a4d99 100644
--- a/src/com/vaadin/event/dd/acceptCriteria/AcceptAll.java
+++ b/src/com/vaadin/event/dd/acceptCriteria/AcceptAll.java
@@ -4,7 +4,9 @@
package com.vaadin.event.dd.acceptCriteria;
import com.vaadin.event.dd.DragAndDropEvent;
+import com.vaadin.terminal.gwt.client.ui.dd.VAcceptAll;
+@ClientCriterion(VAcceptAll.class)
public final class AcceptAll extends ClientSideCriterion {
private static AcceptCriterion singleton = new AcceptAll();
diff --git a/src/com/vaadin/event/dd/acceptCriteria/AcceptCriterion.java b/src/com/vaadin/event/dd/acceptCriteria/AcceptCriterion.java
index 24b0d9f2b8..1029e51baa 100644
--- a/src/com/vaadin/event/dd/acceptCriteria/AcceptCriterion.java
+++ b/src/com/vaadin/event/dd/acceptCriteria/AcceptCriterion.java
@@ -3,13 +3,15 @@
*/
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;
-public interface AcceptCriterion {
+public interface AcceptCriterion extends Serializable {
/**
* Criterion that can be used create policy to accept/discard dragged
diff --git a/src/com/vaadin/event/dd/acceptCriteria/And.java b/src/com/vaadin/event/dd/acceptCriteria/And.java
index 29a4a6aa2e..91144771f9 100644
--- a/src/com/vaadin/event/dd/acceptCriteria/And.java
+++ b/src/com/vaadin/event/dd/acceptCriteria/And.java
@@ -11,6 +11,7 @@ import com.vaadin.terminal.PaintTarget;
* TODO consider replacing this with Union
*
*/
+@ClientCriterion(com.vaadin.terminal.gwt.client.ui.dd.VAnd.class)
public class And extends ClientSideCriterion {
/**
*
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..ebc58bcbe3
--- /dev/null
+++ b/src/com/vaadin/event/dd/acceptCriteria/ClientCriterion.java
@@ -0,0 +1,22 @@
+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.VAcceptCriteria;
+
+/**
+ * TODO
+ *
+ * @since 6.2
+ */
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.TYPE)
+public @interface ClientCriterion {
+ /**
+ * @return the client side counterpart for the annotated criterion
+ */
+ Class<? extends VAcceptCriteria> value();
+}
diff --git a/src/com/vaadin/event/dd/acceptCriteria/ComponentFilter.java b/src/com/vaadin/event/dd/acceptCriteria/ComponentFilter.java
index 85b0a953e3..fc0ffd2c53 100644
--- a/src/com/vaadin/event/dd/acceptCriteria/ComponentFilter.java
+++ b/src/com/vaadin/event/dd/acceptCriteria/ComponentFilter.java
@@ -7,8 +7,10 @@ import com.vaadin.event.ComponentTransferable;
import com.vaadin.event.dd.DragAndDropEvent;
import com.vaadin.terminal.PaintException;
import com.vaadin.terminal.PaintTarget;
+import com.vaadin.terminal.gwt.client.ui.dd.VComponentFilter;
import com.vaadin.ui.Component;
+@ClientCriterion(VComponentFilter.class)
public class ComponentFilter extends ClientSideCriterion {
private Component[] component;
diff --git a/src/com/vaadin/event/dd/acceptCriteria/IsDatabound.java b/src/com/vaadin/event/dd/acceptCriteria/IsDatabound.java
index 4b40296e3b..10ac493bf3 100644
--- a/src/com/vaadin/event/dd/acceptCriteria/IsDatabound.java
+++ b/src/com/vaadin/event/dd/acceptCriteria/IsDatabound.java
@@ -5,7 +5,9 @@ package com.vaadin.event.dd.acceptCriteria;
import com.vaadin.event.DataBoundTransferable;
import com.vaadin.event.dd.DragAndDropEvent;
+import com.vaadin.terminal.gwt.client.ui.dd.VDataBound;
+@ClientCriterion(VDataBound.class)
public final class IsDatabound extends ClientSideCriterion {
private static IsDatabound singleton = new IsDatabound();
diff --git a/src/com/vaadin/event/dd/acceptCriteria/Not.java b/src/com/vaadin/event/dd/acceptCriteria/Not.java
index 58d1aed5df..d11df81d55 100644
--- a/src/com/vaadin/event/dd/acceptCriteria/Not.java
+++ b/src/com/vaadin/event/dd/acceptCriteria/Not.java
@@ -4,7 +4,9 @@
package com.vaadin.event.dd.acceptCriteria;
import com.vaadin.event.dd.DragAndDropEvent;
+import com.vaadin.terminal.gwt.client.ui.dd.VNot;
+@ClientCriterion(VNot.class)
public class Not extends ClientSideCriterion {
private AcceptCriterion acceptCriterion;
diff --git a/src/com/vaadin/event/dd/acceptCriteria/Or.java b/src/com/vaadin/event/dd/acceptCriteria/Or.java
index 59f4de90f2..60b7152338 100644
--- a/src/com/vaadin/event/dd/acceptCriteria/Or.java
+++ b/src/com/vaadin/event/dd/acceptCriteria/Or.java
@@ -6,11 +6,13 @@ 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;
/**
* TODO consider replacing this with intersection
*
*/
+@ClientCriterion(VOr.class)
public class Or extends ClientSideCriterion {
/**
*
diff --git a/src/com/vaadin/event/dd/acceptCriteria/OverTreeNode.java b/src/com/vaadin/event/dd/acceptCriteria/OverTreeNode.java
index 80321ef963..9eeed0b617 100644
--- a/src/com/vaadin/event/dd/acceptCriteria/OverTreeNode.java
+++ b/src/com/vaadin/event/dd/acceptCriteria/OverTreeNode.java
@@ -4,6 +4,7 @@
package com.vaadin.event.dd.acceptCriteria;
import com.vaadin.event.dd.DragAndDropEvent;
+import com.vaadin.terminal.gwt.client.ui.dd.VOverTreeNode;
import com.vaadin.ui.Tree;
import com.vaadin.ui.Tree.Location;
import com.vaadin.ui.Tree.TreeDropDetails;
@@ -14,6 +15,7 @@ import com.vaadin.ui.Tree.TreeDropDetails;
* TODO relocate close to {@link Tree} as this is tree specifif
*
*/
+@ClientCriterion(VOverTreeNode.class)
public class OverTreeNode extends ClientSideCriterion {
private static final long serialVersionUID = 1L;
diff --git a/src/com/vaadin/event/dd/acceptCriteria/ServerSideCriterion.java b/src/com/vaadin/event/dd/acceptCriteria/ServerSideCriterion.java
index 36a25346ca..382af29237 100644
--- a/src/com/vaadin/event/dd/acceptCriteria/ServerSideCriterion.java
+++ b/src/com/vaadin/event/dd/acceptCriteria/ServerSideCriterion.java
@@ -4,7 +4,9 @@ import java.io.Serializable;
import com.vaadin.terminal.PaintException;
import com.vaadin.terminal.PaintTarget;
+import com.vaadin.terminal.gwt.client.ui.dd.VServerAccept;
+@ClientCriterion(VServerAccept.class)
public abstract class ServerSideCriterion implements Serializable,
AcceptCriterion {
diff --git a/src/com/vaadin/terminal/gwt/client/ui/dd/ServerCriterion.java b/src/com/vaadin/terminal/gwt/client/ui/dd/ServerCriterion.java
deleted file mode 100644
index 3aca021146..0000000000
--- a/src/com/vaadin/terminal/gwt/client/ui/dd/ServerCriterion.java
+++ /dev/null
@@ -1,18 +0,0 @@
-package com.vaadin.terminal.gwt.client.ui.dd;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-@Retention(RetentionPolicy.RUNTIME)
-@Target(ElementType.TYPE)
-public @interface ServerCriterion {
- /**
- * Class type would be nice but annotating should come from different
- * direction to cope with gwt compiler.
- *
- * @return
- */
- String value();
-}
diff --git a/src/com/vaadin/terminal/gwt/client/ui/dd/VAbstractDropHandler.java b/src/com/vaadin/terminal/gwt/client/ui/dd/VAbstractDropHandler.java
index aaf90f899d..2bf363d1ff 100644
--- a/src/com/vaadin/terminal/gwt/client/ui/dd/VAbstractDropHandler.java
+++ b/src/com/vaadin/terminal/gwt/client/ui/dd/VAbstractDropHandler.java
@@ -12,7 +12,7 @@ import com.vaadin.terminal.gwt.client.UIDL;
public abstract class VAbstractDropHandler implements VDropHandler {
private UIDL criterioUIDL;
- private VAcceptCriteria acceptCriteria = new AcceptAll();
+ private VAcceptCriteria acceptCriteria = new VAcceptAll();
/**
* Implementor/user of {@link VAbstractDropHandler} must pass the UIDL
diff --git a/src/com/vaadin/terminal/gwt/client/ui/dd/AcceptAll.java b/src/com/vaadin/terminal/gwt/client/ui/dd/VAcceptAll.java
index 8600fe9fd5..2a5f993492 100644
--- a/src/com/vaadin/terminal/gwt/client/ui/dd/AcceptAll.java
+++ b/src/com/vaadin/terminal/gwt/client/ui/dd/VAcceptAll.java
@@ -5,8 +5,7 @@ package com.vaadin.terminal.gwt.client.ui.dd;
import com.vaadin.terminal.gwt.client.UIDL;
-@ServerCriterion("com.vaadin.event.dd.acceptCriteria.AcceptAll")
-final class AcceptAll implements VAcceptCriteria {
+final public class VAcceptAll implements VAcceptCriteria {
public void accept(VDragEvent drag, UIDL configuration,
VAcceptCallback callback) {
callback.accepted(drag);
diff --git a/src/com/vaadin/terminal/gwt/client/ui/dd/And.java b/src/com/vaadin/terminal/gwt/client/ui/dd/VAnd.java
index 42a341d7e3..42b77e2db3 100644
--- a/src/com/vaadin/terminal/gwt/client/ui/dd/And.java
+++ b/src/com/vaadin/terminal/gwt/client/ui/dd/VAnd.java
@@ -6,8 +6,7 @@ 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.And")
-final class And implements VAcceptCriteria {
+final public class VAnd implements VAcceptCriteria {
private boolean b1;
private boolean b2;
private VAcceptCriteria crit1;
diff --git a/src/com/vaadin/terminal/gwt/client/ui/dd/ComponentCriteria.java b/src/com/vaadin/terminal/gwt/client/ui/dd/VComponentFilter.java
index ae129365c4..ce84d7aaab 100644
--- a/src/com/vaadin/terminal/gwt/client/ui/dd/ComponentCriteria.java
+++ b/src/com/vaadin/terminal/gwt/client/ui/dd/VComponentFilter.java
@@ -6,8 +6,7 @@ package com.vaadin.terminal.gwt.client.ui.dd;
import com.vaadin.terminal.gwt.client.Paintable;
import com.vaadin.terminal.gwt.client.UIDL;
-@ServerCriterion("com.vaadin.event.dd.acceptCriteria.ComponentFilter")
-final class ComponentCriteria implements VAcceptCriteria {
+final public class VComponentFilter implements VAcceptCriteria {
public void accept(VDragEvent drag, UIDL configuration,
VAcceptCallback callback) {
try {
diff --git a/src/com/vaadin/terminal/gwt/client/ui/dd/HasItemId.java b/src/com/vaadin/terminal/gwt/client/ui/dd/VDataBound.java
index 30716b43a5..a5cfda3815 100644
--- a/src/com/vaadin/terminal/gwt/client/ui/dd/HasItemId.java
+++ b/src/com/vaadin/terminal/gwt/client/ui/dd/VDataBound.java
@@ -5,8 +5,7 @@ package com.vaadin.terminal.gwt.client.ui.dd;
import com.vaadin.terminal.gwt.client.UIDL;
-@ServerCriterion("com.vaadin.event.dd.acceptCriteria.IsDatabound")
-final class HasItemId implements VAcceptCriteria {
+final public class VDataBound implements VAcceptCriteria {
public void accept(VDragEvent drag, UIDL configuration,
VAcceptCallback callback) {
if (drag.getTransferable().getData("itemId") != null) {
diff --git a/src/com/vaadin/terminal/gwt/client/ui/dd/LazyInitItemIdentifiers.java b/src/com/vaadin/terminal/gwt/client/ui/dd/VLazyInitItemIdentifiers.java
index b1fed80336..689ed0eb62 100644
--- a/src/com/vaadin/terminal/gwt/client/ui/dd/LazyInitItemIdentifiers.java
+++ b/src/com/vaadin/terminal/gwt/client/ui/dd/VLazyInitItemIdentifiers.java
@@ -7,8 +7,12 @@ import java.util.HashSet;
import com.vaadin.terminal.gwt.client.UIDL;
-@ServerCriterion("com.vaadin.ui.Tree.TreeDropCriterion")
-final class LazyInitItemIdentifiers implements VAcceptCriteria {
+/**
+ *
+ * @deprecated example class testing custom behavior
+ */
+@Deprecated
+final public class VLazyInitItemIdentifiers implements VAcceptCriteria {
private boolean loaded = false;
private HashSet<String> hashSet;
private VDragEvent lastDragEvent;
diff --git a/src/com/vaadin/terminal/gwt/client/ui/dd/Not.java b/src/com/vaadin/terminal/gwt/client/ui/dd/VNot.java
index 3b5915c73b..8ce753e886 100644
--- a/src/com/vaadin/terminal/gwt/client/ui/dd/Not.java
+++ b/src/com/vaadin/terminal/gwt/client/ui/dd/VNot.java
@@ -6,8 +6,7 @@ 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 {
+final public class VNot implements VAcceptCriteria {
private boolean b1;
private VAcceptCriteria crit1;
diff --git a/src/com/vaadin/terminal/gwt/client/ui/dd/Or.java b/src/com/vaadin/terminal/gwt/client/ui/dd/VOr.java
index ea79edcd4e..324dc08d6a 100644
--- a/src/com/vaadin/terminal/gwt/client/ui/dd/Or.java
+++ b/src/com/vaadin/terminal/gwt/client/ui/dd/VOr.java
@@ -6,8 +6,7 @@ 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 {
+final public class VOr implements VAcceptCriteria {
private boolean b1;
private boolean b2;
private VAcceptCriteria crit1;
diff --git a/src/com/vaadin/terminal/gwt/client/ui/dd/OverTreeNode.java b/src/com/vaadin/terminal/gwt/client/ui/dd/VOverTreeNode.java
index 4948a31436..ebdc6bfed9 100644
--- a/src/com/vaadin/terminal/gwt/client/ui/dd/OverTreeNode.java
+++ b/src/com/vaadin/terminal/gwt/client/ui/dd/VOverTreeNode.java
@@ -5,8 +5,7 @@ package com.vaadin.terminal.gwt.client.ui.dd;
import com.vaadin.terminal.gwt.client.UIDL;
-@ServerCriterion("com.vaadin.event.dd.acceptCriteria.OverTreeNode")
-final class OverTreeNode implements VAcceptCriteria {
+final public class VOverTreeNode implements VAcceptCriteria {
public void accept(VDragEvent drag, UIDL configuration,
VAcceptCallback callback) {
Boolean containsKey = (Boolean) drag.getDropDetails().get(
diff --git a/src/com/vaadin/terminal/gwt/client/ui/dd/ServerAccept.java b/src/com/vaadin/terminal/gwt/client/ui/dd/VServerAccept.java
index 4cacfc1f4f..238b0c8cb4 100644
--- a/src/com/vaadin/terminal/gwt/client/ui/dd/ServerAccept.java
+++ b/src/com/vaadin/terminal/gwt/client/ui/dd/VServerAccept.java
@@ -5,8 +5,7 @@ package com.vaadin.terminal.gwt.client.ui.dd;
import com.vaadin.terminal.gwt.client.UIDL;
-@ServerCriterion("com.vaadin.event.dd.acceptCriteria.ServerSideCriterion")
-final class ServerAccept implements VAcceptCriteria {
+final public class VServerAccept implements VAcceptCriteria {
public void accept(final VDragEvent drag, UIDL configuration,
final VAcceptCallback callback) {
diff --git a/src/com/vaadin/terminal/gwt/widgetsetutils/AcceptCriterionGenerator.java b/src/com/vaadin/terminal/gwt/widgetsetutils/AcceptCriterionGenerator.java
index b0dca0da20..91c50f046b 100644
--- a/src/com/vaadin/terminal/gwt/widgetsetutils/AcceptCriterionGenerator.java
+++ b/src/com/vaadin/terminal/gwt/widgetsetutils/AcceptCriterionGenerator.java
@@ -3,7 +3,6 @@ package com.vaadin.terminal.gwt.widgetsetutils;
import java.io.PrintWriter;
import java.util.Collection;
import java.util.Date;
-import java.util.LinkedList;
import com.google.gwt.core.ext.Generator;
import com.google.gwt.core.ext.GeneratorContext;
@@ -14,7 +13,9 @@ import com.google.gwt.core.ext.typeinfo.JClassType;
import com.google.gwt.core.ext.typeinfo.TypeOracle;
import com.google.gwt.user.rebind.ClassSourceFileComposerFactory;
import com.google.gwt.user.rebind.SourceWriter;
-import com.vaadin.terminal.gwt.client.ui.dd.ServerCriterion;
+import com.vaadin.event.dd.acceptCriteria.AcceptCriterion;
+import com.vaadin.event.dd.acceptCriteria.ClientCriterion;
+import com.vaadin.terminal.gwt.client.ui.dd.VAcceptCriteria;
import com.vaadin.ui.ClientWidget;
/**
@@ -89,27 +90,6 @@ public class AcceptCriterionGenerator extends Generator {
}
- private Collection<JClassType> getAvailableCriteria(GeneratorContext context) {
-
- Collection<JClassType> crits = new LinkedList<JClassType>();
-
- JClassType[] types = context.getTypeOracle().getTypes();
- for (int i = 0; i < types.length; i++) {
- JClassType jClassType = types[i];
- JClassType[] implementedInterfaces = jClassType
- .getImplementedInterfaces();
- for (int j = 0; j < implementedInterfaces.length; j++) {
- String qualifiedSourceName = implementedInterfaces[j]
- .getQualifiedSourceName();
- if (qualifiedSourceName
- .equals("com.vaadin.terminal.gwt.client.ui.dd.VAcceptCriteria")) {
- crits.add(jClassType);
- }
- }
- }
- return crits;
- }
-
private void generateInstantiatorMethod(SourceWriter sourceWriter,
GeneratorContext context, TreeLogger logger) {
@@ -118,30 +98,21 @@ public class AcceptCriterionGenerator extends Generator {
sourceWriter.println("name = name.intern();");
- Collection<JClassType> paintablesHavingWidgetAnnotation = getAvailableCriteria(context);
-
- for (JClassType jClassType : paintablesHavingWidgetAnnotation) {
- ServerCriterion annotation = jClassType
- .getAnnotation(ServerCriterion.class);
- if (annotation == null) {
- // throw new RuntimeException(
- // "No server side implementation defined for "
- // + jClassType.getName());
- continue;
- } else {
- System.out.print("Printing for instantiation rule for "
- + annotation.value());
- }
- String serversideclass = annotation.value();
+ Collection<Class<? extends AcceptCriterion>> clientSideVerifiableCriterion = ClassPathExplorer
+ .getCriterion();
+ for (Class<? extends AcceptCriterion> class1 : clientSideVerifiableCriterion) {
+ String canonicalName = class1.getCanonicalName();
+ Class<? extends VAcceptCriteria> clientClass = class1
+ .getAnnotation(ClientCriterion.class).value();
sourceWriter.print("if (\"");
- sourceWriter.print(serversideclass);
+ sourceWriter.print(canonicalName);
sourceWriter.print("\" == name) return GWT.create(");
- sourceWriter.print(jClassType.getName());
+ sourceWriter.print(clientClass.getCanonicalName());
sourceWriter.println(".class );");
sourceWriter.print("else ");
-
}
+
sourceWriter.println("return null;");
sourceWriter.outdent();
sourceWriter.println("}");
diff --git a/src/com/vaadin/terminal/gwt/widgetsetutils/ClassPathExplorer.java b/src/com/vaadin/terminal/gwt/widgetsetutils/ClassPathExplorer.java
index 912cfa37a3..b3c670ba81 100644
--- a/src/com/vaadin/terminal/gwt/widgetsetutils/ClassPathExplorer.java
+++ b/src/com/vaadin/terminal/gwt/widgetsetutils/ClassPathExplorer.java
@@ -27,6 +27,8 @@ import java.util.jar.Manifest;
import java.util.logging.Level;
import java.util.logging.Logger;
+import com.vaadin.event.dd.acceptCriteria.AcceptCriterion;
+import com.vaadin.event.dd.acceptCriteria.ClientCriterion;
import com.vaadin.terminal.Paintable;
import com.vaadin.ui.ClientWidget;
@@ -83,6 +85,15 @@ public class ClassPathExplorer {
}
+ public static Collection<Class<? extends AcceptCriterion>> getCriterion() {
+ if (acceptCriterion.isEmpty()) {
+ // accept criterion are searched as a side effect, normally after
+ // paintable detection
+ getPaintablesHavingWidgetAnnotation();
+ }
+ return acceptCriterion;
+ }
+
/**
* Finds available widgetset names.
*
@@ -385,6 +396,8 @@ public class ClassPathExplorer {
}
});
+ private static Set<Class<? extends AcceptCriterion>> acceptCriterion = new HashSet<Class<? extends AcceptCriterion>>();
+
private static void tryToAdd(final String fullclassName,
Collection<Class<? extends Paintable>> paintables) {
try {
@@ -401,7 +414,10 @@ public class ClassPathExplorer {
if (c.getAnnotation(ClientWidget.class) != null) {
paintables.add((Class<? extends Paintable>) c);
// System.out.println("Found paintable " + fullclassName);
+ } else if (c.getAnnotation(ClientCriterion.class) != null) {
+ acceptCriterion.add((Class<? extends AcceptCriterion>) c);
}
+
} catch (ClassNotFoundException e) {
// e.printStackTrace();
} catch (LinkageError e) {
diff --git a/src/com/vaadin/ui/Tree.java b/src/com/vaadin/ui/Tree.java
index 3bb1e6f696..ab8eae8419 100644
--- a/src/com/vaadin/ui/Tree.java
+++ b/src/com/vaadin/ui/Tree.java
@@ -33,6 +33,7 @@ import com.vaadin.event.dd.DragSource;
import com.vaadin.event.dd.DropHandler;
import com.vaadin.event.dd.DropTarget;
import com.vaadin.event.dd.TargetDetailsImpl;
+import com.vaadin.event.dd.acceptCriteria.ClientCriterion;
import com.vaadin.event.dd.acceptCriteria.ServerSideCriterion;
import com.vaadin.terminal.KeyMapper;
import com.vaadin.terminal.PaintException;
@@ -40,6 +41,7 @@ import com.vaadin.terminal.PaintTarget;
import com.vaadin.terminal.Resource;
import com.vaadin.terminal.gwt.client.MouseEventDetails;
import com.vaadin.terminal.gwt.client.ui.VTree;
+import com.vaadin.terminal.gwt.client.ui.dd.VLazyInitItemIdentifiers;
/**
* Tree component. A Tree can be used to select an item (or multiple items) from
@@ -1218,6 +1220,7 @@ public class Tree extends AbstractSelect implements Container.Hierarchical,
* <p>
* See client side counterpart
*/
+ @ClientCriterion(VLazyInitItemIdentifiers.class)
public static abstract class TreeDropCriterion extends ServerSideCriterion {
private Tree tree;