summaryrefslogtreecommitdiffstats
path: root/client-compiler/src
diff options
context:
space:
mode:
authorMikael Grankvist <mgrankvi@vaadin.com>2014-07-01 14:11:05 +0300
committerVaadin Code Review <review@vaadin.com>2014-08-07 06:32:16 +0000
commit75f42d32229c2a4c5198a8d2b5ae5b2d90a7f8ff (patch)
treed946f20d5e405819ef3cc8bf7141c6cd75f22a8d /client-compiler/src
parentf5afdd6d4acae5d9bccf47ebc320787b53659cce (diff)
downloadvaadin-framework-75f42d32229c2a4c5198a8d2b5ae5b2d90a7f8ff.tar.gz
vaadin-framework-75f42d32229c2a4c5198a8d2b5ae5b2d90a7f8ff.zip
DelegateToWidget will now be run even for parent states for extending
states (#14059) Updated the code to encompass Leif's suggestion. Change-Id: I70c0a4a93b9fe9ee8b2c458d666a1fec791f20b4
Diffstat (limited to 'client-compiler/src')
-rw-r--r--client-compiler/src/com/vaadin/server/widgetsetutils/ConnectorBundleLoaderFactory.java19
-rw-r--r--client-compiler/src/com/vaadin/server/widgetsetutils/metadata/ConnectorBundle.java27
-rw-r--r--client-compiler/src/com/vaadin/server/widgetsetutils/metadata/WidgetInitVisitor.java2
3 files changed, 28 insertions, 20 deletions
diff --git a/client-compiler/src/com/vaadin/server/widgetsetutils/ConnectorBundleLoaderFactory.java b/client-compiler/src/com/vaadin/server/widgetsetutils/ConnectorBundleLoaderFactory.java
index 5519dd1aae..a6ca690a8a 100644
--- a/client-compiler/src/com/vaadin/server/widgetsetutils/ConnectorBundleLoaderFactory.java
+++ b/client-compiler/src/com/vaadin/server/widgetsetutils/ConnectorBundleLoaderFactory.java
@@ -639,13 +639,18 @@ public class ConnectorBundleLoaderFactory extends Generator {
private void writeDelegateToWidget(TreeLogger logger,
SplittingSourceWriter w, ConnectorBundle bundle) {
- Set<Property> needsDelegateToWidget = bundle.getNeedsDelegateToWidget();
- for (Property property : needsDelegateToWidget) {
- w.println("store.setDelegateToWidget(%s, \"%s\", \"%s\");",
- getClassLiteralString(property.getBeanType()),
- property.getName(),
- property.getAnnotation(DelegateToWidget.class).value());
-
+ Map<JClassType, Set<Property>> needsDelegateToWidget = bundle
+ .getNeedsDelegateToWidget();
+ for (Entry<JClassType, Set<Property>> entry : needsDelegateToWidget
+ .entrySet()) {
+ JClassType beanType = entry.getKey();
+ for (Property property : entry.getValue()) {
+ w.println(
+ "store.setDelegateToWidget(%s, \"%s\", \"%s\");",
+ getClassLiteralString(beanType),// property.getBeanType()),
+ property.getName(),
+ property.getAnnotation(DelegateToWidget.class).value());
+ }
w.splitIfNeeded();
}
}
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 8bbcac4ecb..e8a384298f 100644
--- a/client-compiler/src/com/vaadin/server/widgetsetutils/metadata/ConnectorBundle.java
+++ b/client-compiler/src/com/vaadin/server/widgetsetutils/metadata/ConnectorBundle.java
@@ -1,12 +1,12 @@
/*
* Copyright 2000-2014 Vaadin Ltd.
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
@@ -38,6 +38,7 @@ import com.google.gwt.core.ext.typeinfo.JType;
import com.google.gwt.core.ext.typeinfo.NotFoundException;
import com.google.gwt.core.ext.typeinfo.TypeOracle;
import com.google.gwt.json.client.JSONValue;
+import com.google.gwt.thirdparty.guava.common.collect.Sets;
import com.vaadin.client.ApplicationConnection;
import com.vaadin.client.ComponentConnector;
import com.vaadin.client.ServerConnector;
@@ -72,7 +73,7 @@ public class ConnectorBundle {
private final Map<JClassType, Set<JMethod>> needsOnStateChange = new HashMap<JClassType, Set<JMethod>>();
private final Set<Property> needsProperty = new HashSet<Property>();
- private final Set<Property> needsDelegateToWidget = new HashSet<Property>();
+ private final Map<JClassType, Set<Property>> needsDelegateToWidget = new HashMap<JClassType, Set<Property>>();
private ConnectorBundle(String name, ConnectorBundle previousBundle,
Collection<TypeVisitor> visitors,
@@ -567,23 +568,25 @@ public class ConnectorBundle {
}
}
- public void setNeedsDelegateToWidget(Property property) {
- if (!isNeedsDelegateToWidget(property)) {
- needsDelegateToWidget.add(property);
+ public void setNeedsDelegateToWidget(Property property, JClassType type) {
+ if (!isNeedsDelegateToWidget(type)) {
+ needsDelegateToWidget.put(type, Sets.newHashSet(property));
+ } else if (!needsDelegateToWidget.get(type).contains(property)) {
+ needsDelegateToWidget.get(type).add(property);
}
}
- private boolean isNeedsDelegateToWidget(Property property) {
- if (needsDelegateToWidget.contains(property)) {
+ private boolean isNeedsDelegateToWidget(JClassType type) {
+ if (needsDelegateToWidget.containsKey(type)) {
return true;
} else {
return previousBundle != null
- && previousBundle.isNeedsDelegateToWidget(property);
+ && previousBundle.isNeedsDelegateToWidget(type);
}
}
- public Set<Property> getNeedsDelegateToWidget() {
- return Collections.unmodifiableSet(needsDelegateToWidget);
+ public Map<JClassType, Set<Property>> getNeedsDelegateToWidget() {
+ return Collections.unmodifiableMap(needsDelegateToWidget);
}
public void setNeedsOnStateChangeHandler(JClassType type, JMethod method) {
diff --git a/client-compiler/src/com/vaadin/server/widgetsetutils/metadata/WidgetInitVisitor.java b/client-compiler/src/com/vaadin/server/widgetsetutils/metadata/WidgetInitVisitor.java
index e3fee8d9ee..a77b523d14 100644
--- a/client-compiler/src/com/vaadin/server/widgetsetutils/metadata/WidgetInitVisitor.java
+++ b/client-compiler/src/com/vaadin/server/widgetsetutils/metadata/WidgetInitVisitor.java
@@ -59,7 +59,7 @@ public class WidgetInitVisitor extends TypeVisitor {
.getAnnotation(DelegateToWidget.class);
if (delegateToWidget != null) {
// Generate meta data required for @DelegateToWidget
- bundle.setNeedsDelegateToWidget(property);
+ bundle.setNeedsDelegateToWidget(property, stateType);
// Find the delegate target method
String methodName = DelegateToWidget.Helper