]> source.dussan.org Git - vaadin-framework.git/commitdiff
Read-only styles shouldn't override borderless background styles. (#11692)
authorAnna Koskinen <Ansku@users.noreply.github.com>
Fri, 16 Aug 2019 10:49:38 +0000 (13:49 +0300)
committerOlli Tietäväinen <ollit@vaadin.com>
Fri, 16 Aug 2019 10:49:38 +0000 (13:49 +0300)
* Read-only styles shouldn't override borderless background styles.

- Fixed for ComboBox and DateField styles, other tested components
already do it right.

Fixes #11671

* Merge branch 'master' into issue11671

14 files changed:
themes/src/main/themes/VAADIN/themes/valo/components/_combobox.scss
themes/src/main/themes/VAADIN/themes/valo/components/_datefield.scss
uitest/src/main/java/com/vaadin/tests/components/uitest/BackgroundColorThemeTestUI.java [new file with mode: 0644]
uitest/src/main/java/com/vaadin/tests/components/uitest/TestSampler.java
uitest/src/main/java/com/vaadin/tests/components/uitest/ThemeTestUI.java
uitest/src/main/java/com/vaadin/tests/components/uitest/components/ButtonsCssTest.java
uitest/src/main/java/com/vaadin/tests/components/uitest/components/DatesCssTest.java
uitest/src/main/java/com/vaadin/tests/components/uitest/components/FormsCssTest.java
uitest/src/main/java/com/vaadin/tests/components/uitest/components/SelectsCssTest.java
uitest/src/main/java/com/vaadin/tests/components/uitest/components/SlidersCssTest.java
uitest/src/main/java/com/vaadin/tests/components/uitest/components/TablesCssTest.java
uitest/src/main/java/com/vaadin/tests/components/uitest/components/TextFieldsCssTest.java
uitest/src/main/java/com/vaadin/tests/components/uitest/components/TreeCssTest.java
uitest/src/main/java/com/vaadin/tests/components/uitest/components/TreeTableCssTest.java

index 8e45fc4afc2a9f6e23fbcee21b922092aa898aa2..21d38e97081fa894709470294bff3fe7bf9c4a53 100644 (file)
         display: none;
       }
     }
+
+    &.borderless {
+      [class*="input"] {
+        @include valo-textfield-borderless-style;
+      }
+    }
   }
 }
 
index 58baa5d6f7a9653aabd88e86e17b2df6048fe657..c94a792d529decf209200b9c2045c785567ed0cf 100644 (file)
         display: none;
       }
     }
+
+    &.borderless {
+      [class*="textfield"] {
+        @include valo-textfield-borderless-style;
+      }
+    }
   }
 }
 
diff --git a/uitest/src/main/java/com/vaadin/tests/components/uitest/BackgroundColorThemeTestUI.java b/uitest/src/main/java/com/vaadin/tests/components/uitest/BackgroundColorThemeTestUI.java
new file mode 100644 (file)
index 0000000..249d479
--- /dev/null
@@ -0,0 +1,19 @@
+package com.vaadin.tests.components.uitest;
+
+public class BackgroundColorThemeTestUI extends ThemeTestUI {
+    @Override
+    protected boolean showAdditionalControlFields() {
+        return true;
+    }
+
+    @Override
+    protected Integer getTicketNumber() {
+        return 11671;
+    }
+
+    @Override
+    protected String getTestDescription() {
+        return super.getTestDescription()
+                + "<br>Read-only styles shouldn't override the transparent background of borderless components.";
+    }
+}
index 19a2148001ef85912db61690d061baabcc04eec9..e368fd29ec99a9b9aef2a60499c68bb4e7ac7955 100644 (file)
@@ -3,6 +3,7 @@ package com.vaadin.tests.components.uitest;
 import java.util.ArrayList;
 import java.util.List;
 
+import com.vaadin.data.HasValue.ValueChangeListener;
 import com.vaadin.tests.components.uitest.components.AccordionsCssTest;
 import com.vaadin.tests.components.uitest.components.ButtonsCssTest;
 import com.vaadin.tests.components.uitest.components.DatesCssTest;
@@ -36,6 +37,7 @@ public class TestSampler extends TabSheet {
     public static final String ICON_URL = "../runo/icons/16/help.png";
 
     private List<Component> components = new ArrayList<>();
+    private List<ValueChangeListener<Boolean>> readOnlyChangeListeners = new ArrayList<ValueChangeListener<Boolean>>();
 
     private ComponentContainer currentTab;
 
@@ -198,4 +200,13 @@ public class TestSampler extends TabSheet {
             c.addStyleName(newStyleName);
         }
     }
+
+    public List<ValueChangeListener<Boolean>> getReadOnlyChangeListeners() {
+        return readOnlyChangeListeners;
+    }
+
+    public void addReadOnlyChangeListener(
+            ValueChangeListener<Boolean> listener) {
+        readOnlyChangeListeners.add(listener);
+    }
 }
index 9355c47ef91caa6215af426896300b3c2b848618..4160444b72336cdfe38b7fdecb284a6c9fd44637 100644 (file)
@@ -1,15 +1,25 @@
 package com.vaadin.tests.components.uitest;
 
+import java.util.Arrays;
+
+import com.vaadin.data.HasValue.ValueChangeListener;
 import com.vaadin.server.VaadinRequest;
 import com.vaadin.tests.components.AbstractReindeerTestUI;
+import com.vaadin.tests.util.TestUtils;
+import com.vaadin.ui.Alignment;
 import com.vaadin.ui.Button;
+import com.vaadin.ui.CheckBox;
+import com.vaadin.ui.ComboBox;
 import com.vaadin.ui.HorizontalLayout;
 import com.vaadin.v7.ui.TextField;
 
+@SuppressWarnings("deprecation")
 public class ThemeTestUI extends AbstractReindeerTestUI {
 
     private TextField customStyle;
     private Button setStyleName;
+    private CheckBox readOnly;
+    private ComboBox<String> bgColor;
     private TestSampler sampler;
     private String customStyleName = null;
 
@@ -23,12 +33,31 @@ public class ThemeTestUI extends AbstractReindeerTestUI {
 
         selectors.addComponent(customStyle);
         selectors.addComponent(setStyleName);
+        if (showAdditionalControlFields()) {
+            selectors.addComponent(readOnly);
+            selectors.setComponentAlignment(readOnly, Alignment.MIDDLE_LEFT);
+            selectors.addComponent(bgColor);
+        }
 
         addComponent(selectors);
 
         sampler = new TestSampler();
+        if (showAdditionalControlFields()) {
+            for (ValueChangeListener<Boolean> listener : sampler
+                    .getReadOnlyChangeListeners()) {
+                readOnly.addValueChangeListener(listener);
+            }
+        }
         addComponent(sampler);
 
+        if (showAdditionalControlFields()) {
+            TestUtils.injectCSS(getLayout().getUI(),
+                    "body .v-app .yellow {background-color: yellow;}");
+        }
+    }
+
+    protected boolean showAdditionalControlFields() {
+        return false;
     }
 
     private void createCustomStyleStringField() {
@@ -37,6 +66,22 @@ public class ThemeTestUI extends AbstractReindeerTestUI {
         setStyleName = new Button("Set stylename",
                 event -> onCustomStyleNameChanged(customStyle.getValue()));
         setStyleName.setId("setcuststyle");
+
+        if (showAdditionalControlFields()) {
+            readOnly = new CheckBox("Set read-only");
+            bgColor = new ComboBox<>(null, Arrays.asList(
+                    "Default sampler background", "Yellow sampler background"));
+            bgColor.setValue("Default sampler background");
+            bgColor.setEmptySelectionAllowed(false);
+            bgColor.setWidth("270px");
+            bgColor.addValueChangeListener(event -> {
+                if ("Yellow sampler background".equals(bgColor.getValue())) {
+                    addStyleName("yellow");
+                } else {
+                    removeStyleName("yellow");
+                }
+            });
+        }
     }
 
     private void onCustomStyleNameChanged(String newStyleName) {
index 0e6d6b1902ac81a9ade7ecbd3ffb426c59a58daf..0660f0ed1e9ecc44ba8e723452ee75ba1dddad22 100644 (file)
@@ -13,6 +13,7 @@ import com.vaadin.v7.ui.themes.ChameleonTheme;
 import com.vaadin.v7.ui.themes.Reindeer;
 import com.vaadin.v7.ui.themes.Runo;
 
+@SuppressWarnings("deprecation")
 public class ButtonsCssTest extends GridLayout {
 
     private TestSampler parent;
@@ -48,14 +49,14 @@ public class ButtonsCssTest extends GridLayout {
         b.setId("button" + debugIdCounter++);
         addComponent(b);
 
-        CheckBox cb = new CheckBox("Checkbox");
-        cb.setId("button" + debugIdCounter++);
-        addComponent(cb);
+        CheckBox cb1 = new CheckBox("Checkbox");
+        cb1.setId("button" + debugIdCounter++);
+        addComponent(cb1);
 
-        cb = new CheckBox("Checkbox with icon");
-        cb.setIcon(new ThemeResource(TestSampler.ICON_URL));
-        cb.setId("button" + debugIdCounter++);
-        addComponent(cb);
+        CheckBox cb2 = new CheckBox("Checkbox with icon");
+        cb2.setIcon(new ThemeResource(TestSampler.ICON_URL));
+        cb2.setId("button" + debugIdCounter++);
+        addComponent(cb2);
 
         Link l = new Link("A link", new ExternalResource(""));
         l.setId("button" + debugIdCounter++);
@@ -76,6 +77,10 @@ public class ButtonsCssTest extends GridLayout {
                 TestSampler.ICON_URL);
         createButtonWith("Down", ChameleonTheme.BUTTON_DOWN, null);
 
+        parent.addReadOnlyChangeListener(event -> {
+            cb1.setReadOnly(!cb1.isReadOnly());
+            cb2.setReadOnly(!cb2.isReadOnly());
+        });
     }
 
     private void createButtonWith(String caption, String primaryStyleName,
index ec35e282c6c954f7d9d2c9ef5d6adbb364cf7a13..118503f02c01206636c7790dfc796630a6264463 100644 (file)
@@ -1,17 +1,20 @@
 package com.vaadin.tests.components.uitest.components;
 
 import java.time.LocalDate;
+import java.util.Iterator;
 
 import com.vaadin.shared.ui.datefield.DateResolution;
 import com.vaadin.tests.components.TestDateField;
 import com.vaadin.tests.components.uitest.TestSampler;
 import com.vaadin.ui.AbstractDateField;
+import com.vaadin.ui.AbstractField;
 import com.vaadin.ui.Component;
 import com.vaadin.ui.DateField;
 import com.vaadin.ui.GridLayout;
 import com.vaadin.ui.InlineDateField;
 import com.vaadin.v7.ui.themes.ChameleonTheme;
 
+@SuppressWarnings("deprecation")
 public class DatesCssTest extends GridLayout {
 
     private TestSampler parent;
@@ -45,6 +48,16 @@ public class DatesCssTest extends GridLayout {
                 "130px");
         createDateFieldWith("Big 130px", ChameleonTheme.DATEFIELD_BIG, "130px");
 
+        parent.addReadOnlyChangeListener(event -> {
+            Iterator<Component> iterator = iterator();
+            while (iterator.hasNext()) {
+                Component c = iterator.next();
+                if (c instanceof AbstractField) {
+                    AbstractField<?> af = (AbstractField<?>) c;
+                    af.setReadOnly(!af.isReadOnly());
+                }
+            }
+        });
     }
 
     private void createDateFieldWith(String caption, String primaryStyleName,
index 81e0a9aa3d449dc68f33083959a8a39f58ea9d38..f07523c0e36f742287236419b7eee0d4845ae747 100644 (file)
@@ -9,6 +9,7 @@ import com.vaadin.v7.data.fieldgroup.BeanFieldGroup;
 import com.vaadin.v7.data.fieldgroup.FieldGroup;
 import com.vaadin.v7.data.util.BeanItem;
 
+@SuppressWarnings("deprecation")
 public class FormsCssTest extends HorizontalLayout {
 
     private TestSampler parent;
@@ -37,6 +38,10 @@ public class FormsCssTest extends HorizontalLayout {
         login.setHeight("150px");
         addComponent(login);
 
+        parent.addReadOnlyChangeListener(event -> {
+            fg.setReadOnly(!fg.isReadOnly());
+            // it's not possible to set LoginForm read-only
+        });
     }
 
     @Override
index 039135c4b278cf7eb61c696e25225301a3ecda8a..6cd23d754390fccffc810b3787e8eb001850b49c 100644 (file)
@@ -1,5 +1,7 @@
 package com.vaadin.tests.components.uitest.components;
 
+import java.util.Iterator;
+
 import com.vaadin.tests.components.uitest.TestSampler;
 import com.vaadin.ui.Component;
 import com.vaadin.ui.GridLayout;
@@ -12,6 +14,7 @@ import com.vaadin.v7.ui.Select;
 import com.vaadin.v7.ui.TwinColSelect;
 import com.vaadin.v7.ui.themes.ChameleonTheme;
 
+@SuppressWarnings("deprecation")
 public class SelectsCssTest extends GridLayout {
 
     private TestSampler parent;
@@ -80,6 +83,17 @@ public class SelectsCssTest extends GridLayout {
                 "100px");
         createComboBoxWith("SelectButton",
                 ChameleonTheme.COMBOBOX_SELECT_BUTTON, "100px");
+
+        parent.addReadOnlyChangeListener(event -> {
+            Iterator<Component> iterator = iterator();
+            while (iterator.hasNext()) {
+                Component c = iterator.next();
+                if (c instanceof AbstractSelect) {
+                    AbstractSelect as = (AbstractSelect) c;
+                    as.setReadOnly(!as.isReadOnly());
+                }
+            }
+        });
     }
 
     private void createComboBoxWith(String caption, String primaryStyleName,
index db6b6fc4bca988da78bf9b5a68ba385e2df7116c..ec3127cd4e2f5865bbf6b8b9b72c3b2877058872 100644 (file)
@@ -9,13 +9,18 @@ public class SlidersCssTest {
     private int debugIdCounter = 0;
 
     public SlidersCssTest(TestSampler parent) {
-        Slider slide = new Slider();
-        slide.setId("slider" + debugIdCounter++);
-        parent.addComponent(slide);
+        Slider slide1 = new Slider();
+        slide1.setId("slider" + debugIdCounter++);
+        parent.addComponent(slide1);
 
-        slide = new Slider();
-        slide.setOrientation(SliderOrientation.VERTICAL);
-        slide.setId("slider" + debugIdCounter++);
-        parent.addComponent(slide);
+        Slider slide2 = new Slider();
+        slide2.setOrientation(SliderOrientation.VERTICAL);
+        slide2.setId("slider" + debugIdCounter++);
+        parent.addComponent(slide2);
+
+        parent.addReadOnlyChangeListener(event -> {
+            slide1.setReadOnly(!slide1.isReadOnly());
+            slide2.setReadOnly(!slide2.isReadOnly());
+        });
     }
 }
index c29bb4be8af2b85caa4bfe3487885c497b591025..e4e78daade8b44b1f497f3e22b4c4884944f70a3 100644 (file)
@@ -1,16 +1,19 @@
 package com.vaadin.tests.components.uitest.components;
 
 import java.util.HashSet;
+import java.util.Iterator;
 
 import com.vaadin.event.Action;
 import com.vaadin.server.ThemeResource;
 import com.vaadin.tests.components.uitest.TestSampler;
 import com.vaadin.tests.util.TestUtils;
+import com.vaadin.ui.Component;
 import com.vaadin.ui.GridLayout;
 import com.vaadin.v7.ui.Table;
 import com.vaadin.v7.ui.themes.ChameleonTheme;
 import com.vaadin.v7.ui.themes.Reindeer;
 
+@SuppressWarnings("deprecation")
 public class TablesCssTest extends GridLayout {
 
     private TestSampler parent;
@@ -37,6 +40,16 @@ public class TablesCssTest extends GridLayout {
         createTableWith("Striped", ChameleonTheme.TABLE_STRIPED);
         createTableWith("Strong", Reindeer.TABLE_STRONG);
 
+        parent.addReadOnlyChangeListener(event -> {
+            Iterator<Component> iterator = iterator();
+            while (iterator.hasNext()) {
+                Component c = iterator.next();
+                if (c instanceof Table) {
+                    Table t = (Table) c;
+                    t.setReadOnly(!t.isReadOnly());
+                }
+            }
+        });
     }
 
     private void createTableWith(String caption, String primaryStyleName) {
index 15001e71892ffbdf415863b8a0451bdf73308783..6a7a06f2085e963ccea12663c5c1fcce1eadb2ec 100644 (file)
@@ -1,6 +1,9 @@
 package com.vaadin.tests.components.uitest.components;
 
+import java.util.Iterator;
+
 import com.vaadin.tests.components.uitest.TestSampler;
+import com.vaadin.ui.AbstractField;
 import com.vaadin.ui.Component;
 import com.vaadin.ui.GridLayout;
 import com.vaadin.ui.PasswordField;
@@ -10,6 +13,7 @@ import com.vaadin.v7.ui.TextArea;
 import com.vaadin.v7.ui.themes.ChameleonTheme;
 import com.vaadin.v7.ui.themes.Reindeer;
 
+@SuppressWarnings("deprecation")
 public class TextFieldsCssTest extends GridLayout {
 
     private TestSampler parent;
@@ -41,6 +45,16 @@ public class TextFieldsCssTest extends GridLayout {
         rta.setId("textfield" + debugIdCounter++);
         addComponent(rta, 0, 1, 6, 1);
 
+        parent.addReadOnlyChangeListener(event -> {
+            Iterator<Component> iterator = iterator();
+            while (iterator.hasNext()) {
+                Component c = iterator.next();
+                if (c instanceof AbstractField) {
+                    AbstractField<?> af = (AbstractField<?>) c;
+                    af.setReadOnly(!af.isReadOnly());
+                }
+            }
+        });
     }
 
     private void createTextFieldWith(String caption, String primaryStyleName,
index 25f475018bb33c8361cba766caa81a6cac1ce8a6..bfe50850a85305126d2fa08d1d5ce0eba683e549 100644 (file)
@@ -6,6 +6,7 @@ import com.vaadin.v7.data.Item;
 import com.vaadin.v7.data.util.HierarchicalContainer;
 import com.vaadin.v7.ui.Tree;
 
+@SuppressWarnings("deprecation")
 public class TreeCssTest {
     private int debugIdCounter = 0;
 
@@ -45,6 +46,9 @@ public class TreeCssTest {
         }
 
         parent.addComponent(tree);
+
+        parent.addReadOnlyChangeListener(
+                event -> tree.setReadOnly(!tree.isReadOnly()));
     }
 
     private HierarchicalContainer createHierarchicalContainer() {
index 097fa979e06812c67237b231a262895d6454203d..ca42a45b54264d9d7d0b90eaa1670afe67270882 100644 (file)
@@ -5,6 +5,7 @@ import com.vaadin.v7.data.Item;
 import com.vaadin.v7.data.util.HierarchicalContainer;
 import com.vaadin.v7.ui.TreeTable;
 
+@SuppressWarnings("deprecation")
 public class TreeTableCssTest {
     private int debugIdCounter = 0;
 
@@ -12,6 +13,7 @@ public class TreeTableCssTest {
         TreeTable treeTable = new TreeTable();
         treeTable.setId("treetable" + debugIdCounter++);
         treeTable.setWidth("100%");
+        treeTable.setSelectable(true);
         parent.addComponent(treeTable);
 
         HierarchicalContainer hc = createHierarchicalContainer();
@@ -21,6 +23,9 @@ public class TreeTableCssTest {
         for (Object itemId : treeTable.getItemIds()) {
             treeTable.setCollapsed(itemId, false);
         }
+
+        parent.addReadOnlyChangeListener(
+                event -> treeTable.setReadOnly(!treeTable.isReadOnly()));
     }
 
     private HierarchicalContainer createHierarchicalContainer() {