de.matthiasmann.twl.textarea
Class SimpleTextAreaModel

java.lang.Object
  extended by de.matthiasmann.twl.model.HasCallback
      extended by de.matthiasmann.twl.textarea.SimpleTextAreaModel
All Implemented Interfaces:
TextAreaModel, WithRunnableCallback, java.lang.Iterable<TextAreaModel.Element>

public class SimpleTextAreaModel
extends HasCallback
implements TextAreaModel

A simple text area model which represents the complete text as a single paragraph.

The initial style is an empty style - see Style.Style(). It can be changed before setting the text.

See Also:
setStyle(de.matthiasmann.twl.textarea.Style)

Nested Class Summary
 
Nested classes/interfaces inherited from interface de.matthiasmann.twl.textarea.TextAreaModel
TextAreaModel.BlockElement, TextAreaModel.Clear, TextAreaModel.ContainerElement, TextAreaModel.Display, TextAreaModel.Element, TextAreaModel.FloatPosition, TextAreaModel.HAlignment, TextAreaModel.ImageElement, TextAreaModel.LineBreakElement, TextAreaModel.LinkElement, TextAreaModel.ListElement, TextAreaModel.OrderedListElement, TextAreaModel.ParagraphElement, TextAreaModel.TableCellElement, TextAreaModel.TableElement, TextAreaModel.TextElement, TextAreaModel.VAlignment, TextAreaModel.WidgetElement
 
Constructor Summary
SimpleTextAreaModel()
           
SimpleTextAreaModel(java.lang.String text)
          Constructs a SimpleTextAreaModel with pre-formatted text.
 
Method Summary
 Style getStyle()
          Returns the style used for the next call to setText(java.lang.String, boolean)
 java.util.Iterator<TextAreaModel.Element> iterator()
           
 void setStyle(Style style)
          Sets the style used for the next call to setText(java.lang.String, boolean).
 void setText(java.lang.String text)
          Sets the text for this SimpleTextAreaModel as pre-formatted text.
 void setText(java.lang.String text, boolean preformatted)
          Sets the text for this SimpleTextAreaModel.
 
Methods inherited from class de.matthiasmann.twl.model.HasCallback
addCallback, doCallback, hasCallbacks, removeCallback
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface de.matthiasmann.twl.textarea.TextAreaModel
addCallback, removeCallback
 

Constructor Detail

SimpleTextAreaModel

public SimpleTextAreaModel()

SimpleTextAreaModel

public SimpleTextAreaModel(java.lang.String text)
Constructs a SimpleTextAreaModel with pre-formatted text. Use '\n' to create line breaks.

Parameters:
text - the text (interpreted as pre-formatted)
See Also:
setText(java.lang.String)
Method Detail

getStyle

public Style getStyle()
Returns the style used for the next call to setText(java.lang.String, boolean)

Returns:
the style

setStyle

public void setStyle(Style style)
Sets the style used for the next call to setText(java.lang.String, boolean). It does not affect the currently set text.

Parameters:
style - the style
Throws:
java.lang.NullPointerException - when style is null

setText

public void setText(java.lang.String text)
Sets the text for this SimpleTextAreaModel as pre-formatted text. Use '\n' to create line breaks. This is equivalent to calling setText(text, true);

Parameters:
text - the text (interpreted as pre-formatted)
See Also:
setText(java.lang.String, boolean)

setText

public void setText(java.lang.String text,
                    boolean preformatted)
Sets the text for this SimpleTextAreaModel. Use '\n' to create line breaks.

The preformatted will set the white space attribute as follows:

false = white-space: normal
true = white-space: pre

Parameters:
text - the text
preformatted - if the text should be treated as pre-formated or not.

iterator

public java.util.Iterator<TextAreaModel.Element> iterator()
Specified by:
iterator in interface java.lang.Iterable<TextAreaModel.Element>