From a5b8209d928815aab9eee2151bdd00686a2b0ff7 Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Tue, 28 May 2013 19:52:21 +0300 Subject: Add primary style name support for ProgressBar/Indicator (#9913) Change-Id: I3d773640d2f1c8cd1b71c673685afd7059811d16 --- client/src/com/vaadin/client/ui/VProgressBar.java | 32 ++++++++++++++++------ .../com/vaadin/client/ui/VProgressIndicator.java | 6 ++++ 2 files changed, 29 insertions(+), 9 deletions(-) (limited to 'client/src') diff --git a/client/src/com/vaadin/client/ui/VProgressBar.java b/client/src/com/vaadin/client/ui/VProgressBar.java index 3eb8725520..8cfc28005c 100644 --- a/client/src/com/vaadin/client/ui/VProgressBar.java +++ b/client/src/com/vaadin/client/ui/VProgressBar.java @@ -21,6 +21,8 @@ import com.google.gwt.user.client.DOM; import com.google.gwt.user.client.Element; import com.google.gwt.user.client.ui.HasEnabled; import com.google.gwt.user.client.ui.Widget; +import com.vaadin.client.ApplicationConnection; +import com.vaadin.shared.ui.progressindicator.ProgressBarState; /** * Widget for showing the current progress of a long running task. @@ -35,26 +37,39 @@ import com.google.gwt.user.client.ui.Widget; */ public class VProgressBar extends Widget implements HasEnabled { - public static final String CLASSNAME = "v-progressindicator"; Element wrapper = DOM.createDiv(); Element indicator = DOM.createDiv(); - protected boolean indeterminate = false; - protected float state = 0.0f; + private boolean indeterminate = false; + private float state = 0.0f; private boolean enabled; public VProgressBar() { setElement(DOM.createDiv()); getElement().appendChild(wrapper); - setStyleName(CLASSNAME); wrapper.appendChild(indicator); - indicator.setClassName(CLASSNAME + "-indicator"); - wrapper.setClassName(CLASSNAME + "-wrapper"); + + setStylePrimaryName(ProgressBarState.PRIMARY_STYLE_NAME); + } + + /* + * (non-Javadoc) + * + * @see + * com.google.gwt.user.client.ui.UIObject#setStylePrimaryName(java.lang. + * String) + */ + @Override + public void setStylePrimaryName(String style) { + super.setStylePrimaryName(style); + indicator.setClassName(getStylePrimaryName() + "-indicator"); + wrapper.setClassName(getStylePrimaryName() + "-wrapper"); + } public void setIndeterminate(boolean indeterminate) { this.indeterminate = indeterminate; - setStyleName(CLASSNAME + "-indeterminate", indeterminate); + setStyleName(getStylePrimaryName() + "-indeterminate", indeterminate); } public void setState(float state) { @@ -78,8 +93,7 @@ public class VProgressBar extends Widget implements HasEnabled { @Override public void setEnabled(boolean enabled) { this.enabled = enabled; - setStyleName("v-disabled", !enabled); - + setStyleName(ApplicationConnection.DISABLED_CLASSNAME, !enabled); } } diff --git a/client/src/com/vaadin/client/ui/VProgressIndicator.java b/client/src/com/vaadin/client/ui/VProgressIndicator.java index 500a5def30..c75113b5f4 100644 --- a/client/src/com/vaadin/client/ui/VProgressIndicator.java +++ b/client/src/com/vaadin/client/ui/VProgressIndicator.java @@ -16,6 +16,8 @@ package com.vaadin.client.ui; +import com.vaadin.shared.ui.progressindicator.ProgressIndicatorState; + /** * * @author Vaadin Ltd @@ -25,4 +27,8 @@ package com.vaadin.client.ui; @Deprecated public class VProgressIndicator extends VProgressBar { + public VProgressIndicator() { + super(); + setStylePrimaryName(ProgressIndicatorState.PRIMARY_STYLE_NAME); + } } -- cgit v1.2.3