Package jaxx.runtime.validator.swing
Class SwingValidatorUtil
java.lang.Object
org.nuiton.validator.bean.simple.SimpleBeanValidators
jaxx.runtime.validator.swing.SwingValidatorUtil
public class SwingValidatorUtil
extends org.nuiton.validator.bean.simple.SimpleBeanValidators
The helper class for swing validation module.
- Author:
- Tony Chemit - chemit@codelutin.com
-
Field Summary
-
Constructor Summary
Constructors Modifier Constructor Description protectedSwingValidatorUtil() -
Method Summary
Modifier and Type Method Description static <O> voidaddHightLighterOnEditor(org.nuiton.validator.bean.list.BeanListValidator<O> validator, org.jdesktop.swingx.JXTable editor, SwingListValidatorDataLocator<O> dataLocator, org.nuiton.validator.NuitonValidatorScope... scopes)Add hightlighters on the editor of beans.static voiddetectValidatorFields(JAXXValidator ui)Detects on aJAXXValidatorui all the validator fields it contains.static java.util.List<java.lang.String>detectValidators(JAXXValidator ui)Given aJAXXValidatorui, detects on it all the validators it contains.static java.awt.ColorgetColor(org.nuiton.validator.NuitonValidatorScope scope)static java.util.EnumMap<org.nuiton.validator.NuitonValidatorScope,java.awt.Color>getColors()static javax.swing.ImageIcongetErrorIcon()static SwingValidatorMessageListMouseListenergetErrorListMouseListener(javax.swing.JList list)static SwingValidatorMessageTableMouseListenergetErrorTableMouseListener(javax.swing.JTable table)static javax.swing.ImageIcongetFatalIcon()static java.lang.StringgetFieldName(SwingListValidatorMessage model, java.lang.String value)static java.lang.StringgetFieldName(SwingValidatorMessage model, java.lang.String value)static java.lang.StringgetFieldName(UnifiedValidatorMessage model, java.lang.String value)static java.lang.StringgetFieldName(UnifiedValidatorMessage model, java.lang.String value, java.lang.String valueFallBack)static javax.swing.ImageIcongetIcon(org.nuiton.validator.NuitonValidatorScope scope)static java.util.EnumMap<org.nuiton.validator.NuitonValidatorScope,javax.swing.ImageIcon>getIcons()static javax.swing.ImageIcongetInfoIcon()static SwingValidatorMessageTableMouseListenergetListErrorTableMouseListener(javax.swing.JTable table)static java.lang.StringgetMessage(SwingListValidatorMessage model)static java.lang.StringgetMessage(SwingValidatorMessage model)static java.lang.StringgetMessage(UnifiedValidatorMessage model)static java.lang.StringgetMessage(org.nuiton.validator.bean.simple.SimpleBeanValidatorMessage model)protected static com.google.common.collect.Multimap<javax.swing.JComponent,ValidatorField>getValidatorEditors(JAXXValidator ui)static javax.swing.ImageIcongetWarningIcon()static voidinstallUI(javax.swing.JTable errorTable, SimpleBeanValidatorMessageTableRenderer render)Prepare the ui where to display the validators messages.static voidinstallUI(javax.swing.JTable errorTable, SwingListValidatorMessageTableRenderer render)Prepare the ui where to display the validators messages.static voidinstallUI(javax.swing.JTable errorTable, SwingValidatorMessageTableRenderer render)Prepare the ui where to display the validators messages.static voidinstallUI(JAXXValidator ui)To install all the stuff for validation on aJAXXValidatorui.static voidlistenValidatorContextNameAndRefreshFields(SwingValidator<?> validator, JAXXValidator ui)Method to listen the modification of the context name and at each time reload fields of the ui.static <O> SwingValidator<O>newValidator(java.lang.Class<O> type, java.lang.String context)static SwingValidatorMessageListMouseListenerregisterErrorListMouseListener(javax.swing.JList list)Register for a given validator list ui a validator mouse listener.static SwingValidatorMessageTableMouseListenerregisterErrorTableMouseListener(javax.swing.JTable table)Register for a given validator table ui a validator mouse listener Note: there is onlt one listener registred for a givne table model, so invokin this method twice or more will have no effect.static <O> voidregisterListValidator(org.nuiton.validator.bean.list.BeanListValidator<O> validator, SwingListValidatorMessageTableModel errorTableModel, javax.swing.JTable dataTable, javax.swing.JTable errorTable, SwingListValidatorDataLocator<O> dataLocator)Prepare the ui where to display the validators messages.static voidsetValidatorBean(JAXXObject ui, java.lang.Object bean, java.lang.String... excludeIds)Convinient method to attach a bean to all validators of an JAXXObject.static voidsetValidatorChanged(JAXXObject ui, boolean newValue, java.lang.String... excludeIds)Convinient method to set the changed property to all validators of an JAXXObject.Methods inherited from class org.nuiton.validator.bean.simple.SimpleBeanValidators
getScopes, getScopesCountMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Field Details
-
icons
protected static java.util.EnumMap<org.nuiton.validator.NuitonValidatorScope,javax.swing.ImageIcon> icons -
colors
protected static java.util.EnumMap<org.nuiton.validator.NuitonValidatorScope,java.awt.Color> colors
-
-
Constructor Details
-
SwingValidatorUtil
protected SwingValidatorUtil()
-
-
Method Details
-
getIcons
public static java.util.EnumMap<org.nuiton.validator.NuitonValidatorScope,javax.swing.ImageIcon> getIcons() -
getColors
public static java.util.EnumMap<org.nuiton.validator.NuitonValidatorScope,java.awt.Color> getColors() -
getColor
public static java.awt.Color getColor(org.nuiton.validator.NuitonValidatorScope scope) -
getIcon
public static javax.swing.ImageIcon getIcon(org.nuiton.validator.NuitonValidatorScope scope) -
getFatalIcon
public static javax.swing.ImageIcon getFatalIcon() -
getErrorIcon
public static javax.swing.ImageIcon getErrorIcon() -
getWarningIcon
public static javax.swing.ImageIcon getWarningIcon() -
getInfoIcon
public static javax.swing.ImageIcon getInfoIcon() -
newValidator
public static <O> SwingValidator<O> newValidator(java.lang.Class<O> type, java.lang.String context) -
installUI
To install all the stuff for validation on aJAXXValidatorui. This method is called after validators has beeen detected in the ui (via the methoddetectValidators(JAXXValidator)).. It will first find and register all validator field via the methodJAXXValidator.registerValidatorFields(), then for each validators it will install ui for it (says connect validator to ui via layers) and will reload attached bean to make visible bean validation state on ui. This method is always inovked by a generated jaxx-validator file at the end of the$completeSetupmethod.- Parameters:
ui- the validator ui to init.
-
detectValidators
Given aJAXXValidatorui, detects on it all the validators it contains. A validator is detected from the annotationValidatorplaced on his field. This method is always inovked by a generated jaxx-validator file at the end of the$completeSetupmethod.- Parameters:
ui- the ui where to seek for validators.- Returns:
- the list of ids of validators found on the given ui
-
detectValidatorFields
Detects on aJAXXValidatorui all the validator fields it contains. A validator field is detected via the annotation placed on his field or his getter (in cas of inheritance). Each field found will be registred to his corresponding validator via the methodSwingValidator.setFieldRepresentation(String, JComponent). By default, this method is invoked in the generated methodJAXXValidator.registerValidatorFields()by a generated jaxx-validator file.- Parameters:
ui- the ui to seek
-
installUI
public static void installUI(javax.swing.JTable errorTable, SwingValidatorMessageTableRenderer render)Prepare the ui where to display the validators messages.- Parameters:
errorTable- the table where to display validators messagesrender- renderer to use
-
installUI
public static void installUI(javax.swing.JTable errorTable, SimpleBeanValidatorMessageTableRenderer render)Prepare the ui where to display the validators messages.- Parameters:
errorTable- the table where to display simpleBean validators messagesrender- renderer to use- Since:
- 2.6.23
-
installUI
public static void installUI(javax.swing.JTable errorTable, SwingListValidatorMessageTableRenderer render)Prepare the ui where to display the validators messages.- Parameters:
errorTable- the table where to display validators messagesrender- renderer to use- Since:
- 2.5.3
-
registerListValidator
public static <O> void registerListValidator(org.nuiton.validator.bean.list.BeanListValidator<O> validator, SwingListValidatorMessageTableModel errorTableModel, javax.swing.JTable dataTable, javax.swing.JTable errorTable, SwingListValidatorDataLocator<O> dataLocator)Prepare the ui where to display the validators messages.- Parameters:
errorTableModel-errorTable- the table where to display validators messages- Since:
- 2.5.3
-
addHightLighterOnEditor
public static <O> void addHightLighterOnEditor(org.nuiton.validator.bean.list.BeanListValidator<O> validator, org.jdesktop.swingx.JXTable editor, SwingListValidatorDataLocator<O> dataLocator, org.nuiton.validator.NuitonValidatorScope... scopes)Add hightlighters on the editor of beans.- Type Parameters:
O- type of bean to validate- Parameters:
validator- the validator where to find bean stateseditor- the editor of beansdataLocator- the data locatorscopes- scopes to hightlight- Since:
- 2.5.3
-
registerErrorListMouseListener
public static SwingValidatorMessageListMouseListener registerErrorListMouseListener(javax.swing.JList list)Register for a given validator list ui a validator mouse listener. Note: there is only one listener registred for a given list model, so invoking this method tiwce or more will have no effect.- Parameters:
list- the validation ui list- Returns:
- the listener instanciate or found
- See Also:
SwingValidatorMessageListMouseListener
-
registerErrorTableMouseListener
public static SwingValidatorMessageTableMouseListener registerErrorTableMouseListener(javax.swing.JTable table)Register for a given validator table ui a validator mouse listener Note: there is onlt one listener registred for a givne table model, so invokin this method twice or more will have no effect.- Parameters:
table- the validator table ui- Returns:
- the listener instanciate or found
- See Also:
SwingValidatorMessageTableMouseListener
-
getErrorListMouseListener
public static SwingValidatorMessageListMouseListener getErrorListMouseListener(javax.swing.JList list)- Parameters:
list- the validator list ui- Returns:
- the validator list mouse listener, or
nullif not found - See Also:
SwingValidatorMessageListMouseListener
-
getErrorTableMouseListener
public static SwingValidatorMessageTableMouseListener getErrorTableMouseListener(javax.swing.JTable table)- Parameters:
table- the validator table ui- Returns:
- the validator table mouse listener, or
nullif not found - See Also:
SwingValidatorMessageTableMouseListener
-
getListErrorTableMouseListener
public static SwingValidatorMessageTableMouseListener getListErrorTableMouseListener(javax.swing.JTable table)- Parameters:
table- the validator table ui- Returns:
- the validator table mouse listener, or
nullif not found - See Also:
SwingValidatorMessageTableMouseListener
-
getMessage
-
getMessage
public static java.lang.String getMessage(org.nuiton.validator.bean.simple.SimpleBeanValidatorMessage model) -
getMessage
-
getMessage
-
getFieldName
-
getFieldName
public static java.lang.String getFieldName(SwingListValidatorMessage model, java.lang.String value) -
getFieldName
-
getFieldName
public static java.lang.String getFieldName(UnifiedValidatorMessage model, java.lang.String value, java.lang.String valueFallBack) -
listenValidatorContextNameAndRefreshFields
public static void listenValidatorContextNameAndRefreshFields(SwingValidator<?> validator, JAXXValidator ui)Method to listen the modification of the context name and at each time reload fields of the ui.- Parameters:
validator- validator to listenui- ui to refresh when context name has changed- Since:
- 2.2.1
-
setValidatorBean
public static void setValidatorBean(JAXXObject ui, java.lang.Object bean, java.lang.String... excludeIds)Convinient method to attach a bean to all validators of an JAXXObject. It is possible to exclude some validator to be treated.- Parameters:
ui- the ui containing the validatros to treatebean- the bean to attach in validators (can be null)excludeIds- the list of validator id to exclude
-
setValidatorChanged
public static void setValidatorChanged(JAXXObject ui, boolean newValue, java.lang.String... excludeIds)Convinient method to set the changed property to all validators of an JAXXObject. It is possible to exclude some validator to be treated.- Parameters:
ui- the ui containing the validatros to treatenewValue- the new value to set in changed validator propertyexcludeIds- the list of validator id to exclude
-
getValidatorEditors
protected static com.google.common.collect.Multimap<javax.swing.JComponent,ValidatorField> getValidatorEditors(JAXXValidator ui)
-