Package io.jmix.ui.component
Class ComponentsHelper
java.lang.Object
io.jmix.ui.component.ComponentsHelper
Utility class working with GenericUI components.
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
fillErrorMessages
(Validatable component, ValidationException e, ValidationErrors errors) Place component with error message to validation errors container.static Action
findAction
(Frame frame, String actionId) Searches for action with the givenactionId
inside offrame
.static Action
findAction
(String actionName, Frame frame) Searches for an action by name.static int
findActionById
(List<Action> actionList, String actionId) static Component
findChildComponent
(HasComponents container, com.vaadin.ui.Component target) static Component
findChildComponent
(Collection<Component> components, com.vaadin.ui.Component vaadinSource, com.vaadin.ui.Component target) static Component
findComponent
(Frame frame, String id) Searches for a component by identifier, down by the hierarchy of frames.static Component.Focusable
focusChildComponent
(Component container) static void
focusComponent
(Component component) Focus component (or its nearest focusable parent) and activate all its parents, for instance: select Tab, expand GroupBox.static Component
getComponent
(HasComponents container, String id) static String
static String
static <T extends com.vaadin.ui.Component>
Collection<T>getComponents
(com.vaadin.ui.HasComponents container, Class<T> aClass) static Collection<Component>
getComponents
(HasComponents container) Returns the collection of components within the specified container and all of its children.static String
static com.vaadin.ui.Component
getComposition
(Component component) Returns underlying Vaadin component, which serves as the outermost container for the supplied GUI component.static com.vaadin.ui.Component
getDirectChildComponent
(com.vaadin.ui.Component targetComponent, com.vaadin.ui.Component vaadinSource) static Component
getFrameComponent
(Frame frame, String id) static String
getFullFrameId
(Frame frame) static MetaProperty
getMetaProperty
(HasValueSource<?> component) static MetaPropertyPath
getMetaPropertyPath
(HasValueSource<?> component) static Window
getParentWindow
(ScreenFragment frameOwner) static Screen
getScreen
(ScreenFragment frameOwner) static ScreenContext
getScreenContext
(Component.BelongToFrame component) Get screen context for UI component.static ShortcutTriggeredEvent
getShortcutEvent
(Component source, com.vaadin.ui.Component target) static com.vaadin.ui.Component
getVaadinSource
(Component source) static Window
getWindow
(Component.BelongToFrame component) Get the topmost window for the specified component.static Component
getWindowComponent
(Window window, String id) static Window
getWindowImplementation
(Component.BelongToFrame component) Get the topmost window for the specified component.static Window
getWindowNN
(Component.BelongToFrame component) static boolean
isComponentEnabled
(com.vaadin.ui.Component child) Tests if component enabled and visible and its container enabled.static boolean
isComponentExpanded
(Component component) static boolean
isComponentVisible
(com.vaadin.ui.Component child) Tests if component visible and its container visible.static boolean
isComponentVisibleToClient
(com.vaadin.ui.Component child) Checks if the component should be visible to the client.static void
setClickShortcut
(com.vaadin.ui.Button button, String shortcut) static void
setStyleName
(Component component, String styleName, boolean add) Null-safe helper analog ofComponent.addStyleName(String)
andComponent.removeStyleName(String)
static void
traverseComponents
(HasComponents container, Consumer<Component> visitor) Visit all components below the specified container.static void
traverseValidatable
(HasComponents container, Consumer<Validatable> visitor) Visit allValidatable
components below the specified container.static com.vaadin.ui.Component
Returns underlying Vaadin component implementation.static boolean
walkComponents
(HasComponents container, ComponentFinder finder) Iterates over all components applying finder instance.static void
walkComponents
(HasComponents container, ComponentVisitor visitor) Visit all components below the specified container.
-
Method Details
-
getComponents
Returns the collection of components within the specified container and all of its children.- Parameters:
container
- container to start from- Returns:
- collection of components
-
traverseComponents
Visit all components below the specified container.- Parameters:
container
- container to start fromvisitor
- visitor instance
-
traverseValidatable
Visit allValidatable
components below the specified container.- Parameters:
container
- container to start fromvisitor
- visitor instance
-
getWindowComponent
-
getFrameComponent
-
getComponent
-
findComponent
Searches for a component by identifier, down by the hierarchy of frames.- Parameters:
frame
- frame to start fromid
- component identifier- Returns:
- component instance or null if not found
-
walkComponents
Visit all components below the specified container.- Parameters:
container
- container to start fromvisitor
- visitor instance
-
walkComponents
Iterates over all components applying finder instance. Stops when the component is found and returnstrue
. If no component is found returnsfalse
.- Parameters:
container
- container to start fromfinder
- finder instance- Returns:
true
if component has been found,false
otherwise
-
getWindow
Get the topmost window for the specified component.- Parameters:
component
- component instance- Returns:
- topmost window in the hierarchy of frames for this component.
Can be null only if the component wasn't properly initialized.
-
getWindowNN
-
getScreenContext
Get screen context for UI component.- Parameters:
component
- component- Returns:
- screen context
- Throws:
IllegalStateException
- in case window cannot be inferred
-
getScreen
-
getParentWindow
-
getWindowImplementation
Get the topmost window for the specified component.- Parameters:
component
- component instance- Returns:
- topmost client specific window in the hierarchy of frames for this component.
Can be null only if the component wasn't properly initialized.
-
getFullFrameId
-
findAction
Searches for an action by name.- Parameters:
actionName
- action name, can be a path to an action contained in someActionsHolder
frame
- current frame- Returns:
- action instance or null if there is no action with the specified name
- Throws:
IllegalStateException
- if the component denoted by the path doesn't exist or is not an ActionsHolder
-
getComponentPath
-
getComponentWidth
-
getComponentHeight
-
fillErrorMessages
public static void fillErrorMessages(Validatable component, ValidationException e, ValidationErrors errors) Place component with error message to validation errors container.- Parameters:
component
- validatable componente
- exceptionerrors
- errors container
-
findActionById
-
focusComponent
Focus component (or its nearest focusable parent) and activate all its parents, for instance: select Tab, expand GroupBox.- Parameters:
component
- component
-
focusChildComponent
-
setStyleName
Null-safe helper analog ofComponent.addStyleName(String)
andComponent.removeStyleName(String)
Adds or removes a style name. Multiple styles can be specified as a space-separated list of style names.
If the
add
parameter is true, the style name is added to the component. If theadd
parameter is false, the style name is removed from the component.- Parameters:
component
- componentstyleName
- style name to add or removeadd
- add style name, or remove
-
findAction
Searches for action with the givenactionId
inside offrame
.- Parameters:
frame
- frameactionId
- action id- Returns:
- action instance or null if action not found
-
getComponents
public static <T extends com.vaadin.ui.Component> Collection<T> getComponents(com.vaadin.ui.HasComponents container, Class<T> aClass) -
unwrap
Returns underlying Vaadin component implementation.- Parameters:
component
- GUI component- Returns:
- Vaadin component
- See Also:
-
getComposition
Returns underlying Vaadin component, which serves as the outermost container for the supplied GUI component. For simple components likeButton
this method returns the same result asunwrap(io.jmix.ui.component.Component)
.- Parameters:
component
- GUI component- Returns:
- Vaadin component
- See Also:
-
isComponentVisibleToClient
public static boolean isComponentVisibleToClient(com.vaadin.ui.Component child) Checks if the component should be visible to the client. Returns false if the child should not be sent to the client, true otherwise.- Parameters:
child
- The child to check- Returns:
- true if the child is visible to the client, false otherwise
-
isComponentVisible
public static boolean isComponentVisible(com.vaadin.ui.Component child) Tests if component visible and its container visible.- Parameters:
child
- component- Returns:
- component visibility
-
isComponentEnabled
public static boolean isComponentEnabled(com.vaadin.ui.Component child) Tests if component enabled and visible and its container enabled.- Parameters:
child
- component- Returns:
- component enabled state
-
isComponentExpanded
-
getShortcutEvent
public static ShortcutTriggeredEvent getShortcutEvent(Component source, com.vaadin.ui.Component target) -
getVaadinSource
-
findChildComponent
@Nullable public static Component findChildComponent(HasComponents container, com.vaadin.ui.Component target) -
findChildComponent
@Nullable public static Component findChildComponent(Collection<Component> components, com.vaadin.ui.Component vaadinSource, com.vaadin.ui.Component target) -
getDirectChildComponent
@Nullable public static com.vaadin.ui.Component getDirectChildComponent(com.vaadin.ui.Component targetComponent, com.vaadin.ui.Component vaadinSource) - Returns:
- the direct child component of the layout which contains the component involved to event
-
setClickShortcut
-
getMetaPropertyPath
-
getMetaProperty
-