Class RichTextArea
- java.lang.Object
-
- com.vaadin.server.AbstractClientConnector
-
- com.vaadin.ui.AbstractComponent
-
- com.vaadin.ui.AbstractField<String>
-
- com.vaadin.ui.RichTextArea
-
- All Implemented Interfaces:
HasValue<String>,ContextClickEvent.ContextClickNotifier,MethodEventSource,ClientConnector,Sizeable,Connector,Component,Component.Focusable,HasValueChangeMode,Serializable
public class RichTextArea extends AbstractField<String> implements HasValueChangeMode
A simple RichTextArea to edit HTML format text.- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.vaadin.server.ClientConnector
ClientConnector.AttachEvent, ClientConnector.AttachListener, ClientConnector.ConnectorErrorEvent, ClientConnector.DetachEvent, ClientConnector.DetachListener
-
Nested classes/interfaces inherited from interface com.vaadin.ui.Component
Component.ErrorEvent, Component.Event, Component.Focusable, Component.Listener
-
Nested classes/interfaces inherited from interface com.vaadin.data.HasValue
HasValue.ValueChangeEvent<V>, HasValue.ValueChangeListener<V>
-
Nested classes/interfaces inherited from interface com.vaadin.server.Sizeable
Sizeable.Unit
-
-
Field Summary
-
Fields inherited from class com.vaadin.ui.AbstractComponent
DESIGN_ATTR_PLAIN_TEXT
-
Fields inherited from interface com.vaadin.server.Sizeable
SIZE_UNDEFINED, UNITS_CM, UNITS_EM, UNITS_EX, UNITS_INCH, UNITS_MM, UNITS_PERCENTAGE, UNITS_PICAS, UNITS_PIXELS, UNITS_POINTS
-
-
Constructor Summary
Constructors Constructor Description RichTextArea()Constructs an emptyRichTextAreawith no caption.RichTextArea(HasValue.ValueChangeListener<String> valueChangeListener)Constructs a newRichTextAreawith a value change listener.RichTextArea(String caption)Constructs an emptyRichTextAreawith the given caption.RichTextArea(String caption, HasValue.ValueChangeListener<String> valueChangeListener)Constructs a newRichTextAreawith the given caption and a value change listener.RichTextArea(String caption, String value)Constructs a newRichTextAreawith the given caption and initial text contents.RichTextArea(String caption, String value, HasValue.ValueChangeListener<String> valueChangeListener)Constructs a newRichTextAreawith the given caption, initial text contents and a value change listener.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddSnippet(Snippet snippet)Add aSnippetobject to the menu.voidaddSnippet(String snippet)Add a predefined content snippet to the menu.voidaddSnippet(String title, String snippet)Add a predefined content snippet to the menu.voidaddSnippets(String[] snippets)Add predefined content snippets to the menu.voidaddSnippets(String[] titles, String[] snippets)Add predefined content snippets to the menu.voidaddSnippets(Collection<Snippet> snippets)AddSnippetobjects to the menu.voidclearSnippets()Remove all snippets - this also hides the snippets drop-down unless new snippets are added.protected voiddoSetValue(String value)Sets the value of this field.StringgetEmptyValue()Returns the value that represents an empty value.protected RichTextAreaStategetState()Returns the shared state bean with information to be sent from the server to the client.protected RichTextAreaStategetState(boolean markAsDirty)Returns the shared state for this connector.StringgetValue()Returns the current value of this object.ValueChangeModegetValueChangeMode()Returns the currently setValueChangeMode.intgetValueChangeTimeout()Returns the currently set timeout, in milliseconds, for how oftenHasValue.ValueChangeEvents are triggered if the currentValueChangeModeis set to eitherValueChangeMode.LAZYorValueChangeMode.TIMEOUT.voidreadDesign(org.jsoup.nodes.Element design, DesignContext designContext)Reads the component state from the given design.voidselectAll()Selects all text in the rich text area.voidsetValue(String value)Sets the value of this object.voidsetValueChangeMode(ValueChangeMode mode)Sets the mode how the TextField triggersHasValue.ValueChangeEvents.voidsetValueChangeTimeout(int timeout)Sets how oftenHasValue.ValueChangeEvents are triggered when theValueChangeModeis set to eitherValueChangeMode.LAZYorValueChangeMode.TIMEOUT.voidwriteDesign(org.jsoup.nodes.Element design, DesignContext designContext)Writes the component state to the given design.-
Methods inherited from class com.vaadin.ui.AbstractField
addValueChangeListener, createValueChange, focus, getCustomAttributes, getTabIndex, isDifferentValue, isReadOnly, isRequiredIndicatorVisible, setReadOnly, setRequiredIndicatorVisible, setTabIndex, setValue
-
Methods inherited from class com.vaadin.ui.AbstractComponent
addContextClickListener, addListener, addShortcutListener, addStyleName, attach, beforeClientResponse, detach, findAncestor, fireComponentErrorEvent, fireComponentEvent, getActionManager, getCaption, getComponentError, getData, getDebugId, getDescription, getErrorMessage, getHeight, getHeightUnits, getIcon, getId, getLocale, getParent, getPrimaryStyleName, getStyleName, getWidth, getWidthUnits, isCaptionAsHtml, isConnectorEnabled, isEnabled, isOrHasAncestor, isResponsive, isVisible, removeContextClickListener, removeListener, removeShortcutListener, removeStyleName, setCaption, setCaptionAsHtml, setComponentError, setData, setDebugId, setDescription, setDescription, setEnabled, setHeight, setHeight, setHeightFull, setHeightUndefined, setIcon, setId, setLocale, setParent, setPrimaryStyleName, setResponsive, setSizeFull, setSizeUndefined, setStyleName, setVisible, setWidth, setWidth, setWidthFull, setWidthUndefined
-
Methods inherited from class com.vaadin.server.AbstractClientConnector
addAttachListener, addDetachListener, addExtension, addListener, addListener, addListener, addListener, addListener, addListener, addMethodInvocationToQueue, createState, encodeState, equals, fireEvent, getAllChildrenIterable, getConnectorId, getErrorHandler, getExtensions, getListeners, getResource, getRpcManager, getRpcProxy, getSession, getStateType, getUI, handleConnectorRequest, hashCode, hasListeners, isAttached, isThis, markAsDirty, markAsDirtyRecursive, registerRpc, registerRpc, removeAttachListener, removeDetachListener, removeExtension, removeListener, removeListener, removeListener, removeListener, removeListener, requestRepaint, requestRepaintAll, retrievePendingRpcCalls, setErrorHandler, setResource, updateDiffstate
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.vaadin.server.ClientConnector
addAttachListener, addDetachListener, beforeClientResponse, detach, encodeState, getErrorHandler, getExtensions, getRpcManager, getStateType, handleConnectorRequest, isAttached, isConnectorEnabled, markAsDirty, markAsDirtyRecursive, removeAttachListener, removeDetachListener, removeExtension, requestRepaint, requestRepaintAll, retrievePendingRpcCalls, setErrorHandler
-
Methods inherited from interface com.vaadin.ui.Component
addListener, addStyleName, addStyleNames, attach, getCaption, getDescription, getIcon, getId, getLocale, getParent, getPrimaryStyleName, getStyleName, getUI, isEnabled, isVisible, removeListener, removeStyleName, removeStyleNames, setCaption, setEnabled, setIcon, setId, setParent, setPrimaryStyleName, setStyleName, setStyleName, setVisible
-
Methods inherited from interface com.vaadin.shared.Connector
getConnectorId
-
Methods inherited from interface com.vaadin.data.HasValue
clear, getDefaultValidator, getOptionalValue, isEmpty
-
Methods inherited from interface com.vaadin.server.Sizeable
getHeight, getHeightUnits, getWidth, getWidthUnits, setHeight, setHeight, setHeightFull, setHeightUndefined, setSizeFull, setSizeUndefined, setWidth, setWidth, setWidthFull, setWidthUndefined
-
-
-
-
Constructor Detail
-
RichTextArea
public RichTextArea()
Constructs an emptyRichTextAreawith no caption.
-
RichTextArea
public RichTextArea(String caption)
Constructs an emptyRichTextAreawith the given caption.- Parameters:
caption- the caption for the editor.
-
RichTextArea
public RichTextArea(String caption, String value)
Constructs a newRichTextAreawith the given caption and initial text contents.- Parameters:
caption- the caption for the editor.value- the initial text content of the editor, notnull
-
RichTextArea
public RichTextArea(HasValue.ValueChangeListener<String> valueChangeListener)
Constructs a newRichTextAreawith a value change listener.The listener is called when the value of this
TextFieldis changed either by the user or programmatically.- Parameters:
valueChangeListener- the value change listener, notnull- Since:
- 8.0
-
RichTextArea
public RichTextArea(String caption, HasValue.ValueChangeListener<String> valueChangeListener)
Constructs a newRichTextAreawith the given caption and a value change listener.The listener is called when the value of this
TextFieldis changed either by the user or programmatically.- Parameters:
caption- the caption for the fieldvalueChangeListener- the value change listener, notnull- Since:
- 8.0
-
RichTextArea
public RichTextArea(String caption, String value, HasValue.ValueChangeListener<String> valueChangeListener)
Constructs a newRichTextAreawith the given caption, initial text contents and a value change listener.The listener is called when the value of this
RichTextAreais changed either by the user or programmatically.- Parameters:
caption- the caption for the fieldvalue- the value for the field, notnullvalueChangeListener- the value change listener, notnull- Since:
- 8.0
-
-
Method Detail
-
readDesign
public void readDesign(org.jsoup.nodes.Element design, DesignContext designContext)Description copied from interface:ComponentReads the component state from the given design.The component is responsible not only for updating its own state but also for ensuring that its children update their state based on the design.
It is assumed that the component is in its default state when this method is called. Reading should only take into consideration attributes specified in the design and not reset any unspecified attributes to their defaults.
This method must not modify the design.
- Specified by:
readDesignin interfaceComponent- Overrides:
readDesignin classAbstractField<String>- Parameters:
design- The element to obtain the state fromdesignContext- The DesignContext instance used for parsing the design
-
writeDesign
public void writeDesign(org.jsoup.nodes.Element design, DesignContext designContext)Description copied from interface:ComponentWrites the component state to the given design.The component is responsible not only for writing its own state but also for ensuring that its children write their state to the design.
This method must not modify the component state.
- Specified by:
writeDesignin interfaceComponent- Overrides:
writeDesignin classAbstractField<String>- Parameters:
design- The element to write the component state to. Any previous attributes or child nodes are not cleared.designContext- The DesignContext instance used for writing the design
-
getState
protected RichTextAreaState getState()
Description copied from class:AbstractComponentReturns the shared state bean with information to be sent from the server to the client. Subclasses should override this method and set any relevant fields of the state returned by super.getState().- Overrides:
getStatein classAbstractField<String>- Returns:
- updated component shared state
-
getState
protected RichTextAreaState getState(boolean markAsDirty)
Description copied from class:AbstractClientConnectorReturns the shared state for this connector.- Overrides:
getStatein classAbstractField<String>- Parameters:
markAsDirty- true if the connector should automatically be marked dirty, false otherwise- Returns:
- The shared state for this connector. Never null.
- See Also:
AbstractClientConnector.getState()
-
setValue
public void setValue(String value)
Sets the value of this object. If the new value is not equal togetValue(), fires aHasValue.ValueChangeEvent. ThrowsNullPointerExceptionif the value is null.- Specified by:
setValuein interfaceHasValue<String>- Overrides:
setValuein classAbstractField<String>- Parameters:
value- the new value, notnull- Throws:
NullPointerException- ifvalueisnull
-
getValue
public String getValue()
Description copied from interface:HasValueReturns the current value of this object.Implementation note: the implementing class should document whether null values may be returned or not.
-
getEmptyValue
public String getEmptyValue()
Description copied from interface:HasValueReturns the value that represents an empty value.By default
HasValueis expected to supportnullas empty values. Specific implementations might not support this.- Specified by:
getEmptyValuein interfaceHasValue<String>- Returns:
- empty value
- See Also:
Binder#bind(HasValue, ValueProvider, Setter)
-
doSetValue
protected void doSetValue(String value)
Description copied from class:AbstractFieldSets the value of this field. May do sanitization or throwIllegalArgumentExceptionif the value is invalid. Typically saves the value to shared state.- Specified by:
doSetValuein classAbstractField<String>- Parameters:
value- the new value of the field
-
selectAll
public void selectAll()
Selects all text in the rich text area. As a side effect, focuses the rich text area.- Since:
- 6.5
-
setValueChangeMode
public void setValueChangeMode(ValueChangeMode mode)
Description copied from interface:HasValueChangeModeSets the mode how the TextField triggersHasValue.ValueChangeEvents.- Specified by:
setValueChangeModein interfaceHasValueChangeMode- Parameters:
mode- the new mode- See Also:
ValueChangeMode
-
getValueChangeMode
public ValueChangeMode getValueChangeMode()
Description copied from interface:HasValueChangeModeReturns the currently setValueChangeMode.- Specified by:
getValueChangeModein interfaceHasValueChangeMode- Returns:
- the mode used to trigger
HasValue.ValueChangeEvents. - See Also:
ValueChangeMode
-
setValueChangeTimeout
public void setValueChangeTimeout(int timeout)
Description copied from interface:HasValueChangeModeSets how oftenHasValue.ValueChangeEvents are triggered when theValueChangeModeis set to eitherValueChangeMode.LAZYorValueChangeMode.TIMEOUT.- Specified by:
setValueChangeTimeoutin interfaceHasValueChangeMode- Parameters:
timeout- timeout in milliseconds, must be greater or equal to 0- See Also:
ValueChangeMode
-
getValueChangeTimeout
public int getValueChangeTimeout()
Description copied from interface:HasValueChangeModeReturns the currently set timeout, in milliseconds, for how oftenHasValue.ValueChangeEvents are triggered if the currentValueChangeModeis set to eitherValueChangeMode.LAZYorValueChangeMode.TIMEOUT.- Specified by:
getValueChangeTimeoutin interfaceHasValueChangeMode- Returns:
- the timeout in milliseconds of how often
HasValue.ValueChangeEvents are triggered.
-
addSnippet
public void addSnippet(String snippet)
Add a predefined content snippet to the menu. HTML formatting is allowed. Drop-down menu is visible after the first snippet is added. The title of the snippet is automatically generated from the first 20 characters of the snippet.- Parameters:
snippet- snippet text, can be HTML formatted- Since:
- 8.16
-
addSnippet
public void addSnippet(String title, String snippet)
Add a predefined content snippet to the menu. HTML formatting is allowed in the snippet text. Drop down menu is visible after the first snippet is added. This method allows assigning a custom title to the added snippet.- Parameters:
title- string to display in drop-down menusnippet- snippet text, can be HTML formatted- Since:
- 8.16
-
addSnippet
public void addSnippet(Snippet snippet)
Add aSnippetobject to the menu. Drop-down menu is visible after the first snippet is added.- Parameters:
snippet- aSnippetobject- Since:
- 8.16
-
addSnippets
public void addSnippets(String[] snippets)
Add predefined content snippets to the menu. HTML formatting is allowed. Drop down menu is visible after the first snippet is added. The titles of snippets in the drop-down menu are automatically generated from the first 20 characters of the snippet text.- Parameters:
snippets- array of snippet body text, can be HTML formatted- Since:
- 8.16
-
addSnippets
public void addSnippets(String[] titles, String[] snippets)
Add predefined content snippets to the menu. HTML formatting is allowed in the snippet text. Drop-down menu is visible after the first snippet is added. Each snippet is assigned a title from the titles array, or has one automatically generated from the snippet text if the corresponding value in the titles array is null. The array sizes must match exactly.- Parameters:
titles- array of strings to display as snippet titles. This array may include nulls, in which case the title is automatically generated from the first 20 characters in the snippet text.snippets- array of snippet text, can be HTML formatted- Since:
- 8.16
-
addSnippets
public void addSnippets(Collection<Snippet> snippets)
AddSnippetobjects to the menu. Drop-down menu is visible after the first snippet has been added.- Parameters:
snippets- aCollectionof Snippet objects- Since:
- 8.16
-
clearSnippets
public void clearSnippets()
Remove all snippets - this also hides the snippets drop-down unless new snippets are added.- Since:
- 8.16
-
-