Package io.jmix.flowui.kit.component
Class ComponentUtils
java.lang.Object
io.jmix.flowui.kit.component.ComponentUtils
Utility class working with Vaadin UI components.
- See Also:
-
ComponentUtil
-
Method Summary
Modifier and TypeMethodDescriptionstatic com.vaadin.flow.component.ShortcutRegistrationaddClickShortcut(com.vaadin.flow.component.ClickNotifier<?> component, KeyCombination shortcutCombination) Adds a shortcut which 'clicks' theComponentwhich implementsClickNotifierinterface.static voidaddComponentsToSlot(com.vaadin.flow.dom.Element element, String slot, com.vaadin.flow.component.Component... components) Deprecated, for removal: This API element is subject to removal in a future version.static voidDeprecated, for removal: This API element is subject to removal in a future version.useSlotUtils.clearSlot(HasElement, String)insteadstatic com.vaadin.flow.component.icon.IconconvertToIcon(com.vaadin.flow.component.icon.VaadinIcon icon) Creates a newIconinstance with the icon determined by the passedVaadinIcon.static com.vaadin.flow.component.icon.FontIconcopyFontIcon(com.vaadin.flow.component.icon.FontIcon fontIcon) Creates a copy of font icon component.static com.vaadin.flow.component.ComponentcopyIcon(com.vaadin.flow.component.Component icon) Creates a copy of icon component.static com.vaadin.flow.component.icon.IconcopyIconComponent(com.vaadin.flow.component.icon.Icon icon) Creates a copy of icon component.static com.vaadin.flow.component.icon.SvgIconcopySvgIcon(com.vaadin.flow.component.icon.SvgIcon svgIcon) Creates a copy of svg icon component.static intfindActionIndexById(List<Action> actions, String actionId) Returns the index of the first occurrence of the action with specified id in the passed actions list, or -1 if this list does not contain the action.static booleanisAutoSize(String size) Checks if a passed string represents 'auto' size.static booleanGets the component visibility value.static com.vaadin.flow.component.icon.IconCreates a newIconinstance with the icon determined by the passed string.static voidsetEnabled(com.vaadin.flow.component.HasEnabled hasEnabled, boolean enabled) Sets the component enabled state.static <T> voidsetItemsMap(com.vaadin.flow.component.checkbox.CheckboxGroup<T> component, Map<T, String> items) static <T> voidsetItemsMap(com.vaadin.flow.component.combobox.ComboBox<T> component, Map<T, String> items) static <T> voidsetItemsMap(com.vaadin.flow.component.listbox.ListBox<T> component, Map<T, String> items) static <T> voidsetItemsMap(com.vaadin.flow.component.listbox.MultiSelectListBox<T> component, Map<T, String> items) static <T> voidsetItemsMap(com.vaadin.flow.component.radiobutton.RadioButtonGroup<T> component, Map<T, String> items) static <T> voidsetItemsMap(com.vaadin.flow.component.select.Select<T> component, Map<T, String> items) static voidsetItemsMap(EnhancedLoginForm component, Map<Locale, String> items) static <T> voidsetItemsMap(JmixTwinColumn<T> component, Map<T, String> items) static voidsetVisible(com.vaadin.flow.component.Component component, boolean visible) Sets the component visibility value.
-
Method Details
-
parseIcon
Creates a newIconinstance with the icon determined by the passed string. If a passed string contains ':' delimiter then a newIconis created using icon collection and icon name values, otherwise the passed string is considered asVaadinIconconstant name.- Parameters:
iconString- a string representing an icon- Returns:
- a new instance of
Iconcomponent
-
convertToIcon
@Nullable public static com.vaadin.flow.component.icon.Icon convertToIcon(@Nullable com.vaadin.flow.component.icon.VaadinIcon icon) Creates a newIconinstance with the icon determined by the passedVaadinIcon.- Parameters:
icon- aVaadinIconinstance- Returns:
- a new instance of
Iconcomponent
-
copyIcon
public static com.vaadin.flow.component.Component copyIcon(com.vaadin.flow.component.Component icon) Creates a copy of icon component. For the moment only Icon, SvgIcon and FontIcon types are supported.- Parameters:
icon- icon component to copy- Returns:
- icon component copy
-
copyIconComponent
public static com.vaadin.flow.component.icon.Icon copyIconComponent(com.vaadin.flow.component.icon.Icon icon) Creates a copy of icon component.- Parameters:
icon- icon component to copy- Returns:
- icon component copy
-
copySvgIcon
public static com.vaadin.flow.component.icon.SvgIcon copySvgIcon(com.vaadin.flow.component.icon.SvgIcon svgIcon) Creates a copy of svg icon component.- Parameters:
svgIcon- svg icon component to copy- Returns:
- svg icon component copy
-
copyFontIcon
public static com.vaadin.flow.component.icon.FontIcon copyFontIcon(com.vaadin.flow.component.icon.FontIcon fontIcon) Creates a copy of font icon component.- Parameters:
fontIcon- font icon component to copy- Returns:
- font icon component copy
-
addComponentsToSlot
@Deprecated(since="2.1", forRemoval=true) public static void addComponentsToSlot(com.vaadin.flow.dom.Element element, String slot, com.vaadin.flow.component.Component... components) Deprecated, for removal: This API element is subject to removal in a future version.SlotUtils.addToSlot(HasElement, String, Component...)instead- Parameters:
element- the parent component element to add the components toslot- the name of the slot inside the parentcomponents- components to add to the specified slot.
-
clearSlot
@Deprecated(since="2.1", forRemoval=true) public static void clearSlot(com.vaadin.flow.dom.Element element, String slot) Deprecated, for removal: This API element is subject to removal in a future version.useSlotUtils.clearSlot(HasElement, String)instead- Parameters:
element- the component element to get children fromslot- the name of the slot inside the parent
-
findActionIndexById
Returns the index of the first occurrence of the action with specified id in the passed actions list, or -1 if this list does not contain the action.- Parameters:
actions- actions list to search fromactionId- action id to search for- Returns:
- the index of the first occurrence of the action with specified id in the passed actions list, or -1 if this list does not contain the action
-
setItemsMap
public static <T> void setItemsMap(com.vaadin.flow.component.checkbox.CheckboxGroup<T> component, Map<T, String> items) Sets key set from passedMapas component's items andMapvalues as visual representation of corresponding item, effectively definingItemLabelGenerator.- Type Parameters:
T- the component items type- Parameters:
component- the component to set items andItemLabelGeneratoritems- a map to be used as a source of items and their visual representation
-
setItemsMap
public static <T> void setItemsMap(com.vaadin.flow.component.radiobutton.RadioButtonGroup<T> component, Map<T, String> items) Sets key set from passedMapas component's items andMapvalues as visual representation of corresponding item, effectively definingItemLabelGenerator.- Type Parameters:
T- the component items type- Parameters:
component- the component to set items andItemLabelGeneratoritems- a map to be used as a source of items and their visual representation
-
setItemsMap
public static <T> void setItemsMap(com.vaadin.flow.component.listbox.ListBox<T> component, Map<T, String> items) Sets key set from passedMapas component's items andMapvalues as visual representation of corresponding item, effectively definingItemLabelGenerator.- Type Parameters:
T- the component items type- Parameters:
component- the component to set items andItemLabelGeneratoritems- a map to be used as a source of items and their visual representation
-
setItemsMap
public static <T> void setItemsMap(com.vaadin.flow.component.listbox.MultiSelectListBox<T> component, Map<T, String> items) Sets key set from passedMapas component's items andMapvalues as visual representation of corresponding item, effectively definingItemLabelGenerator.- Type Parameters:
T- the component items type- Parameters:
component- the component to set items andItemLabelGeneratoritems- a map to be used as a source of items and their visual representation
-
setItemsMap
public static <T> void setItemsMap(com.vaadin.flow.component.combobox.ComboBox<T> component, Map<T, String> items) Sets key set from passedMapas component's items andMapvalues as visual representation of corresponding item, effectively definingItemLabelGenerator.- Type Parameters:
T- the component items type- Parameters:
component- the component to set items andItemLabelGeneratoritems- a map to be used as a source of items and their visual representation
-
setItemsMap
public static <T> void setItemsMap(com.vaadin.flow.component.select.Select<T> component, Map<T, String> items) Sets key set from passedMapas component's items andMapvalues as visual representation of corresponding item, effectively definingItemLabelGenerator.- Type Parameters:
T- the component items type- Parameters:
component- the component to set items andItemLabelGeneratoritems- a map to be used as a source of items and their visual representation
-
setItemsMap
Sets key set from passedMapas component's items andMapvalues as visual representation of corresponding item, effectively definingItemLabelGenerator.- Parameters:
component- the component to set items andItemLabelGeneratoritems- a map to be used as a source of items and their visual representation
-
setItemsMap
Sets key set from passedMapas component's items andMapvalues as visual representation of corresponding item, effectively definingItemLabelGenerator.- Parameters:
component- the component to set items andItemLabelGeneratoritems- a map to be used as a source of items and their visual representation
-
isAutoSize
Checks if a passed string represents 'auto' size. Should be in a format understood by the browser, e.g. "100px" or "2.5em".- Parameters:
size- a- Returns:
trueif passed string represents 'auto' size,falseotherwise
-
setVisible
public static void setVisible(com.vaadin.flow.component.Component component, boolean visible) Sets the component visibility value. If the component is wrapped insideFormLayout.FormItemthen its visibility value is also changed.- Parameters:
component- the component to set visibility valuevisible- the component visibility value
-
setEnabled
public static void setEnabled(com.vaadin.flow.component.HasEnabled hasEnabled, boolean enabled) Sets the component enabled state. If the component is wrapped insideFormLayout.FormItemthen its enabled state is also changed.- Parameters:
hasEnabled- the component to set enabled stateenabled- the component enabled state
-
isVisible
Gets the component visibility value. Throws an exception if a passed object is not a component.- Parameters:
component- the component to get visibility value- Returns:
trueif the component is visible,falseotherwise- Throws:
IllegalArgumentException- if a passed object is not a component
-
addClickShortcut
public static com.vaadin.flow.component.ShortcutRegistration addClickShortcut(com.vaadin.flow.component.ClickNotifier<?> component, KeyCombination shortcutCombination) Adds a shortcut which 'clicks' theComponentwhich implementsClickNotifierinterface.- Parameters:
component- a component to add shortcutshortcutCombination- an object that stores information about key, modifiers and additional settings- Returns:
ShortcutRegistrationfor configuring the shortcut and removing
-
SlotUtils.addToSlot(HasElement, String, Component...)instead