org.apache.pivot.wtk
Class TextInput

java.lang.Object
  extended by org.apache.pivot.wtk.Component
      extended by org.apache.pivot.wtk.TextInput
All Implemented Interfaces:
ConstrainedVisual, Visual

public class TextInput
extends Component

A component that allows a user to enter a single line of unformatted text.


Nested Class Summary
static interface TextInput.Skin
          Text input skin interface.
static interface TextInput.TextBindMapping
          Translates between text and context data during data binding.
 
Nested classes/interfaces inherited from class org.apache.pivot.wtk.Component
Component.DecoratorSequence, Component.StyleDictionary, Component.UserDataDictionary
 
Field Summary
static int DEFAULT_TEXT_SIZE
           
 
Constructor Summary
TextInput()
           
 
Method Summary
 void clear()
          Clears any bound values in the component.
 void clearSelection()
          Clears the selection.
 void copy()
           
 void cut()
           
 void delete(boolean backspace)
           
 Bounds getCharacterBounds(int offset)
           
 int getInsertionPoint(int x)
           
 int getMaximumLength()
          Returns the maximum length of the text input's text content.
 String getPrompt()
          Returns the text input's prompt.
 String getSelectedText()
          Returns the currently selected text.
 Span getSelection()
          Returns a span representing the current selection.
 int getSelectionLength()
          Returns the length of the selection.
 int getSelectionStart()
          Returns the starting index of the selection.
 String getText()
           
 TextInput.TextBindMapping getTextBindMapping()
           
 BindType getTextBindType()
           
 ListenerList<TextInputBindingListener> getTextInputBindingListeners()
          Returns the text input binding listener list.
 ListenerList<TextInputCharacterListener> getTextInputCharacterListeners()
          Returns the text input character listener list.
 ListenerList<TextInputListener> getTextInputListeners()
          Returns the text input listener list.
 ListenerList<TextInputSelectionListener> getTextInputSelectionListeners()
          Returns the text input selection listener list.
 ListenerList<TextInputTextListener> getTextInputTextListeners()
          Returns the text input text listener list.
 String getTextKey()
          Returns the text input's text key.
 int getTextLength()
          Returns the character count of the text node.
 TextNode getTextNode()
          Returns the text node that backs the text input's content.
 int getTextSize()
          Returns the text size.
 Validator getValidator()
          Gets the validator associated with this text input.
 void insert(char character)
          Inserts a single character into the text input's content.
 void insert(String text)
          Inserts text into the text input's content.
 boolean isPassword()
          Returns the password flag.
 boolean isStrictValidation()
          Returns the text input's strict validation flag.
 boolean isTextValid()
          Tells whether or not this text input's text is currently valid as defined by its validator.
 void load(Object context)
          Copies bound values from the bind context to the component.
 void paste()
           
 void redo()
           
 void selectAll()
          Selects all text.
 void setMaximumLength(int maximumLength)
          Sets the maximum length of the text input's text content.
 void setPassword(boolean password)
          Sets or clears the password flag.
 void setPrompt(String prompt)
          Sets the text input's prompt.
 void setSelection(int selectionStart, int selectionLength)
          Sets the selection.
 void setSelection(Span selection)
          Sets the selection.
protected  void setSkin(Skin skin)
          Sets the skin, replacing any previous skin.
 void setStrictValidation(boolean strictValidation)
          Sets the text input's strict validation flag.
 void setText(String text)
           
 void setTextBindMapping(TextInput.TextBindMapping textBindMapping)
           
 void setTextBindType(BindType textBindType)
           
 void setTextBindType(String textBindType)
           
 void setTextKey(String textKey)
          Sets the text input's text key.
 void setTextNode(TextNode textNode)
          Sets the text node that backs the text input's content.
 void setTextSize(int textSize)
          Sets the text size.
 void setValidator(Validator validator)
          Sets the validator associated with this text input.
 void store(Object context)
          Copies bound values from the component to the bind context.
 void undo()
           
 
Methods inherited from class org.apache.pivot.wtk.Component
clearFocus, getAncestor, getAttribute, getAutomationID, getBaseline, getBaseline, getBounds, getComponentClassListeners, getComponentDataListeners, getComponentDecoratorListeners, getComponentKeyListeners, getComponentListeners, getComponentMouseButtonListeners, getComponentMouseListeners, getComponentMouseWheelListeners, getComponentStateListeners, getCursor, getDecoratedBounds, getDecorators, getDisplay, getDragSource, getDropTarget, getFocusedComponent, getGraphics, getHeight, getLocation, getMaximumPreferredHeight, getMaximumPreferredWidth, getMenuHandler, getMinimumPreferredHeight, getMinimumPreferredWidth, getParent, getPreferredHeight, getPreferredHeight, getPreferredHeightLimits, getPreferredSize, getPreferredWidth, getPreferredWidth, getPreferredWidthLimits, getSize, getSkin, getStyles, getTooltipText, getUserData, getVisibleArea, getVisibleArea, getVisibleArea, getWidth, getWindow, getX, getY, installThemeSkin, invalidate, isBlocked, isEnabled, isFocusable, isFocused, isMouseOver, isOpaque, isPreferredHeightSet, isPreferredSizeSet, isPreferredWidthSet, isShowing, isValid, isVisible, keyPressed, keyReleased, keyTyped, layout, mapPointFromAncestor, mapPointFromAncestor, mapPointToAncestor, mapPointToAncestor, mouseClick, mouseDown, mouseMove, mouseOut, mouseOver, mouseUp, mouseWheel, paint, reenterMouse, repaint, repaint, repaint, repaint, repaint, repaint, requestFocus, scrollAreaToVisible, scrollAreaToVisible, setAttribute, setAutomationID, setCursor, setCursor, setDragSource, setDropTarget, setEnabled, setHeight, setLocation, setLocation, setMaximumPreferredHeight, setMaximumPreferredWidth, setMenuHandler, setMinimumPreferredHeight, setMinimumPreferredWidth, setParent, setPreferredHeight, setPreferredHeightLimits, setPreferredHeightLimits, setPreferredSize, setPreferredSize, setPreferredWidth, setPreferredWidthLimits, setPreferredWidthLimits, setSize, setSize, setStyles, setStyles, setStyles, setTooltipText, setVisible, setWidth, setX, setY, toString, transferFocus, validate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT_TEXT_SIZE

public static final int DEFAULT_TEXT_SIZE
See Also:
Constant Field Values
Constructor Detail

TextInput

public TextInput()
Method Detail

setSkin

protected void setSkin(Skin skin)
Description copied from class: Component
Sets the skin, replacing any previous skin.

Overrides:
setSkin in class Component
Parameters:
skin - The new skin.

getTextNode

public TextNode getTextNode()
Returns the text node that backs the text input's content.


setTextNode

public void setTextNode(TextNode textNode)
Sets the text node that backs the text input's content.

Parameters:
textNode -

getText

public String getText()

setText

public void setText(String text)

insert

public void insert(char character)
Inserts a single character into the text input's content. The character replaces the current selection.

Parameters:
character - The character to insert.

insert

public void insert(String text)
Inserts text into the text input's content. The text replaces the current selection.

Parameters:
text - The text to insert.

getTextLength

public int getTextLength()
Returns the character count of the text node.

Returns:
The text node's length, or 0 if the text node is null.

delete

public void delete(boolean backspace)

cut

public void cut()

copy

public void copy()

paste

public void paste()

undo

public void undo()

redo

public void redo()

getSelectionStart

public int getSelectionStart()
Returns the starting index of the selection.

Returns:
The starting index of the selection.

getSelectionLength

public int getSelectionLength()
Returns the length of the selection.

Returns:
The length of the selection; may be 0.

getSelection

public Span getSelection()
Returns a span representing the current selection.

Returns:
A span containing the current selection. Both start and end points are inclusive. Returns null if the selection is empty.

setSelection

public void setSelection(int selectionStart,
                         int selectionLength)
Sets the selection. The sum of the selection start and length must be less than the length of the text input's content.

Parameters:
selectionStart - The starting index of the selection.
selectionLength - The length of the selection.

setSelection

public final void setSelection(Span selection)
Sets the selection.

Parameters:
selection -
See Also:
setSelection(int, int)

selectAll

public void selectAll()
Selects all text.


clearSelection

public void clearSelection()
Clears the selection.


getSelectedText

public String getSelectedText()
Returns the currently selected text.

Returns:
A new string containing a copy of the text in the selected range, or null if nothing is selected.

getTextSize

public int getTextSize()
Returns the text size.

Returns:
The number of characters to display in the text input.

setTextSize

public void setTextSize(int textSize)
Sets the text size.

Parameters:
textSize - The number of characters to display in the text input.

getMaximumLength

public int getMaximumLength()
Returns the maximum length of the text input's text content.

Returns:
The maximum length of the text input's text content.

setMaximumLength

public void setMaximumLength(int maximumLength)
Sets the maximum length of the text input's text content.

Parameters:
maximumLength - The maximum length of the text input's text content.

isPassword

public boolean isPassword()
Returns the password flag.

Returns:
true if this is a password text input; false, otherwise.

setPassword

public void setPassword(boolean password)
Sets or clears the password flag. If the password flag is set, the text input will visually mask its contents.

Parameters:
password - true if this is a password text input; false, otherwise.

getPrompt

public String getPrompt()
Returns the text input's prompt.


setPrompt

public void setPrompt(String prompt)
Sets the text input's prompt.

Parameters:
prompt - The prompt text, or null for no prompt.

getTextKey

public String getTextKey()
Returns the text input's text key.

Returns:
The text key, or null if no text key is set.

setTextKey

public void setTextKey(String textKey)
Sets the text input's text key.

Parameters:
textKey - The text key, or null to clear the binding.

getTextBindType

public BindType getTextBindType()

setTextBindType

public void setTextBindType(BindType textBindType)

setTextBindType

public final void setTextBindType(String textBindType)

getTextBindMapping

public TextInput.TextBindMapping getTextBindMapping()

setTextBindMapping

public void setTextBindMapping(TextInput.TextBindMapping textBindMapping)

load

public void load(Object context)
Description copied from class: Component
Copies bound values from the bind context to the component. This functionality must be provided by the subclass; the base implementation is a no-op.

Overrides:
load in class Component

store

public void store(Object context)
Description copied from class: Component
Copies bound values from the component to the bind context. This functionality must be provided by the subclass; the base implementation is a no-op.

Overrides:
store in class Component

clear

public void clear()
Description copied from class: Component
Clears any bound values in the component.

Overrides:
clear in class Component

getInsertionPoint

public int getInsertionPoint(int x)

getCharacterBounds

public Bounds getCharacterBounds(int offset)

getValidator

public Validator getValidator()
Gets the validator associated with this text input.


setValidator

public void setValidator(Validator validator)
Sets the validator associated with this text input.

Parameters:
validator - The validator to use, or null to use no validator.

isStrictValidation

public boolean isStrictValidation()
Returns the text input's strict validation flag.


setStrictValidation

public void setStrictValidation(boolean strictValidation)
Sets the text input's strict validation flag. When enabled, only valid text will be accepted by the text input.

Parameters:
strictValidation -

isTextValid

public boolean isTextValid()
Tells whether or not this text input's text is currently valid as defined by its validator. If there is no validator associated with this text input, the text is assumed to always be valid.


getTextInputListeners

public ListenerList<TextInputListener> getTextInputListeners()
Returns the text input listener list.


getTextInputTextListeners

public ListenerList<TextInputTextListener> getTextInputTextListeners()
Returns the text input text listener list.


getTextInputCharacterListeners

public ListenerList<TextInputCharacterListener> getTextInputCharacterListeners()
Returns the text input character listener list.


getTextInputSelectionListeners

public ListenerList<TextInputSelectionListener> getTextInputSelectionListeners()
Returns the text input selection listener list.


getTextInputBindingListeners

public ListenerList<TextInputBindingListener> getTextInputBindingListeners()
Returns the text input binding listener list.