summaryrefslogtreecommitdiffstats
path: root/client
diff options
context:
space:
mode:
Diffstat (limited to 'client')
-rw-r--r--client/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java61
-rw-r--r--client/src/com/vaadin/terminal/gwt/client/metadata/Property.java9
-rw-r--r--client/src/com/vaadin/terminal/gwt/client/metadata/TypeDataStore.java6
-rw-r--r--client/src/com/vaadin/terminal/gwt/client/ui/MediaBaseConnector.java3
-rw-r--r--client/src/com/vaadin/terminal/gwt/client/ui/splitpanel/AbstractSplitPanelConnector.java3
-rw-r--r--client/src/com/vaadin/terminal/gwt/client/ui/textarea/TextAreaConnector.java9
6 files changed, 71 insertions, 20 deletions
diff --git a/client/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java b/client/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java
index 58357ae3fc..10f63d0f51 100644
--- a/client/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java
+++ b/client/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java
@@ -68,7 +68,10 @@ import com.vaadin.terminal.gwt.client.communication.RpcManager;
import com.vaadin.terminal.gwt.client.communication.StateChangeEvent;
import com.vaadin.terminal.gwt.client.extensions.AbstractExtensionConnector;
import com.vaadin.terminal.gwt.client.metadata.ConnectorBundleLoader;
+import com.vaadin.terminal.gwt.client.metadata.NoDataException;
+import com.vaadin.terminal.gwt.client.metadata.Property;
import com.vaadin.terminal.gwt.client.metadata.Type;
+import com.vaadin.terminal.gwt.client.metadata.TypeData;
import com.vaadin.terminal.gwt.client.ui.AbstractComponentConnector;
import com.vaadin.terminal.gwt.client.ui.VContextMenu;
import com.vaadin.terminal.gwt.client.ui.dd.VDragAndDropManager;
@@ -1148,6 +1151,8 @@ public class ApplicationConnection {
" * Hierarchy state change event processing completed",
10);
+ delegateToWidget(pendingStateChangeEvents);
+
// Fire state change events.
sendStateChangeEvents(pendingStateChangeEvents);
@@ -1264,6 +1269,62 @@ public class ApplicationConnection {
}
+ private void delegateToWidget(
+ Collection<StateChangeEvent> pendingStateChangeEvents) {
+ VConsole.log(" * Running @DelegateToWidget");
+
+ for (StateChangeEvent sce : pendingStateChangeEvents) {
+ ServerConnector connector = sce.getConnector();
+ if (connector instanceof ComponentConnector) {
+ ComponentConnector component = (ComponentConnector) connector;
+ Type type = TypeData.getType(component.getClass());
+
+ Type stateType;
+ try {
+ stateType = type.getMethod("getState")
+ .getReturnType();
+ } catch (NoDataException e) {
+ throw new RuntimeException(
+ "Can not find the state type for "
+ + type.getSignature(), e);
+ }
+
+ Set<String> changedProperties = sce
+ .getChangedProperties();
+ for (String propertyName : changedProperties) {
+ Property property = stateType
+ .getProperty(propertyName);
+ String method = property
+ .getDelegateToWidgetMethodName();
+ if (method != null) {
+ doDelegateToWidget(component, property, method);
+ }
+ }
+
+ }
+ }
+ }
+
+ private void doDelegateToWidget(ComponentConnector component,
+ Property property, String methodName) {
+ Type type = TypeData.getType(component.getClass());
+ try {
+ Type widgetType = type.getMethod("getWidget")
+ .getReturnType();
+ Widget widget = component.getWidget();
+
+ Object propertyValue = property.getValue(component
+ .getState());
+
+ widgetType.getMethod(methodName).invoke(widget,
+ propertyValue);
+ } catch (NoDataException e) {
+ throw new RuntimeException(
+ "Missing data needed to invoke @DelegateToWidget for "
+ + Util.getSimpleName(component), e);
+ }
+ }
+
/**
* Sends the state change events created while updating the state
* information.
diff --git a/client/src/com/vaadin/terminal/gwt/client/metadata/Property.java b/client/src/com/vaadin/terminal/gwt/client/metadata/Property.java
index 082d032e64..69e41ce75d 100644
--- a/client/src/com/vaadin/terminal/gwt/client/metadata/Property.java
+++ b/client/src/com/vaadin/terminal/gwt/client/metadata/Property.java
@@ -4,6 +4,8 @@
package com.vaadin.terminal.gwt.client.metadata;
+import com.vaadin.shared.annotations.DelegateToWidget;
+
public class Property {
private final Type bean;
private final String name;
@@ -21,15 +23,12 @@ public class Property {
TypeDataStore.getSetter(this).invoke(bean, value);
}
- public String getDelegateToWidgetMethod() {
+ public String getDelegateToWidgetMethodName() {
String value = TypeDataStore.getDelegateToWidget(this);
if (value == null) {
return null;
- } else if (value.isEmpty()) {
- return "set" + Character.toUpperCase(value.charAt(0))
- + value.substring(1);
} else {
- return value;
+ return DelegateToWidget.Helper.getDelegateTarget(getName(), value);
}
}
diff --git a/client/src/com/vaadin/terminal/gwt/client/metadata/TypeDataStore.java b/client/src/com/vaadin/terminal/gwt/client/metadata/TypeDataStore.java
index 55740f69da..9c19410c88 100644
--- a/client/src/com/vaadin/terminal/gwt/client/metadata/TypeDataStore.java
+++ b/client/src/com/vaadin/terminal/gwt/client/metadata/TypeDataStore.java
@@ -101,6 +101,12 @@ public class TypeDataStore {
return get().delegateToWidget.get(property);
}
+ public void setDelegateToWidget(Class<?> clazz, String propertyName,
+ String delegateValue) {
+ delegateToWidget.put(new Property(getType(clazz), propertyName),
+ delegateValue);
+ }
+
public void setReturnType(Class<?> type, String methodName, Type returnType) {
returnTypes.put(new Method(getType(type), methodName), returnType);
}
diff --git a/client/src/com/vaadin/terminal/gwt/client/ui/MediaBaseConnector.java b/client/src/com/vaadin/terminal/gwt/client/ui/MediaBaseConnector.java
index 2f52971aeb..33d97f4ed8 100644
--- a/client/src/com/vaadin/terminal/gwt/client/ui/MediaBaseConnector.java
+++ b/client/src/com/vaadin/terminal/gwt/client/ui/MediaBaseConnector.java
@@ -49,9 +49,6 @@ public abstract class MediaBaseConnector extends AbstractComponentConnector {
public void onStateChanged(StateChangeEvent stateChangeEvent) {
super.onStateChanged(stateChangeEvent);
- getWidget().setControls(getState().isShowControls());
- getWidget().setAutoplay(getState().isAutoplay());
- getWidget().setMuted(getState().isMuted());
for (int i = 0; i < getState().getSources().size(); i++) {
URLReference source = getState().getSources().get(i);
String sourceType = getState().getSourceTypes().get(i);
diff --git a/client/src/com/vaadin/terminal/gwt/client/ui/splitpanel/AbstractSplitPanelConnector.java b/client/src/com/vaadin/terminal/gwt/client/ui/splitpanel/AbstractSplitPanelConnector.java
index 9f4df02380..912f9a7c83 100644
--- a/client/src/com/vaadin/terminal/gwt/client/ui/splitpanel/AbstractSplitPanelConnector.java
+++ b/client/src/com/vaadin/terminal/gwt/client/ui/splitpanel/AbstractSplitPanelConnector.java
@@ -138,9 +138,6 @@ public abstract class AbstractSplitPanelConnector extends
// Splitter updates
SplitterState splitterState = getState().getSplitterState();
- getWidget().setLocked(splitterState.isLocked());
- getWidget().setPositionReversed(splitterState.isPositionReversed());
-
getWidget().setStylenames();
getWidget().minimumPosition = splitterState.getMinPosition()
diff --git a/client/src/com/vaadin/terminal/gwt/client/ui/textarea/TextAreaConnector.java b/client/src/com/vaadin/terminal/gwt/client/ui/textarea/TextAreaConnector.java
index 5fb7f97044..d5abed4fa9 100644
--- a/client/src/com/vaadin/terminal/gwt/client/ui/textarea/TextAreaConnector.java
+++ b/client/src/com/vaadin/terminal/gwt/client/ui/textarea/TextAreaConnector.java
@@ -18,7 +18,6 @@ package com.vaadin.terminal.gwt.client.ui.textarea;
import com.vaadin.shared.ui.Connect;
import com.vaadin.shared.ui.textarea.TextAreaState;
-import com.vaadin.terminal.gwt.client.communication.StateChangeEvent;
import com.vaadin.terminal.gwt.client.ui.textfield.TextFieldConnector;
import com.vaadin.ui.TextArea;
@@ -31,14 +30,6 @@ public class TextAreaConnector extends TextFieldConnector {
}
@Override
- public void onStateChanged(StateChangeEvent stateChangeEvent) {
- super.onStateChanged(stateChangeEvent);
-
- getWidget().setRows(getState().getRows());
- getWidget().setWordwrap(getState().isWordwrap());
- }
-
- @Override
public VTextArea getWidget() {
return (VTextArea) super.getWidget();
}