diff options
author | Teemu Suo-Anttila <teemusa@vaadin.com> | 2016-10-27 14:53:13 +0300 |
---|---|---|
committer | Vaadin Code Review <review@vaadin.com> | 2016-11-02 10:03:23 +0000 |
commit | cff9d87dd9554727a44cf6af535a644706391ab4 (patch) | |
tree | c1731b600e86beb5005662fd25350a9ee29a71e1 /uitest | |
parent | 2cb106ce095edd5fc8a72b38a856c76ece05684e (diff) | |
download | vaadin-framework-cff9d87dd9554727a44cf6af535a644706391ab4.tar.gz vaadin-framework-cff9d87dd9554727a44cf6af535a644706391ab4.zip |
Move setReadOnly from Component to HasValue
Change-Id: Ib867b71cab4cf5cda89f272986930297b7a84ced
Diffstat (limited to 'uitest')
6 files changed, 22 insertions, 25 deletions
diff --git a/uitest/src/main/java/com/vaadin/tests/components/AbstractComponentTestCase.java b/uitest/src/main/java/com/vaadin/tests/components/AbstractComponentTestCase.java index f34c663029..10959a73b1 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/AbstractComponentTestCase.java +++ b/uitest/src/main/java/com/vaadin/tests/components/AbstractComponentTestCase.java @@ -12,6 +12,7 @@ import com.vaadin.server.UserError; import com.vaadin.server.VaadinRequest; import com.vaadin.ui.AbstractComponent; import com.vaadin.ui.Layout.SpacingHandler; +import com.vaadin.v7.ui.AbstractLegacyComponent; import com.vaadin.v7.ui.Field; public abstract class AbstractComponentTestCase<T extends AbstractComponent> @@ -124,8 +125,13 @@ public abstract class AbstractComponentTestCase<T extends AbstractComponent> protected Command<T, String> descriptionCommand = (c, value, data) -> c .setDescription(value); - protected Command<T, Boolean> readonlyCommand = (c, enabled, data) -> c - .setReadOnly(enabled); + protected Command<T, Boolean> readonlyCommand = (c, enabled, data) -> { + if (c instanceof HasValue) { + ((HasValue) c).setReadOnly(enabled); + } else if (c instanceof AbstractLegacyComponent) { + ((AbstractLegacyComponent) c).setReadOnly(enabled); + } + }; protected Command<T, Boolean> visibleCommand = (c, enabled, data) -> c .setVisible(enabled); diff --git a/uitest/src/main/java/com/vaadin/tests/components/select/OptionGroupBaseSelects.java b/uitest/src/main/java/com/vaadin/tests/components/select/OptionGroupBaseSelects.java index 1d05753815..c98f434d62 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/select/OptionGroupBaseSelects.java +++ b/uitest/src/main/java/com/vaadin/tests/components/select/OptionGroupBaseSelects.java @@ -4,6 +4,7 @@ import com.vaadin.tests.components.ComponentTestCase; import com.vaadin.ui.CheckBox; import com.vaadin.ui.Component; import com.vaadin.ui.HorizontalLayout; +import com.vaadin.v7.ui.AbstractLegacyComponent; import com.vaadin.v7.ui.AbstractSelect; import com.vaadin.v7.ui.ListSelect; import com.vaadin.v7.ui.NativeSelect; @@ -27,7 +28,8 @@ public class OptionGroupBaseSelects cb.addValueChangeListener(event -> { for (Component c : layout) { if (c instanceof AbstractSelect) { - c.setReadOnly(!c.isReadOnly()); + AbstractLegacyComponent legacyComponent = (AbstractLegacyComponent) c; + legacyComponent.setReadOnly(!legacyComponent.isReadOnly()); } } }); diff --git a/uitest/src/main/java/com/vaadin/tests/components/upload/DisabledUploadButton.java b/uitest/src/main/java/com/vaadin/tests/components/upload/DisabledUploadButton.java index adce9c25e5..5a73cd3fbd 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/upload/DisabledUploadButton.java +++ b/uitest/src/main/java/com/vaadin/tests/components/upload/DisabledUploadButton.java @@ -13,13 +13,6 @@ public class DisabledUploadButton extends AbstractReindeerTestUI { addComponent(upload); - addButton("Set readonly", new Button.ClickListener() { - @Override - public void buttonClick(Button.ClickEvent event) { - upload.setReadOnly(true); - } - }); - addButton("Set disabled", new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { diff --git a/uitest/src/main/java/com/vaadin/tests/layouts/CaptionsInLayoutsWaiAria.java b/uitest/src/main/java/com/vaadin/tests/layouts/CaptionsInLayoutsWaiAria.java index 5c8788f53e..9bcb9cd799 100644 --- a/uitest/src/main/java/com/vaadin/tests/layouts/CaptionsInLayoutsWaiAria.java +++ b/uitest/src/main/java/com/vaadin/tests/layouts/CaptionsInLayoutsWaiAria.java @@ -24,6 +24,7 @@ import com.vaadin.ui.VerticalLayout; import com.vaadin.v7.data.Item; import com.vaadin.v7.data.Property.ValueChangeEvent; import com.vaadin.v7.data.Property.ValueChangeListener; +import com.vaadin.v7.ui.AbstractLegacyComponent; import com.vaadin.v7.ui.Field; import com.vaadin.v7.ui.NativeSelect; import com.vaadin.v7.ui.OptionGroup; @@ -163,7 +164,11 @@ public class CaptionsInLayoutsWaiAria extends TestBase { protected void setReadOnly(boolean value) { for (Component c : components) { - c.setReadOnly(value); + if (c instanceof HasValue) { + ((HasValue<String>) c).setReadOnly(value); + } else if (c instanceof AbstractLegacyComponent) { + ((AbstractLegacyComponent) c).setReadOnly(value); + } } } diff --git a/uitest/src/main/java/com/vaadin/tests/themes/valo/Forms.java b/uitest/src/main/java/com/vaadin/tests/themes/valo/Forms.java index 1332ec67ad..3a7df7cd90 100644 --- a/uitest/src/main/java/com/vaadin/tests/themes/valo/Forms.java +++ b/uitest/src/main/java/com/vaadin/tests/themes/valo/Forms.java @@ -27,13 +27,13 @@ import com.vaadin.ui.Alignment; import com.vaadin.ui.Button; import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Button.ClickListener; -import com.vaadin.ui.themes.ValoTheme; import com.vaadin.ui.CheckBox; import com.vaadin.ui.FormLayout; import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.Label; import com.vaadin.ui.RichTextArea; import com.vaadin.ui.VerticalLayout; +import com.vaadin.ui.themes.ValoTheme; import com.vaadin.v7.ui.ComboBox; import com.vaadin.v7.ui.OptionGroup; import com.vaadin.v7.ui.TextArea; @@ -45,6 +45,9 @@ import com.vaadin.v7.ui.TextField; * @author Vaadin Ltd */ public class Forms extends VerticalLayout implements View { + + private boolean readOnly = true; + public Forms() { setSpacing(true); setMargin(true); @@ -150,26 +153,23 @@ public class Forms extends VerticalLayout implements View { "<div><p><span>Integer legentibus erat a ante historiarum dapibus.</span> <span>Vivamus sagittis lacus vel augue laoreet rutrum faucibus.</span> <span>A communi observantia non est recedendum.</span> <span>Morbi fringilla convallis sapien, id pulvinar odio volutpat.</span> <span>Ab illo tempore, ab est sed immemorabili.</span> <span>Quam temere in vitiis, legem sancimus haerentia.</span></p><p><span>Morbi odio eros, volutpat ut pharetra vitae, lobortis sed nibh.</span> <span>Quam diu etiam furor iste tuus nos eludet?</span> <span>Cum sociis natoque penatibus et magnis dis parturient.</span> <span>Quam diu etiam furor iste tuus nos eludet?</span> <span>Tityre, tu patulae recubans sub tegmine fagi dolor.</span></p><p><span>Curabitur blandit tempus ardua ridiculus sed magna.</span> <span>Phasellus laoreet lorem vel dolor tempus vehicula.</span> <span>Etiam habebis sem dicantur magna mollis euismod.</span> <span>Hi omnes lingua, institutis, legibus inter se differunt.</span></p></div>"); form.addComponent(bio); - form.setReadOnly(true); bio.setReadOnly(true); Button edit = new Button("Edit", new ClickListener() { @Override public void buttonClick(ClickEvent event) { - boolean readOnly = form.isReadOnly(); if (readOnly) { bio.setReadOnly(false); - form.setReadOnly(false); form.removeStyleName(ValoTheme.FORMLAYOUT_LIGHT); event.getButton().setCaption("Save"); event.getButton().addStyleName(ValoTheme.BUTTON_PRIMARY); } else { bio.setReadOnly(true); - form.setReadOnly(true); form.addStyleName(ValoTheme.FORMLAYOUT_LIGHT); event.getButton().setCaption("Edit"); event.getButton().removeStyleName(ValoTheme.BUTTON_PRIMARY); } + readOnly = !readOnly; } }); diff --git a/uitest/src/test/java/com/vaadin/tests/components/upload/DisabledUploadButtonTest.java b/uitest/src/test/java/com/vaadin/tests/components/upload/DisabledUploadButtonTest.java index cc97b4d7d1..cbc6423893 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/upload/DisabledUploadButtonTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/upload/DisabledUploadButtonTest.java @@ -36,15 +36,6 @@ public class DisabledUploadButtonTest extends MultiBrowserTest { } @Test - public void buttonIsReadonly() { - assertThat(getUploadButtonClass(), not(containsString("v-disabled"))); - - clickButton("Set readonly"); - - assertThat(getUploadButtonClass(), containsString("v-disabled")); - } - - @Test public void buttonIsDisabled() { assertThat(getUploadButtonClass(), not(containsString("v-disabled"))); |