From: Artur Signell Date: Tue, 28 May 2013 16:52:21 +0000 (+0300) Subject: Add primary style name support for ProgressBar/Indicator (#9913) X-Git-Tag: 7.1.0~90^2~18 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=a5b8209d928815aab9eee2151bdd00686a2b0ff7;p=vaadin-framework.git Add primary style name support for ProgressBar/Indicator (#9913) Change-Id: I3d773640d2f1c8cd1b71c673685afd7059811d16 --- diff --git a/WebContent/VAADIN/themes/base/base.scss b/WebContent/VAADIN/themes/base/base.scss index 83e463fa00..514579830d 100644 --- a/WebContent/VAADIN/themes/base/base.scss +++ b/WebContent/VAADIN/themes/base/base.scss @@ -88,7 +88,10 @@ $line-height: normal; @include base-orderedlayout; @include base-panel; @include base-popupview; - @include base-progressindicator; + @include base-progressindicator(v-progressbar); + /* For legacy ProgressIndicator component */ + @include base-progressindicator(v-progressindicator); + @include base-select; @include base-shadow; @include base-slider; diff --git a/WebContent/VAADIN/themes/chameleon/components/components.scss b/WebContent/VAADIN/themes/chameleon/components/components.scss index 9f29827de0..9c8a56b33d 100644 --- a/WebContent/VAADIN/themes/chameleon/components/components.scss +++ b/WebContent/VAADIN/themes/chameleon/components/components.scss @@ -29,7 +29,11 @@ @include chameleon-notification; @include chameleon-panel; @include chameleon-popupview; - @include chameleon-progressindicator; + + @include chameleon-progressindicator(v-progressbar); + /* For legacy ProgressIndicator component */ + @include chameleon-progressindicator(v-progressindicator); + @include chameleon-slider; @include chameleon-splitpanel; @include chameleon-table; diff --git a/WebContent/VAADIN/themes/liferay/liferay.scss b/WebContent/VAADIN/themes/liferay/liferay.scss index 7d7665ad86..273c065772 100644 --- a/WebContent/VAADIN/themes/liferay/liferay.scss +++ b/WebContent/VAADIN/themes/liferay/liferay.scss @@ -42,7 +42,9 @@ @include liferay-notification; @include liferay-panel; @include liferay-popupview; - @include liferay-progressindicator; + @include liferay-progressindicator(v-progressbar); + /* For legacy ProgressIndicator component */ + @include liferay-progressindicator(v-progressindicator); @include liferay-select; @include liferay-slider; @include liferay-splitpanel; diff --git a/WebContent/VAADIN/themes/reindeer/reindeer.scss b/WebContent/VAADIN/themes/reindeer/reindeer.scss index 3cf1c392e3..485839ecc7 100644 --- a/WebContent/VAADIN/themes/reindeer/reindeer.scss +++ b/WebContent/VAADIN/themes/reindeer/reindeer.scss @@ -56,7 +56,10 @@ $line-height: normal; @include reindeer-notification; @include reindeer-panel; @include reindeer-popupview; - @include reindeer-progressindicator; + @include reindeer-progressindicator(v-progressbar); + /* For legacy ProgressIndicator component */ + @include reindeer-progressindicator(v-progressindicator); + @include reindeer-select; @include reindeer-slider; @include reindeer-splitpanel; diff --git a/WebContent/VAADIN/themes/runo/runo.scss b/WebContent/VAADIN/themes/runo/runo.scss index 6e88b14eb4..33ad35a8af 100644 --- a/WebContent/VAADIN/themes/runo/runo.scss +++ b/WebContent/VAADIN/themes/runo/runo.scss @@ -58,7 +58,11 @@ $line-height: 18px; @include runo-orderedlayout; @include runo-panel; @include runo-popupview; - @include runo-progressindicator; + + @include runo-progressindicator(v-progressbar); + /* For legacy ProgressIndicator component */ + @include runo-progressindicator(v-progressindicator); + @include runo-select; @include runo-shadow; @include runo-slider; 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); + } } diff --git a/shared/src/com/vaadin/shared/ui/progressindicator/ProgressBarState.java b/shared/src/com/vaadin/shared/ui/progressindicator/ProgressBarState.java index fef1030c63..1cc8d7d9ae 100644 --- a/shared/src/com/vaadin/shared/ui/progressindicator/ProgressBarState.java +++ b/shared/src/com/vaadin/shared/ui/progressindicator/ProgressBarState.java @@ -26,7 +26,11 @@ import com.vaadin.shared.communication.SharedState; * @author Vaadin Ltd */ public class ProgressBarState extends AbstractFieldState { + public static final String PRIMARY_STYLE_NAME = "v-progressbar"; + { + primaryStyleName = PRIMARY_STYLE_NAME; + } public boolean indeterminate = false; public Float state = 0.0f; diff --git a/shared/src/com/vaadin/shared/ui/progressindicator/ProgressIndicatorState.java b/shared/src/com/vaadin/shared/ui/progressindicator/ProgressIndicatorState.java index f555476be8..2ca7627f4f 100644 --- a/shared/src/com/vaadin/shared/ui/progressindicator/ProgressIndicatorState.java +++ b/shared/src/com/vaadin/shared/ui/progressindicator/ProgressIndicatorState.java @@ -17,5 +17,11 @@ package com.vaadin.shared.ui.progressindicator; @Deprecated public class ProgressIndicatorState extends ProgressBarState { + public static final String PRIMARY_STYLE_NAME = "v-progressindicator"; + + { + primaryStyleName = PRIMARY_STYLE_NAME; + } + public int pollingInterval = 1000; } diff --git a/uitest/src/com/vaadin/tests/components/AbstractComponentTestCase.java b/uitest/src/com/vaadin/tests/components/AbstractComponentTestCase.java index 81ec4a9da4..8666956bdb 100644 --- a/uitest/src/com/vaadin/tests/components/AbstractComponentTestCase.java +++ b/uitest/src/com/vaadin/tests/components/AbstractComponentTestCase.java @@ -226,6 +226,13 @@ public abstract class AbstractComponentTestCase } }; + protected Command primaryStyleNameCommand = new Command() { + @Override + public void execute(T c, String value, Object data) { + c.setPrimaryStyleName(value); + } + }; + @Override protected String getDescription() { return "Generic test case for " + getTestClass().getSimpleName(); diff --git a/uitest/src/com/vaadin/tests/components/progressindicator/ProgressBarGenericTest.java b/uitest/src/com/vaadin/tests/components/progressindicator/ProgressBarGenericTest.java new file mode 100644 index 0000000000..79797c60a2 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/progressindicator/ProgressBarGenericTest.java @@ -0,0 +1,55 @@ +package com.vaadin.tests.components.progressindicator; + +import java.util.LinkedHashMap; + +import com.vaadin.tests.components.abstractfield.AbstractFieldTest; +import com.vaadin.ui.ProgressBar; + +public class ProgressBarGenericTest extends AbstractFieldTest { + + private Command indeterminate = new Command() { + + @Override + public void execute(ProgressBar c, Boolean value, Object data) { + c.setIndeterminate(value); + } + }; + + @Override + protected Class getTestClass() { + return ProgressBar.class; + } + + @Override + protected void createActions() { + super.createActions(); + createBooleanAction("Indeterminate", CATEGORY_FEATURES, false, + indeterminate, null); + createValueSelection(CATEGORY_FEATURES); + createPrimaryStyleNameSelect(); + } + + /** + * @since + */ + protected void createPrimaryStyleNameSelect() { + LinkedHashMap options = new LinkedHashMap(); + String primaryStyle = getComponent().getPrimaryStyleName(); + options.put(primaryStyle, primaryStyle); + options.put(primaryStyle + "-foo", primaryStyle + "-foo"); + options.put("foo", "foo"); + createSelectAction("Primary style name", CATEGORY_DECORATIONS, options, + primaryStyle, primaryStyleNameCommand); + + } + + private void createValueSelection(String categorySelection) { + LinkedHashMap options = new LinkedHashMap(); + options.put("null", null); + for (float f = 0; f <= 1; f += 0.1) { + options.put("" + f, f); + } + createSelectAction("Value", categorySelection, options, null, + setValueCommand); + } +} diff --git a/uitest/src/com/vaadin/tests/components/progressindicator/ProgressBarPrimaryStyleName.html b/uitest/src/com/vaadin/tests/components/progressindicator/ProgressBarPrimaryStyleName.html new file mode 100644 index 0000000000..92f678947a --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/progressindicator/ProgressBarPrimaryStyleName.html @@ -0,0 +1,121 @@ + + + + + + +New Test + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
New Test
open/run/com.vaadin.tests.components.progressindicator.ProgressBarGenericTest?restartApplication
assertCSSClassvaadin=runcomvaadintestscomponentsprogressindicatorProgressBarGenericTest::PID_StestComponentv-progressbar
assertCSSClassvaadin=runcomvaadintestscomponentsprogressindicatorProgressBarGenericTest::PID_StestComponent/domChild[0]v-progressbar-wrapper
assertCSSClassvaadin=runcomvaadintestscomponentsprogressindicatorProgressBarGenericTest::PID_StestComponent/domChild[0]/domChild[0]v-progressbar-indicator
mouseClickvaadin=runcomvaadintestscomponentsprogressindicatorProgressBarGenericTest::PID_Smenu#item036,8
mouseClickvaadin=runcomvaadintestscomponentsprogressindicatorProgressBarGenericTest::Root/VOverlay[0]/VMenuBar[0]#item145,4
mouseClickvaadin=runcomvaadintestscomponentsprogressindicatorProgressBarGenericTest::Root/VOverlay[1]/VMenuBar[0]#item667,10
mouseClickvaadin=runcomvaadintestscomponentsprogressindicatorProgressBarGenericTest::Root/VOverlay[2]/VMenuBar[0]#item237,7
assertNotCSSClassvaadin=runcomvaadintestscomponentsprogressindicatorProgressBarGenericTest::PID_StestComponentv-progressbar
assertCSSClassvaadin=runcomvaadintestscomponentsprogressindicatorProgressBarGenericTest::PID_StestComponentfoo
assertNotCSSClassvaadin=runcomvaadintestscomponentsprogressindicatorProgressBarGenericTest::PID_StestComponent/domChild[0]v-progressbar-wrapper
assertCSSClassvaadin=runcomvaadintestscomponentsprogressindicatorProgressBarGenericTest::PID_StestComponent/domChild[0]foo-wrapper
assertNotCSSClassvaadin=runcomvaadintestscomponentsprogressindicatorProgressBarGenericTest::PID_StestComponent/domChild[0]/domChild[0]v-progressbar-indicator
assertCSSClassvaadin=runcomvaadintestscomponentsprogressindicatorProgressBarGenericTest::PID_StestComponent/domChild[0]/domChild[0]foo-indicator
mouseClickvaadin=runcomvaadintestscomponentsprogressindicatorProgressBarGenericTest::PID_Smenu#item020,13
mouseClickvaadin=runcomvaadintestscomponentsprogressindicatorProgressBarGenericTest::Root/VOverlay[0]/VMenuBar[0]#item134,11
mouseClickvaadin=runcomvaadintestscomponentsprogressindicatorProgressBarGenericTest::Root/VOverlay[1]/VMenuBar[0]#item651,4
mouseClickvaadin=runcomvaadintestscomponentsprogressindicatorProgressBarGenericTest::Root/VOverlay[2]/VMenuBar[0]#item038,6
assertCSSClassvaadin=runcomvaadintestscomponentsprogressindicatorProgressBarGenericTest::PID_StestComponentv-progressbar
assertCSSClassvaadin=runcomvaadintestscomponentsprogressindicatorProgressBarGenericTest::PID_StestComponent/domChild[0]v-progressbar-wrapper
assertCSSClassvaadin=runcomvaadintestscomponentsprogressindicatorProgressBarGenericTest::PID_StestComponent/domChild[0]/domChild[0]v-progressbar-indicator
+ +