org.netbeans.jemmy.drivers.text
Class TextKeyboardDriver

java.lang.Object
  extended by org.netbeans.jemmy.drivers.LightSupportiveDriver
      extended by org.netbeans.jemmy.drivers.text.TextKeyboardDriver
All Implemented Interfaces:
LightDriver, TextDriver
Direct Known Subclasses:
AWTTextKeyboardDriver, SwingTextKeyboardDriver

public abstract class TextKeyboardDriver
extends LightSupportiveDriver
implements TextDriver

Superclass for all TextDrivers using keyboard.

Author:
Alexandre Iline(alexandre.iline@sun.com)

Constructor Summary
TextKeyboardDriver(String[] supported)
          Constructs a TextKeyboardDriver.
 
Method Summary
 void changeCaretPosition(ComponentOperator oper, int position)
          Moves caret.
protected  void changeCaretPosition(ComponentOperator oper, int position, int preModifiers)
          Changes current caret position to specifyed.
 void changeText(ComponentOperator oper, String text)
          Replace component text.
 void clearText(ComponentOperator oper)
          Clears component text.
 void enterText(ComponentOperator oper, String text)
          Type text and push enter.
abstract  Timeout getBetweenTimeout(ComponentOperator oper)
          Returns a timeout to sleep between text typing and caret operations.
abstract  int getCaretPosition(ComponentOperator oper)
          Returns current caret position.
abstract  org.netbeans.jemmy.drivers.text.NavigationKey[] getKeys(ComponentOperator oper)
          Returns an array of navigation keys.
abstract  int getSelectionEnd(ComponentOperator oper)
          Returns a caret position of selection end.
abstract  int getSelectionStart(ComponentOperator oper)
          Returns a caret position of selection start.
abstract  String getText(ComponentOperator oper)
          Returns operator's text.
 void selectText(ComponentOperator oper, int startPosition, int finalPosition)
          Selects text.
 void typeText(ComponentOperator oper, String text, int caretPosition)
          Types new text.
 
Methods inherited from class org.netbeans.jemmy.drivers.LightSupportiveDriver
checkSupported, getSupported
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TextKeyboardDriver

public TextKeyboardDriver(String[] supported)
Constructs a TextKeyboardDriver.

Parameters:
supported - an array of supported class names
Method Detail

changeCaretPosition

public void changeCaretPosition(ComponentOperator oper,
                                int position)
Description copied from interface: TextDriver
Moves caret.

Specified by:
changeCaretPosition in interface TextDriver
Parameters:
oper - Text component operator.
position - Position to move caret to.

selectText

public void selectText(ComponentOperator oper,
                       int startPosition,
                       int finalPosition)
Description copied from interface: TextDriver
Selects text.

Specified by:
selectText in interface TextDriver
Parameters:
oper - Text component operator.
startPosition - a posistion of selction start
finalPosition - a posistion of selction end

clearText

public void clearText(ComponentOperator oper)
Description copied from interface: TextDriver
Clears component text.

Specified by:
clearText in interface TextDriver
Parameters:
oper - Text component operator.

typeText

public void typeText(ComponentOperator oper,
                     String text,
                     int caretPosition)
Description copied from interface: TextDriver
Types new text.

Specified by:
typeText in interface TextDriver
Parameters:
oper - Text component operator.
text - New text to type.
caretPosition - Type text at that position.

changeText

public void changeText(ComponentOperator oper,
                       String text)
Description copied from interface: TextDriver
Replace component text.

Specified by:
changeText in interface TextDriver
Parameters:
oper - Text component operator.
text - New text to type.

enterText

public void enterText(ComponentOperator oper,
                      String text)
Description copied from interface: TextDriver
Type text and push enter.

Specified by:
enterText in interface TextDriver
Parameters:
oper - Text component operator.
text - New text to type.

getText

public abstract String getText(ComponentOperator oper)
Returns operator's text.

Parameters:
oper - an operator.
Returns:
string representing component text.

getCaretPosition

public abstract int getCaretPosition(ComponentOperator oper)
Returns current caret position.

Parameters:
oper - an operator.
Returns:
int represnting current operator's caret position.

getSelectionStart

public abstract int getSelectionStart(ComponentOperator oper)
Returns a caret position of selection start.

Parameters:
oper - an operator.
Returns:
int represnting index of operator's selection start.

getSelectionEnd

public abstract int getSelectionEnd(ComponentOperator oper)
Returns a caret position of selection end.

Parameters:
oper - an operator.
Returns:
int represnting index of operator's selection end.

getKeys

public abstract org.netbeans.jemmy.drivers.text.NavigationKey[] getKeys(ComponentOperator oper)
Returns an array of navigation keys.

Parameters:
oper - an operator.
Returns:
an array on NavigationKey instances.

getBetweenTimeout

public abstract Timeout getBetweenTimeout(ComponentOperator oper)
Returns a timeout to sleep between text typing and caret operations.

Parameters:
oper - an operator.
Returns:
a Timeout instance.

changeCaretPosition

protected void changeCaretPosition(ComponentOperator oper,
                                   int position,
                                   int preModifiers)
Changes current caret position to specifyed.

Parameters:
oper - an operator.
position - new caret position
preModifiers - a modifiers (combination of InputEvent.*_MASK fields) pushed before caret moving (like shift during text selection).