|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjavax.swing.text.AbstractDocument
javax.swing.text.PlainDocument
com.metamatrix.toolbox.ui.widget.text.DefaultTextFieldModel
public class DefaultTextFieldModel
The default model for TextFields.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class javax.swing.text.AbstractDocument |
---|
javax.swing.text.AbstractDocument.AbstractElement, javax.swing.text.AbstractDocument.AttributeContext, javax.swing.text.AbstractDocument.BranchElement, javax.swing.text.AbstractDocument.Content, javax.swing.text.AbstractDocument.DefaultDocumentEvent, javax.swing.text.AbstractDocument.ElementEdit, javax.swing.text.AbstractDocument.LeafElement |
Field Summary |
---|
Fields inherited from class javax.swing.text.PlainDocument |
---|
lineLimitAttribute, tabSizeAttribute |
Fields inherited from class javax.swing.text.AbstractDocument |
---|
BAD_LOCATION, BidiElementName, ContentElementName, ElementNameAttribute, listenerList, ParagraphElementName, SectionElementName |
Fields inherited from interface com.metamatrix.toolbox.ui.widget.text.TextConstants |
---|
IS_MODIFIED_PROPERTY, IS_VALID_PROPERTY, MAXIMUM_LENGTH_PROPERTY, TEXT_PROPERTY |
Fields inherited from interface javax.swing.text.Document |
---|
StreamDescriptionProperty, TitleProperty |
Constructor Summary | |
---|---|
DefaultTextFieldModel()
|
Method Summary | |
---|---|
void |
addPropertyChangeListener(java.beans.PropertyChangeListener listener)
Registers a PropertyChangeListener to be notified of text and validity changes to the model. |
void |
addValidator(Validator validator)
Adds the specified text validator to the end of the list of registered validators. |
void |
addValidator(Validator validator,
int index)
Adds the specified text validator to the list of registered validators at the specified index. |
void |
commit()
Commits any new text set on the model. |
protected void |
firePropertyChangeEvent(java.beans.PropertyChangeEvent event)
Notifies all registered PropertyChangeListeners of a property change. |
protected void |
firePropertyChangeEvent(java.lang.String prop,
boolean oldVal,
boolean newVal)
Notifies all registered PropertyChangeListeners of a boolean value (flag) change. |
protected void |
firePropertyChangeEvent(java.lang.String prop,
int oldVal,
int newVal)
Notifies all registered PropertyChangeListeners of a integer value change. |
protected void |
firePropertyChangeEvent(java.lang.String prop,
java.lang.String oldText,
java.lang.String newText)
Notifies all registered PropertyChangeListeners of a text change. |
int |
getMaximumLength()
|
java.lang.Object |
getValidationResult()
Retrieves the result of the last validation check. |
protected void |
initializeDefaultTextFieldModel()
|
void |
insertString(int index,
java.lang.String text,
javax.swing.text.AttributeSet ignored)
Overridden to prevent insertion of invalid characters and mark model as modified. |
protected void |
invalidInsertionAttempted(char character,
int subIndex)
Called whenever an attempt is made to insert an invalid character. |
boolean |
isValid()
Determines whether the model's contents are valid by invoking each of its registered Validators. |
void |
remove(int index,
int length)
Overridden to mark model as modified. |
void |
removePropertyChangeListener(java.beans.PropertyChangeListener listener)
Unregisters a PropertyChangeListener. |
void |
removeValiditor(int index)
Removes the text validator at the specified index from the list of registered validators. |
void |
removeValiditor(Validator validator)
Removes the specified text validator from the list of registered validators. |
void |
rollback()
Rollsback to the previous value in the model. |
void |
setInvalidCharacters(java.lang.String invalidCharacters)
Sets the list of invalid characters that cannot be inserted into this model. |
void |
setMaximumLength(int length)
|
void |
setModified(boolean isModified)
Sets whether the model is marked as modified. |
void |
setValid(boolean isValid)
Sets whether the model's contents are marked as valid. |
void |
setValidCharacters(java.lang.String validCharacters)
Sets the list of valid characters that can be inserted into this model. |
Methods inherited from class javax.swing.text.PlainDocument |
---|
createDefaultRoot, getDefaultRootElement, getParagraphElement, insertUpdate, removeUpdate |
Methods inherited from class javax.swing.text.AbstractDocument |
---|
addDocumentListener, addUndoableEditListener, createBranchElement, createLeafElement, createPosition, dump, fireChangedUpdate, fireInsertUpdate, fireRemoveUpdate, fireUndoableEditUpdate, getAsynchronousLoadPriority, getAttributeContext, getBidiRootElement, getContent, getCurrentWriter, getDocumentFilter, getDocumentListeners, getDocumentProperties, getEndPosition, getLength, getListeners, getProperty, getRootElements, getStartPosition, getText, getText, getUndoableEditListeners, postRemoveUpdate, putProperty, readLock, readUnlock, removeDocumentListener, removeUndoableEditListener, render, replace, setAsynchronousLoadPriority, setDocumentFilter, setDocumentProperties, writeLock, writeUnlock |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public DefaultTextFieldModel()
Method Detail |
---|
public void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
listener
- A PropertyChangeListenerpublic void addValidator(Validator validator)
validator
- An instance of Validatorpublic void addValidator(Validator validator, int index)
validator
- An instance of Validatorindex
- The index within the validation list that the validator should be addedpublic void commit()
protected void firePropertyChangeEvent(java.beans.PropertyChangeEvent event)
protected void firePropertyChangeEvent(java.lang.String prop, java.lang.String oldText, java.lang.String newText)
protected void firePropertyChangeEvent(java.lang.String prop, boolean oldVal, boolean newVal)
protected void firePropertyChangeEvent(java.lang.String prop, int oldVal, int newVal)
public int getMaximumLength()
public java.lang.Object getValidationResult()
protected void initializeDefaultTextFieldModel()
public void insertString(int index, java.lang.String text, javax.swing.text.AttributeSet ignored) throws javax.swing.text.BadLocationException
insertString
in interface javax.swing.text.Document
insertString
in class javax.swing.text.PlainDocument
javax.swing.text.BadLocationException
protected void invalidInsertionAttempted(char character, int subIndex)
character
- The invalid character for which insertion was attemptedsubIndex
- The index within the model's text where the insertion was attemptedpublic boolean isValid()
public void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
listener
- A PropertyChangeListenerpublic void remove(int index, int length) throws javax.swing.text.BadLocationException
remove
in interface javax.swing.text.Document
remove
in class javax.swing.text.AbstractDocument
javax.swing.text.BadLocationException
public void removeValiditor(int index)
public void removeValiditor(Validator validator)
public void rollback() throws javax.swing.text.BadLocationException
javax.swing.text.BadLocationException
public void setInvalidCharacters(java.lang.String invalidCharacters) throws java.text.ParseException
"A-Z"
). To explicitly specify a dash as an invalid character, it must be entered as either the first character
in the string (not part of a range) or the final character in any range within the string.
Note that "A-Z"
specifies a different range than "a-z"
.
invalidCharacters
- A list of invalid characters and/or character ranges
java.text.ParseException
- If a dash appears at the end of the stringpublic void setMaximumLength(int length)
public void setModified(boolean isModified)
isModified
- True if the model should be marked as modifiedpublic void setValid(boolean isValid)
isValid
- True if the model's contents should be marked as validpublic void setValidCharacters(java.lang.String validCharacters) throws java.text.ParseException
"A-Z"
). To explicitly specify a dash as a valid character, it must be entered as either the first character in
the string (not part of a range) or the final character in any range within the string.
Note that "A-Z"
specifies a different range than "a-z"
.
validCharacters
- A list of valid characters and/or character ranges
java.text.ParseException
- If a dash appears at the end of the string
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |