Class LinkkiText

  • All Implemented Interfaces:
    com.vaadin.flow.component.AttachNotifier, com.vaadin.flow.component.DetachNotifier, com.vaadin.flow.component.HasElement, com.vaadin.flow.component.HasStyle, com.vaadin.flow.component.HasText, com.vaadin.flow.component.textfield.HasPrefixAndSuffix, Serializable, HasIcon
    Direct Known Subclasses:
    LinkkiAnchor

    @Tag("linkki-text")
    @JsModule("./src/linkki-text.ts")
    public class LinkkiText
    extends com.vaadin.flow.component.Component
    implements HasIcon, com.vaadin.flow.component.textfield.HasPrefixAndSuffix, com.vaadin.flow.component.HasText
    A text component that can have an additional VaadinIcon and a label. It also supports a HTML mode.
    See Also:
    Serialized Form
    • Nested Class Summary

      • Nested classes/interfaces inherited from interface com.vaadin.flow.component.HasText

        com.vaadin.flow.component.HasText.WhiteSpace
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
        LinkkiText()
      Creates an empty LinkkiText with no text and no icons.
      protected LinkkiText​(com.vaadin.flow.component.HasText content, String text, com.vaadin.flow.component.icon.VaadinIcon icon)  
        LinkkiText​(String text, com.vaadin.flow.component.icon.VaadinIcon icon)
      Creates a new LinkkiText component with a plain text and an icon as prefix component.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected com.vaadin.flow.component.HasText getContent()  
      com.vaadin.flow.component.icon.VaadinIcon getIcon()
      Returns the icon of this component.
      IconPosition getIconPosition()
      Getter for the currently set position of the icon.
      String getText()
      void setIcon​(com.vaadin.flow.component.icon.VaadinIcon icon)
      Sets the icon of this component.
      protected void setIconOnComponent​(com.vaadin.flow.component.icon.VaadinIcon icon)  
      protected void setIconOnComponent​(com.vaadin.flow.component.icon.VaadinIcon icon, Consumer<com.vaadin.flow.component.icon.Icon> iconConsumer)  
      void setIconPosition​(IconPosition position)
      Sets the icon position to be used.
      void setText​(String text)
      Sets the given text as content of this component.
      void setText​(String text, boolean html)
      Sets the given text as content of this component.
      • Methods inherited from class com.vaadin.flow.component.Component

        addListener, findAncestor, fireEvent, from, get, getChildren, getElement, getEventBus, getId, getListeners, getLocale, getParent, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getUI, hasListener, isAttached, isTemplateMapped, isVisible, onAttach, onDetach, onEnabledStateChanged, scrollIntoView, set, setElement, setId, setVisible
      • Methods inherited from interface com.vaadin.flow.component.AttachNotifier

        addAttachListener
      • Methods inherited from interface com.vaadin.flow.component.DetachNotifier

        addDetachListener
      • Methods inherited from interface com.vaadin.flow.component.HasElement

        getElement
      • Methods inherited from interface com.vaadin.flow.component.textfield.HasPrefixAndSuffix

        getPrefixComponent, getSuffixComponent, setPrefixComponent, setSuffixComponent
      • Methods inherited from interface com.vaadin.flow.component.HasStyle

        addClassName, addClassNames, getClassName, getClassNames, getStyle, hasClassName, removeClassName, removeClassNames, setClassName, setClassName
      • Methods inherited from interface com.vaadin.flow.component.HasText

        getWhiteSpace, setWhiteSpace
    • Constructor Detail

      • LinkkiText

        public LinkkiText()
        Creates an empty LinkkiText with no text and no icons.
      • LinkkiText

        public LinkkiText​(String text,
                          @CheckForNull
                          com.vaadin.flow.component.icon.VaadinIcon icon)
        Creates a new LinkkiText component with a plain text and an icon as prefix component.
      • LinkkiText

        protected LinkkiText​(com.vaadin.flow.component.HasText content,
                             String text,
                             @CheckForNull
                             com.vaadin.flow.component.icon.VaadinIcon icon)
    • Method Detail

      • getContent

        protected com.vaadin.flow.component.HasText getContent()
      • getText

        public String getText()
        Specified by:
        getText in interface com.vaadin.flow.component.HasText
        Implementation Note:
        in case of HTML mode it returns the content as string including all HTML tags
      • setText

        public void setText​(String text)
        Sets the given text as content of this component.

        To set HTML content use setText(String, boolean) instead.

        Specified by:
        setText in interface com.vaadin.flow.component.HasText
        Parameters:
        text - the text to set
      • setText

        public void setText​(String text,
                            boolean html)
        Sets the given text as content of this component.

        HTML text will be sanitized by using HtmlSanitizer.sanitizeText(String) for security reasons.
        Note that user-supplied strings have to be escaped when including them in the HTML content. Otherwise, they will also be interpreted as HTML.

        Parameters:
        text - the text or HTML content to set
        html - use the text as HTML content when true, use the text as plain text otherwise
      • setIconPosition

        public void setIconPosition​(@CheckForNull
                                    IconPosition position)
        Sets the icon position to be used.
        Parameters:
        position - The position which defines whether the icon should be displayed on the left or on the right side of the text
      • getIcon

        @CheckForNull
        public com.vaadin.flow.component.icon.VaadinIcon getIcon()
        Description copied from interface: HasIcon
        Returns the icon of this component. When no icon is present, null is returned.
        Specified by:
        getIcon in interface HasIcon
      • setIcon

        public void setIcon​(@Nullable
                            com.vaadin.flow.component.icon.VaadinIcon icon)
        Description copied from interface: HasIcon
        Sets the icon of this component. A value of null can be used to remove the icon.
        Specified by:
        setIcon in interface HasIcon
      • setIconOnComponent

        protected void setIconOnComponent​(@CheckForNull
                                          com.vaadin.flow.component.icon.VaadinIcon icon)
      • setIconOnComponent

        protected void setIconOnComponent​(@CheckForNull
                                          com.vaadin.flow.component.icon.VaadinIcon icon,
                                          Consumer<com.vaadin.flow.component.icon.Icon> iconConsumer)