|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
public interface ItsNatFormattedTextField
Is the base interface of text based components which text is rendered/edited as a single line and following a format.
This component type is inspired in javax.swing.JFormattedTextField.
Some documentation is borrowed from Swing.
This component maintains two values, the value returned by ItsNatTextComponent.getText()
is the value in the visual control rendering the component, and the value returned by getValue().
The last one is restricted to the scope defined by getItsNatFormatter().
When a new value on the visual control is set as the component value calling commitEdit() first
is validated/converted calling ItsNatFormattedTextField.ItsNatFormatter.stringToValue(String,ItsNatFormattedTextField).
Any change to the internal value is notified with a "value" property change event
and may be vetoed (see setValue(Object)).
| Nested Class Summary | |
|---|---|
static interface |
ItsNatFormattedTextField.ItsNatFormatter
Defines an ItsNat formatter. |
static interface |
ItsNatFormattedTextField.ItsNatFormatterFactory
Defines an ItsNat formatter factory. |
| Field Summary | |
|---|---|
static int |
COMMIT
Constant identifying that when focus is lost, commitEdit should be invoked. |
static int |
COMMIT_OR_REVERT
Constant identifying that when focus is lost, commitEdit should be invoked. |
static int |
PERSIST
Constant identifying that when focus is lost, the edited value should be left. |
static int |
REVERT
Constant identifying that when focus is lost, editing value should be reverted to current value set on the component. |
| Method Summary | |
|---|---|
void |
commitEdit()
Forces the current value to be taken from the control and set as the current value converted first using the current ItsNatFormattedTextField.ItsNatFormatter. |
ItsNatFormattedTextField.ItsNatFormatterFactory |
createDefaultItsNatFormatterFactory()
Creates a new default ItsNat formatter factory. |
ItsNatFormattedTextField.ItsNatFormatter |
createItsNatFormatter(java.text.Format format)
Creates an ItsNat formatter wrapping the specified java.text.Format. |
int |
getFocusLostBehavior()
Returns the behavior when focus is lost. |
ItsNatFormattedTextField.ItsNatFormatter |
getItsNatFormatter()
This method is called when the component needs to convert an Object value from/to String. |
ItsNatFormattedTextField.ItsNatFormatterFactory |
getItsNatFormatterFactory()
Returns the current ItsNat formatter factory. |
java.lang.Object |
getValue()
Returns the last valid value. |
boolean |
hasFocus()
Informs whether this component has the focus. |
boolean |
isEdited()
Informs whether visual control content has changed and component value is still not modified. |
boolean |
isEditValid()
Returns true if the current value being edited is valid. |
void |
setFocusLostBehavior(int behavior)
Sets the behavior when focus is lost. |
void |
setFormat(java.text.Format format)
Defines a default ItsNat formatter based on the specified java.text.Format. |
void |
setItsNatFormatter(ItsNatFormattedTextField.ItsNatFormatter formatter)
Sets the default ItsNat formatter. |
void |
setItsNatFormatterFactory(ItsNatFormattedTextField.ItsNatFormatterFactory tf)
Sets the current ItsNat formatter factory. |
void |
setValue(java.lang.Object value)
Sets the value that will be formatted to the control by an ItsNatFormattedTextField.ItsNatFormatter obtained from the current
ItsNatFormattedTextField.ItsNatFormatterFactory. |
| Methods inherited from interface org.itsnat.comp.text.ItsNatTextField |
|---|
getItsNatTextFieldUI |
| Methods inherited from interface org.itsnat.comp.text.ItsNatTextComponent |
|---|
appendString, createDefaultDocument, getDocument, getItsNatTextComponentUI, getText, getText, insertString, replaceString, setDocument, setText |
| Methods inherited from interface org.itsnat.comp.ItsNatElementComponent |
|---|
getElement, getItsNatElementComponentUI |
| Methods inherited from interface org.itsnat.core.ItsNatUserData |
|---|
containsUserValueName, getUserValue, getUserValueNames, removeUserValue, setUserValue |
| Field Detail |
|---|
static final int COMMIT
commitEdit should be invoked. If in committing the
new value a ParseException or
PropertyVetoException is thrown, the invalid
value will remain.
setFocusLostBehavior(int),
Constant Field Valuesstatic final int COMMIT_OR_REVERT
commitEdit should be invoked. If in commiting the new
value a ParseException or
PropertyVetoException is thrown, the value will be
reverted.
setFocusLostBehavior(int),
Constant Field Valuesstatic final int REVERT
setFocusLostBehavior(int),
Constant Field Valuesstatic final int PERSIST
setFocusLostBehavior(int),
Constant Field Values| Method Detail |
|---|
int getFocusLostBehavior()
COMMIT_OR_REVERT,
COMMIT,
REVERT or
PERSIST
Note that some ItsNatFormattedTextField.ItsNatFormatters may push changes to the
control value.
COMMIT_OR_REVERT by defaultsetFocusLostBehavior(int)void setFocusLostBehavior(int behavior)
COMMIT_OR_REVERT,
COMMIT,
REVERT or
PERSIST
behavior - identifies behavior when focus is lostgetFocusLostBehavior()java.lang.Object getValue()
ItsNatFormattedTextField.ItsNatFormatter this may not return the current
edited value. The currently edited value can be obtained by invoking
commitEdit() followed by getValue().
void setValue(java.lang.Object value)
throws java.beans.PropertyVetoException
ItsNatFormattedTextField.ItsNatFormatter obtained from the current
ItsNatFormattedTextField.ItsNatFormatterFactory. If no
ItsNatFormattedTextField.ItsNatFormatterFactory has been specified, this will
attempt to create one based on the type of value.
This new value is "voted" before is set firing a java.beans.PropertyChangeEvent
event, with name "value", sent to the listeners registered with ItsNatComponent.addVetoableChangeListener(VetoableChangeListener)
if some listener does a "veto" (throws a java.beans.PropertyVetoException)
the new value is not set. If finally set the PropertyChangeEvent event
is sent to the listeners registered with
ItsNatComponent.addPropertyChangeListener(java.beans.PropertyChangeListener)
or ItsNatComponent.addPropertyChangeListener(String,java.beans.PropertyChangeListener)
with property name "value".
value - value to display (and may be edit).
java.beans.PropertyVetoException - if the new value was vetoed.
void commitEdit()
throws java.text.ParseException,
java.beans.PropertyVetoException
ItsNatFormattedTextField.ItsNatFormatter.
java.text.ParseException - if the ItsNatFormattedTextField.ItsNatFormatter is not able
to format the current control value
java.beans.PropertyVetoException - if the new value was vetoed.boolean isEdited()
boolean isEditValid()
boolean hasFocus()
Returned value is only valid if this component processes "focus" and "blur" events.
ItsNatFormattedTextField.ItsNatFormatterFactory createDefaultItsNatFormatterFactory()
Current implementation is an ItsNatFormatterFactoryDefault.
ItsNatFormattedTextField.ItsNatFormatterFactory getItsNatFormatterFactory()
By default ItsNat provides a default factory created with
createDefaultItsNatFormatterFactory().
setItsNatFormatterFactory(ItsNatFormatterFactory)void setItsNatFormatterFactory(ItsNatFormattedTextField.ItsNatFormatterFactory tf)
tf - the new formatter factory. May be null.ItsNatFormattedTextField.ItsNatFormatter getItsNatFormatter()
If a formatter was defined explicitly with a call to setItsNatFormatter(ItsNatFormatter)
this method returns this formatter, else returns the formatter of
the default formatter factory (getItsNatFormatterFactory() calling
ItsNatFormattedTextField.ItsNatFormatterFactory.getItsNatFormatter(ItsNatFormattedTextField),
if no factory is defined or the factory has not an appropriated formatter,
then the component tries to build an appropriated formatter to the current
value (getValue()).
void setItsNatFormatter(ItsNatFormattedTextField.ItsNatFormatter formatter)
formatter - the default formatter. May be null (the factory will be used).void setFormat(java.text.Format format)
java.text.Format.
The method createItsNatFormatter(java.text.Format) is called to create
an ItsNat formatter wrapping this format. The new ItsNat formatter is
set calling setItsNatFormatter(ItsNatFormatter).
format - the java.text.Format object to set as the default formatter.ItsNatFormattedTextField.ItsNatFormatter createItsNatFormatter(java.text.Format format)
java.text.Format.
Current implementation uses Format.parseObject(String) and
Format.format(Object) to convert string and values.
format - the java.text.Format to wrap.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||