From cff9d87dd9554727a44cf6af535a644706391ab4 Mon Sep 17 00:00:00 2001 From: Teemu Suo-Anttila Date: Thu, 27 Oct 2016 14:53:13 +0300 Subject: Move setReadOnly from Component to HasValue Change-Id: Ib867b71cab4cf5cda89f272986930297b7a84ced --- .../com/vaadin/v7/ui/AbstractLegacyComponent.java | 60 +++++++++++++++++++++- 1 file changed, 58 insertions(+), 2 deletions(-) (limited to 'compatibility-server') 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); -- cgit v1.2.3