Class AbstractComponent<T extends com.vaadin.ui.Component>

java.lang.Object
io.jmix.ui.component.impl.AbstractComponent<T>
All Implemented Interfaces:
AttachNotifier, Component, Component.BelongToFrame, Component.HasCaption, Component.HasDescription, Component.HasIcon, Component.HasXmlDescriptor, Component.Wrapper, HasContextHelp, HasDebugId, HasHtmlCaption, HasHtmlDescription, HasHtmlSanitizer
Direct Known Subclasses:
AbstractActionsHolderComponent, AbstractBox, AbstractDataGrid, AbstractOrderedLayout, AbstractPagination, AbstractResourceView, AbstractValueComponent, AbstractViewComponent, AccordionImpl, AppMenuImpl, AppWorkAreaImpl, BpmnModelerImpl, BpmnViewerImpl, ButtonImpl, CalendarImpl, CapsLockIndicatorImpl, ChartImpl, CustomChartImpl, FileMultiUploadFieldImpl, FormImpl, GeoMapImpl, GrapesJsHtmlEditorImpl, GridLayoutImpl, GroupBoxImpl, HtmlBoxLayoutImpl, JavaScriptComponentImpl, LinkImpl, LogoutButtonImpl, NewWindowButtonImpl, OutcomesPanelImpl, PivotTableImpl, PopupButtonImpl, PopupViewImpl, ResponsiveGridLayoutImpl, ScrollBoxLayoutImpl, SideMenuImpl, SplitPanelImpl, StockChartImpl, TabSheetImpl, TimeZoneIndicatorImpl, TreeImpl, UserActionsButtonImpl, WebdavDocumentLinkImpl

  • Field Details

    • ICON_STYLE

      public static final String ICON_STYLE
      See Also:
    • id

      protected String id
    • component

      protected T extends com.vaadin.ui.Component component
    • element

      protected org.dom4j.Element element
    • frame

      protected Frame frame
    • parent

      protected Component parent
    • alignment

      protected Component.Alignment alignment
    • icon

      protected String icon
    • descriptionAsHtml

      protected boolean descriptionAsHtml
    • htmlSanitizerEnabled

      protected Boolean htmlSanitizerEnabled
    • contextHelpIconClickHandler

      protected Consumer<HasContextHelp.ContextHelpIconClickEvent> contextHelpIconClickHandler
    • contextHelpIconClickListener

      protected com.vaadin.shared.Registration contextHelpIconClickListener
    • applicationContext

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

    • AbstractComponent

      public AbstractComponent()
  • 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)
    • 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
    • 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
    • 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()
    • 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
    • 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
    • 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 name)
      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:
      name - 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.
    • 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
    • isEnabledRecursive

      public boolean isEnabledRecursive()
      Specified by:
      isEnabledRecursive in interface Component
      Returns:
      true if the component and all its parent components are enabled
    • 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
    • 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
    • isVisibleRecursive

      public boolean isVisibleRecursive()
      Specified by:
      isVisibleRecursive in interface Component
      Returns:
      true if the component and all its parent components are visible
    • 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
    • getIcon

      public String getIcon()
      Description copied from interface: Component.HasIcon
      Get icon source: "font-icon:ADD", "icons/myicon.png", "theme://createIcon", etc.
      Specified by:
      getIcon in interface Component.HasIcon
    • getCaption

      @Nullable public String getCaption()
      Specified by:
      getCaption in interface Component.HasCaption
      Returns:
      the caption of the component
    • setCaption

      public void setCaption(@Nullable String caption)
      Description copied from interface: Component.HasCaption
      Sets the component's caption.
      Specified by:
      setCaption in interface Component.HasCaption
      Parameters:
      caption - the new component's caption
    • isCaptionAsHtml

      public boolean isCaptionAsHtml()
      Specified by:
      isCaptionAsHtml in interface HasHtmlCaption
      Returns:
      true if the caption is rendered as HTML, false if rendered as plain text
    • setCaptionAsHtml

      public void setCaptionAsHtml(boolean captionAsHtml)
      Description copied from interface: HasHtmlCaption
      Sets whether the caption is rendered as HTML.
      Specified by:
      setCaptionAsHtml in interface HasHtmlCaption
      Parameters:
      captionAsHtml - true if the caption is rendered as HTML, false if rendered as plain text
      See Also:
    • getDescription

      @Nullable public String getDescription()
      Specified by:
      getDescription in interface Component.HasDescription
      Returns:
      the components description, used in tooltips
    • setDescription

      public void setDescription(@Nullable String description)
      Description copied from interface: Component.HasDescription
      Sets the component's description.
      Specified by:
      setDescription in interface Component.HasDescription
      Parameters:
      description - the new description to set
    • isDescriptionAsHtml

      public boolean isDescriptionAsHtml()
      Specified by:
      isDescriptionAsHtml in interface HasHtmlDescription
      Returns:
      true if the description is rendered as HTML, false if rendered as plain text
    • setDescriptionAsHtml

      public void setDescriptionAsHtml(boolean descriptionAsHtml)
      Description copied from interface: HasHtmlDescription
      Sets whether the description is rendered as HTML.
      Specified by:
      setDescriptionAsHtml in interface HasHtmlDescription
      Parameters:
      descriptionAsHtml - true if the description is rendered as HTML, false if rendered as plain text
      See Also:
    • setIcon

      public void setIcon(@Nullable String icon)
      Description copied from interface: Component.HasIcon
      Set an icon by its source: "font-icon:ADD", "icons/myicon.png", "theme://createIcon", etc.
      Specified by:
      setIcon in interface Component.HasIcon
    • setIconFromSet

      public void setIconFromSet(@Nullable Icons.Icon icon)
      Description copied from interface: Component.HasIcon
      Set an icon from an icon set.
      Specified by:
      setIconFromSet in interface Component.HasIcon
    • getIconResource

      @Nullable protected com.vaadin.server.Resource getIconResource(String icon)
    • getIconName

      @Nullable protected String getIconName(@Nullable Icons.Icon icon)
    • 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
    • getComponent

      public T getComponent()
      Specified by:
      getComponent in interface Component.Wrapper
    • getComposition

      public com.vaadin.ui.Component getComposition()
      Specified by:
      getComposition in interface Component.Wrapper
    • getXmlDescriptor

      @Nullable public org.dom4j.Element getXmlDescriptor()
      Specified by:
      getXmlDescriptor in interface Component.HasXmlDescriptor
    • setXmlDescriptor

      public void setXmlDescriptor(@Nullable org.dom4j.Element element)
      Specified by:
      setXmlDescriptor in interface Component.HasXmlDescriptor
    • getContextHelpText

      @Nullable public String getContextHelpText()
      Specified by:
      getContextHelpText in interface HasContextHelp
      Returns:
      context help text
    • setContextHelpText

      public void setContextHelpText(@Nullable String contextHelpText)
      Description copied from interface: HasContextHelp
      Sets context help text. If set, then a special icon will be added for a field.
      Specified by:
      setContextHelpText in interface HasContextHelp
      Parameters:
      contextHelpText - context help text to be set
    • isContextHelpTextHtmlEnabled

      public boolean isContextHelpTextHtmlEnabled()
      Specified by:
      isContextHelpTextHtmlEnabled in interface HasContextHelp
      Returns:
      true if field accepts context help text in HTML format, false otherwise
    • setContextHelpTextHtmlEnabled

      public void setContextHelpTextHtmlEnabled(boolean enabled)
      Description copied from interface: HasContextHelp
      Defines if context help text can be presented as HTML.
      Specified by:
      setContextHelpTextHtmlEnabled in interface HasContextHelp
      Parameters:
      enabled - true if field accepts context help text in HTML format, false otherwise
    • getContextHelpIconClickHandler

      @Nullable public Consumer<HasContextHelp.ContextHelpIconClickEvent> getContextHelpIconClickHandler()
      Specified by:
      getContextHelpIconClickHandler in interface HasContextHelp
      Returns:
      a context help icon click handler
    • setContextHelpIconClickHandler

      public void setContextHelpIconClickHandler(@Nullable Consumer<HasContextHelp.ContextHelpIconClickEvent> handler)
      Description copied from interface: HasContextHelp
      Sets a context help icon click handler. If set, then a special icon will be added for a field. Click handler has priority over context help text, i.e. no tooltip with context help text will be shown if click listener is set.
      Specified by:
      setContextHelpIconClickHandler in interface HasContextHelp
      Parameters:
      handler - the handler to set
    • onContextHelpIconClick

      protected void onContextHelpIconClick(com.vaadin.ui.Component.HasContextHelp.ContextHelpIconClickEvent e)
    • 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
    • hasValidationError

      protected boolean hasValidationError()
    • setValidationError

      protected void setValidationError(@Nullable String errorMessage)
    • 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
    • sanitize

      @Nullable protected String sanitize(@Nullable String html)
    • getUiProperties

      protected UiProperties getUiProperties()
    • getUiComponentProperties

      protected UiComponentProperties getUiComponentProperties()
    • getHtmlSanitizer

      protected HtmlSanitizer getHtmlSanitizer()