Class AbstractTextComponentValidator
java.lang.Object
org.openstreetmap.josm.gui.util.ChangeNotifier
org.openstreetmap.josm.gui.widgets.AbstractTextComponentValidator
- All Implemented Interfaces:
ActionListener,FocusListener,PropertyChangeListener,EventListener,DocumentListener
- Direct Known Subclasses:
BoundingBoxSelectionPanel.LatitudeValidator,BoundingBoxSelectionPanel.LongitudeValidator,ChangesetIdTextField.ChangesetIdValidator,DateValidator,DefaultTextComponentValidator,LatLonDialog.EastNorthValidator,LatLonDialog.LatLonValidator,OsmApiUrlInputPanel.ApiUrlValidator,OsmIdTextField.OsmIdValidator,TileSelectionBBoxChooser.TileAddressValidator,TileSelectionBBoxChooser.TileCoordinateValidator,TimeValidator,UidInputFieldValidator,UploadStrategySelectionPanel.ChunkSizeValidator,UploadTextComponentValidator
public abstract class AbstractTextComponentValidator
extends ChangeNotifier
implements ActionListener, FocusListener, DocumentListener, PropertyChangeListener
This is an abstract class for a validator on a text component.
Subclasses implement
validate(). validate() is invoked whenever
- the content of the text component changes (the validator is a
DocumentListener) - the text component loses focus (the validator is a
FocusListener) - the text component is a
JosmTextFieldand anActionEventis detected
- Since:
- 2688
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static enum -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final Colorprotected static final Borderprotected static final Colorprivate Stringprivate final JTextComponentprotected static final Borderprotected static final Colorprotected static final Colorprotected static final Borderprotected static final Colorprotected static final Color -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedCreates the validator and wires it to the text componenttc.protectedAbstractTextComponentValidator(JTextComponent tc, boolean addActionListener) Alternative constructor that allows to turn off the actionListener.protectedAbstractTextComponentValidator(JTextComponent tc, boolean addFocusListener, boolean addDocumentListener, boolean addActionListener) Constructs a newAbstractTextComponentValidator. -
Method Summary
Modifier and TypeMethodDescriptionvoidvoidprivate voidfeedback(Border border, Color background, String tooltip, AbstractTextComponentValidator.Status status, String msg) protected voidprotected voidfeedbackInvalid(String msg) protected voidfeedbackValid(String msg) protected voidfeedbackWarning(String msg) voidvoidReplies the decorated text componentprivate booleanhasChanged(String msg, AbstractTextComponentValidator.Status status) voidabstract booleanisValid()Replies true if the current content of the decorated text component is valid; false otherwisevoidvoidabstract voidvalidate()Implement in subclasses to validate the content of the text component.Methods inherited from class org.openstreetmap.josm.gui.util.ChangeNotifier
addChangeListener, fireStateChanged, removeChangeListener
-
Field Details
-
ERROR_COLOR
-
ERROR_BORDER
-
ERROR_BACKGROUND
-
WARNING_COLOR
-
WARNING_BORDER
-
WARNING_FOREGROUND
-
WARNING_BACKGROUND
-
VALID_COLOR
-
VALID_BORDER
-
tc
-
status
-
msg
-
-
Constructor Details
-
AbstractTextComponentValidator
Creates the validator and wires it to the text componenttc.- Parameters:
tc- the text component. Must not be null.- Throws:
IllegalArgumentException- if tc is null
-
AbstractTextComponentValidator
Alternative constructor that allows to turn off the actionListener. This can be useful if the enter key stroke needs to be forwarded to the default button in a dialog.- Parameters:
tc- text componentaddActionListener-trueto add the action listener
-
AbstractTextComponentValidator
protected AbstractTextComponentValidator(JTextComponent tc, boolean addFocusListener, boolean addDocumentListener, boolean addActionListener) Constructs a newAbstractTextComponentValidator.- Parameters:
tc- text componentaddFocusListener-trueto add the focus listeneraddDocumentListener-trueto add the document listeneraddActionListener-trueto add the action listener
-
-
Method Details
-
feedbackInvalid
-
feedbackWarning
-
feedbackDisabled
-
feedbackValid
-
hasChanged
-
feedback
-
getComponent
Replies the decorated text component- Returns:
- the decorated text component
-
validate
Implement in subclasses to validate the content of the text component. -
isValid
Replies true if the current content of the decorated text component is valid; false otherwise- Returns:
- true if the current content of the decorated text component is valid
-
focusGained
- Specified by:
focusGainedin interfaceFocusListener
-
focusLost
- Specified by:
focusLostin interfaceFocusListener
-
actionPerformed
- Specified by:
actionPerformedin interfaceActionListener
-
changedUpdate
- Specified by:
changedUpdatein interfaceDocumentListener
-
insertUpdate
- Specified by:
insertUpdatein interfaceDocumentListener
-
removeUpdate
- Specified by:
removeUpdatein interfaceDocumentListener
-
propertyChange
- Specified by:
propertyChangein interfacePropertyChangeListener
-