Class PresentationUtils

java.lang.Object
com.appjars.utils.PresentationUtils

@Component public class PresentationUtils extends Object
  • Constructor Details

    • PresentationUtils

      public PresentationUtils()
  • Method Details

    • copyToClipboard

      public static void copyToClipboard(String text)
    • 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 ComponentUtil with 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

      public static ScreenSize getScreenSize(int width, int height)
      Determines the ScreenSize category based on the provided width and height.
      Parameters:
      width - The width of the screen.
      height - The height of the screen.
      Returns:
      The ScreenSize category 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 added
      label - 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 added
      label - 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 added
      label - the string for the label
      Returns:
      a component with the label added