aboutsummaryrefslogtreecommitdiffstats
path: root/src/com/vaadin/terminal/gwt
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/vaadin/terminal/gwt')
-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
13 files changed, 43 insertions, 78 deletions
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) {