Class UIHelper


  • public abstract class UIHelper
    extends java.lang.Object
    This class provides several helper methods for ui stuff, e.g. creating a button. So the amount of code is reduced generally.
    Author:
    Markus von RĂ¼den
    • Constructor Summary

      Constructors 
      Constructor Description
      UIHelper()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static com.vaadin.ui.Button createButton​(java.lang.String buttonCaption, java.lang.String buttonDescription, com.vaadin.server.Resource icon, com.vaadin.ui.Button.ClickListener clickListener)  
      static com.vaadin.v7.ui.Label createLabel​(java.lang.String caption, java.lang.String content)  
      static <T extends com.vaadin.ui.UI>
      T
      getCurrent​(java.lang.Class<T> clazz)  
      static java.lang.String loadContentFromFile​(java.lang.Class<?> clazz, java.lang.String resourceName)
      Loads the resourceName from the classpath using the given clazz.
      static void showNotification​(java.lang.String message)  
      static void showNotification​(java.lang.String title, java.lang.String message, com.vaadin.ui.Notification.Type type)  
      static void showNotification​(java.lang.String title, java.lang.String message, com.vaadin.ui.Notification.Type type, int delayMsec)  
      static void showValidationError​(java.lang.String errorMessage)
      Shows a validation error to the user.
      static void validateField​(com.vaadin.v7.ui.Field<?> field, boolean swallowValidationExceptions)
      Validates the given field and sets the component error accordingly.
      static void validateFields​(java.util.Collection<com.vaadin.v7.ui.Field<?>> fields, boolean swallowValidationExceptions)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • DEFAULT_NOTIFICATION_DELAY

        public static int DEFAULT_NOTIFICATION_DELAY
    • Constructor Detail

      • UIHelper

        public UIHelper()
    • Method Detail

      • createButton

        public static com.vaadin.ui.Button createButton​(java.lang.String buttonCaption,
                                                        java.lang.String buttonDescription,
                                                        com.vaadin.server.Resource icon,
                                                        com.vaadin.ui.Button.ClickListener clickListener)
      • createLabel

        public static com.vaadin.v7.ui.Label createLabel​(java.lang.String caption,
                                                         java.lang.String content)
      • loadContentFromFile

        public static java.lang.String loadContentFromFile​(java.lang.Class<?> clazz,
                                                           java.lang.String resourceName)
        Loads the resourceName from the classpath using the given clazz. If the resource couldn't be loaded an empty string is returned.
        Parameters:
        clazz - The class to use for loading the resource.
        resourceName - The name of the resource to be loaded (e.g. /folder/filename.txt)
        Returns:
        The content of the file, each line separated by line.separator or empty string if the resource does not exist.
      • showValidationError

        public static void showValidationError​(java.lang.String errorMessage)
        Shows a validation error to the user.
        Parameters:
        errorMessage - the error message.
      • getCurrent

        public static <T extends com.vaadin.ui.UI> T getCurrent​(java.lang.Class<T> clazz)
      • showNotification

        public static void showNotification​(java.lang.String message)
      • showNotification

        public static void showNotification​(java.lang.String title,
                                            java.lang.String message,
                                            com.vaadin.ui.Notification.Type type)
      • showNotification

        public static void showNotification​(java.lang.String title,
                                            java.lang.String message,
                                            com.vaadin.ui.Notification.Type type,
                                            int delayMsec)
      • validateField

        public static void validateField​(com.vaadin.v7.ui.Field<?> field,
                                         boolean swallowValidationExceptions)
                                  throws com.vaadin.v7.data.Validator.InvalidValueException
        Validates the given field and sets the component error accordingly. Please note, that the provided field must implement Field and must be a sub class of AbstractComponent.
        Parameters:
        field - The field to validate (must be a sub class of AbstractComponent).
        swallowValidationExceptions - Indicates if an InvalidValueException is swallowed and not propagated. If false the first occurring InvalidValueException is thrown.
        Throws:
        com.vaadin.v7.data.Validator.InvalidValueException - If the field is not valid (see Validator.validate(Object).
      • validateFields

        public static void validateFields​(java.util.Collection<com.vaadin.v7.ui.Field<?>> fields,
                                          boolean swallowValidationExceptions)