|
||||||||||
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
AbstractComponent
AbstractComponent.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 AbstractComponent
target
- target UIDL stream where the component should paint
itself to
PaintException
- if the operation failedpublic abstract java.lang.Class getType()
Property
getValue
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 Property
public boolean isReadOnly()
isReadOnly
in interface Property
isReadOnly
in class AbstractComponent
true
if the Property is in read-only mode,
false
if it's notpublic void setReadOnly(boolean readOnly)
setReadOnly
in interface Property
setReadOnly
in class AbstractComponent
readOnly
- new read-only status of the PropertyComponent.setReadOnly(boolean)
public boolean isInvalidCommitted()
BufferedValidatable
isInvalidCommitted
in interface BufferedValidatable
public void setInvalidCommitted(boolean isCommitted)
BufferedValidatable
setInvalidCommitted
in interface BufferedValidatable
public void commit() throws Buffered.SourceException
Buffered
commit
is called.
commit
in interface Buffered
Buffered.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 Buffered
Buffered.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 Buffered
true
if the value in the object has been
modified since the last data source update, false
if
not.public boolean isWriteThrough()
Buffered
commit
being called after the modification.
isWriteThrough
in interface Buffered
true
if the object is in write-through mode,
false
if it's not.public void setWriteThrough(boolean writeTrough) throws Buffered.SourceException
Buffered
commit()
operation will be performed.
setWriteThrough
in interface Buffered
writeTrough
- Boolean value to indicate if the object should be
in write-through mode after the call.
Buffered.SourceException
public boolean isReadThrough()
Buffered
isReadThrough
in interface Buffered
true
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 Buffered
readTrough
- 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 Property
toString
in class java.lang.Object
String
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 Property
newValue
- 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.Viewer
null
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.Viewer
newDataSource
- the new data source Propertypublic void addValidator(Validator validator)
addValidator
in interface Validatable
validator
- the new validator to be addedpublic java.util.Collection getValidators()
getValidators
in interface Validatable
public void removeValidator(Validator validator)
removeValidator
in interface Validatable
validator
- the validator to removepublic boolean isValid()
isValid
in interface Validatable
true
if all registered validators claim that
the current value is valid, false
otherwisepublic void validate() throws Validator.InvalidValueException
Validatable
Validator.InvalidValueException
validate
in interface Validatable
Validator.InvalidValueException
- if the value is not validpublic boolean isInvalidAllowed()
isInvalidAllowed
in interface Validatable
Validatable.isInvalidAllowed()
public void setInvalidAllowed(boolean invalidAllowed) throws java.lang.UnsupportedOperationException
setInvalidAllowed
in interface Validatable
java.lang.UnsupportedOperationException
Validatable.setInvalidAllowed(boolean)
public ErrorMessage getErrorMessage()
getErrorMessage
in class AbstractComponent
AbstractComponent.getErrorMessage()
public void addListener(Property.ValueChangeListener listener)
Property.ValueChangeNotifier
addListener
in interface Property.ValueChangeNotifier
listener
- the new Listener to be registeredpublic void removeListener(Property.ValueChangeListener listener)
Property.ValueChangeNotifier
removeListener
in interface Property.ValueChangeNotifier
listener
- listener to be removedprotected void fireValueChange()
public void addListener(Property.ReadOnlyStatusChangeListener listener)
Property.ReadOnlyStatusChangeNotifier
addListener
in interface Property.ReadOnlyStatusChangeNotifier
listener
- the new Listener to be registeredpublic void removeListener(Property.ReadOnlyStatusChangeListener listener)
Property.ReadOnlyStatusChangeNotifier
removeListener
in interface Property.ReadOnlyStatusChangeNotifier
listener
- listener to be removedprotected void fireReadOnlyStatusChange()
public void valueChange(Property.ValueChangeEvent event)
valueChange
in interface Property.ValueChangeListener
event
- 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 |