From 3a0512694e402c0056d2899e0865a4a9eeb2d807 Mon Sep 17 00:00:00 2001 From: Teemu Suo-Anttila Date: Thu, 3 May 2018 15:05:06 +0300 Subject: Promote AbstractComponent setStyleName method to Component (#10873) --- .../main/java/com/vaadin/ui/AbstractComponent.java | 28 ---------------------- server/src/main/java/com/vaadin/ui/Component.java | 28 ++++++++++++++++++++++ 2 files changed, 28 insertions(+), 28 deletions(-) diff --git a/server/src/main/java/com/vaadin/ui/AbstractComponent.java b/server/src/main/java/com/vaadin/ui/AbstractComponent.java index b86fef894f..d900f34872 100644 --- a/server/src/main/java/com/vaadin/ui/AbstractComponent.java +++ b/server/src/main/java/com/vaadin/ui/AbstractComponent.java @@ -255,34 +255,6 @@ 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. - *

- * Functionally this is equivalent to using {@link #addStyleName(String)} or - * {@link #removeStyleName(String)} - * - * @since 7.5 - * @param style - * the style name to be added or removed - * @param add - * true to add the given style, false - * 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. diff --git a/server/src/main/java/com/vaadin/ui/Component.java b/server/src/main/java/com/vaadin/ui/Component.java index acd14886fb..3264ac5070 100644 --- a/server/src/main/java/com/vaadin/ui/Component.java +++ b/server/src/main/java/com/vaadin/ui/Component.java @@ -133,6 +133,34 @@ public interface Component extends ClientConnector, Sizeable { */ public void setStyleName(String style); + /** + * 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. + *

+ * Functionally this is equivalent to using {@link #addStyleName(String)} or + * {@link #removeStyleName(String)} + * + * @since 8.5 + * @param style + * the style name to be added or removed + * @param add + * true to add the given style, false + * to remove it + * @see #addStyleName(String) + * @see #removeStyleName(String) + */ + public default void setStyleName(String style, boolean add) { + if (add) { + addStyleName(style); + } else { + removeStyleName(style); + } + } + /** * Adds one or more style names to this component. Multiple styles can be * specified as a space-separated list of style names. The style name will -- cgit v1.2.3