org.openstreetmap.josm.gui.widgets
Class AbstractTextComponentValidator

java.lang.Object
  extended by org.openstreetmap.josm.gui.widgets.AbstractTextComponentValidator
All Implemented Interfaces:
java.awt.event.ActionListener, java.awt.event.FocusListener, java.beans.PropertyChangeListener, java.util.EventListener, javax.swing.event.DocumentListener
Direct Known Subclasses:
AdvancedChangesetQueryPanel.DateValidator, AdvancedChangesetQueryPanel.TimeValidator, AdvancedChangesetQueryPanel.UidInputFieldValidator, AdvancedChangesetQueryPanel.UserNameInputValidator, BoundingBoxSelectionPanel.LatitudeValidator, BoundingBoxSelectionPanel.LongitudeValidator, FullyAutomaticAuthorizationUI.PasswordValidator, FullyAutomaticAuthorizationUI.UserNameValidator, FullyAutomaticPropertiesPanel.UserNameValidator, ManualAuthorizationUI.AccessTokenKeyValidator, ManualAuthorizationUI.AccessTokenSecretValidator, OsmApiUrlInputPanel.ApiUrlValidator, OsmIdTextField.OsmIdValidator, SingleChangesetDownloadPanel.ChangesetIdValidator, TileSelectionBBoxChooser.TileAddressValidator, TileSelectionBBoxChooser.TileCoordinateValidator, UserNameValidator

public abstract class AbstractTextComponentValidator
extends java.lang.Object
implements java.awt.event.ActionListener, java.awt.event.FocusListener, javax.swing.event.DocumentListener, java.beans.PropertyChangeListener

This is an abstract class for a validator on a text component. Subclasses implement validate(). validate() is invoked whenever


Field Summary
private static java.awt.Color ERROR_BACKGROUND
           
private static javax.swing.border.Border ERROR_BORDER
           
private  java.lang.String msg
           
private  javax.swing.text.JTextComponent tc
           
private  java.lang.Boolean valid
          remembers whether the content of the text component is currently valid or not; null means, we don't know yet
 
Constructor Summary
AbstractTextComponentValidator(javax.swing.text.JTextComponent tc)
          Creates the validator and weires it to the text component tc.
AbstractTextComponentValidator(javax.swing.text.JTextComponent tc, boolean addActionListener)
          Alternative constructor that allows to turn off the actionListener.
AbstractTextComponentValidator(javax.swing.text.JTextComponent tc, boolean addFocusListener, boolean addDocumentListener, boolean addActionListener)
           
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent arg0)
           
 void changedUpdate(javax.swing.event.DocumentEvent arg0)
           
protected  void feedbackDisabled()
           
protected  void feedbackInvalid(java.lang.String msg)
           
protected  void feedbackValid(java.lang.String msg)
           
 void focusGained(java.awt.event.FocusEvent arg0)
           
 void focusLost(java.awt.event.FocusEvent arg0)
           
 javax.swing.text.JTextComponent getComponent()
          Replies the decorated text component
 void insertUpdate(javax.swing.event.DocumentEvent arg0)
           
abstract  boolean isValid()
          Replies true if the current content of the decorated text component is valid; false otherwise
 void propertyChange(java.beans.PropertyChangeEvent evt)
           
 void removeUpdate(javax.swing.event.DocumentEvent arg0)
           
abstract  void validate()
          Implement in subclasses to validate the content of the text component.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ERROR_BORDER

private static final javax.swing.border.Border ERROR_BORDER

ERROR_BACKGROUND

private static final java.awt.Color ERROR_BACKGROUND

tc

private javax.swing.text.JTextComponent tc

valid

private java.lang.Boolean valid
remembers whether the content of the text component is currently valid or not; null means, we don't know yet


msg

private java.lang.String msg
Constructor Detail

AbstractTextComponentValidator

public AbstractTextComponentValidator(javax.swing.text.JTextComponent tc)
                               throws java.lang.IllegalArgumentException
Creates the validator and weires it to the text component tc.

Parameters:
tc - the text component. Must not be null.
Throws:
java.lang.IllegalArgumentException - thrown if tc is null

AbstractTextComponentValidator

public AbstractTextComponentValidator(javax.swing.text.JTextComponent tc,
                                      boolean addActionListener)
                               throws java.lang.IllegalArgumentException
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.

Throws:
java.lang.IllegalArgumentException

AbstractTextComponentValidator

public AbstractTextComponentValidator(javax.swing.text.JTextComponent tc,
                                      boolean addFocusListener,
                                      boolean addDocumentListener,
                                      boolean addActionListener)
                               throws java.lang.IllegalArgumentException
Throws:
java.lang.IllegalArgumentException
Method Detail

feedbackInvalid

protected void feedbackInvalid(java.lang.String msg)

feedbackDisabled

protected void feedbackDisabled()

feedbackValid

protected void feedbackValid(java.lang.String msg)

getComponent

public javax.swing.text.JTextComponent getComponent()
Replies the decorated text component

Returns:
the decorated text component

validate

public abstract void validate()
Implement in subclasses to validate the content of the text component.


isValid

public abstract boolean 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

public void focusGained(java.awt.event.FocusEvent arg0)
Specified by:
focusGained in interface java.awt.event.FocusListener

focusLost

public void focusLost(java.awt.event.FocusEvent arg0)
Specified by:
focusLost in interface java.awt.event.FocusListener

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent arg0)
Specified by:
actionPerformed in interface java.awt.event.ActionListener

changedUpdate

public void changedUpdate(javax.swing.event.DocumentEvent arg0)
Specified by:
changedUpdate in interface javax.swing.event.DocumentListener

insertUpdate

public void insertUpdate(javax.swing.event.DocumentEvent arg0)
Specified by:
insertUpdate in interface javax.swing.event.DocumentListener

removeUpdate

public void removeUpdate(javax.swing.event.DocumentEvent arg0)
Specified by:
removeUpdate in interface javax.swing.event.DocumentListener

propertyChange

public void propertyChange(java.beans.PropertyChangeEvent evt)
Specified by:
propertyChange in interface java.beans.PropertyChangeListener


JOSM