org.millstone.base.ui
Class Label

java.lang.Object
  |
  +--org.millstone.base.ui.AbstractComponent
        |
        +--org.millstone.base.ui.Label
All Implemented Interfaces:
Component, java.util.EventListener, MethodEventSource, Paintable, Property, Property.ValueChangeListener, Property.ValueChangeNotifier, Property.Viewer, VariableOwner

public class Label
extends AbstractComponent
implements Property, Property.Viewer, Property.ValueChangeListener, Property.ValueChangeNotifier

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

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:
3.0.3
Author:
IT Mill Ltd.

Nested Class Summary
 class Label.ValueChangeEvent
          Value change event
 
Nested classes inherited from class org.millstone.base.data.Property
Property.ConversionException, Property.Editor, Property.ReadOnlyException, Property.ReadOnlyStatusChangeEvent, Property.ReadOnlyStatusChangeListener, Property.ReadOnlyStatusChangeNotifier, Property.ValueChangeListener, Property.ValueChangeNotifier, Property.Viewer
 
Nested classes inherited from class org.millstone.base.ui.Component
Component.Listener
 
Nested classes inherited from class org.millstone.base.terminal.Paintable
Paintable.RepaintRequestEvent, Paintable.RepaintRequestListener
 
Field Summary
static int CONTENT_DEFAULT
          The default content mode is plain text
static int CONTENT_PREFORMATTED
          Content mode, where the label contains preformatted text.
static int CONTENT_TEXT
          Content mode, where the label contains only plain text.
static int CONTENT_UIDL
          Formatted content mode, where the contents is XML restricted to the UIDL 1.0 formatting markups
static int CONTENT_XHTML
          Content mode, where the label contains XHTML.
static int CONTENT_XML
          Content mode, where the label contains well-formed or well-balanced XML.
 
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, int contentMode)
          Creates a new instance of Label with text-contents read from given datasource.
Label(java.lang.String content)
          Creates a new instance of Label with text-contents.
Label(java.lang.String content, int contentMode)
          Creates a new instance of Label with text-contents.
 
Method Summary
 void addListener(Property.ValueChangeListener listener)
          Add value change listener
protected  void fireValueChange()
          Emit options change event.
 int getContentMode()
          Returns the namespace.
 Property getPropertyDataSource()
          Get viewing data-source property.
 java.lang.String getTag()
          Get component UIDL tag.
 java.lang.Class getType()
          Returns the type of the Property.
 java.lang.Object getValue()
          Get the value of the label.
 boolean isReadOnly()
          Is the component read-only ?
 void paintContent(PaintTarget target)
          Paint the content of this component.
 void removeListener(Property.ValueChangeListener listener)
          Remove value change listener
 void setContentMode(int contentMode)
          Sets the namespace.
 void setPropertyDataSource(Property newDataSource)
          Set the property as data-source for viewing.
 void setReadOnly(boolean readOnly)
          Set the component to read-only.
 void setValue(java.lang.Object newValue)
          Set the value of the label.
 java.lang.String toString()
          Returns the value of the Property in human readable textual format.
 void valueChange(Property.ValueChangeEvent event)
          Listen value change events from data source.
 
Methods inherited from class org.millstone.base.ui.AbstractComponent
addListener, addListener, addListener, addListener, attach, changeVariables, childRequestedRepaint, dependsOn, detach, fireComponentEvent, fireEvent, getApplication, getCaption, getComponentError, getDescription, getDirectDependencies, getErrorMessage, getIcon, getLocale, getParent, getStyle, getWindow, isEnabled, isImmediate, isVisible, paint, removeDirectDependency, removeListener, removeListener, removeListener, removeListener, removeListener, requestRepaint, requestRepaintRequests, setCaption, setComponentError, setDescription, setEnabled, setIcon, setImmediate, setLocale, setParent, setStyle, setVisible
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

CONTENT_TEXT

public static final int CONTENT_TEXT
Content mode, where the label contains only plain text. The getValue() result is coded to XML when painting

See Also:
Constant Field Values

CONTENT_PREFORMATTED

public static final int CONTENT_PREFORMATTED
Content mode, where the label contains preformatted text.

See Also:
Constant Field Values

CONTENT_UIDL

public static final int CONTENT_UIDL
Formatted content mode, where the contents is XML restricted to the UIDL 1.0 formatting markups

See Also:
Constant Field Values

CONTENT_XHTML

public static final int CONTENT_XHTML
Content mode, where the label contains XHTML. Contents is then enclosed in DIV elements having namespace of "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd".

See Also:
Constant Field Values

CONTENT_XML

public static final int CONTENT_XML
Content mode, where the label contains well-formed or well-balanced XML. Each of the root elements must have their default namespace specified.

See Also:
Constant Field Values

CONTENT_DEFAULT

public static final int CONTENT_DEFAULT
The default content mode is plain text

See Also:
Constant Field Values
Constructor Detail

Label

public Label()
Creates an empty Label.


Label

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


Label

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


Label

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


Label

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

Method Detail

getTag

public java.lang.String getTag()
Get component UIDL tag.

Specified by:
getTag in class AbstractComponent
Returns:
Component UIDL tag as string.

setReadOnly

public void setReadOnly(boolean readOnly)
Set the component to read-only. Readonly is not used in label.

Specified by:
setReadOnly in interface Property
Overrides:
setReadOnly in class AbstractComponent
Parameters:
readOnly - True to enable read-only mode, False to disable it

isReadOnly

public boolean isReadOnly()
Is the component read-only ? Readonly is not used in label - this returns allways false.

Specified by:
isReadOnly in interface Property
Overrides:
isReadOnly in class AbstractComponent
Returns:
True iff the component is in read only mode

paintContent

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

Overrides:
paintContent in class AbstractComponent
Parameters:
target - target UIDL stream where the component should paint itself to
Throws:
PaintException - if the operation failed

getValue

public java.lang.Object getValue()
Get the value of the label. Value of the label is the XML contents of the label.

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

setValue

public void setValue(java.lang.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 - New value of the label

toString

public java.lang.String toString()
Description copied from interface: Property
Returns the value of the Property in human readable textual format. The return value should be assignable to the setValue method if the Property is not in read-only mode.

Specified by:
toString in interface Property
Overrides:
toString in class java.lang.Object
Returns:
String representation of the value stored in the Property

getType

public java.lang.Class getType()
Description copied from interface: Property
Returns the type of the Property. The methods getValue and setValue must be compatible with this type: one must be able to safely cast the value returned from getValue to the given type and pass any variable assignable to this type as an argument to setValue.

Specified by:
getType in interface Property
Returns:
type of the Property

getPropertyDataSource

public Property getPropertyDataSource()
Get viewing data-source property.

Specified by:
getPropertyDataSource in interface Property.Viewer
Returns:
the Property serving as the viewers data source

setPropertyDataSource

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

Specified by:
setPropertyDataSource in interface Property.Viewer
Parameters:
newDataSource - the new data source Property

getContentMode

public int getContentMode()
Returns the namespace.

Returns:
String

setContentMode

public void setContentMode(int contentMode)
Sets the namespace.


addListener

public void addListener(Property.ValueChangeListener listener)
Add value change listener

Specified by:
addListener in interface Property.ValueChangeNotifier
Parameters:
listener - Listener to be added.

removeListener

public void removeListener(Property.ValueChangeListener listener)
Remove value change listener

Specified by:
removeListener in interface Property.ValueChangeNotifier
Parameters:
listener - Listener to be removed.

fireValueChange

protected void fireValueChange()
Emit options change event.


valueChange

public void valueChange(Property.ValueChangeEvent event)
Listen 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)


Copyright © 2000,2001,2002 IT Mill Ltd. All Rights Reserved.