Package jmri.swing
Class SystemNameValidator
java.lang.Object
javax.swing.InputVerifier
com.alexandriasoftware.swing.JInputValidator
jmri.swing.SystemNameValidator
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
ConstructorsConstructorDescriptionSystemNameValidator(JComponent component, Manager<?> manager) Create a SystemNameValidator.SystemNameValidator(JComponent component, Manager<?> manager, boolean required) Create a SystemNameValidator. -
Method Summary
Modifier and TypeMethodDescriptionprotected com.alexandriasoftware.swing.ValidationgetValidation(JComponent component, com.alexandriasoftware.swing.JInputValidatorPreferences preferences) booleanvoidsetManager(Manager<?> manager) Set the Manager used to validate system names.voidsetRequired(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, verifyMethods inherited from class javax.swing.InputVerifier
shouldYieldFocus, shouldYieldFocus, verifyTarget
-
Constructor Details
-
SystemNameValidator
Create a SystemNameValidator. Same as callingSystemNameValidator(javax.swing.JComponent, jmri.Manager, boolean)withrequired == false.- Parameters:
component- the component to validate has a valid system namemanager- the manager that will be used for validation
-
SystemNameValidator
public SystemNameValidator(@Nonnull JComponent component, @Nonnull Manager<?> manager, boolean required) Create a SystemNameValidator.- Parameters:
component- the component to validate has a valid system namemanager- the manager that will be used for validationrequired- true if input must be valid andInputVerifier.verify(javax.swing.JComponent)must return true to allow focus change; false otherwise
-
-
Method Details
-
getValidation
protected com.alexandriasoftware.swing.Validation getValidation(JComponent component, com.alexandriasoftware.swing.JInputValidatorPreferences preferences) - Specified by:
getValidationin classcom.alexandriasoftware.swing.JInputValidator
-
isRequired
-
setRequired
-
setManager
Set the Manager used to validate system names.If the manager changes, fires the a property change for the property
managerand callsJInputValidator.verify(javax.swing.JComponent)to verify any text against the new manager.- Parameters:
manager- the new manager
-