Class SwingValidatorUtil


  • public class SwingValidatorUtil
    extends org.nuiton.validator.bean.simple.SimpleBeanValidators
    The helper class for swing validation module.
    Author:
    Tony Chemit - dev@tchemit.fr
    • Field Detail

      • icons

        protected static EnumMap<org.nuiton.validator.NuitonValidatorScope,ImageIcon> icons
      • colors

        protected static EnumMap<org.nuiton.validator.NuitonValidatorScope,Color> colors
    • Constructor Detail

      • SwingValidatorUtil

        protected SwingValidatorUtil()
    • Method Detail

      • getIcons

        public static EnumMap<org.nuiton.validator.NuitonValidatorScope,ImageIcon> getIcons()
      • getColors

        public static EnumMap<org.nuiton.validator.NuitonValidatorScope,Color> getColors()
      • 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()
      • installUI

        public static void installUI​(JAXXValidator ui)
        To install all the stuff for validation on a JAXXValidator ui.

        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 $completeSetup method.

        Parameters:
        ui - the validator ui to init.
      • detectValidators

        public static List<String> detectValidators​(JAXXValidator ui)
        Given a JAXXValidator ui, detects on it all the validators it contains.

        A validator is detected from the annotation Validator placed on his field.

        This method is always inovked by a generated jaxx-validator file at the end of the $completeSetup method.

        Parameters:
        ui - the ui where to seek for validators.
        Returns:
        the list of ids of validators found on the given ui
      • 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 messages
        render - 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 messages
        render - 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 messages
        render - renderer to use
        Since:
        2.5.3
      • 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 states
        editor - the editor of beans
        dataLocator - the data locator
        scopes - 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 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
      • getMessage

        public static String getMessage​(org.nuiton.validator.bean.simple.SimpleBeanValidatorMessage model)
      • 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 listen
        ui - 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 treate
        bean - 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 treate
        newValue - the new value to set in changed validator property
        excludeIds - the list of validator id to exclude