Class CompositeComponent<T extends Component>

java.lang.Object
io.jmix.ui.component.CompositeComponent<T>
All Implemented Interfaces:
AttachNotifier, Component, Component.BelongToFrame, HasDebugId, HasHtmlSanitizer
Direct Known Subclasses:
AbstractSingleFilterComponent, DashboardImpl, DynamicAttributesPanel, FilterImpl, GroupFilterImpl, NotificationsIndicatorImpl, UserIndicatorImpl

public class CompositeComponent<T extends Component> extends Object implements Component, Component.BelongToFrame, AttachNotifier, HasDebugId, HasHtmlSanitizer
  • Field Details

    • id

      protected String id
    • root

      protected T extends Component root
    • frame

      protected Frame frame
    • prefixId

      protected String prefixId
    • applicationContext

      protected org.springframework.context.ApplicationContext applicationContext
  • Constructor Details

    • CompositeComponent

      public CompositeComponent()
  • Method Details

    • setApplicationContext

      @Autowired public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext)
    • getEventHub

      protected EventHub getEventHub()
    • publish

      protected <E> void publish(Class<E> eventType, E event)
    • hasSubscriptions

      protected boolean hasSubscriptions(Class<?> eventClass)
    • unsubscribe

      protected <E> boolean unsubscribe(Class<E> eventType, Consumer<E> listener)
    • getComposition

      public T getComposition()
      Returns the root component that represents the component tree of the composite component.
      Returns:
      the root component that represents the component tree of the composite component
    • getCompositionOrNull

      @Nullable protected T getCompositionOrNull()
      Returns the root component that represents the component tree of the composite component.
      Returns:
      the root component that represents the component tree of the composite component or null if not yet initialized
      See Also:
    • getInnerComponent

      protected <C> C getInnerComponent(String id)
      Returns an inner component belonging to the whole components tree below this composition.
      Parameters:
      id - the id of a component
      Returns:
      found component
      Throws:
      IllegalArgumentException - if no component is found with given id
      IllegalStateException - if the root component can't contain inner components
      See Also:
    • getInnerComponentOptional

      protected <C> Optional<C> getInnerComponentOptional(String id)
      Returns an inner component belonging to the whole components tree below this composition.
      Parameters:
      id - the id of a component
      Returns:
      found component or null if no component is found
      Throws:
      IllegalStateException - if the root component can't contain inner components
      See Also:
    • setComposition

      protected void setComposition(T composition)
      Sets the root component that represents the component hierarchy of the composite component.
      Parameters:
      composition - a component to set as the root
      Throws:
      IllegalStateException - if the root component is already set
    • updateComponentIds

      protected void updateComponentIds(T composition)
    • updateIdIfNeeded

      protected void updateIdIfNeeded(Component component)
    • getFullId

      protected String getFullId(String id)
    • getPrefixId

      protected String getPrefixId()
    • getId

      @Nullable public String getId()
      Description copied from interface: Component
      Component ID as defined in id attribute
      Specified by:
      getId in interface Component
    • setId

      public void setId(@Nullable String id)
      Description copied from interface: Component
      Set component ID
      Specified by:
      setId in interface Component
    • assignDebugId

      protected void assignDebugId()
    • getDebugId

      @Nullable public String getDebugId()
      Specified by:
      getDebugId in interface HasDebugId
    • setDebugId

      public void setDebugId(@Nullable String id)
      Description copied from interface: HasDebugId
      INTERNAL. Managed by debug Id system.
      Specified by:
      setDebugId in interface HasDebugId
    • getParent

      @Nullable public Component getParent()
      Specified by:
      getParent in interface Component
      Returns:
      parent of component.
    • setParent

      public void setParent(@Nullable Component parent)
      Description copied from interface: Component
      INTERNAL.
      ComponentContainer.add(Component) is normally used for adding components to a parent and the used method will call this method implicitly.
      Specified by:
      setParent in interface Component
      Parameters:
      parent - Parent component
    • isAttached

      public boolean isAttached()
      Specified by:
      isAttached in interface AttachNotifier
      Returns:
      whether a component is attached to a window
    • attached

      public void attached()
      Description copied from interface: AttachNotifier
      Notifies all listeners that component has been attached.
      Specified by:
      attached in interface AttachNotifier
    • detached

      public void detached()
      Description copied from interface: AttachNotifier
      Notifies all listeners that component has been detached.
      Specified by:
      detached in interface AttachNotifier
    • addAttachListener

      public Subscription addAttachListener(Consumer<AttachEvent> listener)
      Description copied from interface: AttachNotifier
      Registers a new attached listener.
      Specified by:
      addAttachListener in interface AttachNotifier
      Parameters:
      listener - a listener to add
      Returns:
      a registration object for removing an event listener added to a source
    • addDetachListener

      public Subscription addDetachListener(Consumer<DetachEvent> listener)
      Description copied from interface: AttachNotifier
      Registers a new detached listener.
      Specified by:
      addDetachListener in interface AttachNotifier
      Parameters:
      listener - a listener to add
      Returns:
      a registration object for removing an event listener added to a source
    • isEnabled

      public boolean isEnabled()
      Description copied from interface: Component
      Is the component enabled?
      Note that this method only returns the status of the component and does not take parents into account. Even though this method returns true the component can be disabled to the user if a parent is disabled.
      Specified by:
      isEnabled in interface Component
      Returns:
      true if the component enabled flag is set to true
    • setEnabled

      public void setEnabled(boolean enabled)
      Description copied from interface: Component
      Sets the component enabled state.
      The user can not interact with disabled components, which are shown with a style that indicates the status. Components are enabled by default.
      Specified by:
      setEnabled in interface Component
      Parameters:
      enabled - enabled flag
    • isResponsive

      public boolean isResponsive()
      Description copied from interface: Component
      Is the component responsive?
      Specified by:
      isResponsive in interface Component
      Returns:
      true if the component applies conditional CSS rules for width / height sizes.
    • setResponsive

      public void setResponsive(boolean responsive)
      Description copied from interface: Component
      Sets component to be responsive by width and height.
      If responsive flag is true then you can use conditional CSS rules that respond to size changes in the browser. You can set specific rules using "width-range" or "height-range" properties in CSS files.
      Specified by:
      setResponsive in interface Component
      Parameters:
      responsive - responsive flag
    • isVisible

      public boolean isVisible()
      Description copied from interface: Component
      Is the component visible?
      A component is visible only if all its parents are also visible. This is not checked by this method though, so even if this method returns true, the component can be hidden from the user because a parent is set to invisible.
      Specified by:
      isVisible in interface Component
      Returns:
      true if the component visibility is set to true
    • setVisible

      public void setVisible(boolean visible)
      Description copied from interface: Component
      Sets visibility value for the component.
      Visible components are drawn in the user interface, while invisible ones are not. The effect is not a cosmetic CSS change - no information about an invisible component will be sent to the client. The effect is thus the same as removing the component from its parent.
      Specified by:
      setVisible in interface Component
      Parameters:
      visible - visible flag
    • isVisibleRecursive

      public boolean isVisibleRecursive()
      Specified by:
      isVisibleRecursive in interface Component
      Returns:
      true if the component and all its parent components are visible
    • isEnabledRecursive

      public boolean isEnabledRecursive()
      Specified by:
      isEnabledRecursive in interface Component
      Returns:
      true if the component and all its parent components are enabled
    • getHeight

      public float getHeight()
      Description copied from interface: Component
      Get component height in Component.getHeightSizeUnit()
      Specified by:
      getHeight in interface Component
    • getHeightSizeUnit

      public SizeUnit getHeightSizeUnit()
      Description copied from interface: Component
      Gets the height property units.
      Specified by:
      getHeightSizeUnit in interface Component
      Returns:
      units used in height property.
    • setHeight

      public void setHeight(@Nullable String height)
      Description copied from interface: Component
      Set component height in Component.getHeightSizeUnit()
      Specified by:
      setHeight in interface Component
    • getWidth

      public float getWidth()
      Description copied from interface: Component
      Get component width in Component.getWidthSizeUnit()
      Specified by:
      getWidth in interface Component
    • getWidthSizeUnit

      public SizeUnit getWidthSizeUnit()
      Description copied from interface: Component
      Gets the width property units.
      Specified by:
      getWidthSizeUnit in interface Component
      Returns:
      units used in the width property.
    • setWidth

      public void setWidth(@Nullable String width)
      Description copied from interface: Component
      Set component width in Component.getWidthSizeUnit()}
      Specified by:
      setWidth in interface Component
    • getAlignment

      public Component.Alignment getAlignment()
      Specified by:
      getAlignment in interface Component
    • setAlignment

      public void setAlignment(Component.Alignment alignment)
      Specified by:
      setAlignment in interface Component
    • getStyleName

      public String getStyleName()
      Description copied from interface: Component
      Styles implementation is client-type-specific.
      Specified by:
      getStyleName in interface Component
      Returns:
      current style name.
    • setStyleName

      public void setStyleName(@Nullable String styleName)
      Description copied from interface: Component
      Sets one or more style names of the component, replacing any previous styles. Multiple styles can be specified as a space-separated list of style names. Styles implementation is client-type-specific.
      Specified by:
      setStyleName in interface Component
      Parameters:
      styleName - one or more style names separated by space.
    • addStyleName

      public void addStyleName(String styleName)
      Description copied from interface: Component
      Adds one or more style names to this component. Multiple styles can be specified as a space-separated list of style names.
      Specified by:
      addStyleName in interface Component
      Parameters:
      styleName - one or more style names separated by space.
    • removeStyleName

      public void removeStyleName(String styleName)
      Description copied from interface: Component
      Removes one or more style names from component. Multiple styles can be specified as a space-separated list of style names.
      Specified by:
      removeStyleName in interface Component
      Parameters:
      styleName - one or more style names separated by space.
    • unwrap

      public <X> X unwrap(Class<X> internalComponentClass)
      Description copied from interface: Component
      Get client specific component instance. Can be used in client module to simplify invocation of underlying API.
      Example:
       com.vaadin.ui.TextField vTextField = textField.unwrap(com.vaadin.ui.TextField.class);
       
      Specified by:
      unwrap in interface Component
      Type Parameters:
      X - type of internal class
      Parameters:
      internalComponentClass - class of underlying component implementation based on Vaadin or Swing
      Returns:
      internal client specific component
    • unwrapOrNull

      @Nullable public <X> X unwrapOrNull(Class<X> internalComponentClass)
      Description copied from interface: Component
      Get client specific component instance. Can be used in client module to simplify invocation of underlying API.
      Returns null if underlying component cannot be casted to the given internalComponentClass. Example:
       com.vaadin.ui.TextField vTextField = textField.unwrapOrNull(com.vaadin.ui.TextField.class);
       
      Specified by:
      unwrapOrNull in interface Component
      Type Parameters:
      X - type of internal class
      Parameters:
      internalComponentClass - class of underlying component implementation based on Vaadin or Swing
      Returns:
      internal client specific component or null if it cannot be casted to given class
    • withUnwrapped

      public <X> void withUnwrapped(Class<X> internalComponentClass, Consumer<X> action)
      Description copied from interface: Component
      Performs the given action with underlying component if it can be casted to the given internalComponentClass. Example:
       textField.withUnwrapped(com.vaadin.ui.TextField.class, vTextField -> {
           // do something
       });
       
      Specified by:
      withUnwrapped in interface Component
      Type Parameters:
      X - type of internal class
      Parameters:
      internalComponentClass - class of underlying component implementation based on Vaadin or Swing
      action - action to perform if underlying component can be casted to given class
    • unwrapComposition

      public <X> X unwrapComposition(Class<X> internalCompositionClass)
      Description copied from interface: Component
      Get the outmost external container of client specific component instance. Can be used in client module to simplify invocation of underlying API.
      Example:
       com.vaadin.ui.Layout vLayout = table.unwrapComposition(com.vaadin.ui.Layout.class);
       
      Specified by:
      unwrapComposition in interface Component
      Type Parameters:
      X - type of internal class
      Parameters:
      internalCompositionClass - class of underlying composition implementation based on Vaadin or Swing
      Returns:
      internal client specific component
    • unwrapCompositionOrNull

      @Nullable public <X> X unwrapCompositionOrNull(Class<X> internalCompositionClass)
      Description copied from interface: Component
      Get the outmost external container of client specific component instance. Can be used in client module to simplify invocation of underlying API.
      Returns null if composition cannot be casted to given internalCompositionClass. Example:
       com.vaadin.ui.Layout vLayout = table.unwrapCompositionOrNull(com.vaadin.ui.Layout.class);
       
      Specified by:
      unwrapCompositionOrNull in interface Component
      Type Parameters:
      X - type of internal class
      Parameters:
      internalCompositionClass - class of underlying composition implementation based on Vaadin or Swing
      Returns:
      internal client specific component or null if cannot be casted to given class
    • withUnwrappedComposition

      public <X> void withUnwrappedComposition(Class<X> internalCompositionClass, Consumer<X> action)
      Description copied from interface: Component
      Get the outmost external container of client specific component instance and performs the given action.
      Can be used in client module to simplify invocation of underlying API.
      Example:
       table.withUnwrappedComposition(com.vaadin.ui.Layout.class, vLayout -> {
           // do something
       });
       
      Specified by:
      withUnwrappedComposition in interface Component
      Type Parameters:
      X - type of internal class
      Parameters:
      internalCompositionClass - class of underlying composition implementation based on Vaadin or Swing
      action - to perform if underlying composition can be casted to given class
    • getFrame

      @Nullable public Frame getFrame()
      Specified by:
      getFrame in interface Component.BelongToFrame
    • setFrame

      public void setFrame(@Nullable Frame frame)
      Specified by:
      setFrame in interface Component.BelongToFrame
    • isHtmlSanitizerEnabled

      public boolean isHtmlSanitizerEnabled()
      Specified by:
      isHtmlSanitizerEnabled in interface HasHtmlSanitizer
      Returns:
      html sanitizer is enabled
    • setHtmlSanitizerEnabled

      public void setHtmlSanitizerEnabled(boolean htmlSanitizerEnabled)
      Description copied from interface: HasHtmlSanitizer
      Sets whether html sanitizer is enabled or not.
      Specified by:
      setHtmlSanitizerEnabled in interface HasHtmlSanitizer
      Parameters:
      htmlSanitizerEnabled - specifies whether html sanitizer is enabled
    • addCreateListener

      protected Subscription addCreateListener(Consumer<CompositeComponent.CreateEvent> listener)
      Registers a new CompositeComponent.CreateEvent listener.
      Parameters:
      listener - a listener to add
      Returns:
      a registration object for removing an event listener added to a source
    • getUiEventListeners

      protected List<org.springframework.context.ApplicationListener> getUiEventListeners()
    • setUiEventListeners

      protected void setUiEventListeners(List<org.springframework.context.ApplicationListener> uiEventListeners)
    • enableEventListeners

      protected void enableEventListeners()
    • disableEventListeners

      protected void disableEventListeners()