Class UIHelper


  • public abstract class UIHelper
    extends 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
    • 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​(String buttonCaption,
                                                        String buttonDescription,
                                                        com.vaadin.server.Resource icon,
                                                        com.vaadin.ui.Button.ClickListener clickListener)
      • createLabel

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

        public static String loadContentFromFile​(Class<?> clazz,
                                                 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​(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​(Class<T> clazz)
      • showNotification

        public static void showNotification​(String message)
      • showNotification

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

        public static void showNotification​(String title,
                                            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​(Collection<com.vaadin.v7.ui.Field<?>> fields,
                                          boolean swallowValidationExceptions)