Converter@Deprecated public abstract class PropertyFormatter<T> extends AbstractProperty<String> implements Property.Viewer, Property.ValueChangeListener, Property.ReadOnlyStatusChangeListener
Property.
This class can be used to implement formatting for any type of Property datasources. The idea is to connect this as proxy between UI component and the original datasource.
For example
adds formatter for Double-typed property that extends
standard "1.0" notation with more zeroes.
textfield.setPropertyDataSource(new PropertyFormatter(property) {
public String format(Object value) {
return ((Double) value).toString() + "000000000";
}
public Object parse(String formattedValue) throws Exception {
return Double.parseDouble(formattedValue);
}
});
AbstractProperty.ReadOnlyStatusChangeEventProperty.Editor, Property.ReadOnlyException, Property.ReadOnlyStatusChangeListener, Property.ReadOnlyStatusChangeNotifier, Property.Transactional<T>, Property.ValueChangeListener, Property.ValueChangeNotifier, Property.Viewer| Modifier | Constructor and Description |
|---|---|
protected |
PropertyFormatter()
Deprecated.
Construct a new
PropertyFormatter that is not connected to any
data source. |
|
PropertyFormatter(Property<T> propertyDataSource)
Deprecated.
Construct a new formatter that is connected to given data source.
|
| Modifier and Type | Method and Description |
|---|---|
abstract String |
format(T value)
Deprecated.
This method must be implemented to format the values received from
DataSource.
|
Property<T> |
getPropertyDataSource()
Deprecated.
Gets the current data source of the formatter, if any.
|
Class<String> |
getType()
Deprecated.
Returns the type of the Property.
|
String |
getValue()
Deprecated.
Get the formatted value.
|
boolean |
isReadOnly()
Deprecated.
Reflects the read-only status of the datasource.
|
abstract T |
parse(String formattedValue)
Deprecated.
Parse string and convert it to format compatible with datasource.
|
void |
readOnlyStatusChange(Property.ReadOnlyStatusChangeEvent event)
Deprecated.
Listens for changes in the datasource.
|
void |
setPropertyDataSource(Property newDataSource)
Deprecated.
Sets the specified Property as the data source for the formatter.
|
void |
setReadOnly(boolean newStatus)
Deprecated.
Sets the Property's read-only mode to the specified status.
|
void |
setValue(String newValue)
Deprecated.
Sets the value of the Property.
|
void |
valueChange(Property.ValueChangeEvent event)
Deprecated.
Listens for changes in the datasource.
|
addListener, addListener, addReadOnlyStatusChangeListener, addValueChangeListener, fireReadOnlyStatusChange, fireValueChange, getListeners, removeListener, removeListener, removeReadOnlyStatusChangeListener, removeValueChangeListener, toStringprotected PropertyFormatter()
PropertyFormatter that is not connected to any
data source. Call setPropertyDataSource(Property) later on to
attach it to a property.public PropertyFormatter(Property<T> propertyDataSource)
format(Object) which can be a problem if the formatter has not
yet been initialized.propertyDataSource - to connect this property to.public Property<T> getPropertyDataSource()
getPropertyDataSource in interface Property.Viewernull if
none defined.public void setPropertyDataSource(Property newDataSource)
Remember that new data sources getValue() must return objects that are compatible with parse() and format() methods.
setPropertyDataSource in interface Property.ViewernewDataSource - the new data source Property.public Class<String> getType()
PropertygetValue and
setValue must be compatible with this type: one must be able
to safely cast the value returned from getValue to the given
type and pass any variable assignable to this type as an argument to
setValue.public String getValue()
public boolean isReadOnly()
isReadOnly in interface Property<String>isReadOnly in class AbstractProperty<String>true if the Property is in read-only mode,
false if it's notpublic abstract String format(T value)
value - Value object got from the datasource. This is guaranteed to be
non-null and of the type compatible with getType() of the
datasource.public abstract T parse(String formattedValue) throws Exception
formattedValue - This is guaranteed to be non-null string.Exception - Any type of exception can be thrown to indicate that the
conversion was not succesful.public void setReadOnly(boolean newStatus)
setReadOnly in interface Property<String>setReadOnly in class AbstractProperty<String>newStatus - the new read-only status of the Property.public void setValue(String newValue) throws Property.ReadOnlyException
Property
Implementing this functionality is optional. If the functionality is
missing, one should declare the Property to be in read-only mode and
throw Property.ReadOnlyException in this function.
setValue in interface Property<String>newValue - New value of the Property. This should be assignable to the
type returned by getTypeProperty.ReadOnlyException - if the object is in read-only modepublic void valueChange(Property.ValueChangeEvent event)
valueChange in interface Property.ValueChangeListenerevent - value change event objectpublic void readOnlyStatusChange(Property.ReadOnlyStatusChangeEvent event)
readOnlyStatusChange in interface Property.ReadOnlyStatusChangeListenerevent - Read-only status change event objectCopyright © 2016 Vaadin Ltd. All rights reserved.