com.vaadin.ui
Class Label

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

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

Label component for showing non-editable short texts. The label content can be set to the modes specified by Label.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.alpha2
Author:
Vaadin Ltd.
See Also:
Serialized Form

Nested Class Summary
static class Label.ContentMode
          Content modes defining how the client should interpret a Label's value.
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.terminal.VariableOwner
VariableOwner.ErrorEvent
 
Nested classes/interfaces inherited from interface com.vaadin.ui.Component
Component.ErrorEvent, Component.ErrorListener, Component.Event, Component.Focusable, Component.Listener, Component.RepaintRequestEvent, Component.RepaintRequestListener
 
Nested classes/interfaces inherited from interface com.vaadin.terminal.Sizeable
Sizeable.Unit
 
Field Summary
static Label.ContentMode CONTENT_DEFAULT
          Deprecated. From 7.0, use Label.ContentMode.DEFAULT instead
static Label.ContentMode CONTENT_PREFORMATTED
          Deprecated. From 7.0, use Label.ContentMode.PREFORMATTED instead
static Label.ContentMode CONTENT_RAW
          Deprecated. From 7.0, use Label.ContentMode.RAW instead
static Label.ContentMode CONTENT_TEXT
          Deprecated. From 7.0, use Label.ContentMode.TEXT instead
static Label.ContentMode CONTENT_XHTML
          Deprecated. From 7.0, use Label.ContentMode.XHTML instead
static Label.ContentMode CONTENT_XML
          Deprecated. From 7.0, use Label.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, Label.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, Label.ContentMode contentMode)
          Creates a new instance of Label with text-contents.
 
Method Summary
 void addListener(Property.ValueChangeListener listener)
          Adds the value change listener.
 void changeVariables(Object source, Map<String,Object> variables)
          Called when one or more variables handled by the implementing class are changed.
 int compareTo(Object other)
          Compares the Label to other objects.
protected  void fireValueChange()
          Emits the options change event.
 Label.ContentMode getContentMode()
          Gets the content mode of the Label.
 Property getPropertyDataSource()
          Gets the viewing data-source property.
 String getStringValue()
          Returns the value of the Property in human readable textual format.
 Class getType()
          Gets the type of the Property.
 Object getValue()
          Gets the value of the label.
 void paintContent(PaintTarget target)
          Paints the content of this component.
 void removeListener(Property.ValueChangeListener listener)
          Removes the value change listener.
 void setContentMode(Label.ContentMode contentMode)
          Sets the content mode of the Label.
 void setPropertyDataSource(Property newDataSource)
          Sets the property as data-source for viewing.
 void setValue(Object newValue)
          Set the value of the label.
 String toString()
          Deprecated. use the data source value or getStringValue() 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, addListener, addMethodInvocationToQueue, addShortcutListener, addStyleName, attach, createState, detach, findAncestor, fireComponentErrorEvent, fireComponentEvent, fireEvent, focus, getActionManager, getApplication, getCaption, getComponentError, getConnectorId, getData, getDebugId, getDescription, getErrorHandler, getErrorMessage, getHeight, getHeightUnits, getIcon, getListeners, getLocale, getParent, getRoot, getRpcManager, getRpcProxy, getState, getStyle, getStyleName, getWidth, getWidthUnits, handleError, hasListeners, isConnectorEnabled, isEnabled, isImmediate, isReadOnly, isVisible, registerRpc, registerRpc, removeListener, removeListener, removeListener, removeListener, removeListener, removeListener, removeShortcutListener, removeStyleName, requestRepaint, retrievePendingRpcCalls, 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 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.VariableOwner
isEnabled, isImmediate
 
Methods inherited from interface com.vaadin.ui.Component
addListener, addListener, addStyleName, attach, detach, getApplication, getCaption, getDebugId, getIcon, getLocale, getParent, getRoot, getState, getStyleName, isEnabled, isReadOnly, isVisible, removeListener, removeListener, removeStyleName, requestRepaint, setCaption, setDebugId, setEnabled, setIcon, setParent, setReadOnly, setStyleName, setVisible, updateState
 
Methods inherited from interface com.vaadin.terminal.gwt.server.ClientConnector
isConnectorEnabled, retrievePendingRpcCalls
 
Methods inherited from interface com.vaadin.terminal.gwt.client.Connector
getConnectorId
 
Methods inherited from interface com.vaadin.terminal.gwt.server.RpcTarget
getRpcManager
 
Methods inherited from interface com.vaadin.terminal.Sizeable
getHeight, getHeightUnits, getWidth, getWidthUnits, setHeight, setHeight, setSizeFull, setSizeUndefined, setWidth, setWidth
 

Field Detail

CONTENT_TEXT

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

CONTENT_PREFORMATTED

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

CONTENT_XHTML

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

CONTENT_XML

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

CONTENT_RAW

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

CONTENT_DEFAULT

@Deprecated
public static final Label.ContentMode CONTENT_DEFAULT
Deprecated. From 7.0, use Label.ContentMode.DEFAULT 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,
             Label.ContentMode contentMode)
Creates a new instance of Label with text-contents.

Parameters:
content -
contentMode -

Label

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

Parameters:
contentSource -
contentMode -
Method Detail

paintContent

public void paintContent(PaintTarget target)
                  throws PaintException
Paints the content of this component.

Specified by:
paintContent in interface Vaadin6Component
Parameters:
target - the Paint Event.
Throws:
PaintException - if the Paint Operation fails.

getValue

public Object getValue()
Gets the value of the label. Value of the label is the XML contents of the label.

Specified by:
getValue in interface Property
Returns:
the Value of the label.

setValue

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

Specified by:
setValue in interface Property
Parameters:
newValue - the New value of the label.

toString

@Deprecated
public String toString()
Deprecated. use the data source value or getStringValue() instead

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

getStringValue

public String getStringValue()
Returns the value of the Property in human readable textual format. This method exists to help migration from previous Vaadin versions by providing a simple replacement for toString(). However, it is normally better to use the value of the label directly.

Returns:
String representation of the value stored in the Property
Since:
7.0

getType

public Class getType()
Gets the type of the Property.

Specified by:
getType in interface Property
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 Label.ContentMode getContentMode()
Gets the content mode of the Label.

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

setContentMode

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

Parameters:
contentMode - the New content mode of the label.
See Also:
Label.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(Object 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<Object>
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)

changeVariables

public void changeVariables(Object source,
                            Map<String,Object> variables)
Description copied from interface: VariableOwner
Called when one or more variables handled by the implementing class are changed.

Specified by:
changeVariables in interface VariableOwner
Parameters:
source - the Source of the variable change. This is the origin of the event. For example in Web Adapter this is the request.
variables - the Mapping from variable names to new variable values.


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