]> source.dussan.org Git - vaadin-framework.git/commitdiff
Add primary style name support for ProgressBar/Indicator (#9913)
authorArtur Signell <artur@vaadin.com>
Tue, 28 May 2013 16:52:21 +0000 (19:52 +0300)
committerVaadin Code Review <review@vaadin.com>
Wed, 29 May 2013 13:42:04 +0000 (13:42 +0000)
Change-Id: I3d773640d2f1c8cd1b71c673685afd7059811d16

12 files changed:
WebContent/VAADIN/themes/base/base.scss
WebContent/VAADIN/themes/chameleon/components/components.scss
WebContent/VAADIN/themes/liferay/liferay.scss
WebContent/VAADIN/themes/reindeer/reindeer.scss
WebContent/VAADIN/themes/runo/runo.scss
client/src/com/vaadin/client/ui/VProgressBar.java
client/src/com/vaadin/client/ui/VProgressIndicator.java
shared/src/com/vaadin/shared/ui/progressindicator/ProgressBarState.java
shared/src/com/vaadin/shared/ui/progressindicator/ProgressIndicatorState.java
uitest/src/com/vaadin/tests/components/AbstractComponentTestCase.java
uitest/src/com/vaadin/tests/components/progressindicator/ProgressBarGenericTest.java [new file with mode: 0644]
uitest/src/com/vaadin/tests/components/progressindicator/ProgressBarPrimaryStyleName.html [new file with mode: 0644]

index 83e463fa0004c32fa42164ae52a86c373136e7d2..514579830db18b459dcce9f42e99449ba45cb9ba 100644 (file)
@@ -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;
index 9f29827de034582e02737d66ab8cb18ffc83fa59..9c8a56b33da2291b94c9856407f884f6ef6dfcf0 100644 (file)
        @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;
index 7d7665ad865e98a3d56071a4b9ec04c94ebe4919..273c0657723f4746187e7d3d11116b0427dcbbd0 100644 (file)
@@ -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;
index 3cf1c392e35dbc36206c0b5f377fd0f287e02754..485839ecc7a0078a3fcfa88c7fb94f5c30aa943f 100644 (file)
@@ -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;
index 6e88b14eb44c81ffce5891bdb404684084ff6ccb..33ad35a8af555f9ceb854743e005cfbfe85d7fd7 100644 (file)
@@ -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;
index 3eb872552064435191f2bb42bade39852db1e5d8..8cfc28005ca5081e85651828e24681f5f89630a5 100644 (file)
@@ -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);
     }
 
 }
index 500a5def30924397d5966139dc595060872dd02f..c75113b5f4496942377f61f071a5d07c1885f556 100644 (file)
@@ -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);
+    }
 }
index fef1030c63b6c42bac7696706eea9db082ea0ee4..1cc8d7d9aef0076d4898c834fd581f0a93b6b64b 100644 (file)
@@ -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;
 
index f555476be8e7569b13aba0b759dabd60102c2f37..2ca7627f4f2e7dbb0ae1f607b0ae3d89bbbea087 100644 (file)
@@ -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;
 }
index 81ec4a9da4af07bb203256912864320b210663f5..8666956bdb0b48d9886ab1728162b45a8ece762b 100644 (file)
@@ -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 (file)
index 0000000..79797c6
--- /dev/null
@@ -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 (file)
index 0000000..92f6789
--- /dev/null
@@ -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>