public class Label extends AbstractComponent implements Property<String>, Property.Viewer, Property.ValueChangeListener, Property.ValueChangeNotifier, Comparable<Label>
ContentMode
The contents of the label may contain simple formatting:
Modifier and Type | Class and Description |
---|---|
static class |
Label.ValueChangeEvent
Value change event
|
Property.Editor, Property.ReadOnlyException, Property.ReadOnlyStatusChangeEvent, Property.ReadOnlyStatusChangeListener, Property.ReadOnlyStatusChangeNotifier, Property.Transactional<T>, Property.ValueChangeListener, Property.ValueChangeNotifier, Property.Viewer
Component.ErrorEvent, Component.Event, Component.Focusable, Component.Listener
ClientConnector.AttachEvent, ClientConnector.AttachListener, ClientConnector.ConnectorErrorEvent, ClientConnector.DetachEvent, ClientConnector.DetachListener
Sizeable.Unit
Modifier and Type | Field and Description |
---|---|
static ContentMode |
CONTENT_DEFAULT
Deprecated.
As of 7.0, use
ContentMode.TEXT instead |
static ContentMode |
CONTENT_PREFORMATTED
Deprecated.
As of 7.0, use
ContentMode.PREFORMATTED instead |
static ContentMode |
CONTENT_RAW
Deprecated.
As of 7.0, use
ContentMode.RAW instead |
static ContentMode |
CONTENT_TEXT
Deprecated.
As of 7.0, use
ContentMode.TEXT instead |
static ContentMode |
CONTENT_XHTML
Deprecated.
As of 7.0, use
ContentMode.HTML instead |
static ContentMode |
CONTENT_XML
Deprecated.
As of 7.0, use
ContentMode.XML instead |
DESIGN_ATTR_PLAIN_TEXT
SIZE_UNDEFINED, UNITS_CM, UNITS_EM, UNITS_EX, UNITS_INCH, UNITS_MM, UNITS_PERCENTAGE, UNITS_PICAS, UNITS_PIXELS, UNITS_POINTS
Constructor and Description |
---|
Label()
Creates an empty Label.
|
Label(Property contentSource)
Creates a new instance of Label with text-contents read from given
datasource.
|
Label(Property contentSource,
ContentMode contentMode)
Creates a new instance of Label with text-contents read from given
datasource.
|
Label(String content)
Creates a new instance of Label with text-contents.
|
Label(String content,
ContentMode contentMode)
Creates a new instance of Label with text-contents.
|
Modifier and Type | Method and Description |
---|---|
void |
addListener(Property.ValueChangeListener listener)
Deprecated.
As of 7.0, replaced by
addValueChangeListener(Property.ValueChangeListener) |
void |
addValueChangeListener(Property.ValueChangeListener listener)
Adds the value change listener.
|
void |
attach()
Notifies the connector that it is connected to a VaadinSession (and
therefore also to a UI).
|
int |
compareTo(Label other)
Compares the Label to other objects.
|
protected void |
fireValueChange()
Emits the options change event.
|
ContentMode |
getContentMode()
Gets the content mode of the Label.
|
Converter<String,Object> |
getConverter()
Gets the converter used to convert the property data source value to the
label value.
|
protected Collection<String> |
getCustomAttributes()
Returns a collection of attributes that should not be handled by the
basic implementation of the
readDesign and writeDesign
methods. |
Property |
getPropertyDataSource()
Gets the viewing data-source property.
|
protected LabelState |
getState()
Returns the shared state bean with information to be sent from the server
to the client.
|
protected LabelState |
getState(boolean markAsDirty)
Returns the shared state for this connector.
|
Class<String> |
getType()
Gets the type of the Property.
|
String |
getValue()
Gets the value of the label.
|
void |
readDesign(org.jsoup.nodes.Element design,
DesignContext designContext)
Reads the component state from the given design.
|
void |
removeListener(Property.ValueChangeListener listener)
Deprecated.
As of 7.0, replaced by
removeValueChangeListener(Property.ValueChangeListener) |
void |
removeValueChangeListener(Property.ValueChangeListener listener)
Removes the value change listener.
|
void |
setContentMode(ContentMode contentMode)
Sets the content mode of the Label.
|
void |
setConverter(Converter<String,?> converter)
Sets the converter used to convert the label value to the property data
source type.
|
void |
setLocale(Locale locale)
Sets the locale of this component.
|
void |
setPropertyDataSource(Property newDataSource)
Sets the property as data-source for viewing.
|
void |
setValue(String newStringValue)
Set the value of the label.
|
String |
toString()
Deprecated.
As of 7.0, use
getValue() to get the value of the
label or getPropertyDataSource() .getValue() to get
the value of the data source. |
void |
valueChange(Property.ValueChangeEvent event)
Listens the value change events from data source.
|
void |
writeDesign(org.jsoup.nodes.Element design,
DesignContext designContext)
Writes the component state to the given design.
|
addContextClickListener, addListener, addShortcutListener, addStyleName, beforeClientResponse, detach, findAncestor, fireComponentErrorEvent, fireComponentEvent, focus, getActionManager, getCaption, getComponentError, getData, getDebugId, getDescription, getErrorMessage, getExplicitImmediateValue, getHeight, getHeightUnits, getIcon, getId, getLocale, getParent, getPrimaryStyleName, getStyleName, getWidth, getWidthUnits, isCaptionAsHtml, isConnectorEnabled, isEnabled, isImmediate, isOrHasAncestor, isReadOnly, isResponsive, isVisible, removeContextClickListener, removeListener, removeShortcutListener, removeStyleName, setCaption, setCaptionAsHtml, setComponentError, setData, setDebugId, setDescription, setEnabled, setHeight, setHeight, setHeightUndefined, setIcon, setId, setImmediate, setParent, setPrimaryStyleName, setReadOnly, setResponsive, setSizeFull, setSizeUndefined, setStyleName, setStyleName, setVisible, setWidth, setWidth, setWidthUndefined
addAttachListener, addDetachListener, addExtension, 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, requestRepaint, requestRepaintAll, retrievePendingRpcCalls, setErrorHandler, setResource
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
isReadOnly, setReadOnly
addAttachListener, addDetachListener, encodeState, getErrorHandler, getExtensions, getRpcManager, getStateType, handleConnectorRequest, isAttached, markAsDirty, markAsDirtyRecursive, removeAttachListener, removeDetachListener, removeExtension, requestRepaint, requestRepaintAll, retrievePendingRpcCalls, setErrorHandler
getConnectorId
@Deprecated public static final ContentMode CONTENT_TEXT
ContentMode.TEXT
instead@Deprecated public static final ContentMode CONTENT_PREFORMATTED
ContentMode.PREFORMATTED
instead@Deprecated public static final ContentMode CONTENT_XHTML
ContentMode.HTML
instead@Deprecated public static final ContentMode CONTENT_XML
ContentMode.XML
instead@Deprecated public static final ContentMode CONTENT_RAW
ContentMode.RAW
instead@Deprecated public static final ContentMode CONTENT_DEFAULT
ContentMode.TEXT
insteadpublic Label()
public Label(String content)
content
- public Label(Property contentSource)
contentSource
- public Label(String content, ContentMode contentMode)
content
- contentMode
- public Label(Property contentSource, ContentMode contentMode)
contentSource
- contentMode
- protected LabelState getState()
AbstractComponent
getState
in class AbstractComponent
protected LabelState getState(boolean markAsDirty)
AbstractClientConnector
getState
in class AbstractComponent
markAsDirty
- true if the connector should automatically be marked dirty,
false otherwiseAbstractClientConnector.getState()
public String getValue()
The value of the label is the text that is shown to the end user.
Depending on the ContentMode
it is plain text or markup.
public void setValue(String newStringValue)
public Class<String> getType()
getType
in interface Property<String>
Property.getType()
public Property getPropertyDataSource()
getPropertyDataSource
in interface Property.Viewer
Property.Viewer#getPropertyDataSource()
public void setPropertyDataSource(Property newDataSource)
setPropertyDataSource
in interface Property.Viewer
newDataSource
- the new data source PropertyProperty.Viewer#setPropertyDataSource(Property)
public ContentMode getContentMode()
ContentMode
public void setContentMode(ContentMode contentMode)
contentMode
- the New content mode of the label.ContentMode
public void addValueChangeListener(Property.ValueChangeListener listener)
addValueChangeListener
in interface Property.ValueChangeNotifier
listener
- the Listener to be added.Property.ValueChangeNotifier#addListener(Property.ValueChangeListener)
@Deprecated public void addListener(Property.ValueChangeListener listener)
addValueChangeListener(Property.ValueChangeListener)
addListener
in interface Property.ValueChangeNotifier
public void removeValueChangeListener(Property.ValueChangeListener listener)
removeValueChangeListener
in interface Property.ValueChangeNotifier
listener
- the Listener to be removed.Property.ValueChangeNotifier#removeListener(Property.ValueChangeListener)
@Deprecated public void removeListener(Property.ValueChangeListener listener)
removeValueChangeListener(Property.ValueChangeListener)
removeListener
in interface Property.ValueChangeNotifier
protected void fireValueChange()
public void valueChange(Property.ValueChangeEvent event)
valueChange
in interface Property.ValueChangeListener
event
- value change event objectProperty.ValueChangeListener#valueChange(Property.ValueChangeEvent)
public void attach()
ClientConnector
The caller of this method is #setParent(ClientConnector)
if the
parent is itself already attached to the session. If not, the parent will
call the ClientConnector.attach()
for all its children when it is attached to
the session. This method is always called before the connector's data is
sent to the client-side for the first time.
The attachment logic is implemented in AbstractClientConnector
.
attach
in interface ClientConnector
attach
in interface Component
attach
in class AbstractComponent
public void setLocale(Locale locale)
AbstractComponent
// Component for which the locale is meaningful InlineDateField date = new InlineDateField("Datum"); // German language specified with ISO 639-1 language // code and ISO 3166-1 alpha-2 country code. date.setLocale(new Locale("de", "DE")); date.setResolution(DateField.RESOLUTION_DAY); layout.addComponent(date);
setLocale
in class AbstractComponent
locale
- the locale to become this component's locale.public int compareTo(Label other)
Labels can be compared to other labels for sorting label contents. This is especially handy for sorting table columns.
In RAW, PREFORMATTED and TEXT modes, the label contents are compared as is. In XML, UIDL and HTML modes, only CDATA is compared and tags ignored. If the other object is not a Label, its toString() return value is used in comparison.
compareTo
in interface Comparable<Label>
other
- the Other object to compare to.Comparable.compareTo(java.lang.Object)
public Converter<String,Object> getConverter()
public void setConverter(Converter<String,?> converter)
converter
- The new converter to use.@Deprecated public String toString()
getValue()
to get the value of the
label or getPropertyDataSource()
.getValue() to get
the value of the data source.If legacy Property toString mode is enabled, returns the value displayed by this label.
If legacy Property toString mode is disabled, the string representation has no special meaning
public void readDesign(org.jsoup.nodes.Element design, DesignContext designContext)
Component
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.
readDesign
in interface Component
readDesign
in class AbstractComponent
design
- The element to obtain the state fromdesignContext
- The DesignContext instance used for parsing the designprotected Collection<String> getCustomAttributes()
AbstractComponent
readDesign
and writeDesign
methods. Typically these are handled in a custom way in the overridden
versions of the above methodsgetCustomAttributes
in class AbstractComponent
public void writeDesign(org.jsoup.nodes.Element design, DesignContext designContext)
Component
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.
writeDesign
in interface Component
writeDesign
in class AbstractComponent
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 designCopyright © 2019 Vaadin Ltd. All rights reserved.