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 voidfillErrorMessages(Validatable component, ValidationException e, ValidationErrors errors) Place component with error message to validation errors container.static ActionfindAction(Frame frame, String actionId) Searches for action with the givenactionIdinside offrame.static ActionfindAction(String actionName, Frame frame) Searches for an action by name.static intfindActionById(List<Action> actionList, String actionId) static ComponentfindChildComponent(HasComponents container, com.vaadin.ui.Component target) static ComponentfindChildComponent(Collection<Component> components, com.vaadin.ui.Component vaadinSource, com.vaadin.ui.Component target) static ComponentfindComponent(Frame frame, String id) Searches for a component by identifier, down by the hierarchy of frames.static Component.FocusablefocusChildComponent(Component container) static voidfocusComponent(Component component) Focus component (or its nearest focusable parent) and activate all its parents, for instance: select Tab, expand GroupBox.static ComponentgetComponent(HasComponents container, String id) static Stringstatic Stringstatic <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 Stringstatic com.vaadin.ui.ComponentgetComposition(Component component) Returns underlying Vaadin component, which serves as the outermost container for the supplied GUI component.static com.vaadin.ui.ComponentgetDirectChildComponent(com.vaadin.ui.Component targetComponent, com.vaadin.ui.Component vaadinSource) static ComponentgetFrameComponent(Frame frame, String id) static StringgetFullFrameId(Frame frame) static MetaPropertygetMetaProperty(HasValueSource<?> component) static MetaPropertyPathgetMetaPropertyPath(HasValueSource<?> component) static WindowgetParentWindow(ScreenFragment frameOwner) static ScreengetScreen(ScreenFragment frameOwner) static ScreenContextgetScreenContext(Component.BelongToFrame component) Get screen context for UI component.static ShortcutTriggeredEventgetShortcutEvent(Component source, com.vaadin.ui.Component target) static com.vaadin.ui.ComponentgetVaadinSource(Component source) static WindowgetWindow(Component.BelongToFrame component) Get the topmost window for the specified component.static ComponentgetWindowComponent(Window window, String id) static WindowgetWindowImplementation(Component.BelongToFrame component) Get the topmost window for the specified component.static WindowgetWindowNN(Component.BelongToFrame component) static booleanisComponentEnabled(com.vaadin.ui.Component child) Tests if component enabled and visible and its container enabled.static booleanisComponentExpanded(Component component) static booleanisComponentVisible(com.vaadin.ui.Component child) Tests if component visible and its container visible.static booleanisComponentVisibleToClient(com.vaadin.ui.Component child) Checks if the component should be visible to the client.static voidsetClickShortcut(com.vaadin.ui.Button button, String shortcut) static voidsetStyleName(Component component, String styleName, boolean add) Null-safe helper analog ofComponent.addStyleName(String)andComponent.removeStyleName(String)static voidtraverseComponents(HasComponents container, Consumer<Component> visitor) Visit all components below the specified container.static voidtraverseValidatable(HasComponents container, Consumer<Validatable> visitor) Visit allValidatablecomponents below the specified container.static com.vaadin.ui.ComponentReturns underlying Vaadin component implementation.static booleanwalkComponents(HasComponents container, ComponentFinder finder) Iterates over all components applying finder instance.static voidwalkComponents(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 allValidatablecomponents 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:
trueif component has been found,falseotherwise
-
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 someActionsHolderframe- 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
addparameter is true, the style name is added to the component. If theaddparameter 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 givenactionIdinside 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 likeButtonthis 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
-