From cff9d87dd9554727a44cf6af535a644706391ab4 Mon Sep 17 00:00:00 2001 From: Teemu Suo-Anttila Date: Thu, 27 Oct 2016 14:53:13 +0300 Subject: [PATCH] Move setReadOnly from Component to HasValue Change-Id: Ib867b71cab4cf5cda89f272986930297b7a84ced --- .../client/ui/window/WindowConnector.java | 2 +- .../vaadin/v7/ui/AbstractLegacyComponent.java | 60 ++++++++++++++++++- .../main/java/com/vaadin/data/HasValue.java | 22 +++++++ .../communication/FileUploadHandler.java | 7 --- .../java/com/vaadin/ui/AbstractComponent.java | 46 ++++++++------ .../java/com/vaadin/ui/AbstractField.java | 18 +----- .../com/vaadin/ui/AbstractMultiSelect.java | 11 +++- .../com/vaadin/ui/AbstractSingleSelect.java | 10 ++++ .../src/main/java/com/vaadin/ui/Button.java | 4 +- .../main/java/com/vaadin/ui/Component.java | 50 ---------------- .../src/main/java/com/vaadin/ui/Window.java | 20 ++----- .../colorpicker/ColorPickerPopup.java | 10 ++++ .../colorpicker/ColorPickerPreview.java | 10 ++++ .../AbstractComponentDeclarativeTestBase.java | 14 +++-- .../component/button/ButtonClickTest.java | 8 --- .../vaadin/shared/ui/window/WindowState.java | 2 + .../components/AbstractComponentTestCase.java | 10 +++- .../select/OptionGroupBaseSelects.java | 4 +- .../upload/DisabledUploadButton.java | 7 --- .../layouts/CaptionsInLayoutsWaiAria.java | 7 ++- .../com/vaadin/tests/themes/valo/Forms.java | 10 ++-- .../upload/DisabledUploadButtonTest.java | 9 --- 22 files changed, 193 insertions(+), 148 deletions(-) diff --git a/client/src/main/java/com/vaadin/client/ui/window/WindowConnector.java b/client/src/main/java/com/vaadin/client/ui/window/WindowConnector.java index eed89f090c..3d5d7bbcfd 100644 --- a/client/src/main/java/com/vaadin/client/ui/window/WindowConnector.java +++ b/client/src/main/java/com/vaadin/client/ui/window/WindowConnector.java @@ -388,7 +388,7 @@ public class WindowConnector extends AbstractSingleComponentContainerConnector clickEventHandler.handleEventHandlerRegistration(); - window.setClosable(!isReadOnly()); + window.setClosable(state.closable); // initialize position from state updateWindowPosition(); diff --git a/compatibility-server/src/main/java/com/vaadin/v7/ui/AbstractLegacyComponent.java b/compatibility-server/src/main/java/com/vaadin/v7/ui/AbstractLegacyComponent.java index 28c1078de7..c4136f633b 100644 --- a/compatibility-server/src/main/java/com/vaadin/v7/ui/AbstractLegacyComponent.java +++ b/compatibility-server/src/main/java/com/vaadin/v7/ui/AbstractLegacyComponent.java @@ -26,8 +26,8 @@ import com.vaadin.v7.shared.AbstractLegacyComponentState; /** * An abstract base class for compatibility components. *

- * Used since immediate property has been removed in Vaadin 8 from - * {@link AbstractComponent}. + * Used since immediate and read-only properties has been removed in Vaadin 8 + * from {@link AbstractComponent}. * * @author Vaadin Ltd * @since 8.0 @@ -78,6 +78,62 @@ public class AbstractLegacyComponent extends AbstractComponent { getState().immediate = immediate; } + /** + * Tests whether the component is in the read-only mode. The user can not + * change the value of a read-only component. As only {@code AbstractField} + * or {@code LegacyField} components normally have a value that can be input + * or changed by the user, this is mostly relevant only to field components, + * though not restricted to them. + * + *

+ * Notice that the read-only mode only affects whether the user can change + * the value of the component; it is possible to, for example, scroll + * a read-only table. + *

+ * + *

+ * The method will return {@code true} if the component or any of its + * parents is in the read-only mode. + *

+ * + * @return true if the component or any of its parents is in + * read-only mode, false if not. + * @see #setReadOnly(boolean) + */ + @Override + public boolean isReadOnly() { + return getState(false).readOnly; + } + + /** + * Sets the read-only mode of the component to the specified mode. The user + * can not change the value of a read-only component. + * + *

+ * As only {@code AbstractField} or {@code LegacyField} components normally + * have a value that can be input or changed by the user, this is mostly + * relevant only to field components, though not restricted to them. + *

+ * + *

+ * Notice that the read-only mode only affects whether the user can change + * the value of the component; it is possible to, for example, scroll + * a read-only table. + *

+ * + *

+ * In Vaadin 8 the read-only property is part of {@link HasValue} API. + *

+ * + * @param readOnly + * a boolean value specifying whether the component is put + * read-only mode or not + */ + @Override + public void setReadOnly(boolean readOnly) { + getState().readOnly = readOnly; + } + @Override public void readDesign(Element design, DesignContext designContext) { super.readDesign(design, designContext); diff --git a/server/src/main/java/com/vaadin/data/HasValue.java b/server/src/main/java/com/vaadin/data/HasValue.java index e02297b7f4..1a612dbb80 100644 --- a/server/src/main/java/com/vaadin/data/HasValue.java +++ b/server/src/main/java/com/vaadin/data/HasValue.java @@ -235,4 +235,26 @@ public interface HasValue extends Serializable { * @return true if visible, false if not */ public boolean isRequiredIndicatorVisible(); + + /** + * Sets the read-only mode of this {@code HasValue} to given mode. The user + * can't change the value when in read-only mode. + *

+ * A {@code HasValue} with a visual component in read-only mode typically + * looks visually different to signal to the user that the value cannot be + * edited. + * + * @param readOnly + * a boolean value specifying whether the component is put + * read-only mode or not + */ + public void setReadOnly(boolean readOnly); + + /** + * Returns whether this {@code HasValue} is in read-only mode or not. + * + * @return {@code false} if the user can modify the value, {@code true} if + * not. + */ + public boolean isReadOnly(); } diff --git a/server/src/main/java/com/vaadin/server/communication/FileUploadHandler.java b/server/src/main/java/com/vaadin/server/communication/FileUploadHandler.java index 7f6bd3a2cc..19c3d45fa9 100644 --- a/server/src/main/java/com/vaadin/server/communication/FileUploadHandler.java +++ b/server/src/main/java/com/vaadin/server/communication/FileUploadHandler.java @@ -36,7 +36,6 @@ import com.vaadin.server.UploadException; import com.vaadin.server.VaadinRequest; import com.vaadin.server.VaadinResponse; import com.vaadin.server.VaadinSession; -import com.vaadin.ui.Component; import com.vaadin.ui.UI; import com.vaadin.ui.Upload.FailedEvent; @@ -444,12 +443,6 @@ public class FileUploadHandler implements RequestHandler { + connector.getConnectorId() + " because the component was disabled"); } - if ((connector instanceof Component) - && ((Component) connector).isReadOnly()) { - // Only checked for legacy reasons - throw new UploadException( - "File upload ignored because the component is read-only"); - } } finally { session.unlock(); } diff --git a/server/src/main/java/com/vaadin/ui/AbstractComponent.java b/server/src/main/java/com/vaadin/ui/AbstractComponent.java index 8711b601e6..5d8c422a7c 100644 --- a/server/src/main/java/com/vaadin/ui/AbstractComponent.java +++ b/server/src/main/java/com/vaadin/ui/AbstractComponent.java @@ -35,6 +35,7 @@ import org.jsoup.nodes.Attribute; import org.jsoup.nodes.Attributes; import org.jsoup.nodes.Element; +import com.vaadin.data.HasValue; import com.vaadin.event.ActionManager; import com.vaadin.event.ConnectorActionManager; import com.vaadin.event.ContextClickEvent; @@ -601,24 +602,6 @@ public abstract class AbstractComponent extends AbstractClientConnector markAsDirty(); } - /* - * Tests if the component is in read-only mode. Don't add a JavaDoc comment - * here, we use the default documentation from implemented interface. - */ - @Override - public boolean isReadOnly() { - return getState(false).readOnly; - } - - /* - * Sets the component's read-only mode. Don't add a JavaDoc comment here, we - * use the default documentation from implemented interface. - */ - @Override - public void setReadOnly(boolean readOnly) { - getState().readOnly = readOnly; - } - /* * Notify the component that it's attached to a window. Don't add a JavaDoc * comment here, we use the default documentation from implemented @@ -1060,6 +1043,33 @@ public abstract class AbstractComponent extends AbstractClientConnector return false; } + /** + * Sets the read-only status in the state of this {@code AbstractComponent}. + * This method should be made public in {@link Component Components} that + * implement {@link HasValue}. + * + * @param readOnly + * a boolean value specifying whether the component is put + * read-only mode or not + */ + protected void setReadOnly(boolean readOnly) { + if (readOnly != isReadOnly()) { + getState().readOnly = readOnly; + } + } + + /** + * Returns the read-only status from the state of this + * {@code AbstractComponent}. This method should be made public in + * {@link Component Components} that implement {@link HasValue}. + * + * @return {@code true} if state has read-only on; {@code false} if not + * @see #setReadOnly(boolean) + */ + protected boolean isReadOnly() { + return getState(false).readOnly; + } + /** * Reads the size of this component from the given design attributes. If the * attributes do not contain relevant size information, defaults is diff --git a/server/src/main/java/com/vaadin/ui/AbstractField.java b/server/src/main/java/com/vaadin/ui/AbstractField.java index 065825b5ad..45f7b4fa0b 100644 --- a/server/src/main/java/com/vaadin/ui/AbstractField.java +++ b/server/src/main/java/com/vaadin/ui/AbstractField.java @@ -59,24 +59,13 @@ public abstract class AbstractField extends AbstractComponent setValue(value, false); } - /** - * Returns whether the value of this field can be changed by the user or - * not. By default fields are not read-only. - * - * @return {@code true} if this field is in read-only mode, {@code false} - * otherwise. - * - * @see #setReadOnly(boolean) - */ @Override public boolean isReadOnly() { return super.isReadOnly(); } /** - * Sets whether the value of this field can be changed by the user or not. A - * field in read-only mode typically looks visually different to signal to - * the user that the value cannot be edited. + * {@inheritDoc} *

* The server ignores (potentially forged) value change requests from the * client to fields that are read-only. Programmatically changing the field @@ -119,9 +108,8 @@ public abstract class AbstractField extends AbstractComponent super.writeDesign(design, designContext); AbstractField def = designContext.getDefaultInstance(this); Attributes attr = design.attributes(); - DesignAttributeHandler.writeAttribute("readonly", attr, - super.isReadOnly(), def.isReadOnly(), Boolean.class, - designContext); + DesignAttributeHandler.writeAttribute("readonly", attr, isReadOnly(), + def.isReadOnly(), Boolean.class, designContext); } @Override diff --git a/server/src/main/java/com/vaadin/ui/AbstractMultiSelect.java b/server/src/main/java/com/vaadin/ui/AbstractMultiSelect.java index 99c1682536..52cd02481c 100644 --- a/server/src/main/java/com/vaadin/ui/AbstractMultiSelect.java +++ b/server/src/main/java/com/vaadin/ui/AbstractMultiSelect.java @@ -491,6 +491,15 @@ public abstract class AbstractMultiSelect @Override protected RequiredIndicatorState getState(boolean markAsDirty) { return (RequiredIndicatorState) super.getState(markAsDirty); - }; + } + + @Override + public void setReadOnly(boolean readOnly) { + super.setReadOnly(readOnly); + } + @Override + public boolean isReadOnly() { + return super.isReadOnly(); + } } diff --git a/server/src/main/java/com/vaadin/ui/AbstractSingleSelect.java b/server/src/main/java/com/vaadin/ui/AbstractSingleSelect.java index 272acf3b09..e23ef105c8 100644 --- a/server/src/main/java/com/vaadin/ui/AbstractSingleSelect.java +++ b/server/src/main/java/com/vaadin/ui/AbstractSingleSelect.java @@ -359,4 +359,14 @@ public abstract class AbstractSingleSelect extends public boolean isRequiredIndicatorVisible() { return super.isRequiredIndicatorVisible(); } + + @Override + public void setReadOnly(boolean readOnly) { + super.setReadOnly(readOnly); + } + + @Override + public boolean isReadOnly() { + return super.isReadOnly(); + } } diff --git a/server/src/main/java/com/vaadin/ui/Button.java b/server/src/main/java/com/vaadin/ui/Button.java index 86321f357c..c4d30c6100 100644 --- a/server/src/main/java/com/vaadin/ui/Button.java +++ b/server/src/main/java/com/vaadin/ui/Button.java @@ -325,7 +325,7 @@ public class Button extends AbstractFocusable * * @param listener * the Listener to be removed. - * + * * @deprecated As of 8.0, replaced by {@link Registration#remove()} in the * registration object returned from * {@link #addClickListener(ClickListener)}. @@ -342,7 +342,7 @@ public class Button extends AbstractFocusable * No action is taken is the button is disabled. */ public void click() { - if (isEnabled() && !isReadOnly()) { + if (isEnabled()) { fireClick(); } } diff --git a/server/src/main/java/com/vaadin/ui/Component.java b/server/src/main/java/com/vaadin/ui/Component.java index b5ffebef12..5ffdf600b3 100644 --- a/server/src/main/java/com/vaadin/ui/Component.java +++ b/server/src/main/java/com/vaadin/ui/Component.java @@ -369,56 +369,6 @@ public interface Component extends ClientConnector, Sizeable, Serializable { @Override public HasComponents getParent(); - /** - * Tests whether the component is in the read-only mode. The user can not - * change the value of a read-only component. As only {@code AbstractField} - * or {@code LegacyField} components normally have a value that can be input - * or changed by the user, this is mostly relevant only to field components, - * though not restricted to them. - * - *

- * Notice that the read-only mode only affects whether the user can change - * the value of the component; it is possible to, for example, scroll - * a read-only table. - *

- * - *

- * The method will return {@code true} if the component or any of its - * parents is in the read-only mode. - *

- * - * @return true if the component or any of its parents is in - * read-only mode, false if not. - * @see #setReadOnly(boolean) - */ - public boolean isReadOnly(); - - /** - * Sets the read-only mode of the component to the specified mode. The user - * can not change the value of a read-only component. - * - *

- * As only {@code AbstractField} or{@code LegacyField} components normally - * have a value that can be input or changed by the user, this is mostly - * relevant only to field components, though not restricted to them. - *

- * - *

- * Notice that the read-only mode only affects whether the user can change - * the value of the component; it is possible to, for example, scroll - * a read-only table. - *

- * - *

- * This method will trigger a {@link RepaintRequestEvent}. - *

- * - * @param readOnly - * a boolean value specifying whether the component is put - * read-only mode or not - */ - public void setReadOnly(boolean readOnly); - /** * Gets the caption of the component. * diff --git a/server/src/main/java/com/vaadin/ui/Window.java b/server/src/main/java/com/vaadin/ui/Window.java index df06e54457..f41a127b0f 100644 --- a/server/src/main/java/com/vaadin/ui/Window.java +++ b/server/src/main/java/com/vaadin/ui/Window.java @@ -736,15 +736,10 @@ public class Window extends Panel * close event to the server. Setting closable to false will remove the X * from the window and prevent the user from closing the window. * - * Note! For historical reasons readonly controls the closability of the - * window and therefore readonly and closable affect each other. Setting - * readonly to true will set closable to false and vice versa. - *

- * * @return true if the window can be closed by the user. */ public boolean isClosable() { - return !isReadOnly(); + return getState(false).closable; } /** @@ -753,25 +748,20 @@ public class Window extends Panel * close event to the server. Setting closable to false will remove the X * from the window and prevent the user from closing the window. * - * Note! For historical reasons readonly controls the closability of the - * window and therefore readonly and closable affect each other. Setting - * readonly to true will set closable to false and vice versa. - *

- * * @param closable * determines if the window can be closed by the user. */ public void setClosable(boolean closable) { - setReadOnly(!closable); + if (closable != isClosable()) { + getState().closable = closable; + } } /** * Indicates whether a window can be dragged or not. By default a window is * draggable. - *

* - * @param draggable - * true if the window can be dragged by the user + * @return {@code true} if window is draggable; {@code false} if not */ public boolean isDraggable() { return getState(false).draggable; diff --git a/server/src/main/java/com/vaadin/ui/components/colorpicker/ColorPickerPopup.java b/server/src/main/java/com/vaadin/ui/components/colorpicker/ColorPickerPopup.java index f474e51e99..c86b139520 100644 --- a/server/src/main/java/com/vaadin/ui/components/colorpicker/ColorPickerPopup.java +++ b/server/src/main/java/com/vaadin/ui/components/colorpicker/ColorPickerPopup.java @@ -723,4 +723,14 @@ public class ColorPickerPopup extends Window implements HasValue { private static Logger getLogger() { return Logger.getLogger(ColorPickerPopup.class.getName()); } + + @Override + public void setReadOnly(boolean readOnly) { + super.setReadOnly(readOnly); + } + + @Override + public boolean isReadOnly() { + return super.isReadOnly(); + } } diff --git a/server/src/main/java/com/vaadin/ui/components/colorpicker/ColorPickerPreview.java b/server/src/main/java/com/vaadin/ui/components/colorpicker/ColorPickerPreview.java index 27e5690e3c..023d54c7f4 100644 --- a/server/src/main/java/com/vaadin/ui/components/colorpicker/ColorPickerPreview.java +++ b/server/src/main/java/com/vaadin/ui/components/colorpicker/ColorPickerPreview.java @@ -195,4 +195,14 @@ public class ColorPickerPreview extends CssLayout implements HasValue { public boolean isRequiredIndicatorVisible() { return super.isRequiredIndicatorVisible(); } + + @Override + public void setReadOnly(boolean readOnly) { + super.setReadOnly(readOnly); + } + + @Override + public boolean isReadOnly() { + return super.isReadOnly(); + } } diff --git a/server/src/test/java/com/vaadin/tests/server/component/abstractcomponent/AbstractComponentDeclarativeTestBase.java b/server/src/test/java/com/vaadin/tests/server/component/abstractcomponent/AbstractComponentDeclarativeTestBase.java index 2722dae51a..d4b5901922 100644 --- a/server/src/test/java/com/vaadin/tests/server/component/abstractcomponent/AbstractComponentDeclarativeTestBase.java +++ b/server/src/test/java/com/vaadin/tests/server/component/abstractcomponent/AbstractComponentDeclarativeTestBase.java @@ -39,7 +39,7 @@ import com.vaadin.ui.declarative.DesignContext; * declarative test for a real component should extend it and implement abstract * methods to be able to test the common properties. Components specific * properties should be tested additionally in the subclasses implementations. - * + * * @author Vaadin Ltd * */ @@ -48,14 +48,14 @@ public abstract class AbstractComponentDeclarativeTestBase getComponentClass(); @@ -110,7 +110,13 @@ public abstract class AbstractComponentDeclarativeTestBase @@ -124,8 +125,13 @@ public abstract class AbstractComponentTestCase protected Command descriptionCommand = (c, value, data) -> c .setDescription(value); - protected Command readonlyCommand = (c, enabled, data) -> c - .setReadOnly(enabled); + protected Command readonlyCommand = (c, enabled, data) -> { + if (c instanceof HasValue) { + ((HasValue) c).setReadOnly(enabled); + } else if (c instanceof AbstractLegacyComponent) { + ((AbstractLegacyComponent) c).setReadOnly(enabled); + } + }; protected Command 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) 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 { "

Integer legentibus erat a ante historiarum dapibus. Vivamus sagittis lacus vel augue laoreet rutrum faucibus. A communi observantia non est recedendum. Morbi fringilla convallis sapien, id pulvinar odio volutpat. Ab illo tempore, ab est sed immemorabili. Quam temere in vitiis, legem sancimus haerentia.

Morbi odio eros, volutpat ut pharetra vitae, lobortis sed nibh. Quam diu etiam furor iste tuus nos eludet? Cum sociis natoque penatibus et magnis dis parturient. Quam diu etiam furor iste tuus nos eludet? Tityre, tu patulae recubans sub tegmine fagi dolor.

Curabitur blandit tempus ardua ridiculus sed magna. Phasellus laoreet lorem vel dolor tempus vehicula. Etiam habebis sem dicantur magna mollis euismod. Hi omnes lingua, institutis, legibus inter se differunt.

"); 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 @@ -35,15 +35,6 @@ public class DisabledUploadButtonTest extends MultiBrowserTest { return upload.findElement(By.className("v-button")); } - @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"))); -- 2.39.5