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
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
-
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:
getValidation
in 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
manager
and callsJInputValidator.verify(javax.swing.JComponent)
to verify any text against the new manager.- Parameters:
manager
- the new manager
-