Package com.appjars.utils
Class PresentationUtils
java.lang.Object
com.appjars.utils.PresentationUtils
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidcopyToClipboard(String text) static voidfocusFirstEnabledField(com.vaadin.flow.component.Component container) static ScreenSizegetScreenSize(int width, int height) Determines theScreenSizecategory based on the provided width and height.static voidsetColumnsResizable(com.vaadin.flow.component.grid.Grid<?> grid) Set all columns as resizablestatic <T> voidsetGridColumnsVisible(com.vaadin.flow.component.grid.Grid<T> grid, boolean[] visibleColumns) static com.vaadin.flow.component.ComponentsetLeftLabelToComponent(com.vaadin.flow.component.Component component, String label) Add a Vaadin-style label on the left side of the specified component.static com.vaadin.flow.component.ComponentsetRightLabelToComponent(com.vaadin.flow.component.Component component, String label) Add a Vaadin-style label on the right side of the specified component.static com.vaadin.flow.component.ComponentsetTopLabelToComponent(com.vaadin.flow.component.Component component, String label) Add a Vaadin-style label on top of the specified component.static voidsubscribeWindowScreenSize(Consumer<ScreenSize> callback, com.vaadin.flow.component.UI ui) Subscribes to changes in the browser window's size and calls the specified callback with the updated screen size.
-
Constructor Details
-
PresentationUtils
public PresentationUtils()
-
-
Method Details
-
copyToClipboard
-
focusFirstEnabledField
public static void focusFirstEnabledField(com.vaadin.flow.component.Component container) -
subscribeWindowScreenSize
public static void subscribeWindowScreenSize(Consumer<ScreenSize> callback, com.vaadin.flow.component.UI ui) Subscribes to changes in the browser window's size and calls the specified callback with the updated screen size.This method registers a listener for browser window resize events on the provided UI component (if provided) and triggers the callback with the updated window width and height whenever the window is resized. Additionally, it stores the current width and height in
ComponentUtilwith the keys windowWidth and windowHeight to provide cached values for the callback. The callback receives a ScreenSize that encapsulates the window width and height.- Parameters:
callback- The callback function to be invoked with the updated screen size.uiOpt- An optional UI component where the resize listener should be attached. If not provided, the listener will not be registered.- See Also:
-
getScreenSize
Determines theScreenSizecategory based on the provided width and height.- Parameters:
width- The width of the screen.height- The height of the screen.- Returns:
- The
ScreenSizecategory corresponding to the given dimensions.
-
setGridColumnsVisible
public static <T> void setGridColumnsVisible(com.vaadin.flow.component.grid.Grid<T> grid, boolean[] visibleColumns) -
setColumnsResizable
public static void setColumnsResizable(com.vaadin.flow.component.grid.Grid<?> grid) Set all columns as resizable- Parameters:
grid- the Grid whose columns will be set resizable
-
setTopLabelToComponent
public static com.vaadin.flow.component.Component setTopLabelToComponent(com.vaadin.flow.component.Component component, String label) Add a Vaadin-style label on top of the specified component.- Parameters:
component- the Component to which the label will be addedlabel- the string for the label- Returns:
- a component with the label added
-
setLeftLabelToComponent
public static com.vaadin.flow.component.Component setLeftLabelToComponent(com.vaadin.flow.component.Component component, String label) Add a Vaadin-style label on the left side of the specified component.- Parameters:
component- the Component to which the label will be addedlabel- the string for the label- Returns:
- a component with the label added
-
setRightLabelToComponent
public static com.vaadin.flow.component.Component setRightLabelToComponent(com.vaadin.flow.component.Component component, String label) Add a Vaadin-style label on the right side of the specified component.- Parameters:
component- the Component to which the label will be addedlabel- the string for the label- Returns:
- a component with the label added
-