Package io.jmix.flowui.fragment
Class FragmentUtils
java.lang.Object
io.jmix.flowui.fragment.FragmentUtils
Utility class working with Jmix fragment specifics.
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic Optional<com.vaadin.flow.component.Component>findComponent(Fragment<?> fragment, String id) static Class<? extends com.vaadin.flow.component.Component>findContentType(Class<? extends Fragment<?>> fragmentClass) Returns a class that represents the type of the fragment contentgetComponentId(com.vaadin.flow.component.Component component) Gets the fragment id of the passed component.static FragmentActionsgetFragmentActions(Fragment<?> fragment) GetsFragmentActionsobject from passedFragment.static FragmentDatagetFragmentData(Fragment<?> fragment) GetsFragmentDataobject from passedFragment.static StringgetMessageGroup(String descriptorPath) Gets message group from the passed descriptor path.static StringgetPackage(Class<? extends com.vaadin.flow.component.Component> componentClass) Gets the package of the passed class.static FragmentOwnergetParentController(Fragment<?> fragment) Gets the owner of the passedFragment.static StringresolveDescriptorPath(Class<? extends com.vaadin.flow.component.Component> componentClass) Resolves a path to the XML descriptor.static booleanReturns whether the component has the same fragment id as passed.static voidsetComponentId(com.vaadin.flow.component.Component component, String id) Sets the fragment id to the passed component.static voidsetFragmentActions(Fragment<?> fragment, FragmentActions actions) SetsFragmentActionsobject to passedFragment.static voidsetFragmentData(Fragment<?> fragment, FragmentData data) SetsFragmentDataobject to passedFragment.static voidsetParentController(Fragment<?> fragment, FragmentOwner parentController) Sets the owner to the passedFragment.
-
Field Details
-
ID_KEY
- See Also:
-
-
Method Details
-
getComponentId
Gets the fragment id of the passed component.Note: Fragment id is stored in the component
Attributesfield instead of setting it as actual id usingComponent.setId(String). This is done to avoid id duplicates in components tree when several fragments of the same type is used simultaneously or fragment inner components have the same id as other components in the components tree- Parameters:
component- the component to get fragment id- Returns:
- the fragment id of the passed component
-
setComponentId
Sets the fragment id to the passed component.Note: Fragment id is stored in the component
Attributesfield instead of setting it as actual id usingComponent.setId(String). This is done to avoid id duplicates in components tree when several fragments of the same type is used simultaneously or fragment inner components have the same id as other components in the components tree- Parameters:
component- component to set fragment idid- id to set
-
getFragmentData
GetsFragmentDataobject from passedFragment.- Parameters:
fragment- fragment to get data holder- Returns:
FragmentDataobject from passedFragment
-
setFragmentData
SetsFragmentDataobject to passedFragment.- Parameters:
fragment- fragment to set data holderdata- data holder to set
-
getFragmentActions
GetsFragmentActionsobject from passedFragment.- Parameters:
fragment- fragment to get actions holder- Returns:
FragmentActionsobject from passedFragment
-
setFragmentActions
SetsFragmentActionsobject to passedFragment.- Parameters:
fragment- fragment to set actions holderactions- actions holder to set
-
getParentController
Gets the owner of the passedFragment.- Parameters:
fragment- fragment to get the owner- Returns:
- the owner of the passed fragment
-
setParentController
Sets the owner to the passedFragment.- Parameters:
fragment- fragment to set the ownerparentController- the owner
-
sameId
Returns whether the component has the same fragment id as passed.- Parameters:
component- component to compare idid- id to compare- Returns:
trueif the component has the same fragment id as passed,falseotherwise- See Also:
-
findComponent
public static Optional<com.vaadin.flow.component.Component> findComponent(Fragment<?> fragment, String id) -
findContentType
public static Class<? extends com.vaadin.flow.component.Component> findContentType(Class<? extends Fragment<?>> fragmentClass) Returns a class that represents the type of the fragment content- Parameters:
fragmentClass- the fragment class to get the type of content- Returns:
- a class that represents the type of the fragment content
- Throws:
IllegalStateException- if either fragment is used as raw type or it is impossible to determine the fragment content type
-
getPackage
public static String getPackage(Class<? extends com.vaadin.flow.component.Component> componentClass) Gets the package of the passed class.- Parameters:
componentClass- a class to get package- Returns:
- the package of the passed class
-
getMessageGroup
Gets message group from the passed descriptor path.- Parameters:
descriptorPath- descriptor path to get message group- Returns:
- message group from the passed descriptor path
-
resolveDescriptorPath
@Nullable public static String resolveDescriptorPath(Class<? extends com.vaadin.flow.component.Component> componentClass) Resolves a path to the XML descriptor. If the value contains a file name only (i.e. don't start with '/'), it is assumed that the file is located in the package of the fragment class.- Parameters:
componentClass- a component class for which to resolve XML descriptor path- Returns:
- a path to the XML descriptor
-