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 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

      public static void installUI​(JAXXValidator ui)
      To install all the stuff for validation on a JAXXValidator ui. This method is called after validators has beeen 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 java.util.List<java.lang.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
    • detectValidatorFields

      public static void detectValidatorFields​(JAXXValidator ui)
      Detects on a JAXXValidator ui 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​(javax.swing.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​(javax.swing.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​(javax.swing.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, 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 states
      editor - the editor of beans
      dataLocator - the data locator
      scopes - 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 null if 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 null if 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 null if not found
      See Also:
      SwingValidatorMessageTableMouseListener
    • getMessage

      public static java.lang.String getMessage​(SwingValidatorMessage model)
    • getMessage

      public static java.lang.String getMessage​(org.nuiton.validator.bean.simple.SimpleBeanValidatorMessage model)
    • getMessage

      public static java.lang.String getMessage​(SwingListValidatorMessage model)
    • getMessage

      public static java.lang.String getMessage​(UnifiedValidatorMessage model)
    • getFieldName

      public static java.lang.String getFieldName​(SwingValidatorMessage model, java.lang.String value)
    • getFieldName

      public static java.lang.String getFieldName​(SwingListValidatorMessage model, java.lang.String value)
    • getFieldName

      public static java.lang.String getFieldName​(UnifiedValidatorMessage model, java.lang.String value)
    • 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 listen
      ui - 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 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, 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 treate
      newValue - the new value to set in changed validator property
      excludeIds - the list of validator id to exclude
    • getValidatorEditors

      protected static com.google.common.collect.Multimap<javax.swing.JComponent,​ValidatorField> getValidatorEditors​(JAXXValidator ui)