|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object
|
+--org.millstone.base.ui.AbstractComponent
|
+--org.millstone.base.ui.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 Property
interface. 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. |
class |
AbstractField.ValueChangeEvent
An Event object specifying the Property whose value
has been changed. |
| Nested classes inherited from class org.millstone.base.data.Buffered |
Buffered.SourceException |
| Nested classes inherited from class org.millstone.base.data.Property |
Property.ConversionException, Property.Editor, Property.ReadOnlyException, Property.ReadOnlyStatusChangeListener, Property.ReadOnlyStatusChangeNotifier, Property.ValueChangeListener, Property.ValueChangeNotifier, Property.Viewer |
| Nested classes inherited from class org.millstone.base.ui.Component |
Component.Listener |
| Nested classes inherited from class org.millstone.base.terminal.Paintable |
Paintable.RepaintRequestEvent, Paintable.RepaintRequestListener |
| 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 |
commit()
Updates all changes since the previous commit to the data source. |
static AbstractField |
constructField(java.lang.Class propertyType)
Create field by the type of the property. |
void |
discard()
Discards all changes since last commit. |
protected void |
fireReadOnlyStatusChange()
Emit a read-only status change event. |
protected void |
fireValueChange()
Emit a value change event. |
void |
focus()
Ask 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. |
Property |
getPropertyDataSource()
Gets the current data source of the field, if any. |
abstract java.lang.Class |
getType()
Returns the type of the Property. |
java.util.Collection |
getValidators()
Gets the validators of the field. |
java.lang.Object |
getValue()
Gets the current value of the field. |
boolean |
isInvalidAllowed()
Fields allow invalid values by default. |
boolean |
isInvalidCommitted()
Is the invalid data 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 |
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)
Remove 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 a validator from the field. |
void |
setInvalidAllowed(boolean invalidAllowed)
Fields allow invalid values by default. |
void |
setInvalidCommitted(boolean isCommitted)
Set 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)
Change 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 |
setValue(java.lang.Object newValue)
Set the value of the field. |
void |
setWriteThrough(boolean writeTrough)
Sets the object's write-through mode to the specified status. |
java.lang.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 org.millstone.base.ui.AbstractComponent |
addListener, addListener, addListener, addListener, attach, changeVariables, childRequestedRepaint, dependsOn, detach, fireComponentEvent, fireEvent, getApplication, getCaption, getComponentError, getDescription, getDirectDependencies, getIcon, getLocale, getParent, getStyle, getTag, getWindow, isEnabled, isImmediate, isVisible, paint, removeDirectDependency, removeListener, removeListener, removeListener, removeListener, removeListener, requestRepaint, requestRepaintRequests, setCaption, setComponentError, setDescription, setEnabled, setIcon, setImmediate, setLocale, setParent, setStyle, setVisible |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| 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 - target UIDL stream where the component should paint
itself to
PaintException - if the operation failedpublic abstract java.lang.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 class AbstractComponenttrue if the Property is in read-only mode,
false if it's notpublic void setReadOnly(boolean readOnly)
setReadOnly in interface PropertysetReadOnly in class AbstractComponentreadOnly - new read-only status of the PropertyComponent.setReadOnly(boolean)public boolean isInvalidCommitted()
BufferedValidatable
isInvalidCommitted in interface BufferedValidatablepublic void setInvalidCommitted(boolean isCommitted)
BufferedValidatable
setInvalidCommitted in interface BufferedValidatable
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.SourceExceptionpublic boolean isReadThrough()
Buffered
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 java.lang.String toString()
toString in interface PropertytoString in class java.lang.ObjectString representation of the value stored in the
Propertypublic java.lang.Object getValue()
getValue in interface Property
public void setValue(java.lang.Object newValue)
throws Property.ReadOnlyException,
Property.ConversionException
setValue in interface PropertynewValue - New value of the field.
Property.ConversionException - if newValue can't
be converted into the Property's native type directly or through
String
Property.ReadOnlyException - if the object is in read-only
modepublic 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 Propertypublic void addValidator(Validator validator)
addValidator in interface Validatablevalidator - the new validator to be addedpublic java.util.Collection getValidators()
getValidators in interface Validatablepublic void removeValidator(Validator validator)
removeValidator in interface Validatablevalidator - the validator to removepublic 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
ValidatableValidator.InvalidValueException
validate in interface ValidatableValidator.InvalidValueException - if the value is not validpublic boolean isInvalidAllowed()
isInvalidAllowed in interface ValidatableValidatable.isInvalidAllowed()
public void setInvalidAllowed(boolean invalidAllowed)
throws java.lang.UnsupportedOperationException
setInvalidAllowed in interface Validatablejava.lang.UnsupportedOperationExceptionValidatable.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 changedpublic void focus()
public static AbstractField constructField(java.lang.Class propertyType)
This returns most suitable field type for editing property of given type
propertyType - Type of the property, that needs to be edited.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||