Package jmri.swing

Class SystemNameValidator

java.lang.Object
javax.swing.InputVerifier
com.alexandriasoftware.swing.JInputValidator
jmri.swing.SystemNameValidator

public class SystemNameValidator extends com.alexandriasoftware.swing.JInputValidator
A JInputValidator that validates a NamedBean system name.

Until the component gets focus, no validation icon is shown. Once the component has focus the following icons are shown:

  • If the component is blank and required was false when the validator was created, no validation is shown.
  • If the component is blank and required was true when the validator was created, a warning icon is shown.
  • If the component has an invalid system name, an error icon is shown.
  • If the component has a potentially valid system name, a waring icon is shown.
  • If the component has a valid system name, a success icon is shown.
  • Constructor Summary

    Constructors
    Constructor
    Description
    SystemNameValidator(JComponent component, Manager<?> manager)
    Create a SystemNameValidator.
    SystemNameValidator(JComponent component, Manager<?> manager, boolean required)
    Create a SystemNameValidator.
  • Method Summary

    Modifier and Type
    Method
    Description
    protected com.alexandriasoftware.swing.Validation
    getValidation(JComponent component, com.alexandriasoftware.swing.JInputValidatorPreferences preferences)
     
    boolean
     
    void
    setManager(Manager<?> manager)
    Set the Manager used to validate system names.
    void
    setRequired(boolean required)
     

    Methods inherited from class com.alexandriasoftware.swing.JInputValidator

    addPropertyChangeListener, addPropertyChangeListener, getComponent, getNoneValidation, getPropertyChangeListeners, getPropertyChangeListeners, getPropertyChangeSupport, getToolTipText, getValidation, isVerifying, removePropertyChangeListener, removePropertyChangeListener, setToolTipText, setValidationPreferences, setVerifying, trimHtmlTags, verify

    Methods inherited from class javax.swing.InputVerifier

    shouldYieldFocus, shouldYieldFocus, verifyTarget

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

  • Method Details

    • getValidation

      protected com.alexandriasoftware.swing.Validation getValidation(JComponent component, com.alexandriasoftware.swing.JInputValidatorPreferences preferences)
      Specified by:
      getValidation in class com.alexandriasoftware.swing.JInputValidator
    • isRequired

      public boolean isRequired()
    • setRequired

      public void setRequired(boolean required)
    • setManager

      public void setManager(@Nonnull Manager<?> manager)
      Set the Manager used to validate system names.

      If the manager changes, fires the a property change for the property manager and calls JInputValidator.verify(javax.swing.JComponent) to verify any text against the new manager.

      Parameters:
      manager - the new manager