|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.itmill.toolkit.terminal.Identifiable
com.itmill.toolkit.ui.AbstractComponent
com.itmill.toolkit.ui.AbstractField
public abstract class AbstractField
Abstract field component for implementing buffered property editors. The
field may hold an internal value, or it may be connected to any data source
that implements the Propertyinterface.
AbstractField implements that interface itself, too, so
accessing the Property value represented by it is straightforward.
AbstractField also provides the Buffered
interface for buffering the data source value. By default the Field is in
write through-mode and setWriteThrough(boolean)should be called to
enable buffering.
The class also supports validators
to make sure the value contained in the field is valid.
| Nested Class Summary | |
|---|---|
class |
AbstractField.ReadOnlyStatusChangeEvent
An Event object specifying the Property whose read-only
status has changed. |
| Nested classes/interfaces inherited from interface com.itmill.toolkit.ui.Field |
|---|
Field.ValueChangeEvent |
| Nested classes/interfaces inherited from interface com.itmill.toolkit.ui.Component |
|---|
Component.ErrorEvent, Component.ErrorListener, Component.Event, Component.Focusable, Component.Listener |
| Nested classes/interfaces inherited from interface com.itmill.toolkit.terminal.Paintable |
|---|
Paintable.RepaintRequestEvent, Paintable.RepaintRequestListener |
| Nested classes/interfaces inherited from interface com.itmill.toolkit.data.Buffered |
|---|
Buffered.SourceException |
| Nested classes/interfaces inherited from interface com.itmill.toolkit.data.Property |
|---|
Property.ConversionException, Property.Editor, Property.ReadOnlyException, Property.ReadOnlyStatusChangeListener, Property.ReadOnlyStatusChangeNotifier, Property.ValueChangeListener, Property.ValueChangeNotifier, Property.Viewer |
| Constructor Summary | |
|---|---|
AbstractField()
|
|
| Method Summary | |
|---|---|
void |
addListener(Property.ReadOnlyStatusChangeListener listener)
Registers a new read-only status change listener for this Property. |
void |
addListener(Property.ValueChangeListener listener)
Registers a new value change listener for this Property. |
void |
addValidator(Validator validator)
Adds a new validator for the field's value. |
void |
attach()
Notifies the component that it is connected to an application. |
void |
commit()
Updates all changes since the previous commit to the data source. |
static AbstractField |
constructField(Class propertyType)
Creates abstract field by the type of the property. |
void |
discard()
Discards all changes since last commit. |
void |
finalize()
Free used resources. |
protected void |
fireReadOnlyStatusChange()
Emits the read-only status change event. |
protected void |
fireValueChange()
Emits the value change event. |
void |
focus()
Asks the terminal to place the cursor to this field. |
ErrorMessage |
getErrorMessage()
Error messages shown by the fields are composites of the error message thrown by the superclasses (that is the component error message), validation errors and buffered source errors. |
long |
getFocusableId()
Gets the unique ID of focusable |
Property |
getPropertyDataSource()
Gets the current data source of the field, if any. |
int |
getTabIndex()
Gets the tab index of this field. |
abstract Class |
getType()
Returns the type of the Property. |
Collection |
getValidators()
Gets the validators of the field. |
Object |
getValue()
Gets the current value of the field. |
boolean |
isInvalidAllowed()
Fields allow invalid values by default. |
boolean |
isInvalidCommitted()
Tests if the invalid data is committed to datasource. |
boolean |
isModified()
Tests if the value stored in the object has been modified since it was last updated from the data source. |
boolean |
isReadOnly()
The abstract field is read only also if the data source is in readonly mode. |
boolean |
isReadThrough()
Tests if the object is in read-through mode. |
boolean |
isRequired()
Is this field required. |
boolean |
isValid()
Tests the current value against all registered validators. |
boolean |
isWriteThrough()
Tests if the object is in write-through mode. |
void |
paintContent(PaintTarget target)
Paints any needed component-specific things to the given UIDL stream. |
void |
removeListener(Property.ReadOnlyStatusChangeListener listener)
Removes a previously registered read-only status change listener. |
void |
removeListener(Property.ValueChangeListener listener)
Removes a previously registered value change listener. |
void |
removeValidator(Validator validator)
Removes the validator from the field. |
protected void |
setInternalValue(Object newValue)
Sets the internal field value. |
void |
setInvalidAllowed(boolean invalidAllowed)
Fields allow invalid values by default. |
void |
setInvalidCommitted(boolean isCommitted)
Sets if the invalid data should be committed to datasource. |
void |
setPropertyDataSource(Property newDataSource)
Sets the specified Property as the data source for the field. |
void |
setReadOnly(boolean readOnly)
Changes the readonly state and throw read-only status change events. |
void |
setReadThrough(boolean readTrough)
Sets the object's read-through mode to the specified status. |
void |
setRequired(boolean required)
Sets the field required. |
void |
setTabIndex(int tabIndex)
Gets the tab index of this field. |
void |
setValue(Object newValue)
Sets the value of the field. |
void |
setWriteThrough(boolean writeTrough)
Sets the object's write-through mode to the specified status. |
String |
toString()
Returns the value of the Property in human readable textual format. |
void |
validate()
Checks the validity of the validatable |
void |
valueChange(Property.ValueChangeEvent event)
This method listens to data source value changes and passes the changes forwards. |
| Methods inherited from class com.itmill.toolkit.ui.AbstractComponent |
|---|
addListener, addListener, addListener, addListener, changeVariables, childRequestedRepaint, dependsOn, detach, fireComponentErrorEvent, fireComponentEvent, fireEvent, getApplication, getCaption, getComponentError, getData, getDescription, getDirectDependencies, getIcon, getLocale, getParent, getStyle, getTag, getWindow, isEnabled, isImmediate, isVisible, paint, removeDirectDependency, removeListener, removeListener, removeListener, removeListener, removeListener, requestRepaint, requestRepaintRequests, setCaption, setComponentError, setData, setDescription, setEnabled, setIcon, setImmediate, setLocale, setParent, setStyle, setVisible |
| Methods inherited from class com.itmill.toolkit.terminal.Identifiable |
|---|
getDebugId, getUIID, setDebugId, setUIID |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface com.itmill.toolkit.ui.Field |
|---|
getDescription, setCaption, setDescription |
| Methods inherited from interface com.itmill.toolkit.ui.Component |
|---|
addListener, childRequestedRepaint, detach, getApplication, getCaption, getIcon, getLocale, getParent, getStyle, getWindow, isEnabled, isVisible, removeListener, setEnabled, setParent, setStyle, setVisible |
| Methods inherited from interface com.itmill.toolkit.terminal.Paintable |
|---|
addListener, paint, removeListener, requestRepaint, requestRepaintRequests |
| Methods inherited from interface com.itmill.toolkit.terminal.VariableOwner |
|---|
changeVariables, dependsOn, getDirectDependencies, isImmediate, removeDirectDependency |
| Constructor Detail |
|---|
public AbstractField()
| Method Detail |
|---|
public void paintContent(PaintTarget target)
throws PaintException
AbstractComponentAbstractComponent.paint(PaintTarget) method handles all general
attributes common to all components, and it calls this method to paint
any component-specific attributes to the UIDL stream.
paintContent in class AbstractComponenttarget - the target UIDL stream where the component should paint itself
to
PaintException - if the paint operation failed.public abstract Class 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.
getType in interface Propertypublic boolean isReadOnly()
isReadOnly in interface PropertyisReadOnly in interface ComponentisReadOnly in class AbstractComponenttrue if the component is in read-only mode,
false if not.public void setReadOnly(boolean readOnly)
setReadOnly in interface PropertysetReadOnly in interface ComponentsetReadOnly in class AbstractComponentreadOnly - the boolean value specifying if the component should be in
read-only mode after the call or not.Component.setReadOnly(boolean)public boolean isInvalidCommitted()
isInvalidCommitted in interface BufferedValidatableBufferedValidatable.isInvalidCommitted()public void setInvalidCommitted(boolean isCommitted)
setInvalidCommitted in interface BufferedValidatableBufferedValidatable.setInvalidCommitted(boolean)
public void commit()
throws Buffered.SourceException
Bufferedcommit is called.
commit in interface BufferedBuffered.SourceException - if the operation fails because of an exception is thrown by
the data source. The cause is included in the exception.
public void discard()
throws Buffered.SourceException
Buffered
discard in interface BufferedBuffered.SourceException - if the operation fails because of an exception is thrown by
the data source. The cause is included in the exception.public boolean isModified()
Buffered
isModified in interface Bufferedtrue if the value in the object has been modified
since the last data source update, false if not.public boolean isWriteThrough()
Bufferedcommit being called after the modification.
isWriteThrough in interface Bufferedtrue if the object is in write-through mode,
false if it's not.
public void setWriteThrough(boolean writeTrough)
throws Buffered.SourceException
Bufferedcommit operation
will be performed.
setWriteThrough in interface BufferedwriteTrough - Boolean value to indicate if the object should be in
write-through mode after the call.
Buffered.SourceException - If the operation fails because of an exception is thrown by
the data source.public boolean isReadThrough()
BufferedThe only exception to this rule is that when the object is not in write-through mode and it's buffer contains a modified value, the value retrieved from the object will be the locally modified value in the buffer which may differ from the value in the data source.
isReadThrough in interface Bufferedtrue if the object is in read-through mode,
false if it's not.
public void setReadThrough(boolean readTrough)
throws Buffered.SourceException
Buffered
setReadThrough in interface BufferedreadTrough - Boolean value to indicate if the object should be in
read-through mode after the call.
Buffered.SourceException - If the operation fails because of an exception is thrown by
the data source. The cause is included in the exception.public String toString()
toString in interface PropertytoString in class ObjectString representation of the value stored in the
PropertyObject.toString()public Object getValue()
getValue in interface Property
public void setValue(Object newValue)
throws Property.ReadOnlyException,
Property.ConversionException
setValue in interface PropertynewValue - the New value of the field.
Property.ReadOnlyException
Property.ConversionExceptionpublic Property getPropertyDataSource()
getPropertyDataSource in interface Property.Viewernull if
none defined.public void setPropertyDataSource(Property newDataSource)
Sets the specified Property as the data source for the field. All uncommitted changes to the field are discarded and the value is refreshed from the new data source.
If the datasource has any validators, the same validators are added to the field. Because the default behavior of the field is to allow invalid values, but not to allow committing them, this only adds visual error messages to fields and do not allow committing them as long as the value is invalid. After the value is valid, the error message is not shown and the commit can be done normally.
setPropertyDataSource in interface Property.ViewernewDataSource - the new data source Property.public void addValidator(Validator validator)
addValidator in interface Validatablevalidator - the new validator to be added.public Collection getValidators()
getValidators in interface Validatablepublic void removeValidator(Validator validator)
removeValidator in interface Validatablevalidator - the validator to remove.public boolean isValid()
isValid in interface Validatabletrue if all registered validators claim that the
current value is valid, false otherwise.
public void validate()
throws Validator.InvalidValueException
validate in interface ValidatableValidator.InvalidValueException - if the value is not validValidatable.validate()public boolean isInvalidAllowed()
isInvalidAllowed in interface ValidatableValidatable.isInvalidAllowed()
public void setInvalidAllowed(boolean invalidAllowed)
throws UnsupportedOperationException
In common setting where the user wants to assure the correctness of the datasource, but allow temporarily invalid contents in the field, the user should add the validators to datasource, that should not allow invalid values. The validators are automatically copied to the field when the datasource is set.
setInvalidAllowed in interface ValidatableUnsupportedOperationException - if the setInvalidAllowed is not supported.Validatable.setInvalidAllowed(boolean)public ErrorMessage getErrorMessage()
getErrorMessage in class AbstractComponentAbstractComponent.getErrorMessage()public void addListener(Property.ValueChangeListener listener)
Property.ValueChangeNotifier
addListener in interface Property.ValueChangeNotifierlistener - the new Listener to be registeredpublic void removeListener(Property.ValueChangeListener listener)
Property.ValueChangeNotifier
removeListener in interface Property.ValueChangeNotifierlistener - listener to be removedprotected void fireValueChange()
public void addListener(Property.ReadOnlyStatusChangeListener listener)
Property.ReadOnlyStatusChangeNotifier
addListener in interface Property.ReadOnlyStatusChangeNotifierlistener - the new Listener to be registeredpublic void removeListener(Property.ReadOnlyStatusChangeListener listener)
Property.ReadOnlyStatusChangeNotifier
removeListener in interface Property.ReadOnlyStatusChangeNotifierlistener - listener to be removedprotected void fireReadOnlyStatusChange()
public void valueChange(Property.ValueChangeEvent event)
valueChange in interface Property.ValueChangeListenerevent - the value change event telling the data source contents have
changed.public void focus()
focus in interface Component.Focusablepublic static AbstractField constructField(Class propertyType)
This returns most suitable field type for editing property of given type.
propertyType - the Type of the property, that needs to be edited.public int getTabIndex()
getTabIndex in interface Component.Focusablepublic void setTabIndex(int tabIndex)
setTabIndex in interface Component.FocusabletabIndex - the tab order of this component. Negative value means
unspecified.protected void setInternalValue(Object newValue)
newValue - the new value to be set.public long getFocusableId()
getFocusableId in interface Component.FocusableComponent.Focusable.getFocusableId()public void attach()
attach in interface Componentattach in class AbstractComponentComponent.attach()public boolean isRequired()
isRequired in interface Fieldtrue if the field is required .otherwise
false.public void setRequired(boolean required)
setRequired in interface Fieldrequired - Is the field required.
public void finalize()
throws Throwable
finalize in class ObjectThrowableObject.finalize()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||