summaryrefslogtreecommitdiffstats
path: root/client-compiler
diff options
context:
space:
mode:
authorLeif Åstrand <leif@vaadin.com>2014-07-02 15:02:02 +0300
committerLeif Åstrand <leif@vaadin.com>2014-11-25 08:12:08 +0000
commitec1d9a12ca0e1e7e6ae13d58d9b361c19986cdd3 (patch)
tree1eb42c436d9b75ec9471abd5bc9c81a77e8506d3 /client-compiler
parent759ec0e19569ba6b0d0e43f68cdd25e26ecf55d6 (diff)
downloadvaadin-framework-ec1d9a12ca0e1e7e6ae13d58d9b361c19986cdd3.tar.gz
vaadin-framework-ec1d9a12ca0e1e7e6ae13d58d9b361c19986cdd3.zip
Add @NoLayout annotation (#12936)
This commit adds support for @NoLayout and updates most framework components to use the annotation where it makes sense Change-Id: I99320a6aa6de717da5f2463dd8acfcd412165767
Diffstat (limited to 'client-compiler')
-rw-r--r--client-compiler/src/com/vaadin/server/widgetsetutils/ConnectorBundleLoaderFactory.java22
-rw-r--r--client-compiler/src/com/vaadin/server/widgetsetutils/metadata/ClientRpcVisitor.java4
-rw-r--r--client-compiler/src/com/vaadin/server/widgetsetutils/metadata/ConnectorBundle.java20
3 files changed, 46 insertions, 0 deletions
diff --git a/client-compiler/src/com/vaadin/server/widgetsetutils/ConnectorBundleLoaderFactory.java b/client-compiler/src/com/vaadin/server/widgetsetutils/ConnectorBundleLoaderFactory.java
index 7c3bb1eb77..13bd7051f6 100644
--- a/client-compiler/src/com/vaadin/server/widgetsetutils/ConnectorBundleLoaderFactory.java
+++ b/client-compiler/src/com/vaadin/server/widgetsetutils/ConnectorBundleLoaderFactory.java
@@ -68,6 +68,7 @@ import com.vaadin.server.widgetsetutils.metadata.TypeVisitor;
import com.vaadin.server.widgetsetutils.metadata.WidgetInitVisitor;
import com.vaadin.shared.annotations.Delayed;
import com.vaadin.shared.annotations.DelegateToWidget;
+import com.vaadin.shared.annotations.NoLayout;
import com.vaadin.shared.communication.ClientRpc;
import com.vaadin.shared.communication.ServerRpc;
import com.vaadin.shared.ui.Connect;
@@ -454,6 +455,10 @@ public class ConnectorBundleLoaderFactory extends Generator {
writer.println("var data = {");
writer.indent();
+ if (property.getAnnotation(NoLayout.class) != null) {
+ writer.println("noLayout: 1, ");
+ }
+
writer.println("setter: function(bean, value) {");
writer.indent();
property.writeSetterBody(logger, writer, "bean", "value");
@@ -497,6 +502,7 @@ public class ConnectorBundleLoaderFactory extends Generator {
writeParamTypes(w, bundle);
writeProxys(w, bundle);
writeDelayedInfo(w, bundle);
+ writeNoLayoutRpcMethods(w, bundle);
w.println("%s(store);", loadNativeJsMethodName);
@@ -509,6 +515,22 @@ public class ConnectorBundleLoaderFactory extends Generator {
writeOnStateChangeHandlers(logger, w, bundle);
}
+ private void writeNoLayoutRpcMethods(SplittingSourceWriter w,
+ ConnectorBundle bundle) {
+ Map<JClassType, Set<JMethod>> needsNoLayout = bundle
+ .getNeedsNoLayoutRpcMethods();
+ for (Entry<JClassType, Set<JMethod>> entry : needsNoLayout.entrySet()) {
+ JClassType type = entry.getKey();
+
+ for (JMethod method : entry.getValue()) {
+ w.println("store.setNoLayoutRpcMethod(%s, \"%s\");",
+ getClassLiteralString(type), method.getName());
+ }
+
+ w.splitIfNeeded();
+ }
+ }
+
private void writeOnStateChangeHandlers(TreeLogger logger,
SplittingSourceWriter w, ConnectorBundle bundle)
throws UnableToCompleteException {
diff --git a/client-compiler/src/com/vaadin/server/widgetsetutils/metadata/ClientRpcVisitor.java b/client-compiler/src/com/vaadin/server/widgetsetutils/metadata/ClientRpcVisitor.java
index 856f67657f..1df3d78588 100644
--- a/client-compiler/src/com/vaadin/server/widgetsetutils/metadata/ClientRpcVisitor.java
+++ b/client-compiler/src/com/vaadin/server/widgetsetutils/metadata/ClientRpcVisitor.java
@@ -24,6 +24,7 @@ import com.google.gwt.core.ext.UnableToCompleteException;
import com.google.gwt.core.ext.typeinfo.JClassType;
import com.google.gwt.core.ext.typeinfo.JMethod;
import com.google.gwt.core.ext.typeinfo.JType;
+import com.vaadin.shared.annotations.NoLayout;
public class ClientRpcVisitor extends TypeVisitor {
@Override
@@ -39,6 +40,9 @@ public class ClientRpcVisitor extends TypeVisitor {
bundle.setNeedsInvoker(type, method);
bundle.setNeedsParamTypes(type, method);
+ if (method.getAnnotation(NoLayout.class) != null) {
+ bundle.setNeedsNoLayoutRpcMethod(type, method);
+ }
JType[] parameterTypes = method.getParameterTypes();
for (JType paramType : parameterTypes) {
diff --git a/client-compiler/src/com/vaadin/server/widgetsetutils/metadata/ConnectorBundle.java b/client-compiler/src/com/vaadin/server/widgetsetutils/metadata/ConnectorBundle.java
index 4a079c38b0..2c2d091d5e 100644
--- a/client-compiler/src/com/vaadin/server/widgetsetutils/metadata/ConnectorBundle.java
+++ b/client-compiler/src/com/vaadin/server/widgetsetutils/metadata/ConnectorBundle.java
@@ -73,6 +73,7 @@ public class ConnectorBundle {
private final Map<JClassType, Set<JMethod>> needsParamTypes = new HashMap<JClassType, Set<JMethod>>();
private final Map<JClassType, Set<JMethod>> needsDelayedInfo = new HashMap<JClassType, Set<JMethod>>();
private final Map<JClassType, Set<JMethod>> needsOnStateChange = new HashMap<JClassType, Set<JMethod>>();
+ private final Map<JClassType, Set<JMethod>> needsNoLayoutRpcMethods = new HashMap<JClassType, Set<JMethod>>();
private final Set<Property> needsProperty = new HashSet<Property>();
private final Map<JClassType, Set<Property>> needsDelegateToWidget = new HashMap<JClassType, Set<Property>>();
@@ -634,6 +635,25 @@ public class ConnectorBundle {
return Collections.unmodifiableMap(needsOnStateChange);
}
+ public void setNeedsNoLayoutRpcMethod(JClassType type, JMethod method) {
+ if (!isNeedsNoLayoutRpcMethod(type, method)) {
+ addMapping(needsNoLayoutRpcMethods, type, method);
+ }
+ }
+
+ private boolean isNeedsNoLayoutRpcMethod(JClassType type, JMethod method) {
+ if (hasMapping(needsNoLayoutRpcMethods, type, method)) {
+ return true;
+ } else {
+ return previousBundle != null
+ && previousBundle.isNeedsNoLayoutRpcMethod(type, method);
+ }
+ }
+
+ public Map<JClassType, Set<JMethod>> getNeedsNoLayoutRpcMethods() {
+ return Collections.unmodifiableMap(needsNoLayoutRpcMethods);
+ }
+
public static JMethod findInheritedMethod(JClassType type,
String methodName, JType... params) {