diff options
author | Artur Signell <artur@vaadin.com> | 2015-05-15 15:55:59 +0300 |
---|---|---|
committer | Vaadin Code Review <review@vaadin.com> | 2015-06-05 14:18:22 +0000 |
commit | d5381626ec2e058ac7fb31c4af789b248df92669 (patch) | |
tree | 6cbb02399773bde339e32dd196eab7f099e322c5 /server | |
parent | b6c30ed3c070eefdcb7e26d490e6d82c165ad8f3 (diff) | |
download | vaadin-framework-d5381626ec2e058ac7fb31c4af789b248df92669.tar.gz vaadin-framework-d5381626ec2e058ac7fb31c4af789b248df92669.zip |
Add setStyleName(String, boolean) shorthand for add/removeStyleName (#17825)
Change-Id: I91f4faae3e40ad4cd2b3037ce64d8776f61c004e
Diffstat (limited to 'server')
-rw-r--r-- | server/src/com/vaadin/ui/AbstractComponent.java | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/server/src/com/vaadin/ui/AbstractComponent.java b/server/src/com/vaadin/ui/AbstractComponent.java index 27d97d5e03..338898372a 100644 --- a/server/src/com/vaadin/ui/AbstractComponent.java +++ b/server/src/com/vaadin/ui/AbstractComponent.java @@ -243,6 +243,34 @@ public abstract class AbstractComponent extends AbstractClientConnector } } + /** + * Adds or removes a style name. Multiple styles can be specified as a + * space-separated list of style names. + * + * If the {@code add} parameter is true, the style name is added to the + * component. If the {@code add} parameter is false, the style name is + * removed from the component. + * <p> + * Functionally this is equivalent to using {@link #addStyleName(String)} or + * {@link #removeStyleName(String)} + * + * @since + * @param style + * the style name to be added or removed + * @param add + * <code>true</code> to add the given style, <code>false</code> + * to remove it + * @see #addStyleName(String) + * @see #removeStyleName(String) + */ + public void setStyleName(String style, boolean add) { + if (add) { + addStyleName(style); + } else { + removeStyleName(style); + } + } + /* * Get's the component's caption. Don't add a JavaDoc comment here, we use * the default documentation from implemented interface. |