aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArtur Signell <artur@vaadin.com>2016-02-07 18:30:54 +0200
committerTeemu Suo-Anttila <teemusa@vaadin.com>2016-05-11 14:47:08 +0300
commitb3b5c062b02ca5edfc5527090c027145704ee51a (patch)
tree138766400e5e6c20cdec27fa3df2777c75570ef1
parent19ad71e9e21dfea2dd756f96e473e00c3077f35a (diff)
downloadvaadin-framework-b3b5c062b02ca5edfc5527090c027145704ee51a.tar.gz
vaadin-framework-b3b5c062b02ca5edfc5527090c027145704ee51a.zip
Use error styles for NativeSelect/ListSelect/TwinColSelect in Valo (#19550)
Change-Id: Ifc87f48b8145b56c7b83b9ce4aa1db8a698d7d49
-rw-r--r--all/src/main/templates/release-notes.html1
-rw-r--r--themes/src/main/themes/VAADIN/themes/valo/components/_nativeselect.scss7
-rw-r--r--themes/src/main/themes/VAADIN/themes/valo/components/_twincolselect.scss7
-rw-r--r--uitest/src/main/java/com/vaadin/tests/validation/FieldErrorIndication.java115
4 files changed, 128 insertions, 2 deletions
diff --git a/all/src/main/templates/release-notes.html b/all/src/main/templates/release-notes.html
index 437b0d5d00..8c2a7d653e 100644
--- a/all/src/main/templates/release-notes.html
+++ b/all/src/main/templates/release-notes.html
@@ -114,6 +114,7 @@
<li>System properties now override application parameters for settings such as production mode (see above).</li>
<li>The return type of BootstrapHandler.getWidgetsetForUI() has changed.</li>
<li>Vaadin shared no longer depends on a custom build of Guava. Any project that depends on Guava as a transitive dependency should use standard Guava.</li>
+ <li>Valo theme field error styles now apply to NativeSelect, ListSelect and TwinColSelect as well.</li>
</ul>
<h3 id="knownissues">Known Issues and Limitations</h3>
<ul>
diff --git a/themes/src/main/themes/VAADIN/themes/valo/components/_nativeselect.scss b/themes/src/main/themes/VAADIN/themes/valo/components/_nativeselect.scss
index d0b2caf745..b747b0bb54 100644
--- a/themes/src/main/themes/VAADIN/themes/valo/components/_nativeselect.scss
+++ b/themes/src/main/themes/VAADIN/themes/valo/components/_nativeselect.scss
@@ -23,10 +23,13 @@
}
}
}
+ .#{$primary-stylename}-error {
+ .#{$primary-stylename}-select {
+ @include valo-textfield-error-style;
+ }
+ }
}
-
-
/**
*
*
diff --git a/themes/src/main/themes/VAADIN/themes/valo/components/_twincolselect.scss b/themes/src/main/themes/VAADIN/themes/valo/components/_twincolselect.scss
index 51063e236f..1d9a7e773e 100644
--- a/themes/src/main/themes/VAADIN/themes/valo/components/_twincolselect.scss
+++ b/themes/src/main/themes/VAADIN/themes/valo/components/_twincolselect.scss
@@ -78,6 +78,13 @@
}
}
+ .#{$primary-stylename}-error {
+ .#{$primary-stylename}-options,
+ .#{$primary-stylename}-selections {
+ @include valo-textfield-error-style;
+ }
+ }
+
}
diff --git a/uitest/src/main/java/com/vaadin/tests/validation/FieldErrorIndication.java b/uitest/src/main/java/com/vaadin/tests/validation/FieldErrorIndication.java
new file mode 100644
index 0000000000..3135ce0592
--- /dev/null
+++ b/uitest/src/main/java/com/vaadin/tests/validation/FieldErrorIndication.java
@@ -0,0 +1,115 @@
+/*
+ * Copyright 2000-2014 Vaadin Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.vaadin.tests.validation;
+
+import java.util.Set;
+
+import com.vaadin.data.Validator;
+import com.vaadin.data.validator.StringLengthValidator;
+import com.vaadin.server.UserError;
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.tests.components.AbstractTestUI;
+import com.vaadin.ui.AbstractField;
+import com.vaadin.ui.ComboBox;
+import com.vaadin.ui.Component;
+import com.vaadin.ui.Field;
+import com.vaadin.ui.HorizontalLayout;
+import com.vaadin.ui.ListSelect;
+import com.vaadin.ui.NativeSelect;
+import com.vaadin.ui.PasswordField;
+import com.vaadin.ui.RichTextArea;
+import com.vaadin.ui.TextArea;
+import com.vaadin.ui.TextField;
+import com.vaadin.ui.TwinColSelect;
+import com.vaadin.ui.VerticalLayout;
+
+public class FieldErrorIndication extends AbstractTestUI {
+
+ @Override
+ protected void setup(VaadinRequest request) {
+ HorizontalLayout hl = new HorizontalLayout();
+ addComponent(hl);
+
+ VerticalLayout vl = new VerticalLayout();
+ hl.addComponent(vl);
+
+ ComboBox comboBox = new ComboBox("ComboBox");
+ comboBox.addItem("ok");
+ comboBox.addItem("error");
+ comboBox.addValidator(new StringLengthValidator("fail", 0, 2, false));
+ comboBox.setValue("error");
+
+ ListSelect listSelect = new ListSelect("ListSelect");
+ listSelect.addItem("ok");
+ listSelect.addItem("error");
+ listSelect.addValidator(new StringLengthValidator("fail", 0, 2, false));
+ listSelect.setValue("error");
+
+ NativeSelect nativeSelect = new NativeSelect("NativeSelect");
+ nativeSelect.addItem("ok");
+ nativeSelect.addItem("error");
+ nativeSelect
+ .addValidator(new StringLengthValidator("fail", 0, 2, false));
+ nativeSelect.setValue("error");
+ TwinColSelect twinColSelect = new TwinColSelect("TwinColSelect");
+ twinColSelect.addItem("ok");
+ twinColSelect.addItem("error");
+ twinColSelect.addValidator(new Validator() {
+
+ @Override
+ public void validate(Object value) throws InvalidValueException {
+ if (value instanceof Set && ((Set) value).size() == 1
+ && ((Set) value).contains("ok")) {
+ return;
+ }
+
+ throw new InvalidValueException("fail");
+ }
+
+ });
+ twinColSelect.setValue("error");
+
+ vl.addComponents(comboBox, listSelect, nativeSelect, twinColSelect);
+
+ Class<? extends AbstractField>[] textFields = new Class[] {
+ TextField.class, TextArea.class, RichTextArea.class,
+ PasswordField.class };
+ vl = new VerticalLayout();
+ hl.addComponent(vl);
+ for (Class<? extends Field> fieldClass : textFields) {
+ vl.addComponent(getField(fieldClass));
+ }
+
+ }
+
+ /**
+ * @since
+ * @param fieldClass
+ * @return
+ */
+ private Component getField(Class<? extends Field> fieldClass) {
+ AbstractField f;
+ try {
+ f = (AbstractField) fieldClass.newInstance();
+ f.setCaption(fieldClass.getSimpleName());
+ f.setComponentError(new UserError("fail"));
+ return f;
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return null;
+ }
+}