diff options
author | Artur Signell <artur@vaadin.com> | 2012-09-24 16:19:41 +0300 |
---|---|---|
committer | Artur Signell <artur@vaadin.com> | 2012-10-23 14:42:57 +0300 |
commit | 0121af0c28d92db37dea94050f3453ecf46556b9 (patch) | |
tree | ba8397bcfbf5747708f040fee76a6dd5cb8bc515 /server/src/com/vaadin/ui | |
parent | ce0640100a3892a1e36d25df1b85de73b6e2d1d0 (diff) | |
download | vaadin-framework-0121af0c28d92db37dea94050f3453ecf46556b9.tar.gz vaadin-framework-0121af0c28d92db37dea94050f3453ecf46556b9.zip |
Changed Property.setValue(Object) to setValue(T) (#8791)
Change-Id: I9f0e6bd62102c5adc461884b1f3b2cbe69f19259
Diffstat (limited to 'server/src/com/vaadin/ui')
-rw-r--r-- | server/src/com/vaadin/ui/AbstractField.java | 14 | ||||
-rw-r--r-- | server/src/com/vaadin/ui/AbstractSelect.java | 2 | ||||
-rw-r--r-- | server/src/com/vaadin/ui/AbstractTextField.java | 2 | ||||
-rw-r--r-- | server/src/com/vaadin/ui/DefaultFieldFactory.java | 4 | ||||
-rw-r--r-- | server/src/com/vaadin/ui/Form.java | 4 | ||||
-rw-r--r-- | server/src/com/vaadin/ui/Label.java | 9 | ||||
-rw-r--r-- | server/src/com/vaadin/ui/ProgressIndicator.java | 2 | ||||
-rw-r--r-- | server/src/com/vaadin/ui/Slider.java | 9 |
8 files changed, 14 insertions, 32 deletions
diff --git a/server/src/com/vaadin/ui/AbstractField.java b/server/src/com/vaadin/ui/AbstractField.java index d6dd03c171..59f730f275 100644 --- a/server/src/com/vaadin/ui/AbstractField.java +++ b/server/src/com/vaadin/ui/AbstractField.java @@ -427,17 +427,9 @@ public abstract class AbstractField<T> extends AbstractComponent implements * @throws Property.ReadOnlyException */ @Override - public void setValue(Object newFieldValue) - throws Property.ReadOnlyException, Converter.ConversionException { - // This check is needed as long as setValue accepts Object instead of T - if (newFieldValue != null) { - if (!getType().isAssignableFrom(newFieldValue.getClass())) { - throw new Converter.ConversionException("Value of type " - + newFieldValue.getClass() + " cannot be assigned to " - + getType().getName()); - } - } - setValue((T) newFieldValue, false); + public void setValue(T newFieldValue) throws Property.ReadOnlyException, + Converter.ConversionException { + setValue(newFieldValue, false); } /** diff --git a/server/src/com/vaadin/ui/AbstractSelect.java b/server/src/com/vaadin/ui/AbstractSelect.java index 78fab068dd..d2092ceb2c 100644 --- a/server/src/com/vaadin/ui/AbstractSelect.java +++ b/server/src/com/vaadin/ui/AbstractSelect.java @@ -784,7 +784,7 @@ public abstract class AbstractSelect extends AbstractField<Object> implements * @see com.vaadin.data.Container#getContainerProperty(Object, Object) */ @Override - public Property<?> getContainerProperty(Object itemId, Object propertyId) { + public Property getContainerProperty(Object itemId, Object propertyId) { return items.getContainerProperty(itemId, propertyId); } diff --git a/server/src/com/vaadin/ui/AbstractTextField.java b/server/src/com/vaadin/ui/AbstractTextField.java index 3dd2b4dae8..e8618a33ee 100644 --- a/server/src/com/vaadin/ui/AbstractTextField.java +++ b/server/src/com/vaadin/ui/AbstractTextField.java @@ -429,7 +429,7 @@ public abstract class AbstractTextField extends AbstractField<String> implements } @Override - public void setValue(Object newValue) throws ReadOnlyException { + public void setValue(String newValue) throws ReadOnlyException { super.setValue(newValue); /* * Make sure w reset lastKnownTextContent field on value change. The diff --git a/server/src/com/vaadin/ui/DefaultFieldFactory.java b/server/src/com/vaadin/ui/DefaultFieldFactory.java index 28a5b6c669..5072503428 100644 --- a/server/src/com/vaadin/ui/DefaultFieldFactory.java +++ b/server/src/com/vaadin/ui/DefaultFieldFactory.java @@ -57,9 +57,9 @@ public class DefaultFieldFactory implements FormFieldFactory, TableFieldFactory } @Override - public Field<?> createField(Container container, Object itemId, + public Field createField(Container container, Object itemId, Object propertyId, Component uiContext) { - Property<?> containerProperty = container.getContainerProperty(itemId, + Property containerProperty = container.getContainerProperty(itemId, propertyId); Class<?> type = containerProperty.getType(); Field<?> field = createFieldByPropertyType(type); diff --git a/server/src/com/vaadin/ui/Form.java b/server/src/com/vaadin/ui/Form.java index dd804ef67a..4b7782e0a9 100644 --- a/server/src/com/vaadin/ui/Form.java +++ b/server/src/com/vaadin/ui/Form.java @@ -572,7 +572,7 @@ public class Form extends AbstractField<Object> implements Item.Editor, * @see com.vaadin.data.Item#getItemProperty(Object) */ @Override - public Property<?> getItemProperty(Object id) { + public Property getItemProperty(Object id) { final Field<?> field = fields.get(id); if (field == null) { // field does not exist or it is not (yet) created for this property @@ -593,7 +593,7 @@ public class Form extends AbstractField<Object> implements Item.Editor, * @param propertyId * the id of the property. */ - public Field<?> getField(Object propertyId) { + public Field getField(Object propertyId) { return fields.get(propertyId); } diff --git a/server/src/com/vaadin/ui/Label.java b/server/src/com/vaadin/ui/Label.java index 89281e0c27..27145946d8 100644 --- a/server/src/com/vaadin/ui/Label.java +++ b/server/src/com/vaadin/ui/Label.java @@ -192,14 +192,9 @@ public class Label extends AbstractComponent implements Property<String>, * the New value of the label. */ @Override - public void setValue(Object newStringValue) { - if (newStringValue != null && newStringValue.getClass() != String.class) { - throw new Converter.ConversionException("Value of type " - + newStringValue.getClass() + " cannot be assigned to " - + String.class.getName()); - } + public void setValue(String newStringValue) { if (getPropertyDataSource() == null) { - getState().text = (String) newStringValue; + getState().text = newStringValue; } else { throw new IllegalStateException( "Label is only a Property.Viewer and cannot update its data source"); diff --git a/server/src/com/vaadin/ui/ProgressIndicator.java b/server/src/com/vaadin/ui/ProgressIndicator.java index fa51197a8b..1c35d3d1d8 100644 --- a/server/src/com/vaadin/ui/ProgressIndicator.java +++ b/server/src/com/vaadin/ui/ProgressIndicator.java @@ -153,7 +153,7 @@ public class ProgressIndicator extends AbstractField<Number> implements * @see com.vaadin.ui.AbstractField#setValue() */ @Override - public void setValue(Object newValue) { + public void setValue(Number newValue) { if (dataSource == null) { throw new IllegalStateException("Datasource must be set"); } diff --git a/server/src/com/vaadin/ui/Slider.java b/server/src/com/vaadin/ui/Slider.java index fe913f6b2c..4c829a7cb4 100644 --- a/server/src/com/vaadin/ui/Slider.java +++ b/server/src/com/vaadin/ui/Slider.java @@ -289,14 +289,9 @@ public class Slider extends AbstractField<Double> { } @Override - public void setValue(Object newFieldValue) { - if (newFieldValue instanceof Number) { - // Support setting all types of Numbers - newFieldValue = ((Number) newFieldValue).doubleValue(); - } + public void setValue(Double newFieldValue) { super.setValue(newFieldValue); - // The cast is safe if the above call returned without throwing - getState().value = (Double) newFieldValue; + getState().value = newFieldValue; } /** |