Change-Id: I9f0e6bd62102c5adc461884b1f3b2cbe69f19259tags/7.0.0.beta6
@@ -132,7 +132,7 @@ public interface Container extends Serializable { | |||
* ID of the Property to retrieve | |||
* @return Property with the given ID or <code>null</code> | |||
*/ | |||
public Property<?> getContainerProperty(Object itemId, Object propertyId); | |||
public Property getContainerProperty(Object itemId, Object propertyId); | |||
/** | |||
* Gets the data type of all Properties identified by the given Property ID. |
@@ -40,7 +40,7 @@ public interface Item extends Serializable { | |||
* identifier of the Property to get | |||
* @return the Property with the given ID or <code>null</code> | |||
*/ | |||
public Property<?> getItemProperty(Object id); | |||
public Property getItemProperty(Object id); | |||
/** | |||
* Gets the collection of IDs of all Properties stored in the Item. |
@@ -76,7 +76,7 @@ public interface Property<T> extends Serializable { | |||
* @throws Property.ReadOnlyException | |||
* if the object is in read-only mode | |||
*/ | |||
public void setValue(Object newValue) throws Property.ReadOnlyException; | |||
public void setValue(T newValue) throws Property.ReadOnlyException; | |||
/** | |||
* Returns the type of the Property. The methods <code>getValue</code> and |
@@ -274,8 +274,7 @@ public class FieldGroup implements Serializable { | |||
* If the property was not found in the item or no item has been | |||
* set | |||
*/ | |||
protected Property<?> getItemProperty(Object propertyId) | |||
throws BindException { | |||
protected Property getItemProperty(Object propertyId) throws BindException { | |||
Item item = getItemDataSource(); | |||
if (item == null) { | |||
throw new BindException("Could not lookup property with id " |
@@ -274,7 +274,7 @@ public abstract class AbstractBeanContainer<IDTYPE, BEANTYPE> extends | |||
* java.lang.Object) | |||
*/ | |||
@Override | |||
public Property<?> getContainerProperty(Object itemId, Object propertyId) { | |||
public Property getContainerProperty(Object itemId, Object propertyId) { | |||
Item item = getItem(itemId); | |||
if (item == null) { | |||
return null; |
@@ -671,7 +671,7 @@ public class ContainerHierarchicalWrapper implements Container.Hierarchical, | |||
* documentation from implemented interface. | |||
*/ | |||
@Override | |||
public Property<?> getContainerProperty(Object itemId, Object propertyId) { | |||
public Property getContainerProperty(Object itemId, Object propertyId) { | |||
return container.getContainerProperty(itemId, propertyId); | |||
} | |||
@@ -463,7 +463,7 @@ public class ContainerOrderedWrapper implements Container.Ordered, | |||
* documentation from implemented interface. | |||
*/ | |||
@Override | |||
public Property<?> getContainerProperty(Object itemId, Object propertyId) { | |||
public Property getContainerProperty(Object itemId, Object propertyId) { | |||
return container.getContainerProperty(itemId, propertyId); | |||
} | |||
@@ -481,7 +481,7 @@ public class FilesystemContainer implements Container.Hierarchical { | |||
* @return the requested property's value, or <code>null</code> | |||
*/ | |||
@Override | |||
public Property<?> getContainerProperty(Object itemId, Object propertyId) { | |||
public Property getContainerProperty(Object itemId, Object propertyId) { | |||
if (!(itemId instanceof File)) { | |||
return null; | |||
@@ -633,7 +633,7 @@ public class FilesystemContainer implements Container.Hierarchical { | |||
* here, we use the default documentation from implemented interface. | |||
*/ | |||
@Override | |||
public Property<?> getItemProperty(Object id) { | |||
public Property getItemProperty(Object id) { | |||
return getContainerProperty(file, id); | |||
} | |||
@@ -163,7 +163,7 @@ public class IndexedContainer extends | |||
* java.lang.Object) | |||
*/ | |||
@Override | |||
public Property<?> getContainerProperty(Object itemId, Object propertyId) { | |||
public Property getContainerProperty(Object itemId, Object propertyId) { | |||
if (!containsId(itemId)) { | |||
return null; | |||
} | |||
@@ -734,7 +734,7 @@ public class IndexedContainer extends | |||
* @see com.vaadin.data.Item#getItemProperty(java.lang.Object) | |||
*/ | |||
@Override | |||
public Property<?> getItemProperty(Object id) { | |||
public Property getItemProperty(Object id) { | |||
return new IndexedContainerProperty(itemId, id); | |||
} | |||
@@ -841,7 +841,7 @@ public class IndexedContainer extends | |||
* | |||
* @since 3.0 | |||
*/ | |||
private class IndexedContainerProperty implements Property<Object>, | |||
private class IndexedContainerProperty<T> implements Property<T>, | |||
Property.ValueChangeNotifier { | |||
/** | |||
@@ -881,8 +881,8 @@ public class IndexedContainer extends | |||
* @see com.vaadin.data.Property#getType() | |||
*/ | |||
@Override | |||
public Class<?> getType() { | |||
return types.get(propertyId); | |||
public Class<T> getType() { | |||
return (Class<T>) types.get(propertyId); | |||
} | |||
/* | |||
@@ -891,8 +891,8 @@ public class IndexedContainer extends | |||
* @see com.vaadin.data.Property#getValue() | |||
*/ | |||
@Override | |||
public Object getValue() { | |||
return items.get(itemId).get(propertyId); | |||
public T getValue() { | |||
return (T) items.get(itemId).get(propertyId); | |||
} | |||
/* |
@@ -651,21 +651,14 @@ public class MethodProperty<T> extends AbstractProperty<T> { | |||
* @see #invokeSetMethod(Object) | |||
*/ | |||
@Override | |||
@SuppressWarnings("unchecked") | |||
public void setValue(Object newValue) throws Property.ReadOnlyException { | |||
public void setValue(T newValue) throws Property.ReadOnlyException { | |||
// Checks the mode | |||
if (isReadOnly()) { | |||
throw new Property.ReadOnlyException(); | |||
} | |||
// Checks the type of the value | |||
if (newValue != null && !type.isAssignableFrom(newValue.getClass())) { | |||
throw new IllegalArgumentException( | |||
"Invalid value type for ObjectProperty."); | |||
} | |||
invokeSetMethod((T) newValue); | |||
invokeSetMethod(newValue); | |||
fireValueChange(); | |||
} | |||
@@ -217,19 +217,13 @@ public class NestedMethodProperty<T> extends AbstractProperty<T> { | |||
* @see #invokeSetMethod(Object) | |||
*/ | |||
@Override | |||
public void setValue(Object newValue) throws ReadOnlyException { | |||
public void setValue(T newValue) throws ReadOnlyException { | |||
// Checks the mode | |||
if (isReadOnly()) { | |||
throw new Property.ReadOnlyException(); | |||
} | |||
// Checks the type of the value | |||
if (newValue != null && !type.isAssignableFrom(newValue.getClass())) { | |||
throw new IllegalArgumentException( | |||
"Invalid value type for NestedMethodProperty."); | |||
} | |||
invokeSetMethod((T) newValue); | |||
invokeSetMethod(newValue); | |||
fireValueChange(); | |||
} | |||
@@ -128,23 +128,14 @@ public class ObjectProperty<T> extends AbstractProperty<T> { | |||
* read-only mode | |||
*/ | |||
@Override | |||
@SuppressWarnings("unchecked") | |||
public void setValue(Object newValue) throws Property.ReadOnlyException { | |||
public void setValue(T newValue) throws Property.ReadOnlyException { | |||
// Checks the mode | |||
if (isReadOnly()) { | |||
throw new Property.ReadOnlyException(); | |||
} | |||
// Checks the type of the value | |||
if (newValue != null && !type.isAssignableFrom(newValue.getClass())) { | |||
throw new IllegalArgumentException("Invalid value type " | |||
+ newValue.getClass().getName() | |||
+ " for ObjectProperty of type " + type.getName() + "."); | |||
} | |||
// the cast is safe after an isAssignableFrom check | |||
this.value = (T) newValue; | |||
this.value = newValue; | |||
fireValueChange(); | |||
} |
@@ -212,7 +212,7 @@ public abstract class PropertyFormatter<T> extends AbstractProperty<String> | |||
} | |||
@Override | |||
public void setValue(Object newValue) throws ReadOnlyException { | |||
public void setValue(String newValue) throws ReadOnlyException { | |||
if (dataSource == null) { | |||
return; | |||
} |
@@ -68,7 +68,7 @@ public class PropertysetItem implements Item, Item.PropertySetChangeNotifier, | |||
* @return the Property with the given ID or <code>null</code> | |||
*/ | |||
@Override | |||
public Property<?> getItemProperty(Object id) { | |||
public Property getItemProperty(Object id) { | |||
return map.get(id); | |||
} | |||
@@ -129,7 +129,7 @@ public class TextFileProperty extends AbstractProperty<String> { | |||
* @see com.vaadin.data.Property#setValue(java.lang.Object) | |||
*/ | |||
@Override | |||
public void setValue(Object newValue) throws ReadOnlyException { | |||
public void setValue(String newValue) throws ReadOnlyException { | |||
if (isReadOnly()) { | |||
throw new ReadOnlyException(); | |||
} |
@@ -74,7 +74,7 @@ public class TransactionalPropertyWrapper<T> extends AbstractProperty<T> | |||
} | |||
@Override | |||
public void setValue(Object newValue) throws ReadOnlyException { | |||
public void setValue(T newValue) throws ReadOnlyException { | |||
// Causes a value change to be sent to this listener which in turn fires | |||
// a new value change event for this property | |||
wrappedProperty.setValue(newValue); |
@@ -61,7 +61,7 @@ public final class RowItem implements Item { | |||
} | |||
@Override | |||
public Property<?> getItemProperty(Object id) { | |||
public Property getItemProperty(Object id) { | |||
if (id instanceof String && id != null) { | |||
for (ColumnProperty cp : properties) { | |||
if (id.equals(cp.getPropertyId())) { |
@@ -248,7 +248,7 @@ public class SQLContainer implements Container, Container.Filterable, | |||
*/ | |||
@Override | |||
public Property<?> getContainerProperty(Object itemId, Object propertyId) { | |||
public Property getContainerProperty(Object itemId, Object propertyId) { | |||
Item item = getItem(itemId); | |||
if (item == null) { | |||
return null; |
@@ -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); | |||
} | |||
/** |
@@ -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); | |||
} | |||
@@ -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 |
@@ -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); |
@@ -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); | |||
} | |||
@@ -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"); |
@@ -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"); | |||
} |
@@ -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; | |||
} | |||
/** |
@@ -30,7 +30,7 @@ public abstract class AbstractFilterTest<FILTERTYPE extends Filter> extends | |||
} | |||
@Override | |||
public void setValue(Object newValue) throws ReadOnlyException { | |||
public void setValue(String newValue) throws ReadOnlyException { | |||
throw new ReadOnlyException(); | |||
} | |||
@@ -67,40 +67,6 @@ public class AbstractFieldValueConversions extends TestCase { | |||
assertEquals("abc", paulaBean.getFirstName()); | |||
} | |||
public void testFailingConversion() { | |||
TextField tf = new TextField(); | |||
tf.setConverter(new Converter<String, Integer>() { | |||
@Override | |||
public Integer convertToModel(String value, Locale locale) { | |||
throw new ConversionException("Failed"); | |||
} | |||
@Override | |||
public String convertToPresentation(Integer value, Locale locale) { | |||
throw new ConversionException("Failed"); | |||
} | |||
@Override | |||
public Class<Integer> getModelType() { | |||
// TODO Auto-generated method stub | |||
return null; | |||
} | |||
@Override | |||
public Class<String> getPresentationType() { | |||
// TODO Auto-generated method stub | |||
return null; | |||
} | |||
}); | |||
try { | |||
tf.setValue(1); | |||
fail("setValue(Integer) should throw an exception"); | |||
} catch (Converter.ConversionException e) { | |||
// OK, expected | |||
} | |||
} | |||
public void testIntegerStringConversion() { | |||
TextField tf = new TextField(); | |||
@@ -63,20 +63,20 @@ public class RemoveListenersOnDetach { | |||
}; | |||
}; | |||
Property property = new AbstractProperty() { | |||
Property<String> property = new AbstractProperty<String>() { | |||
@Override | |||
public Object getValue() { | |||
public String getValue() { | |||
return null; | |||
} | |||
@Override | |||
public void setValue(Object newValue) throws ReadOnlyException, | |||
public void setValue(String newValue) throws ReadOnlyException, | |||
ConversionException { | |||
fireValueChange(); | |||
} | |||
@Override | |||
public Class<?> getType() { | |||
public Class<String> getType() { | |||
return String.class; | |||
} | |||
}; |
@@ -10,12 +10,12 @@ public class SliderTest extends TestCase { | |||
public void testOutOfBounds() { | |||
Slider s = new Slider(0, 10); | |||
s.setValue(0); | |||
s.setValue(0.0); | |||
Assert.assertEquals(0.0, s.getValue()); | |||
s.setValue(10); | |||
s.setValue(10.0); | |||
Assert.assertEquals(10.0, s.getValue()); | |||
try { | |||
s.setValue(20); | |||
s.setValue(20.0); | |||
fail("Should throw out of bounds exception"); | |||
} catch (ValueOutOfBoundsException e) { | |||
// TODO: handle exception |
@@ -123,7 +123,7 @@ public abstract class AbstractTestFieldValueChange<T> extends TestCase { | |||
* Override in subclasses to set value with changeVariables(). | |||
*/ | |||
protected void setValue(AbstractField<T> field) { | |||
field.setValue("newValue"); | |||
field.setValue((T) "newValue"); | |||
} | |||
} |
@@ -15,7 +15,7 @@ public class TestMethodProperty { | |||
Integer.TYPE, myTest, "getInt", "setInt", new Object[0], | |||
new Object[] { null }, 0); | |||
methodProperty2.setValue("3"); | |||
methodProperty2.setValue(3); | |||
System.out.println("Succeeded"); | |||
@@ -20,7 +20,7 @@ import com.vaadin.ui.AbstractField; | |||
import com.vaadin.ui.MenuBar; | |||
import com.vaadin.ui.MenuBar.MenuItem; | |||
public abstract class AbstractFieldTest<T extends AbstractField<?>> extends | |||
public abstract class AbstractFieldTest<T extends AbstractField> extends | |||
AbstractComponentTest<T> implements ValueChangeListener, | |||
ReadOnlyStatusChangeListener { | |||
@@ -20,7 +20,7 @@ public class TableWithManyColumns extends TestBase { | |||
for (int row = 0; row < ROWS; row++) { | |||
Item i = t.addItem(String.valueOf(row)); | |||
for (int col = 0; col < COLS; col++) { | |||
Property<?> p = i.getItemProperty("COLUMN_" + col); | |||
Property<String> p = i.getItemProperty("COLUMN_" + col); | |||
p.setValue("item " + row + "/" + col); | |||
} | |||
} |
@@ -34,15 +34,8 @@ public class TextFieldWithPropertyFormatter extends TestBase { | |||
} | |||
@Override | |||
public void setValue(Object newValue) throws ReadOnlyException { | |||
if (newValue == null) { | |||
value = null; | |||
} else if (newValue instanceof BigDecimal) { | |||
value = (BigDecimal) newValue; | |||
} else { | |||
throw new IllegalArgumentException( | |||
"Value must be of type BigDecimal"); | |||
} | |||
public void setValue(BigDecimal newValue) throws ReadOnlyException { | |||
value = newValue; | |||
} | |||
@Override |
@@ -99,7 +99,7 @@ public class HierarchicalWrapperOrdering extends TestBase { | |||
// Get first item | |||
Object itemId = indexedContainer.getIdByIndex(0); | |||
Item item = indexedContainer.getItem(itemId); | |||
Property<String> property = (Property<String>) item | |||
Property<String> property = item | |||
.getItemProperty("name"); | |||
// Prepend with Z so item should get sorted later | |||
property.setValue("Z " + property.getValue()); |
@@ -526,7 +526,7 @@ public class LiferayThemeDemo extends LegacyApplication { | |||
Slider s = new Slider(); | |||
s.setWidth("200px"); | |||
try { | |||
s.setValue(50); | |||
s.setValue(50.0); | |||
} catch (ValueOutOfBoundsException e) { | |||
// TODO Auto-generated catch block | |||
e.printStackTrace(); | |||
@@ -538,7 +538,7 @@ public class LiferayThemeDemo extends LegacyApplication { | |||
s.setOrientation(SliderOrientation.VERTICAL); | |||
s.setHeight("200px"); | |||
try { | |||
s.setValue(50); | |||
s.setValue(50.0); | |||
} catch (ValueOutOfBoundsException e) { | |||
// TODO Auto-generated catch block | |||
e.printStackTrace(); |
@@ -514,7 +514,7 @@ public class HorizontalLayoutTests extends AbstractLayoutTests { | |||
fields[0].setRequiredError("required error"); | |||
fields[1] = new TextField(); | |||
fields[1].setValue("TEXTFIELD2"); | |||
((TextField) fields[1]).setValue("TEXTFIELD2"); | |||
fields[1] | |||
.setComponentError(new UserError("component error, user error")); | |||
@@ -542,7 +542,7 @@ public class VerticalLayoutTests extends AbstractLayoutTests { | |||
fields[0].setRequiredError("required error"); | |||
fields[1] = new TextField(); | |||
fields[1].setValue("TEXTFIELD2"); | |||
((TextField) fields[1]).setValue("TEXTFIELD2"); | |||
fields[1] | |||
.setComponentError(new UserError("component error, user error")); | |||
@@ -80,9 +80,7 @@ class TreeExample extends CustomComponent { | |||
// get the created item | |||
final Item item = tree.getItem(id); | |||
// set our "caption" property | |||
@SuppressWarnings("unchecked") | |||
final Property<String> p = (Property<String>) item | |||
.getItemProperty(CAPTION_PROPERTY); | |||
final Property<String> p = item.getItemProperty(CAPTION_PROPERTY); | |||
p.setValue(caption); | |||
if (parent != null) { | |||
tree.setChildrenAllowed(parent, true); |
@@ -165,7 +165,7 @@ public class Ticket2998 extends LegacyApplication { | |||
return getSecondaryTypesList(itemId); | |||
} | |||
final Field<?> f = super.createField(container, itemId, propertyId, | |||
final Field f = super.createField(container, itemId, propertyId, | |||
uiContext); | |||
if (f != null) { | |||
if (f instanceof TextField) { |
@@ -133,7 +133,7 @@ public class Ticket677 extends LegacyApplication { | |||
table.addContainerProperty("Text", String.class, null); | |||
for (int i = 0; i < 150; i++) { | |||
Item item = table.addItem("Item" + i); | |||
Property<?> p = item.getItemProperty("Text"); | |||
Property<String> p = item.getItemProperty("Text"); | |||
p.setValue(i % 5 == 0 ? "enabled" : "disabled"); | |||
} | |||