Class PreviewActionSupport

java.lang.Object
io.jmix.flowui.kit.meta.component.preview.loader.PreviewActionSupport

public final class PreviewActionSupport extends Object
Shared helpers for preview loaders that build menu items from XML.
  • Method Details

    • resolveText

      public static @Nullable String resolveText(StudioPreviewEnvironment environment, @Nullable String value)
      Resolves a msg:// message reference through the environment, falling back to the raw value when the reference isn't a message key or the environment can't resolve it (e.g. StudioPreviewEnvironment.NOOP). Null-safe: a null value passes through.
    • buildAction

      public static BaseAction<?> buildAction(org.dom4j.Element actionElement, String fallbackId, StudioPreviewEnvironment environment)
      Builds a BaseAction from a declarative <action> element: id attribute (falling back to fallbackId), text (resolved via resolveText(io.jmix.flowui.kit.meta.component.preview.StudioPreviewEnvironment, java.lang.String)), icon (via ComponentLoaderUtils.loadIconSetIcon(Element)), and enabled.
    • findDescendantAction

      public static @Nullable org.dom4j.Element findDescendantAction(org.dom4j.Element parent, String actionId)
      Recursively searches parent's descendants for an <action id="..."> element matching actionId (covers e.g. an <actions> block declared in the view).
      Returns:
      the matching element, or null if none is found
    • loadActionItem

      public static void loadActionItem(org.dom4j.Element itemElement, org.dom4j.Element viewElement, StudioPreviewEnvironment environment, BiConsumer<String,BaseAction<?>> actionItemAdder, BiConsumer<String,String> textItemAdder)
    • applyButtonAction

      public static void applyButtonAction(JmixButton button, String actionRef, org.dom4j.Element viewElement, StudioPreviewEnvironment environment)
      Applies an action="..." reference to a button the way the runtime binder does: the button's own text/icon win, then the action element's attributes, then the standard type defaults. Unresolvable references (e.g. actions created in the controller) fall back to a humanized action id so the button is not blank.
    • addPlaceholderItems

      public static void addPlaceholderItems(BiConsumer<String,String> itemAdder)
    • parseMenuItems

      public static List<PreviewActionSupport.MenuEntry> parseMenuItems(@Nullable String json)
      Parses the StudioPreviewEnvironment.mainMenuItems() JSON. Empty list on any problem.
    • parseObjectArray

      public static List<Map<String,String>> parseObjectArray(@Nullable String json)
      Parses a flat JSON array of objects with string fields (entityProperties/enumItems formats). Empty list on any problem.
    • resolveDataContainer

      public static @Nullable String resolveDataContainer(org.dom4j.Element element)
      The data container id relevant for an element: an inherited dataContainer, or — for filter components that reference a dataLoader — the container owning that loader in the descriptor's <data> section (Studio resolves containers, not loaders).
    • containerEntityClass

      public static @Nullable String containerEntityClass(org.dom4j.Element element, @Nullable String containerId)
      The class attribute of the data container with the given id in this element's own document, null when the container or the attribute is absent.
    • enumPlaceholderItems

      public static List<String> enumPlaceholderItems(org.dom4j.Element element, StudioPreviewEnvironment environment)
      Placeholder items for a list component bound to an enum entity attribute: the enum's localized constants instead of the generic "Item N". Empty when the property is not an enum or the environment cannot resolve it.
    • hasRenderableItem

      public static boolean hasRenderableItem(@Nullable org.dom4j.Element itemsElement, Set<String> renderableNames)
      Whether itemsElement holds at least one child the caller can actually render. An <items> block of only non-renderable children (e.g. componentItem, which needs the runtime LayoutLoader) would otherwise preview as an empty menu, so callers use this to fall back to addPlaceholderItems(java.util.function.BiConsumer<java.lang.String, java.lang.String>) instead.
      Parameters:
      renderableNames - item tag names the calling loader renders