diff options
author | Leif Åstrand <leif@vaadin.com> | 2012-08-24 11:25:05 +0300 |
---|---|---|
committer | Leif Åstrand <leif@vaadin.com> | 2012-08-24 11:25:26 +0300 |
commit | 38ffd4a097094a01c35fbd5b79563e6c8ea02e92 (patch) | |
tree | 90b07bee9ff39dfcebe51909fb63bd1c782611dd /shared | |
parent | 52986fdf881260994e5465012af2afd80447b8b6 (diff) | |
download | vaadin-framework-38ffd4a097094a01c35fbd5b79563e6c8ea02e92.tar.gz vaadin-framework-38ffd4a097094a01c35fbd5b79563e6c8ea02e92.zip |
Make it possible to delegate state changes to widget (#9297)
Diffstat (limited to 'shared')
4 files changed, 35 insertions, 0 deletions
diff --git a/shared/src/com/vaadin/shared/annotations/DelegateToWidget.java b/shared/src/com/vaadin/shared/annotations/DelegateToWidget.java new file mode 100644 index 0000000000..0ac16ecea9 --- /dev/null +++ b/shared/src/com/vaadin/shared/annotations/DelegateToWidget.java @@ -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; + } + } +} diff --git a/shared/src/com/vaadin/shared/ui/AbstractMediaState.java b/shared/src/com/vaadin/shared/ui/AbstractMediaState.java index 2731529caf..80d41dd797 100644 --- a/shared/src/com/vaadin/shared/ui/AbstractMediaState.java +++ b/shared/src/com/vaadin/shared/ui/AbstractMediaState.java @@ -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; } diff --git a/shared/src/com/vaadin/shared/ui/splitpanel/AbstractSplitPanelState.java b/shared/src/com/vaadin/shared/ui/splitpanel/AbstractSplitPanelState.java index 46eb851edd..71f789b70d 100644 --- a/shared/src/com/vaadin/shared/ui/splitpanel/AbstractSplitPanelState.java +++ b/shared/src/com/vaadin/shared/ui/splitpanel/AbstractSplitPanelState.java @@ -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; } diff --git a/shared/src/com/vaadin/shared/ui/textarea/TextAreaState.java b/shared/src/com/vaadin/shared/ui/textarea/TextAreaState.java index 31cec77554..50dc1393a3 100644 --- a/shared/src/com/vaadin/shared/ui/textarea/TextAreaState.java +++ b/shared/src/com/vaadin/shared/ui/textarea/TextAreaState.java @@ -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; } |