Package jmri.swing

Class 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​(javax.swing.JComponent component, Manager<?> manager)
      Create a SystemNameValidator.
      SystemNameValidator​(javax.swing.JComponent component, Manager<?> manager, boolean required)
      Create a SystemNameValidator.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected com.alexandriasoftware.swing.Validation getValidation​(javax.swing.JComponent component, com.alexandriasoftware.swing.JInputValidatorPreferences preferences)  
      boolean isRequired()  
      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 Detail

      • SystemNameValidator

        public SystemNameValidator​(@Nonnull
                                   javax.swing.JComponent component,
                                   @Nonnull
                                   Manager<?> manager,
                                   boolean required)
        Create a SystemNameValidator.
        Parameters:
        component - the component to validate has a valid system name
        manager - the manager that will be used for validation
        required - true if input must be valid and InputVerifier.verify(javax.swing.JComponent) must return true to allow focus change; false otherwise
    • Method Detail

      • getValidation

        protected com.alexandriasoftware.swing.Validation getValidation​(javax.swing.JComponent component,
                                                                        com.alexandriasoftware.swing.JInputValidatorPreferences preferences)
        Specified by:
        getValidation in class com.alexandriasoftware.swing.JInputValidator
      • 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