diff options
author | Artur Signell <artur@vaadin.com> | 2013-05-28 19:52:21 +0300 |
---|---|---|
committer | Vaadin Code Review <review@vaadin.com> | 2013-05-29 13:42:04 +0000 |
commit | a5b8209d928815aab9eee2151bdd00686a2b0ff7 (patch) | |
tree | 8a0cd2d8bbe50dbdeb156b64af0c3883df5622a7 | |
parent | 91182e237f2f4f8784582887970c32b5be3ad7c5 (diff) | |
download | vaadin-framework-a5b8209d928815aab9eee2151bdd00686a2b0ff7.tar.gz vaadin-framework-a5b8209d928815aab9eee2151bdd00686a2b0ff7.zip |
Add primary style name support for ProgressBar/Indicator (#9913)
Change-Id: I3d773640d2f1c8cd1b71c673685afd7059811d16
12 files changed, 243 insertions, 14 deletions
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<T extends AbstractComponent> } }; + protected Command<T, String> primaryStyleNameCommand = new Command<T, String>() { + @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<ProgressBar> { + + private Command<ProgressBar, Boolean> indeterminate = new Command<ProgressBar, Boolean>() { + + @Override + public void execute(ProgressBar c, Boolean value, Object data) { + c.setIndeterminate(value); + } + }; + + @Override + protected Class<ProgressBar> 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<String, String> options = new LinkedHashMap<String, String>(); + 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<String, Object> options = new LinkedHashMap<String, Object>(); + 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 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> +<head profile="http://selenium-ide.openqa.org/profiles/test-case"> +<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> +<link rel="selenium.base" href="http://localhost:8888/" /> +<title>New Test</title> +</head> +<body> +<table cellpadding="1" cellspacing="1" border="1"> +<thead> +<tr><td rowspan="1" colspan="3">New Test</td></tr> +</thead><tbody> +<tr> + <td>open</td> + <td>/run/com.vaadin.tests.components.progressindicator.ProgressBarGenericTest?restartApplication</td> + <td></td> +</tr> +<tr> + <td>assertCSSClass</td> + <td>vaadin=runcomvaadintestscomponentsprogressindicatorProgressBarGenericTest::PID_StestComponent</td> + <td>v-progressbar</td> +</tr> +<tr> + <td>assertCSSClass</td> + <td>vaadin=runcomvaadintestscomponentsprogressindicatorProgressBarGenericTest::PID_StestComponent/domChild[0]</td> + <td>v-progressbar-wrapper</td> +</tr> +<tr> + <td>assertCSSClass</td> + <td>vaadin=runcomvaadintestscomponentsprogressindicatorProgressBarGenericTest::PID_StestComponent/domChild[0]/domChild[0]</td> + <td>v-progressbar-indicator</td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentsprogressindicatorProgressBarGenericTest::PID_Smenu#item0</td> + <td>36,8</td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentsprogressindicatorProgressBarGenericTest::Root/VOverlay[0]/VMenuBar[0]#item1</td> + <td>45,4</td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentsprogressindicatorProgressBarGenericTest::Root/VOverlay[1]/VMenuBar[0]#item6</td> + <td>67,10</td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentsprogressindicatorProgressBarGenericTest::Root/VOverlay[2]/VMenuBar[0]#item2</td> + <td>37,7</td> +</tr> +<tr> + <td>assertNotCSSClass</td> + <td>vaadin=runcomvaadintestscomponentsprogressindicatorProgressBarGenericTest::PID_StestComponent</td> + <td>v-progressbar</td> +</tr> +<tr> + <td>assertCSSClass</td> + <td>vaadin=runcomvaadintestscomponentsprogressindicatorProgressBarGenericTest::PID_StestComponent</td> + <td>foo</td> +</tr> +<tr> + <td>assertNotCSSClass</td> + <td>vaadin=runcomvaadintestscomponentsprogressindicatorProgressBarGenericTest::PID_StestComponent/domChild[0]</td> + <td>v-progressbar-wrapper</td> +</tr> +<tr> + <td>assertCSSClass</td> + <td>vaadin=runcomvaadintestscomponentsprogressindicatorProgressBarGenericTest::PID_StestComponent/domChild[0]</td> + <td>foo-wrapper</td> +</tr> +<tr> + <td>assertNotCSSClass</td> + <td>vaadin=runcomvaadintestscomponentsprogressindicatorProgressBarGenericTest::PID_StestComponent/domChild[0]/domChild[0]</td> + <td>v-progressbar-indicator</td> +</tr> +<tr> + <td>assertCSSClass</td> + <td>vaadin=runcomvaadintestscomponentsprogressindicatorProgressBarGenericTest::PID_StestComponent/domChild[0]/domChild[0]</td> + <td>foo-indicator</td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentsprogressindicatorProgressBarGenericTest::PID_Smenu#item0</td> + <td>20,13</td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentsprogressindicatorProgressBarGenericTest::Root/VOverlay[0]/VMenuBar[0]#item1</td> + <td>34,11</td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentsprogressindicatorProgressBarGenericTest::Root/VOverlay[1]/VMenuBar[0]#item6</td> + <td>51,4</td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentsprogressindicatorProgressBarGenericTest::Root/VOverlay[2]/VMenuBar[0]#item0</td> + <td>38,6</td> +</tr> +<tr> + <td>assertCSSClass</td> + <td>vaadin=runcomvaadintestscomponentsprogressindicatorProgressBarGenericTest::PID_StestComponent</td> + <td>v-progressbar</td> +</tr> +<tr> + <td>assertCSSClass</td> + <td>vaadin=runcomvaadintestscomponentsprogressindicatorProgressBarGenericTest::PID_StestComponent/domChild[0]</td> + <td>v-progressbar-wrapper</td> +</tr> +<tr> + <td>assertCSSClass</td> + <td>vaadin=runcomvaadintestscomponentsprogressindicatorProgressBarGenericTest::PID_StestComponent/domChild[0]/domChild[0]</td> + <td>v-progressbar-indicator</td> +</tr> +</tbody></table> +</body> +</html> |