@@ -30,6 +30,7 @@ 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.shared.annotations.Delayed; | |||
import com.vaadin.shared.annotations.DelegateToWidget; | |||
import com.vaadin.shared.communication.ClientRpc; | |||
import com.vaadin.shared.communication.ServerRpc; | |||
import com.vaadin.shared.ui.Connect; | |||
@@ -182,6 +183,18 @@ public class ConnectorBundleLoaderFactory extends Generator { | |||
writeSetters(logger, w, bundle); | |||
writeGetters(logger, w, bundle); | |||
writeSerializers(logger, w, bundle); | |||
writeDelegateToWidget(logger, w, bundle); | |||
} | |||
private void writeDelegateToWidget(TreeLogger logger, SourceWriter 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()); | |||
} | |||
} | |||
private void writeSerializers(TreeLogger logger, SourceWriter w, | |||
@@ -535,8 +548,11 @@ public class ConnectorBundleLoaderFactory extends Generator { | |||
} | |||
public static void writeClassLiteral(SourceWriter w, JType type) { | |||
w.print(type.getQualifiedSourceName()); | |||
w.print(".class"); | |||
w.print(getClassLiteralString(type)); | |||
} | |||
public static String getClassLiteralString(JType type) { | |||
return type.getQualifiedSourceName() + ".class"; | |||
} | |||
private void writeIdentifiers(SourceWriter w, ConnectorBundle bundle) { |
@@ -61,6 +61,7 @@ public class ConnectorBundle { | |||
private final Set<Property> needsSetter = new HashSet<Property>(); | |||
private final Set<Property> needsType = new HashSet<Property>(); | |||
private final Set<Property> needsGetter = new HashSet<Property>(); | |||
private final Set<Property> needsDelegateToWidget = new HashSet<Property>(); | |||
private ConnectorBundle(String name, ConnectorBundle previousBundle, | |||
Collection<TypeVisitor> visitors, | |||
@@ -585,4 +586,23 @@ public class ConnectorBundle { | |||
&& previousBundle.hasSserializeSupport(type); | |||
} | |||
} | |||
public void setNeedsDelegateToWidget(Property property) { | |||
if (!isNeedsDelegateToWidget(property)) { | |||
needsDelegateToWidget.add(property); | |||
} | |||
} | |||
private boolean isNeedsDelegateToWidget(Property property) { | |||
if (needsDelegateToWidget.contains(property)) { | |||
return true; | |||
} else { | |||
return previousBundle != null | |||
&& previousBundle.isNeedsDelegateToWidget(property); | |||
} | |||
} | |||
public Set<Property> getNeedsDelegateToWidget() { | |||
return Collections.unmodifiableSet(needsDelegateToWidget); | |||
} | |||
} |
@@ -16,6 +16,7 @@ | |||
package com.vaadin.terminal.gwt.widgetsetutils.metadata; | |||
import java.lang.annotation.Annotation; | |||
import java.util.ArrayList; | |||
import java.util.Collection; | |||
import java.util.HashSet; | |||
@@ -29,8 +30,11 @@ import com.google.gwt.user.rebind.SourceWriter; | |||
public class FieldProperty extends Property { | |||
private final JField field; | |||
private FieldProperty(JClassType beanType, JField field) { | |||
super(field.getName(), beanType, field.getType()); | |||
this.field = field; | |||
} | |||
@Override | |||
@@ -74,4 +78,9 @@ public class FieldProperty extends Property { | |||
return fields; | |||
} | |||
@Override | |||
public <T extends Annotation> T getAnnotation(Class<T> annotationClass) { | |||
return field.getAnnotation(annotationClass); | |||
} | |||
} |
@@ -16,6 +16,7 @@ | |||
package com.vaadin.terminal.gwt.widgetsetutils.metadata; | |||
import java.lang.annotation.Annotation; | |||
import java.util.ArrayList; | |||
import java.util.Collection; | |||
import java.util.List; | |||
@@ -121,4 +122,9 @@ public class MethodProperty extends Property { | |||
+ baseName.substring(1); | |||
} | |||
@Override | |||
public <T extends Annotation> T getAnnotation(Class<T> annotationClass) { | |||
return setter.getAnnotation(annotationClass); | |||
} | |||
} |
@@ -16,6 +16,8 @@ | |||
package com.vaadin.terminal.gwt.widgetsetutils.metadata; | |||
import java.lang.annotation.Annotation; | |||
import com.google.gwt.core.ext.TreeLogger; | |||
import com.google.gwt.core.ext.typeinfo.JClassType; | |||
import com.google.gwt.core.ext.typeinfo.JPrimitiveType; | |||
@@ -81,4 +83,7 @@ public abstract class Property { | |||
+ getName().hashCode(); | |||
} | |||
public abstract <T extends Annotation> T getAnnotation( | |||
Class<T> annotationClass); | |||
} |
@@ -5,6 +5,7 @@ | |||
package com.vaadin.terminal.gwt.widgetsetutils.metadata; | |||
import com.google.gwt.core.ext.TreeLogger; | |||
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; | |||
@@ -17,7 +18,7 @@ public abstract class TypeVisitor { | |||
} | |||
public void visitConnector(TreeLogger logger, JClassType type, | |||
ConnectorBundle bundle) { | |||
ConnectorBundle bundle) throws UnableToCompleteException { | |||
// Default does nothing | |||
} | |||
@@ -4,17 +4,21 @@ | |||
package com.vaadin.terminal.gwt.widgetsetutils.metadata; | |||
import java.util.Collection; | |||
import com.google.gwt.core.ext.TreeLogger; | |||
import com.google.gwt.core.ext.TreeLogger.Type; | |||
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.DelegateToWidget; | |||
import com.vaadin.terminal.gwt.client.ui.AbstractComponentConnector; | |||
public class WidgetInitVisitor extends TypeVisitor { | |||
@Override | |||
public void visitConnector(TreeLogger logger, JClassType type, | |||
ConnectorBundle bundle) { | |||
ConnectorBundle bundle) throws UnableToCompleteException { | |||
if (ConnectorBundle.isConnectedComponentConnector(type)) { | |||
JClassType createWidgetClass = findInheritedMethod(type, | |||
"createWidget").getEnclosingType(); | |||
@@ -29,8 +33,41 @@ public class WidgetInitVisitor extends TypeVisitor { | |||
JMethod getWidget = findInheritedMethod(type, "getWidget"); | |||
bundle.setNeedsReturnType(type, getWidget); | |||
JType widgetType = getWidget.getReturnType(); | |||
bundle.setNeedsGwtConstructor(widgetType.isClass()); | |||
JClassType widgetType = getWidget.getReturnType().isClass(); | |||
bundle.setNeedsGwtConstructor(widgetType); | |||
JMethod getState = findInheritedMethod(type, "getState"); | |||
JClassType stateType = getState.getReturnType().isClass(); | |||
Collection<Property> properties = bundle.getProperties(stateType); | |||
for (Property property : properties) { | |||
DelegateToWidget delegateToWidget = property | |||
.getAnnotation(DelegateToWidget.class); | |||
if (delegateToWidget != null) { | |||
bundle.setNeedsDelegateToWidget(property); | |||
String methodName = DelegateToWidget.Helper | |||
.getDelegateTarget(property.getName(), | |||
delegateToWidget.value()); | |||
JMethod delegatedSetter = findInheritedMethod(widgetType, | |||
methodName, property.getPropertyType()); | |||
if (delegatedSetter == null) { | |||
logger.log( | |||
Type.ERROR, | |||
widgetType.getName() | |||
+ "." | |||
+ methodName | |||
+ "(" | |||
+ property.getPropertyType() | |||
.getSimpleSourceName() | |||
+ ") required by @DelegateToWidget for " | |||
+ stateType.getName() + "." | |||
+ property.getName() | |||
+ " can not be found."); | |||
throw new UnableToCompleteException(); | |||
} | |||
bundle.setNeedsInvoker(widgetType, delegatedSetter); | |||
} | |||
} | |||
} | |||
} | |||
} |
@@ -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. |
@@ -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); | |||
} | |||
} | |||
@@ -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); | |||
} |
@@ -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); |
@@ -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() |
@@ -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; | |||
@@ -30,14 +29,6 @@ public class TextAreaConnector extends TextFieldConnector { | |||
return (TextAreaState) super.getState(); | |||
} | |||
@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(); |
@@ -0,0 +1,25 @@ | |||
/* | |||
@VaadinApache2LicenseForJavaFiles@ | |||
*/ | |||
package com.vaadin.shared.annotations; | |||
import java.lang.annotation.ElementType; | |||
import java.lang.annotation.Target; | |||
@Target({ ElementType.METHOD, ElementType.FIELD }) | |||
public @interface DelegateToWidget { | |||
public String value() default ""; | |||
public static class Helper { | |||
public static String getDelegateTarget(String propertyName, | |||
String annotationValue) { | |||
String name = annotationValue; | |||
if (name.isEmpty()) { | |||
name = "set" + Character.toUpperCase(propertyName.charAt(0)) | |||
+ propertyName.substring(1); | |||
} | |||
return name; | |||
} | |||
} | |||
} |
@@ -19,6 +19,7 @@ import java.util.ArrayList; | |||
import java.util.List; | |||
import com.vaadin.shared.ComponentState; | |||
import com.vaadin.shared.annotations.DelegateToWidget; | |||
import com.vaadin.shared.communication.URLReference; | |||
public class AbstractMediaState extends ComponentState { | |||
@@ -39,6 +40,7 @@ public class AbstractMediaState extends ComponentState { | |||
return showControls; | |||
} | |||
@DelegateToWidget("setControls") | |||
public void setShowControls(boolean showControls) { | |||
this.showControls = showControls; | |||
} | |||
@@ -63,6 +65,7 @@ public class AbstractMediaState extends ComponentState { | |||
return autoplay; | |||
} | |||
@DelegateToWidget | |||
public void setAutoplay(boolean autoplay) { | |||
this.autoplay = autoplay; | |||
} | |||
@@ -71,6 +74,7 @@ public class AbstractMediaState extends ComponentState { | |||
return muted; | |||
} | |||
@DelegateToWidget | |||
public void setMuted(boolean muted) { | |||
this.muted = muted; | |||
} |
@@ -19,6 +19,7 @@ import java.io.Serializable; | |||
import com.vaadin.shared.ComponentState; | |||
import com.vaadin.shared.Connector; | |||
import com.vaadin.shared.annotations.DelegateToWidget; | |||
public class AbstractSplitPanelState extends ComponentState { | |||
@@ -120,6 +121,7 @@ public class AbstractSplitPanelState extends ComponentState { | |||
return positionReversed; | |||
} | |||
@DelegateToWidget | |||
public void setPositionReversed(boolean positionReversed) { | |||
this.positionReversed = positionReversed; | |||
} | |||
@@ -128,6 +130,7 @@ public class AbstractSplitPanelState extends ComponentState { | |||
return locked; | |||
} | |||
@DelegateToWidget | |||
public void setLocked(boolean locked) { | |||
this.locked = locked; | |||
} |
@@ -15,6 +15,7 @@ | |||
*/ | |||
package com.vaadin.shared.ui.textarea; | |||
import com.vaadin.shared.annotations.DelegateToWidget; | |||
import com.vaadin.shared.ui.textfield.AbstractTextFieldState; | |||
public class TextAreaState extends AbstractTextFieldState { | |||
@@ -33,6 +34,7 @@ public class TextAreaState extends AbstractTextFieldState { | |||
return rows; | |||
} | |||
@DelegateToWidget | |||
public void setRows(int rows) { | |||
this.rows = rows; | |||
} | |||
@@ -41,6 +43,7 @@ public class TextAreaState extends AbstractTextFieldState { | |||
return wordwrap; | |||
} | |||
@DelegateToWidget | |||
public void setWordwrap(boolean wordwrap) { | |||
this.wordwrap = wordwrap; | |||
} |
@@ -0,0 +1,26 @@ | |||
<?xml version="1.0" encoding="UTF-8"?> | |||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> | |||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> | |||
<head profile="http://selenium-ide.openqa.org/profiles/test-case"> | |||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> | |||
<link rel="selenium.base" href="" /> | |||
<title>New Test</title> | |||
</head> | |||
<body> | |||
<table cellpadding="1" cellspacing="1" border="1"> | |||
<thead> | |||
<tr><td rowspan="1" colspan="3">New Test</td></tr> | |||
</thead><tbody> | |||
<tr> | |||
<td>open</td> | |||
<td>/run/com.vaadin.tests.serialization.DelegateToWidgetTest?restartApplication</td> | |||
<td></td> | |||
</tr> | |||
<tr> | |||
<td>assertText</td> | |||
<td>vaadin=runcomvaadintestsserializationDelegateToWidgetTest::/VVerticalLayout[0]/VVerticalLayout[0]/DelegateWidget[0]</td> | |||
<td>My String<br />42<br />true<br />3.141592653589793</td> | |||
</tr> | |||
</tbody></table> | |||
</body> | |||
</html> |
@@ -0,0 +1,42 @@ | |||
/* | |||
* Copyright 2011 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 | |||
* License for the specific language governing permissions and limitations under | |||
* the License. | |||
*/ | |||
package com.vaadin.tests.serialization; | |||
import com.vaadin.annotations.Widgetset; | |||
import com.vaadin.terminal.WrappedRequest; | |||
import com.vaadin.tests.components.AbstractTestRoot; | |||
import com.vaadin.tests.widgetset.TestingWidgetSet; | |||
import com.vaadin.tests.widgetset.server.DelegateToWidgetComponent; | |||
@Widgetset(TestingWidgetSet.NAME) | |||
public class DelegateToWidgetTest extends AbstractTestRoot { | |||
@Override | |||
protected void setup(WrappedRequest request) { | |||
addComponent(new DelegateToWidgetComponent()); | |||
} | |||
@Override | |||
protected String getTestDescription() { | |||
return "Verifies that @DelegateToWidget has the desired effect"; | |||
} | |||
@Override | |||
protected Integer getTicketNumber() { | |||
return Integer.valueOf(9297); | |||
} | |||
} |
@@ -0,0 +1,21 @@ | |||
/* | |||
* Copyright 2011 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 | |||
* License for the specific language governing permissions and limitations under | |||
* the License. | |||
*/ | |||
package com.vaadin.tests.widgetset; | |||
public class TestingWidgetSet { | |||
public static final String NAME = "com.vaadin.tests.widgetset.TestingWidgetSet"; | |||
} |
@@ -0,0 +1,34 @@ | |||
/* | |||
* Copyright 2011 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 | |||
* License for the specific language governing permissions and limitations under | |||
* the License. | |||
*/ | |||
package com.vaadin.tests.widgetset.client; | |||
import com.vaadin.shared.ui.Connect; | |||
import com.vaadin.terminal.gwt.client.ui.AbstractComponentConnector; | |||
import com.vaadin.tests.widgetset.server.DelegateToWidgetComponent; | |||
@Connect(DelegateToWidgetComponent.class) | |||
public class DelegateConnector extends AbstractComponentConnector { | |||
@Override | |||
public DelegateWidget getWidget() { | |||
return (DelegateWidget) super.getWidget(); | |||
} | |||
@Override | |||
public DelegateState getState() { | |||
return (DelegateState) super.getState(); | |||
} | |||
} |
@@ -0,0 +1,50 @@ | |||
/* | |||
* Copyright 2011 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 | |||
* License for the specific language governing permissions and limitations under | |||
* the License. | |||
*/ | |||
package com.vaadin.tests.widgetset.client; | |||
import com.vaadin.shared.ComponentState; | |||
import com.vaadin.shared.annotations.DelegateToWidget; | |||
public class DelegateState extends ComponentState { | |||
@DelegateToWidget | |||
public String value1; | |||
@DelegateToWidget("setValue2") | |||
public int renamedValue2; | |||
private Boolean value3; | |||
private double renamedValue4; | |||
@DelegateToWidget | |||
public void setValue3(Boolean value3) { | |||
this.value3 = value3; | |||
} | |||
public Boolean getValue3() { | |||
return value3; | |||
} | |||
@DelegateToWidget("setValue4") | |||
public void setRenamedValue4(double renamedValue4) { | |||
this.renamedValue4 = renamedValue4; | |||
} | |||
public double getRenamedValue4() { | |||
return renamedValue4; | |||
} | |||
} |
@@ -0,0 +1,50 @@ | |||
/* | |||
* Copyright 2011 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 | |||
* License for the specific language governing permissions and limitations under | |||
* the License. | |||
*/ | |||
package com.vaadin.tests.widgetset.client; | |||
import com.google.gwt.user.client.ui.HTML; | |||
public class DelegateWidget extends HTML { | |||
private String value1; | |||
private int value2; | |||
private Boolean value3; | |||
private double value4; | |||
public void setValue1(String value1) { | |||
this.value1 = value1; | |||
updateText(); | |||
} | |||
public void setValue2(int value2) { | |||
this.value2 = value2; | |||
updateText(); | |||
} | |||
public void setValue3(Boolean value3) { | |||
this.value3 = value3; | |||
updateText(); | |||
} | |||
public void setValue4(double value4) { | |||
this.value4 = value4; | |||
} | |||
private void updateText() { | |||
setHTML(value1 + "<br />" + value2 + "<br />" + value3 + "<br />" | |||
+ value4 + "<br />"); | |||
} | |||
} |
@@ -0,0 +1,35 @@ | |||
/* | |||
* Copyright 2011 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 | |||
* License for the specific language governing permissions and limitations under | |||
* the License. | |||
*/ | |||
package com.vaadin.tests.widgetset.server; | |||
import com.vaadin.tests.widgetset.client.DelegateState; | |||
import com.vaadin.ui.AbstractComponent; | |||
public class DelegateToWidgetComponent extends AbstractComponent { | |||
public DelegateToWidgetComponent() { | |||
DelegateState state = getState(); | |||
state.value1 = "My String"; | |||
state.renamedValue2 = 42; | |||
state.setValue3(Boolean.TRUE); | |||
state.setRenamedValue4(Math.PI); | |||
} | |||
@Override | |||
protected DelegateState getState() { | |||
return (DelegateState) super.getState(); | |||
} | |||
} |