Package org.opennms.netmgt.vaadin.core
Class UIHelper
- java.lang.Object
-
- org.opennms.netmgt.vaadin.core.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
-
-
Field Summary
Fields Modifier and Type Field Description static int
DEFAULT_NOTIFICATION_DELAY
-
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>
TgetCurrent(java.lang.Class<T> clazz)
static java.lang.String
loadContentFromFile(java.lang.Class<?> clazz, java.lang.String resourceName)
Loads theresourceName
from the classpath using the givenclazz
.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)
-
-
-
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 theresourceName
from the classpath using the givenclazz
. 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 implementField
and must be a sub class ofAbstractComponent
.- Parameters:
field
- The field to validate (must be a sub class ofAbstractComponent
).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 (seeValidator.validate(Object)
.
-
validateFields
public static void validateFields(java.util.Collection<com.vaadin.v7.ui.Field<?>> fields, boolean swallowValidationExceptions)
-
-