Class SwingValidatorUtil
- java.lang.Object
-
- org.nuiton.validator.bean.simple.SimpleBeanValidators
-
- org.nuiton.jaxx.validator.swing.SwingValidatorUtil
-
public class SwingValidatorUtil extends org.nuiton.validator.bean.simple.SimpleBeanValidatorsThe helper class for swing validation module.- Author:
- Tony Chemit - dev@tchemit.fr
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedSwingValidatorUtil()
-
Method Summary
All Methods Static Methods Concrete Methods 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 List<String>detectValidators(JAXXValidator ui)Given aJAXXValidatorui, detects on it all the validators it contains.static ColorgetColor(org.nuiton.validator.NuitonValidatorScope scope)static EnumMap<org.nuiton.validator.NuitonValidatorScope,Color>getColors()static ImageIcongetErrorIcon()static SwingValidatorMessageListMouseListenergetErrorListMouseListener(JList list)static SwingValidatorMessageTableMouseListenergetErrorTableMouseListener(JTable table)static ImageIcongetFatalIcon()static StringgetFieldName(SwingListValidatorMessage model, String value)static StringgetFieldName(SwingValidatorMessage model, String value)static StringgetFieldName(UnifiedValidatorMessage model, String value)static StringgetFieldName(UnifiedValidatorMessage model, String value, String valueFallBack)static ImageIcongetIcon(org.nuiton.validator.NuitonValidatorScope scope)static EnumMap<org.nuiton.validator.NuitonValidatorScope,ImageIcon>getIcons()static ImageIcongetInfoIcon()static SwingValidatorMessageTableMouseListenergetListErrorTableMouseListener(JTable table)static StringgetMessage(SwingListValidatorMessage model)static StringgetMessage(SwingValidatorMessage model)static StringgetMessage(UnifiedValidatorMessage model)static StringgetMessage(org.nuiton.validator.bean.simple.SimpleBeanValidatorMessage model)protected static com.google.common.collect.Multimap<JComponent,ValidatorField>getValidatorEditors(JAXXValidator ui)static ImageIcongetWarningIcon()static voidinstallTabUI(JAXXValidator ui, TabInfoWithValidator tab)static voidinstallUI(JTable errorTable, SimpleBeanValidatorMessageTableRenderer render)Prepare the ui where to display the validators messages.static voidinstallUI(JTable errorTable, SwingListValidatorMessageTableRenderer render)Prepare the ui where to display the validators messages.static voidinstallUI(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(Class<O> type, String context)static SwingValidatorMessageListMouseListenerregisterErrorListMouseListener(JList list)Register for a given validator list ui a validator mouse listener.static SwingValidatorMessageTableMouseListenerregisterErrorTableMouseListener(JTable table)Register for a given validator table ui a validator mouse listenerstatic <O> voidregisterListValidator(org.nuiton.validator.bean.list.BeanListValidator<O> validator, SwingListValidatorMessageTableModel errorTableModel, JTable dataTable, JTable errorTable, SwingListValidatorDataLocator<O> dataLocator)Prepare the ui where to display the validators messages.static voidsetValidatorBean(JAXXObject ui, Object bean, String... excludeIds)Convinient method to attach a bean to all validators of an JAXXObject.static voidsetValidatorChanged(JAXXObject ui, boolean newValue, String... excludeIds)Convinient method to set the changed property to all validators of an JAXXObject.static voiduninstallTabUI(Collection<TabInfoWithValidator> tabEditors, SwingValidatorMessageTableModel errorTableModel)
-
-
-
Method Detail
-
getColor
public static Color getColor(org.nuiton.validator.NuitonValidatorScope scope)
-
getIcon
public static ImageIcon getIcon(org.nuiton.validator.NuitonValidatorScope scope)
-
getFatalIcon
public static ImageIcon getFatalIcon()
-
getErrorIcon
public static ImageIcon getErrorIcon()
-
getWarningIcon
public static ImageIcon getWarningIcon()
-
getInfoIcon
public static ImageIcon getInfoIcon()
-
newValidator
public static <O> SwingValidator<O> newValidator(Class<O> type, String context)
-
installUI
public static void installUI(JAXXValidator ui)
To install all the stuff for validation on aJAXXValidatorui.This method is called after validators has been detected in the ui (via the method
detectValidators(JAXXValidator))..It will first find and register all validator field via the method
JAXXValidator.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
public static List<String> detectValidators(JAXXValidator ui)
Given aJAXXValidatorui, detects on it all the validators it contains.A validator is detected from the annotation
Validatorplaced 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
public static void detectValidatorFields(JAXXValidator ui)
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 method
SwingValidator.setFieldRepresentation(String, JComponent).By default, this method is invoked in the generated method
JAXXValidator.registerValidatorFields()by a generated jaxx-validator file.- Parameters:
ui- the ui to seek
-
installUI
public static void installUI(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(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(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
-
installTabUI
public static void installTabUI(JAXXValidator ui, TabInfoWithValidator tab)
-
uninstallTabUI
public static void uninstallTabUI(Collection<TabInfoWithValidator> tabEditors, SwingValidatorMessageTableModel errorTableModel)
-
registerListValidator
public static <O> void registerListValidator(org.nuiton.validator.bean.list.BeanListValidator<O> validator, SwingListValidatorMessageTableModel errorTableModel, JTable dataTable, 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(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(JTable table)
Register for a given validator table ui a validator mouse listenerNote: 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(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(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(JTable table)
- Parameters:
table- the validator table ui- Returns:
- the validator table mouse listener, or
nullif not found - See Also:
SwingValidatorMessageTableMouseListener
-
getMessage
public static String getMessage(SwingValidatorMessage model)
-
getMessage
public static String getMessage(org.nuiton.validator.bean.simple.SimpleBeanValidatorMessage model)
-
getMessage
public static String getMessage(SwingListValidatorMessage model)
-
getMessage
public static String getMessage(UnifiedValidatorMessage model)
-
getFieldName
public static String getFieldName(SwingValidatorMessage model, String value)
-
getFieldName
public static String getFieldName(SwingListValidatorMessage model, String value)
-
getFieldName
public static String getFieldName(UnifiedValidatorMessage model, String value)
-
getFieldName
public static String getFieldName(UnifiedValidatorMessage model, String value, 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, Object bean, 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, 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<JComponent,ValidatorField> getValidatorEditors(JAXXValidator ui)
-
-