com.vaadin.ui
Class Label

java.lang.Object
  extended by com.vaadin.terminal.AbstractClientConnector
      extended by com.vaadin.ui.AbstractComponent
          extended by com.vaadin.ui.Label
All Implemented Interfaces:
Property<String>, Property.ValueChangeListener, Property.ValueChangeNotifier, Property.Viewer, MethodEventSource, Connector, ClientConnector, RpcTarget, Sizeable, Component, Serializable, Comparable<Label>

public class Label
extends AbstractComponent
implements Property<String>, Property.Viewer, Property.ValueChangeListener, Property.ValueChangeNotifier, Comparable<Label>

Label component for showing non-editable short texts. The label content can be set to the modes specified by ContentMode

The contents of the label may contain simple formatting:

The b,i,u and li tags can contain all the tags in the list recursively.

Since:
3.0
Version:
7.0.0.alpha3
Author:
Vaadin Ltd.
See Also:
Serialized Form

Nested Class Summary
static class Label.ValueChangeEvent
          Value change event
 
Nested classes/interfaces inherited from class com.vaadin.ui.AbstractComponent
AbstractComponent.ComponentErrorEvent, AbstractComponent.ComponentErrorHandler
 
Nested classes/interfaces inherited from interface com.vaadin.data.Property
Property.Editor, Property.ReadOnlyException, Property.ReadOnlyStatusChangeEvent, Property.ReadOnlyStatusChangeListener, Property.ReadOnlyStatusChangeNotifier, Property.Transactional<T>, Property.ValueChangeListener, Property.ValueChangeNotifier, Property.Viewer
 
Nested classes/interfaces inherited from interface com.vaadin.ui.Component
Component.ErrorEvent, Component.ErrorListener, Component.Event, Component.Focusable, Component.Listener
 
Nested classes/interfaces inherited from interface com.vaadin.terminal.Sizeable
Sizeable.Unit
 
Field Summary
static ContentMode CONTENT_DEFAULT
          Deprecated. From 7.0, use ContentMode.TEXT instead
static ContentMode CONTENT_PREFORMATTED
          Deprecated. From 7.0, use ContentMode.PREFORMATTED instead
static ContentMode CONTENT_RAW
          Deprecated. From 7.0, use ContentMode.RAW instead
static ContentMode CONTENT_TEXT
          Deprecated. From 7.0, use ContentMode.TEXT instead
static ContentMode CONTENT_XHTML
          Deprecated. From 7.0, use ContentMode.XHTML instead
static ContentMode CONTENT_XML
          Deprecated. From 7.0, use ContentMode.XML instead
 
Fields inherited from interface com.vaadin.terminal.Sizeable
SIZE_UNDEFINED, UNITS_CM, UNITS_EM, UNITS_EX, UNITS_INCH, UNITS_MM, UNITS_PERCENTAGE, UNITS_PICAS, UNITS_PIXELS, UNITS_POINTS
 
Constructor Summary
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.
 
Method Summary
 void addListener(Property.ValueChangeListener listener)
          Adds the value change listener.
 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.
 Property getPropertyDataSource()
          Gets the viewing data-source property.
 LabelState getState()
          Returns the shared state bean with information to be sent from the server to the client.
 Class<String> getType()
          Gets the type of the Property.
 String getValue()
          Gets the value of the label.
 void removeListener(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 setPropertyDataSource(Property newDataSource)
          Sets the property as data-source for viewing.
 void setValue(Object newStringValue)
          Set the value of the label.
 String toString()
          Deprecated. Use getValue() instead
 void valueChange(Property.ValueChangeEvent event)
          Listens the value change events from data source.
 
Methods inherited from class com.vaadin.ui.AbstractComponent
addListener, addListener, addListener, addListener, addShortcutListener, addStyleName, attach, detach, findAncestor, fireComponentErrorEvent, fireComponentEvent, fireEvent, focus, getActionManager, getApplication, getCaption, getComponentError, getData, getDebugId, getDescription, getErrorHandler, getErrorMessage, getHeight, getHeightUnits, getIcon, getListeners, getLocale, getParent, getRoot, getStyle, getStyleName, getWidth, getWidthUnits, handleError, hasListeners, isConnectorEnabled, isEnabled, isImmediate, isReadOnly, isVisible, removeListener, removeListener, removeListener, removeListener, removeListener, removeShortcutListener, removeStyleName, requestRepaint, setCaption, setComponentError, setData, setDebugId, setDescription, setEnabled, setErrorHandler, setHeight, setHeight, setIcon, setImmediate, setLocale, setParent, setReadOnly, setSizeFull, setSizeUndefined, setStyle, setStyleName, setVisible, setWidth, setWidth, updateState
 
Methods inherited from class com.vaadin.terminal.AbstractClientConnector
addExtension, addMethodInvocationToQueue, createState, getAllChildrenIterable, getConnectorId, getExtensions, getRpcManager, getRpcProxy, getStateType, registerRpc, registerRpc, removeExtension, requestRepaintAll, retrievePendingRpcCalls
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.vaadin.data.Property
isReadOnly, setReadOnly
 
Methods inherited from interface com.vaadin.terminal.gwt.server.ClientConnector
getExtensions, getStateType, removeExtension, requestRepaintAll, retrievePendingRpcCalls
 
Methods inherited from interface com.vaadin.terminal.gwt.client.Connector
getConnectorId
 
Methods inherited from interface com.vaadin.terminal.gwt.server.RpcTarget
getRpcManager
 

Field Detail

CONTENT_TEXT

@Deprecated
public static final ContentMode CONTENT_TEXT
Deprecated. From 7.0, use ContentMode.TEXT instead

CONTENT_PREFORMATTED

@Deprecated
public static final ContentMode CONTENT_PREFORMATTED
Deprecated. From 7.0, use ContentMode.PREFORMATTED instead

CONTENT_XHTML

@Deprecated
public static final ContentMode CONTENT_XHTML
Deprecated. From 7.0, use ContentMode.XHTML instead

CONTENT_XML

@Deprecated
public static final ContentMode CONTENT_XML
Deprecated. From 7.0, use ContentMode.XML instead

CONTENT_RAW

@Deprecated
public static final ContentMode CONTENT_RAW
Deprecated. From 7.0, use ContentMode.RAW instead

CONTENT_DEFAULT

@Deprecated
public static final ContentMode CONTENT_DEFAULT
Deprecated. From 7.0, use ContentMode.TEXT instead
Constructor Detail

Label

public Label()
Creates an empty Label.


Label

public Label(String content)
Creates a new instance of Label with text-contents.

Parameters:
content -

Label

public Label(Property contentSource)
Creates a new instance of Label with text-contents read from given datasource.

Parameters:
contentSource -

Label

public Label(String content,
             ContentMode contentMode)
Creates a new instance of Label with text-contents.

Parameters:
content -
contentMode -

Label

public Label(Property contentSource,
             ContentMode contentMode)
Creates a new instance of Label with text-contents read from given datasource.

Parameters:
contentSource -
contentMode -
Method Detail

getState

public LabelState getState()
Description copied from class: AbstractComponent
Returns 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().

Specified by:
getState in interface Connector
Specified by:
getState in interface Component
Overrides:
getState in class AbstractComponent
Returns:
updated component shared state

getValue

public String getValue()
Gets the value of the label.

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.

Specified by:
getValue in interface Property<String>
Returns:
the value of the label.

setValue

public void setValue(Object newStringValue)
Set the value of the label. Value of the label is the XML contents of the label.

Specified by:
setValue in interface Property<String>
Parameters:
newStringValue - the New value of the label.

toString

@Deprecated
public String toString()
Deprecated. Use getValue() instead

Overrides:
toString in class Object
See Also:
Object.toString()

getType

public Class<String> getType()
Gets the type of the Property.

Specified by:
getType in interface Property<String>
Returns:
type of the Property
See Also:
Property.getType()

getPropertyDataSource

public Property getPropertyDataSource()
Gets the viewing data-source property.

Specified by:
getPropertyDataSource in interface Property.Viewer
Returns:
the data source property.
See Also:
Property.Viewer.getPropertyDataSource()

setPropertyDataSource

public void setPropertyDataSource(Property newDataSource)
Sets the property as data-source for viewing.

Specified by:
setPropertyDataSource in interface Property.Viewer
Parameters:
newDataSource - the new data source Property
See Also:
Property.Viewer.setPropertyDataSource(com.vaadin.data.Property)

getContentMode

public ContentMode getContentMode()
Gets the content mode of the Label.

Returns:
the Content mode of the label.
See Also:
ContentMode

setContentMode

public void setContentMode(ContentMode contentMode)
Sets the content mode of the Label.

Parameters:
contentMode - the New content mode of the label.
See Also:
ContentMode

addListener

public void addListener(Property.ValueChangeListener listener)
Adds the value change listener.

Specified by:
addListener in interface Property.ValueChangeNotifier
Parameters:
listener - the Listener to be added.
See Also:
Property.ValueChangeNotifier.addListener(com.vaadin.data.Property.ValueChangeListener)

removeListener

public void removeListener(Property.ValueChangeListener listener)
Removes the value change listener.

Specified by:
removeListener in interface Property.ValueChangeNotifier
Parameters:
listener - the Listener to be removed.
See Also:
Property.ValueChangeNotifier.removeListener(com.vaadin.data.Property.ValueChangeListener)

fireValueChange

protected void fireValueChange()
Emits the options change event.


valueChange

public void valueChange(Property.ValueChangeEvent event)
Listens the value change events from data source.

Specified by:
valueChange in interface Property.ValueChangeListener
Parameters:
event - value change event object
See Also:
Property.ValueChangeListener.valueChange(Property.ValueChangeEvent)

compareTo

public int compareTo(Label other)
Compares the Label to other objects.

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 XHTML modes, only CDATA is compared and tags ignored. If the other object is not a Label, its toString() return value is used in comparison.

Specified by:
compareTo in interface Comparable<Label>
Parameters:
other - the Other object to compare to.
Returns:
a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.
See Also:
Comparable.compareTo(java.lang.Object)

getConverter

public Converter<String,Object> getConverter()
Gets the converter used to convert the property data source value to the label value.

Returns:
The converter or null if none is set.

setConverter

public void setConverter(Converter<String,?> converter)
Sets the converter used to convert the label value to the property data source type. The converter must have a presentation type of String.

Parameters:
converter - The new converter to use.


Copyright © 2000-2011 Vaadin Ltd. All Rights Reserved.