Class LinkkiText
- java.lang.Object
-
- com.vaadin.flow.component.Component
-
- org.linkki.core.vaadin.component.base.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.HasTextA text component that can have an additionalVaadinIconand a label. It also supports a HTML mode.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static StringCLASS_NAMEprotected static StringICON_CLASS_NAME
-
Constructor Summary
Constructors Modifier Constructor Description LinkkiText()Creates an empty LinkkiText with no text and no icons.protectedLinkkiText(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.HasTextgetContent()com.vaadin.flow.component.icon.VaadinIcongetIcon()Returns the icon of this component.IconPositiongetIconPosition()Getter for the currently setpositionof the icon.StringgetText()voidsetIcon(com.vaadin.flow.component.icon.VaadinIcon icon)Sets the icon of this component.protected voidsetIconOnComponent(com.vaadin.flow.component.icon.VaadinIcon icon)protected voidsetIconOnComponent(com.vaadin.flow.component.icon.VaadinIcon icon, Consumer<com.vaadin.flow.component.icon.Icon> iconConsumer)voidsetIconPosition(IconPosition position)Sets theicon positionto be used.voidsetText(String text)Sets the given text as content of this component.voidsetText(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 class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.vaadin.flow.component.textfield.HasPrefixAndSuffix
getPrefixComponent, getSuffixComponent, setPrefixComponent, setSuffixComponent
-
-
-
-
Field Detail
-
CLASS_NAME
public static final String CLASS_NAME
- See Also:
- Constant Field Values
-
ICON_CLASS_NAME
protected static final String ICON_CLASS_NAME
- See Also:
- Constant Field Values
-
-
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:
getTextin interfacecom.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:
setTextin interfacecom.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 beescapedwhen including them in the HTML content. Otherwise, they will also be interpreted as HTML.- Parameters:
text- the text or HTML content to sethtml- use the text as HTML content whentrue, use the text as plain text otherwise
-
getIconPosition
@CheckForNull public IconPosition getIconPosition()
Getter for the currently setpositionof the icon. The default isIconPosition.LEFT.
-
setIconPosition
public void setIconPosition(@CheckForNull IconPosition position)Sets theicon positionto 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:HasIconReturns the icon of this component. When no icon is present,nullis returned.
-
setIcon
public void setIcon(@Nullable com.vaadin.flow.component.icon.VaadinIcon icon)Description copied from interface:HasIconSets the icon of this component. A value ofnullcan be used to remove the icon.
-
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)
-
-