* 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
display: none;
}
}
+
+ &.borderless {
+ [class*="input"] {
+ @include valo-textfield-borderless-style;
+ }
+ }
}
}
display: none;
}
}
+
+ &.borderless {
+ [class*="textfield"] {
+ @include valo-textfield-borderless-style;
+ }
+ }
}
}
--- /dev/null
+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.";
+ }
+}
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;
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;
c.addStyleName(newStyleName);
}
}
+
+ public List<ValueChangeListener<Boolean>> getReadOnlyChangeListeners() {
+ return readOnlyChangeListeners;
+ }
+
+ public void addReadOnlyChangeListener(
+ ValueChangeListener<Boolean> listener) {
+ readOnlyChangeListeners.add(listener);
+ }
}
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;
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() {
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) {
import com.vaadin.v7.ui.themes.Reindeer;
import com.vaadin.v7.ui.themes.Runo;
+@SuppressWarnings("deprecation")
public class ButtonsCssTest extends GridLayout {
private TestSampler parent;
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++);
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,
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;
"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,
import com.vaadin.v7.data.fieldgroup.FieldGroup;
import com.vaadin.v7.data.util.BeanItem;
+@SuppressWarnings("deprecation")
public class FormsCssTest extends HorizontalLayout {
private TestSampler parent;
login.setHeight("150px");
addComponent(login);
+ parent.addReadOnlyChangeListener(event -> {
+ fg.setReadOnly(!fg.isReadOnly());
+ // it's not possible to set LoginForm read-only
+ });
}
@Override
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;
import com.vaadin.v7.ui.TwinColSelect;
import com.vaadin.v7.ui.themes.ChameleonTheme;
+@SuppressWarnings("deprecation")
public class SelectsCssTest extends GridLayout {
private TestSampler parent;
"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,
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());
+ });
}
}
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;
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) {
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;
import com.vaadin.v7.ui.themes.ChameleonTheme;
import com.vaadin.v7.ui.themes.Reindeer;
+@SuppressWarnings("deprecation")
public class TextFieldsCssTest extends GridLayout {
private TestSampler parent;
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,
import com.vaadin.v7.data.util.HierarchicalContainer;
import com.vaadin.v7.ui.Tree;
+@SuppressWarnings("deprecation")
public class TreeCssTest {
private int debugIdCounter = 0;
}
parent.addComponent(tree);
+
+ parent.addReadOnlyChangeListener(
+ event -> tree.setReadOnly(!tree.isReadOnly()));
}
private HierarchicalContainer createHierarchicalContainer() {
import com.vaadin.v7.data.util.HierarchicalContainer;
import com.vaadin.v7.ui.TreeTable;
+@SuppressWarnings("deprecation")
public class TreeTableCssTest {
private int debugIdCounter = 0;
TreeTable treeTable = new TreeTable();
treeTable.setId("treetable" + debugIdCounter++);
treeTable.setWidth("100%");
+ treeTable.setSelectable(true);
parent.addComponent(treeTable);
HierarchicalContainer hc = createHierarchicalContainer();
for (Object itemId : treeTable.getItemIds()) {
treeTable.setCollapsed(itemId, false);
}
+
+ parent.addReadOnlyChangeListener(
+ event -> treeTable.setReadOnly(!treeTable.isReadOnly()));
}
private HierarchicalContainer createHierarchicalContainer() {