org.nakedobjects.viewer.lightweight.view
Class TextField

java.lang.Object
  extended byorg.nakedobjects.viewer.lightweight.AbstractView
      extended byorg.nakedobjects.viewer.lightweight.AbstractValueView
          extended byorg.nakedobjects.viewer.lightweight.view.TextField
All Implemented Interfaces:
java.lang.Cloneable, DragInternal, InternalView, KeyboardAccessible, View

public class TextField
extends AbstractValueView


Nested Class Summary
 class TextField.CursorPosition
           
 class TextField.Selection
           
 
Field Summary
 
Fields inherited from class org.nakedobjects.viewer.lightweight.AbstractValueView
objectField
 
Fields inherited from class org.nakedobjects.viewer.lightweight.AbstractView
DEBUG, DRAG_HANDLE_WIDTH, HPADDING, ICON_SIZE, VPADDING
 
Fields inherited from interface org.nakedobjects.viewer.lightweight.InternalView
FIELD, NORMAL
 
Constructor Summary
TextField()
           
 
Method Summary
 boolean canFocus()
           
 int charWidth(char ch)
          returns the width (in pixels) of the specified character if it were used in this field.
 void delete()
          Delete the character to the left of the cursor.
 void deleteForward()
          Delete the character to the right of the cursor.
 void drag(InternalDrag drag)
          Indicates the drag started within this view's bounds is continuing.
 void dragFrom(InternalDrag drag)
          Indicates the start of a drag within this view's bounds.
 void dragTo(InternalDrag drag)
          Indicates the drag started within this view's bounds has been finished (although the location may now be outside of its bounds).
 void draw(Canvas canvas)
          Called by the frame, or the parent view, when this view must redraw itself.
 void editComplete()
          Indicates that editing has been completed and the entry should be saved.
 void entered()
          Called as the mouse crosses the bounds, and ends up inside, of this view.
 void exited()
          Called as the mouse crosses the bounds, and ends up outside, of this view.
 void firstClick(Click click)
          Responds to first click by placing the cursor between the two characters nearest the point of the mouse.
 void focusLost()
           
 void focusRecieved()
           
 int getBaseline()
          Returns the postion of the baseline for adjacent label.
 int getMaxWidth()
           
 Size getRequiredSize()
           
 NakedValue getValue()
           
 void init(NakedValue value)
           
 void keyPressed(int keyCode, int modifiers)
          Called when the user presses any key on the keyboard while this view has the focus.
 void keyReleased(int keyCode, int modifiers)
          Called when the user releases any key on the keyboard while this view has the focus.
 void keyTyped(char keyCode)
          Called when the user presses a non-control key (i.e. data entry keys and not shift, up-arrow etc).
 int lineHeight()
           
 void mouseMoved(Location at)
          Detects wheter the point is in the lower right corner, and if so changes the cursor to show it can be resized.
 void paste()
           
 void refresh()
          refresh this views state from the value objects state so that it accurately reflects the value objects value.
 void secondClick(Click click)
          Called when the user double-clicked this view.
 void setMaxTextWidth(int noCharacters)
          Set the maximum width of the field, as a number of characters
 void setMaxWidth(int width)
          Set the maximum width of the field, as a number of pixels
 void setNoLines(int noLines)
          Sets the number of lines to display
 int stringWidth(java.lang.String string)
           
 void thirdClick(Click click)
          Called when the user triple-clicks the mouse buttone within this view.
 
Methods inherited from class org.nakedobjects.viewer.lightweight.AbstractValueView
canChangeValue, clone, dragCancel, getContainedBy, getFieldOf, getIdentified, getPadding, getRoot, hasFocus, indicatesForView, makeView, menuOptions, parentObjectView, refreshDerivedValue, refreshValue, set, toString
 
Methods inherited from class org.nakedobjects.viewer.lightweight.AbstractView
addControl, assignId, backgroundColor, calculateRepaintArea, contains, createCanvas, debugDetails, defaultFieldHeight, dispose, enteredSubview, exitedSubview, getAbsoluteLocation, getBorder, getBounds, getId, getLocation, getName, getParent, getSize, getWorkspace, identifyView, invalidateLayout, isLayoutInvalid, isOpen, isReplaceable, layout, limitBounds, print, redraw, removeControl, repaintAll, setBorder, setBounds, setLayoutValid, setLocation, setParent, setSize, setWorkspace, transparentBackground, validateLayout
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.nakedobjects.viewer.lightweight.InternalView
setParent
 
Methods inherited from interface org.nakedobjects.viewer.lightweight.View
calculateRepaintArea, contains, debugDetails, dispose, enteredSubview, exitedSubview, getAbsoluteLocation, getBorder, getBounds, getId, getLocation, getName, getParent, getSize, getWorkspace, identifyView, invalidateLayout, isLayoutInvalid, isOpen, isReplaceable, layout, print, redraw, setBorder, setBounds, setLocation, setSize, validateLayout
 
Methods inherited from interface org.nakedobjects.viewer.lightweight.KeyboardAccessible
redraw
 

Constructor Detail

TextField

public TextField()
Method Detail

getBaseline

public int getBaseline()
Description copied from class: AbstractView
Returns the postion of the baseline for adjacent label. If the label is drawn on this baseline when top of the label rectangle and this view's rectangle are aligned then the label should share the baseline with whatever text is shown within the view.

Specified by:
getBaseline in interface View
Overrides:
getBaseline in class AbstractView
Returns:
int the baseline to draw the label at.

setMaxTextWidth

public void setMaxTextWidth(int noCharacters)
Set the maximum width of the field, as a number of characters


setMaxWidth

public void setMaxWidth(int width)
Set the maximum width of the field, as a number of pixels


getMaxWidth

public int getMaxWidth()

setNoLines

public void setNoLines(int noLines)
Sets the number of lines to display


getRequiredSize

public Size getRequiredSize()

getValue

public NakedValue getValue()
Specified by:
getValue in class AbstractValueView

canFocus

public boolean canFocus()
Specified by:
canFocus in interface KeyboardAccessible
Overrides:
canFocus in class AbstractValueView

charWidth

public int charWidth(char ch)
returns the width (in pixels) of the specified character if it were used in this field.


delete

public void delete()
Delete the character to the left of the cursor.


deleteForward

public void deleteForward()
Delete the character to the right of the cursor.


drag

public void drag(InternalDrag drag)
Description copied from class: AbstractValueView
Indicates the drag started within this view's bounds is continuing. By default does nothing.

Specified by:
drag in interface DragInternal
Overrides:
drag in class AbstractValueView

dragFrom

public void dragFrom(InternalDrag drag)
Description copied from class: AbstractValueView
Indicates the start of a drag within this view's bounds. By default does nothing.

Specified by:
dragFrom in interface DragInternal
Overrides:
dragFrom in class AbstractValueView

dragTo

public void dragTo(InternalDrag drag)
Description copied from class: AbstractValueView
Indicates the drag started within this view's bounds has been finished (although the location may now be outside of its bounds). By default does nothing.

Specified by:
dragTo in interface DragInternal
Overrides:
dragTo in class AbstractValueView

draw

public void draw(Canvas canvas)
Description copied from interface: View
Called by the frame, or the parent view, when this view must redraw itself.

Specified by:
draw in interface View
Overrides:
draw in class AbstractValueView

editComplete

public void editComplete()
Description copied from class: AbstractValueView
Indicates that editing has been completed and the entry should be saved. Will be called by the view manager when other action place within the parent.

Specified by:
editComplete in interface KeyboardAccessible
Overrides:
editComplete in class AbstractValueView

entered

public void entered()
Description copied from interface: View
Called as the mouse crosses the bounds, and ends up inside, of this view. Is also called as the mouse returns into this view from a contained view.

Specified by:
entered in interface View
Overrides:
entered in class AbstractValueView

exited

public void exited()
Description copied from interface: View
Called as the mouse crosses the bounds, and ends up outside, of this view.

Specified by:
exited in interface View
Overrides:
exited in class AbstractValueView

firstClick

public void firstClick(Click click)
Responds to first click by placing the cursor between the two characters nearest the point of the mouse.

Specified by:
firstClick in interface View
Overrides:
firstClick in class AbstractView
See Also:
View#firstClick(Click)

focusLost

public void focusLost()
Specified by:
focusLost in interface KeyboardAccessible
Overrides:
focusLost in class AbstractValueView

focusRecieved

public void focusRecieved()
Specified by:
focusRecieved in interface KeyboardAccessible
Overrides:
focusRecieved in class AbstractValueView

init

public void init(NakedValue value)
Overrides:
init in class AbstractValueView

keyPressed

public void keyPressed(int keyCode,
                       int modifiers)
Called when the user presses any key on the keyboard while this view has the focus.

Specified by:
keyPressed in interface KeyboardAccessible
Overrides:
keyPressed in class AbstractValueView
Parameters:
keyCode -
modifiers -

keyReleased

public void keyReleased(int keyCode,
                        int modifiers)
Called when the user releases any key on the keyboard while this view has the focus.

Specified by:
keyReleased in interface KeyboardAccessible
Overrides:
keyReleased in class AbstractValueView
Parameters:
keyCode -
modifiers -

keyTyped

public void keyTyped(char keyCode)
Called when the user presses a non-control key (i.e. data entry keys and not shift, up-arrow etc). Such a key press will result in a prior call to keyPressed and a subsequent call to keyReleased.

Specified by:
keyTyped in interface KeyboardAccessible
Overrides:
keyTyped in class AbstractValueView
Parameters:
keyCode -

lineHeight

public int lineHeight()

mouseMoved

public void mouseMoved(Location at)
Detects wheter the point is in the lower right corner, and if so changes the cursor to show it can be resized.

Specified by:
mouseMoved in interface View
Overrides:
mouseMoved in class AbstractView
Parameters:
at - the position relative to the top-left of this view
See Also:
View#mouseMoved(Location)

paste

public void paste()

refresh

public void refresh()
Description copied from class: AbstractValueView
refresh this views state from the value objects state so that it accurately reflects the value objects value.

Specified by:
refresh in class AbstractValueView

secondClick

public void secondClick(Click click)
Description copied from interface: View
Called when the user double-clicked this view. This method will have been preceded by a call to click.

Specified by:
secondClick in interface View
Overrides:
secondClick in class AbstractView

stringWidth

public int stringWidth(java.lang.String string)

thirdClick

public void thirdClick(Click click)
Description copied from interface: View
Called when the user triple-clicks the mouse buttone within this view. This method will have been preceded by a call to doubleClick.

Specified by:
thirdClick in interface View
Overrides:
thirdClick in class AbstractView