public abstract class ComponentsHelper
extends java.lang.Object
Modifier and Type | Method and Description |
---|---|
static void |
fillErrorMessages(Validatable component,
ValidationException e,
ValidationErrors errors)
Place component with error message to validation errors container.
|
static Action |
findAction(Frame frame,
java.lang.String actionId)
Searches for action with the given
actionId inside of frame . |
static Action |
findAction(java.lang.String actionName,
Frame frame)
Searches for an action by name.
|
static int |
findActionById(java.util.List<Action> actionList,
java.lang.String actionId) |
static Component |
findChildComponent(java.util.Collection<Component> components,
com.vaadin.ui.Component vaadinSource,
com.vaadin.ui.Component target) |
static Component |
findChildComponent(HasComponents container,
com.vaadin.ui.Component target) |
static Component |
findComponent(Frame frame,
java.lang.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,
java.lang.String id) |
static java.lang.String |
getComponentHeight(Component c) |
static java.lang.String |
getComponentPath(Component c) |
static java.util.Collection<Component> |
getComponents(HasComponents container)
Returns the collection of components within the specified container and all of its children.
|
static <T extends com.vaadin.ui.Component> |
getComponents(com.vaadin.ui.HasComponents container,
java.lang.Class<T> aClass) |
static java.lang.String |
getComponentWidth(Component c) |
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,
java.lang.String id) |
static java.lang.String |
getFullFrameId(Frame frame) |
static io.jmix.core.metamodel.model.MetaProperty |
getMetaProperty(HasValueSource<?> component) |
static io.jmix.core.metamodel.model.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,
java.lang.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,
java.lang.String shortcut) |
static void |
setStyleName(Component component,
java.lang.String styleName,
boolean add)
Null-safe helper analog of
Component.addStyleName(String) and Component.removeStyleName(String) |
static void |
traverseComponents(HasComponents container,
java.util.function.Consumer<Component> visitor)
Visit all components below the specified container.
|
static void |
traverseValidatable(HasComponents container,
java.util.function.Consumer<Validatable> visitor)
Visit all
Validatable components below the specified container. |
static com.vaadin.ui.Component |
unwrap(Component 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.
|
public static java.util.Collection<Component> getComponents(HasComponents container)
container
- container to start frompublic static void traverseComponents(HasComponents container, java.util.function.Consumer<Component> visitor)
container
- container to start fromvisitor
- visitor instancepublic static void traverseValidatable(HasComponents container, java.util.function.Consumer<Validatable> visitor)
Validatable
components below the specified container.container
- container to start fromvisitor
- visitor instance@Nullable public static Component getWindowComponent(Window window, java.lang.String id)
@Nullable public static Component getFrameComponent(Frame frame, java.lang.String id)
@Nullable public static Component getComponent(HasComponents container, java.lang.String id)
@Nullable public static Component findComponent(Frame frame, java.lang.String id)
frame
- frame to start fromid
- component identifierpublic static void walkComponents(HasComponents container, ComponentVisitor visitor)
container
- container to start fromvisitor
- visitor instancepublic static boolean walkComponents(HasComponents container, ComponentFinder finder)
true
.
If no component is found returns false
.container
- container to start fromfinder
- finder instancetrue
if component has been found, false
otherwise@Nullable public static Window getWindow(Component.BelongToFrame component)
component
- component instancepublic static Window getWindowNN(Component.BelongToFrame component)
public static ScreenContext getScreenContext(Component.BelongToFrame component)
component
- componentjava.lang.IllegalStateException
- in case window cannot be inferred@Nullable public static Screen getScreen(ScreenFragment frameOwner)
@Nullable public static Window getParentWindow(ScreenFragment frameOwner)
@Nullable public static Window getWindowImplementation(Component.BelongToFrame component)
component
- component instancepublic static java.lang.String getFullFrameId(Frame frame)
@Nullable public static Action findAction(java.lang.String actionName, Frame frame)
actionName
- action name, can be a path to an action contained in some ActionsHolder
frame
- current framejava.lang.IllegalStateException
- if the component denoted by the path doesn't exist or is not an ActionsHolderpublic static java.lang.String getComponentPath(Component c)
public static java.lang.String getComponentWidth(Component c)
public static java.lang.String getComponentHeight(Component c)
public static void fillErrorMessages(Validatable component, ValidationException e, ValidationErrors errors)
component
- validatable componente
- exceptionerrors
- errors containerpublic static int findActionById(java.util.List<Action> actionList, java.lang.String actionId)
public static void focusComponent(Component component)
component
- component@Nullable public static Component.Focusable focusChildComponent(Component container)
public static void setStyleName(@Nullable Component component, java.lang.String styleName, boolean add)
Component.addStyleName(String)
and Component.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 the add
parameter is false, the style name is removed from the component.
component
- componentstyleName
- style name to add or removeadd
- add style name, or remove@Nullable public static Action findAction(Frame frame, java.lang.String actionId)
actionId
inside of frame
.frame
- frameactionId
- action idpublic static <T extends com.vaadin.ui.Component> java.util.Collection<T> getComponents(com.vaadin.ui.HasComponents container, java.lang.Class<T> aClass)
public static com.vaadin.ui.Component unwrap(Component component)
component
- GUI componentgetComposition(io.jmix.ui.component.Component)
public static com.vaadin.ui.Component getComposition(Component component)
Button
this method returns the same
result as unwrap(io.jmix.ui.component.Component)
.component
- GUI componentunwrap(io.jmix.ui.component.Component)
public static boolean isComponentVisibleToClient(com.vaadin.ui.Component child)
child
- The child to checkpublic static boolean isComponentVisible(com.vaadin.ui.Component child)
child
- componentpublic static boolean isComponentEnabled(com.vaadin.ui.Component child)
child
- componentpublic static boolean isComponentExpanded(Component component)
public static ShortcutTriggeredEvent getShortcutEvent(Component source, com.vaadin.ui.Component target)
public static com.vaadin.ui.Component getVaadinSource(Component source)
@Nullable public static Component findChildComponent(HasComponents container, com.vaadin.ui.Component target)
@Nullable public static Component findChildComponent(java.util.Collection<Component> components, com.vaadin.ui.Component vaadinSource, com.vaadin.ui.Component target)
@Nullable public static com.vaadin.ui.Component getDirectChildComponent(com.vaadin.ui.Component targetComponent, com.vaadin.ui.Component vaadinSource)
public static void setClickShortcut(com.vaadin.ui.Button button, java.lang.String shortcut)
@Nullable public static io.jmix.core.metamodel.model.MetaPropertyPath getMetaPropertyPath(HasValueSource<?> component)
@Nullable public static io.jmix.core.metamodel.model.MetaProperty getMetaProperty(HasValueSource<?> component)