summaryrefslogtreecommitdiffstats
path: root/server/src/com/vaadin/data
diff options
context:
space:
mode:
authortapio <tapio@vaadin.com>2012-11-08 13:32:06 +0200
committertapio <tapio@vaadin.com>2012-11-08 13:32:06 +0200
commit9b69534bc46e01f5a762284542db460930de44fa (patch)
tree4a192ecb96e7edf5c4305aa0bab5bf5dfa889380 /server/src/com/vaadin/data
parente8ae9f7d6427f7f6daae300dee7931a6e8394bdb (diff)
downloadvaadin-framework-9b69534bc46e01f5a762284542db460930de44fa.tar.gz
vaadin-framework-9b69534bc46e01f5a762284542db460930de44fa.zip
Modified FieldGroup so that fields configured with read only properties
will also be made read only (#9076). Change-Id: I183ae263f4952a51513623d38dc9e04ce1482f45
Diffstat (limited to 'server/src/com/vaadin/data')
-rw-r--r--server/src/com/vaadin/data/fieldgroup/FieldGroup.java27
-rw-r--r--server/src/com/vaadin/data/util/TransactionalPropertyWrapper.java14
2 files changed, 34 insertions, 7 deletions
diff --git a/server/src/com/vaadin/data/fieldgroup/FieldGroup.java b/server/src/com/vaadin/data/fieldgroup/FieldGroup.java
index 6bef69fe5b..5a69cad62e 100644
--- a/server/src/com/vaadin/data/fieldgroup/FieldGroup.java
+++ b/server/src/com/vaadin/data/fieldgroup/FieldGroup.java
@@ -188,7 +188,8 @@ public class FieldGroup implements Serializable {
}
/**
- * Returns the read only status for the fields.
+ * Returns the read only status that is used by default with all fields that
+ * have a writable data source.
* <p>
* Note that this will not accurately represent the read only status of all
* fields if you change the read only status of the fields through some
@@ -201,16 +202,22 @@ public class FieldGroup implements Serializable {
}
/**
- * Updates the read only state of all bound fields.
+ * Sets the read only state to the given value for all fields with writable
+ * data source. Fields with read only data source will always be set to read
+ * only.
*
* @param fieldsReadOnly
- * true to set all bound fields to read only, false to set them
- * to read write
+ * true to set the fields with writable data source to read only,
+ * false to set them to read write
*/
public void setReadOnly(boolean fieldsReadOnly) {
readOnly = fieldsReadOnly;
for (Field<?> field : getFields()) {
- field.setReadOnly(fieldsReadOnly);
+ if (!field.getPropertyDataSource().isReadOnly()) {
+ field.setReadOnly(fieldsReadOnly);
+ } else {
+ field.setReadOnly(true);
+ }
}
}
@@ -325,7 +332,8 @@ public class FieldGroup implements Serializable {
* Configures a field with the settings set for this FieldBinder.
* <p>
* By default this updates the buffered, read only and enabled state of the
- * field. Also adds validators when applicable.
+ * field. Also adds validators when applicable. Fields with read only data
+ * source are always configured as read only.
*
* @param field
* The field to update
@@ -334,7 +342,12 @@ public class FieldGroup implements Serializable {
field.setBuffered(isBuffered());
field.setEnabled(isEnabled());
- field.setReadOnly(isReadOnly());
+
+ if (field.getPropertyDataSource().isReadOnly()) {
+ field.setReadOnly(true);
+ } else {
+ field.setReadOnly(isReadOnly());
+ }
}
/**
diff --git a/server/src/com/vaadin/data/util/TransactionalPropertyWrapper.java b/server/src/com/vaadin/data/util/TransactionalPropertyWrapper.java
index d8d27ae4c8..503bb1c743 100644
--- a/server/src/com/vaadin/data/util/TransactionalPropertyWrapper.java
+++ b/server/src/com/vaadin/data/util/TransactionalPropertyWrapper.java
@@ -122,4 +122,18 @@ public class TransactionalPropertyWrapper<T> extends AbstractProperty<T>
return wrappedProperty;
}
+ @Override
+ public boolean isReadOnly() {
+ return wrappedProperty.isReadOnly();
+ }
+
+ @Override
+ public void setReadOnly(boolean newStatus) {
+ boolean oldStatus = isReadOnly();
+ wrappedProperty.setReadOnly(newStatus);
+ if (oldStatus != isReadOnly()) {
+ fireReadOnlyStatusChange();
+ }
+ }
+
}