Package io.jmix.flowui.fragment
Class FragmentUtils
java.lang.Object
io.jmix.flowui.fragment.FragmentUtils
Utility class working with Jmix fragment specifics.
-
Field Summary
-
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 FragmentActions
getFragmentActions
(Fragment<?> fragment) GetsFragmentActions
object from passedFragment
.static FragmentData
getFragmentData
(Fragment<?> fragment) GetsFragmentData
object from passedFragment
.static String
getMessageGroup
(String descriptorPath) Gets message group from the passed descriptor path.static String
getPackage
(Class<? extends com.vaadin.flow.component.Component> componentClass) Gets the package of the passed class.static FragmentOwner
getParentController
(Fragment<?> fragment) Gets the owner of the passedFragment
.static String
resolveDescriptorPath
(Class<? extends com.vaadin.flow.component.Component> componentClass) Resolves a path to the XML descriptor.static boolean
Returns whether the component has the same fragment id as passed.static void
setComponentId
(com.vaadin.flow.component.Component component, String id) Sets the fragment id to the passed component.static void
setFragmentActions
(Fragment<?> fragment, FragmentActions actions) SetsFragmentActions
object to passedFragment
.static void
setFragmentData
(Fragment<?> fragment, FragmentData data) SetsFragmentData
object to passedFragment
.static void
setParentController
(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
Attributes
field 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
Attributes
field 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
GetsFragmentData
object from passedFragment
.- Parameters:
fragment
- fragment to get data holder- Returns:
FragmentData
object from passedFragment
-
setFragmentData
SetsFragmentData
object to passedFragment
.- Parameters:
fragment
- fragment to set data holderdata
- data holder to set
-
getFragmentActions
GetsFragmentActions
object from passedFragment
.- Parameters:
fragment
- fragment to get actions holder- Returns:
FragmentActions
object from passedFragment
-
setFragmentActions
SetsFragmentActions
object 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:
true
if the component has the same fragment id as passed,false
otherwise- 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
-