summaryrefslogtreecommitdiffstats
path: root/compatibility-server/src
diff options
context:
space:
mode:
authorTeemu Suo-Anttila <teemusa@vaadin.com>2016-10-27 14:53:13 +0300
committerVaadin Code Review <review@vaadin.com>2016-11-02 10:03:23 +0000
commitcff9d87dd9554727a44cf6af535a644706391ab4 (patch)
treec1731b600e86beb5005662fd25350a9ee29a71e1 /compatibility-server/src
parent2cb106ce095edd5fc8a72b38a856c76ece05684e (diff)
downloadvaadin-framework-cff9d87dd9554727a44cf6af535a644706391ab4.tar.gz
vaadin-framework-cff9d87dd9554727a44cf6af535a644706391ab4.zip
Move setReadOnly from Component to HasValue
Change-Id: Ib867b71cab4cf5cda89f272986930297b7a84ced
Diffstat (limited to 'compatibility-server/src')
-rw-r--r--compatibility-server/src/main/java/com/vaadin/v7/ui/AbstractLegacyComponent.java60
1 files changed, 58 insertions, 2 deletions
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.
* <p>
- * 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.
+ *
+ * <p>
+ * Notice that the read-only mode only affects whether the user can change
+ * the <i>value</i> of the component; it is possible to, for example, scroll
+ * a read-only table.
+ * </p>
+ *
+ * <p>
+ * The method will return {@code true} if the component or any of its
+ * parents is in the read-only mode.
+ * </p>
+ *
+ * @return <code>true</code> if the component or any of its parents is in
+ * read-only mode, <code>false</code> 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.
+ *
+ * <p>
+ * 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.
+ * </p>
+ *
+ * <p>
+ * Notice that the read-only mode only affects whether the user can change
+ * the <i>value</i> of the component; it is possible to, for example, scroll
+ * a read-only table.
+ * </p>
+ *
+ * <p>
+ * In Vaadin 8 the read-only property is part of {@link HasValue} API.
+ * </p>
+ *
+ * @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);