org.netbeans.jemmy.operators
Class TextComponentOperator

java.lang.Object
  extended by org.netbeans.jemmy.operators.Operator
      extended by org.netbeans.jemmy.operators.ComponentOperator
          extended by org.netbeans.jemmy.operators.TextComponentOperator
All Implemented Interfaces:
Outputable, Timeoutable
Direct Known Subclasses:
TextAreaOperator, TextFieldOperator

public class TextComponentOperator
extends ComponentOperator
implements Timeoutable, Outputable

This operator type covers java.awt.TextArea component.

Author:
Alexandre Iline ([email protected])
See Also:
Timeouts

Nested Class Summary
static class TextComponentOperator.TextComponentByTextFinder
          Allows to find component by text.
static class TextComponentOperator.TextComponentFinder
          Checks component type.
 
Nested classes/interfaces inherited from class org.netbeans.jemmy.operators.Operator
Operator.ComponentVisualizer, Operator.DefaultPathParser, Operator.DefaultStringComparator, Operator.Finder, Operator.MapAction, Operator.MapBooleanAction, Operator.MapByteAction, Operator.MapCharacterAction, Operator.MapDoubleAction, Operator.MapFloatAction, Operator.MapIntegerAction, Operator.MapLongAction, Operator.MapVoidAction, Operator.NoBlockingAction, Operator.PathParser, Operator.StringComparator
 
Field Summary
static java.lang.String TEXT_DPROP
          Identifier for a "text" property.
 
Fields inherited from class org.netbeans.jemmy.operators.ComponentOperator
HEIGHT_DPROP, IS_SHOWING_DPROP, IS_VISIBLE_DPROP, NAME_DPROP, WIDTH_DPROP, X_DPROP, Y_DPROP
 
Fields inherited from class org.netbeans.jemmy.operators.Operator
CLASS_DPROP, TO_STRING_DPROP
 
Constructor Summary
TextComponentOperator(ContainerOperator cont)
          Constructor.
TextComponentOperator(ContainerOperator cont, ComponentChooser chooser)
          Constructs a TextComponentOperator object.
TextComponentOperator(ContainerOperator cont, ComponentChooser chooser, int index)
          Constructs a TextComponentOperator object.
TextComponentOperator(ContainerOperator cont, int index)
          Constructor.
TextComponentOperator(ContainerOperator cont, java.lang.String text)
          Constructor.
TextComponentOperator(ContainerOperator cont, java.lang.String text, int index)
          Constructor.
TextComponentOperator(java.awt.TextComponent b)
          Constructor.
 
Method Summary
 void addTextListener(java.awt.event.TextListener textListener)
          Maps TextComponent.addTextListener(TextListener) through queue
 void changeCaretPosition(int position)
          Changes caret position.
 void clearText()
          Clears text.
 void copyEnvironment(Operator anotherOperator)
          Copies all environment (output, timeouts, visualizer) from another operator.
 void enterText(java.lang.String text)
          Requests a focus, clears text, types new one and pushes Enter.
static java.awt.TextComponent findTextComponent(java.awt.Container cont, ComponentChooser chooser)
          Searches for the first TextComponent in a container.
static java.awt.TextComponent findTextComponent(java.awt.Container cont, ComponentChooser chooser, int index)
          Searches TextComponent in a container.
static java.awt.TextComponent findTextComponent(java.awt.Container cont, java.lang.String text, boolean ce, boolean ccs)
          Searches TextComponent by text.
static java.awt.TextComponent findTextComponent(java.awt.Container cont, java.lang.String text, boolean ce, boolean ccs, int index)
          Searches TextComponent by text.
 int getCaretPosition()
          Maps TextComponent.getCaretPosition() through queue
 java.util.Hashtable getDump()
          Returns information about component.
 TestOut getOutput()
          Returns print output streams or writers.
 int getPositionByText(java.lang.String text)
          Finds start text position.
 int getPositionByText(java.lang.String text, int index)
          Finds start text position.
 java.lang.String getSelectedText()
          Maps TextComponent.getSelectedText() through queue
 int getSelectionEnd()
          Maps TextComponent.getSelectionEnd() through queue
 int getSelectionStart()
          Maps TextComponent.getSelectionStart() through queue
 java.lang.String getText()
          Maps TextComponent.getText() through queue
protected  TextDriver getTextDriver()
          Return a TextDriver used by this component.
 Timeouts getTimeouts()
          Return current timeouts.
 boolean isEditable()
          Maps TextComponent.isEditable() through queue
 void removeTextListener(java.awt.event.TextListener textListener)
          Maps TextComponent.removeTextListener(TextListener) through queue
 void select(int i, int i1)
          Maps TextComponent.select(int, int) through queue
 void selectAll()
          Maps TextComponent.selectAll() through queue
 void selectText(int startPosition, int finalPosition)
          Selects a part of text.
 void setCaretPosition(int i)
          Maps TextComponent.setCaretPosition(int) through queue
 void setEditable(boolean b)
          Maps TextComponent.setEditable(boolean) through queue
 void setOutput(TestOut out)
          Defines print output streams or writers.
 void setSelectionEnd(int i)
          Maps TextComponent.setSelectionEnd(int) through queue
 void setSelectionStart(int i)
          Maps TextComponent.setSelectionStart(int) through queue
 void setText(java.lang.String string)
          Maps TextComponent.setText(String) through queue
 void setTimeouts(Timeouts timeouts)
          Defines current timeouts.
 void typeText(java.lang.String text)
          Types text starting from known position.
 void typeText(java.lang.String text, int caretPosition)
          Types text starting from known position.
static java.awt.TextComponent waitTextComponent(java.awt.Container cont, ComponentChooser chooser)
          Waits 0'th TextComponent in container.
static java.awt.TextComponent waitTextComponent(java.awt.Container cont, ComponentChooser chooser, int index)
          Waits TextComponent in container.
static java.awt.TextComponent waitTextComponent(java.awt.Container cont, java.lang.String text, boolean ce, boolean ccs)
          Waits TextComponent by text.
static java.awt.TextComponent waitTextComponent(java.awt.Container cont, java.lang.String text, boolean ce, boolean ccs, int index)
          Waits TextComponent by text.
 
Methods inherited from class org.netbeans.jemmy.operators.ComponentOperator
activateWindow, add, addComponentListener, addFocusListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, checkImage, checkImage, clickForPopup, clickForPopup, clickForPopup, clickForPopup, clickMouse, clickMouse, clickMouse, clickMouse, clickMouse, clickMouse, clickMouse, contains, contains, createImage, createImage, dispatchEvent, doLayout, dragMouse, dragMouse, dragMouse, dragNDrop, dragNDrop, dragNDrop, enableInputMethods, enterMouse, exitMouse, findComponent, findComponent, getAlignmentX, getAlignmentY, getBackground, getBounds, getBounds, getCenterX, getCenterXForClick, getCenterY, getCenterYForClick, getColorModel, getComponentAt, getComponentAt, getComponentOrientation, getContainer, getContainers, getCursor, getDropTarget, getEventDispatcher, getFocus, getFont, getFontMetrics, getForeground, getGraphics, getHeight, getInputContext, getInputMethodRequests, getLocale, getLocation, getLocation, getLocationOnScreen, getMaximumSize, getMinimumSize, getName, getParent, getPreferredSize, getSize, getSize, getSource, getToolkit, getTreeLock, getWidth, getWindow, getX, getY, hasFocus, imageUpdate, invalidate, isDisplayable, isDoubleBuffered, isEnabled, isFocusTraversable, isLightweight, isOpaque, isShowing, isValid, isVisible, list, list, list, list, list, makeComponentVisible, moveMouse, paint, paintAll, prepareImage, prepareImage, pressKey, pressKey, pressMouse, pressMouse, print, printAll, pushKey, pushKey, releaseKey, releaseKey, releaseMouse, releaseMouse, remove, removeComponentListener, removeFocusListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFont, setForeground, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, transferFocus, typeKey, typeKey, typeKey, update, validate, waitComponent, waitComponent, waitComponent, waitComponent, waitComponentEnabled, waitComponentShowing, waitComponentVisible, waitHasFocus, wtComponentEnabled
 
Methods inherited from class org.netbeans.jemmy.operators.Operator
addOperatorPackage, addToDump, addToDump, createOperator, getCharBindingMap, getCharKey, getCharModifiers, getCharsKeys, getCharsKeys, getCharsModifiers, getCharsModifiers, getComparator, getDefaultComponentVisualizer, getDefaultMouseButton, getDefaultPathParser, getDefaultStringComparator, getDefaultVerification, getEnvironmentOperator, getParentPath, getParentPath, getPathParser, getPopupMouseButton, getProperties, getQueueTool, getVerification, getVisualizer, isCaptionEqual, isCaptionEqual, isCaptionEqual, lockQueue, parseString, parseString, printDump, produceNoBlocking, produceNoBlocking, produceTimeRestricted, produceTimeRestricted, runMapping, runMapping, runMapping, runMapping, runMapping, runMapping, runMapping, runMapping, runMapping, setCharBindingMap, setComparator, setDefaultComponentVisualizer, setDefaultPathParser, setDefaultStringComparator, setDefaultVerification, setPathParser, setProperties, setVerification, setVisualizer, toStringSource, unlockAndThrow, unlockQueue, waitState
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TEXT_DPROP

public static final java.lang.String TEXT_DPROP
Identifier for a "text" property.

See Also:
getDump(), Constant Field Values
Constructor Detail

TextComponentOperator

public TextComponentOperator(java.awt.TextComponent b)
Constructor.

Parameters:
b - The java.awt.TextComponent managed by this instance.

TextComponentOperator

public TextComponentOperator(ContainerOperator cont,
                             ComponentChooser chooser,
                             int index)
Constructs a TextComponentOperator object.

Parameters:
cont - a container
chooser - a component chooser specifying searching criteria.
index - an index between appropriate ones.

TextComponentOperator

public TextComponentOperator(ContainerOperator cont,
                             ComponentChooser chooser)
Constructs a TextComponentOperator object.

Parameters:
cont - a container
chooser - a component chooser specifying searching criteria.

TextComponentOperator

public TextComponentOperator(ContainerOperator cont,
                             java.lang.String text,
                             int index)
Constructor. Waits for a component in a container to show. The component is identified as the index+1'th java.awt.TextComponent that shows, lies below the container in the display containment hierarchy, and that has the desired text. Uses cont's timeout and output for waiting and to init this operator.

Parameters:
cont - The operator for a container containing the sought for textComponent.
text - TextComponent text.
index - Ordinal component index. The first component has index 0.
See Also:
Operator.isCaptionEqual(String, String, boolean, boolean)

TextComponentOperator

public TextComponentOperator(ContainerOperator cont,
                             java.lang.String text)
Constructor. Waits for a component in a container to show. The component is identified as the first java.awt.TextComponent that shows, lies below the container in the display containment hierarchy, and that has the desired text. Uses cont's timeout and output for waiting and to init this operator.

Parameters:
cont - The operator for a container containing the sought for textComponent.
text - TextComponent text.
See Also:
Operator.isCaptionEqual(String, String, boolean, boolean)

TextComponentOperator

public TextComponentOperator(ContainerOperator cont,
                             int index)
Constructor. Waits component in container first. Uses cont's timeout and output for waiting and to init operator.

Parameters:
cont - The operator for a container containing the sought for textComponent.
index - Ordinal component index.
See Also:
Operator.isCaptionEqual(String, String, boolean, boolean)

TextComponentOperator

public TextComponentOperator(ContainerOperator cont)
Constructor. Waits component in container first. Uses cont's timeout and output for waiting and to init operator.

Parameters:
cont - The operator for a container containing the sought for textComponent.
See Also:
Operator.isCaptionEqual(String, String, boolean, boolean)
Method Detail

findTextComponent

public static java.awt.TextComponent findTextComponent(java.awt.Container cont,
                                                       ComponentChooser chooser,
                                                       int index)
Searches TextComponent in a container.

Parameters:
cont - Container in which to search for the component. The container lies above the component in the display containment hierarchy. The containment need not be direct.
chooser - org.netbeans.jemmy.ComponentChooser implementation, defining and applying search criteria.
index - Ordinal component index. The first index is 0.
Returns:
TextComponent instance or null if component was not found.

findTextComponent

public static java.awt.TextComponent findTextComponent(java.awt.Container cont,
                                                       ComponentChooser chooser)
Searches for the first TextComponent in a container.

Parameters:
cont - Container in which to search for the component. The container lies above the component in the display containment hierarchy. The containment need not be direct.
chooser - org.netbeans.jemmy.ComponentChooser implementation, defining and applying search criteria.
Returns:
TextComponent instance or null if component was not found.

findTextComponent

public static java.awt.TextComponent findTextComponent(java.awt.Container cont,
                                                       java.lang.String text,
                                                       boolean ce,
                                                       boolean ccs,
                                                       int index)
Searches TextComponent by text.

Parameters:
cont - Container to search component in.
text - TextComponent text. If null, contents is not checked.
ce - Compare text exactly.
ccs - Compare text case sensitively.
index - Ordinal component index.
Returns:
TextComponent instance or null if component was not found.
See Also:
Operator.isCaptionEqual(String, String, boolean, boolean)

findTextComponent

public static java.awt.TextComponent findTextComponent(java.awt.Container cont,
                                                       java.lang.String text,
                                                       boolean ce,
                                                       boolean ccs)
Searches TextComponent by text.

Parameters:
cont - Container to search component in.
text - TextComponent text. If null, contents is not checked.
ce - Compare text exactly.
ccs - Compare text case sensitively.
Returns:
TextComponent instance or null if component was not found.
See Also:
Operator.isCaptionEqual(String, String, boolean, boolean)

waitTextComponent

public static java.awt.TextComponent waitTextComponent(java.awt.Container cont,
                                                       ComponentChooser chooser,
                                                       int index)
Waits TextComponent in container.

Parameters:
cont - Container to search component in.
chooser - org.netbeans.jemmy.ComponentChooser implementation.
index - Ordinal component index.
Returns:
TextComponent instance.

waitTextComponent

public static java.awt.TextComponent waitTextComponent(java.awt.Container cont,
                                                       ComponentChooser chooser)
Waits 0'th TextComponent in container.

Parameters:
cont - Container to search component in.
chooser - org.netbeans.jemmy.ComponentChooser implementation.
Returns:
TextComponent instance.

waitTextComponent

public static java.awt.TextComponent waitTextComponent(java.awt.Container cont,
                                                       java.lang.String text,
                                                       boolean ce,
                                                       boolean ccs,
                                                       int index)
Waits TextComponent by text.

Parameters:
cont - Container to search component in.
text - TextComponent text. If null, contents is not checked.
ce - Compare text exactly.
ccs - Compare text case sensitively.
index - Ordinal component index.
Returns:
TextComponent instance.
See Also:
Operator.isCaptionEqual(String, String, boolean, boolean)

waitTextComponent

public static java.awt.TextComponent waitTextComponent(java.awt.Container cont,
                                                       java.lang.String text,
                                                       boolean ce,
                                                       boolean ccs)
Waits TextComponent by text.

Parameters:
cont - Container to search component in.
text - TextComponent text. If null, contents is not checked.
ce - Compare text exactly.
ccs - Compare text case sensitively.
Returns:
TextComponent instance.
See Also:
Operator.isCaptionEqual(String, String, boolean, boolean)

setTimeouts

public void setTimeouts(Timeouts timeouts)
Description copied from interface: Timeoutable
Defines current timeouts.

Specified by:
setTimeouts in interface Timeoutable
Overrides:
setTimeouts in class ComponentOperator
Parameters:
timeouts - A collection of timeout assignments.
See Also:
Timeoutable.getTimeouts()

getTimeouts

public Timeouts getTimeouts()
Description copied from interface: Timeoutable
Return current timeouts.

Specified by:
getTimeouts in interface Timeoutable
Overrides:
getTimeouts in class ComponentOperator
Returns:
the collection of current timeout assignments.
See Also:
Timeoutable.setTimeouts(org.netbeans.jemmy.Timeouts)

setOutput

public void setOutput(TestOut out)
Description copied from interface: Outputable
Defines print output streams or writers.

Specified by:
setOutput in interface Outputable
Overrides:
setOutput in class ComponentOperator
Parameters:
out - Identify the streams or writers used for print output.
See Also:
Outputable.getOutput()

getOutput

public TestOut getOutput()
Description copied from interface: Outputable
Returns print output streams or writers.

Specified by:
getOutput in interface Outputable
Overrides:
getOutput in class ComponentOperator
Returns:
an object that contains references to objects for printing to output and err streams.
See Also:
Outputable.setOutput(org.netbeans.jemmy.TestOut)

copyEnvironment

public void copyEnvironment(Operator anotherOperator)
Description copied from class: Operator
Copies all environment (output, timeouts, visualizer) from another operator.

Overrides:
copyEnvironment in class ComponentOperator
Parameters:
anotherOperator - an operator to copy the environment to.

changeCaretPosition

public void changeCaretPosition(int position)
Changes caret position.

Parameters:
position - Position to move caret to.

selectText

public void selectText(int startPosition,
                       int finalPosition)
Selects a part of text.

Parameters:
startPosition - Start caret position
finalPosition - Final caret position

getPositionByText

public int getPositionByText(java.lang.String text,
                             int index)
Finds start text position.

Parameters:
text - Text to be searched.
index - Index of text instance (first instance has index 0)
Returns:
Caret position correspondent to text start.

getPositionByText

public int getPositionByText(java.lang.String text)
Finds start text position.

Parameters:
text - Text to be searched.
Returns:
Caret position correspondent to text start.

clearText

public void clearText()
Clears text.


typeText

public void typeText(java.lang.String text,
                     int caretPosition)
Types text starting from known position.

Parameters:
text - Text to be typed.
caretPosition - Position to start type text

typeText

public void typeText(java.lang.String text)
Types text starting from known position.

Parameters:
text - Text to be typed.

enterText

public void enterText(java.lang.String text)
Requests a focus, clears text, types new one and pushes Enter.

Parameters:
text - New text value. Shouln't include final '\n'.

getDump

public java.util.Hashtable getDump()
Description copied from class: ComponentOperator
Returns information about component.

Overrides:
getDump in class ComponentOperator
Returns:
a Hashtable containing name-value pairs.

addTextListener

public void addTextListener(java.awt.event.TextListener textListener)
Maps TextComponent.addTextListener(TextListener) through queue


getCaretPosition

public int getCaretPosition()
Maps TextComponent.getCaretPosition() through queue


getSelectedText

public java.lang.String getSelectedText()
Maps TextComponent.getSelectedText() through queue


getSelectionEnd

public int getSelectionEnd()
Maps TextComponent.getSelectionEnd() through queue


getSelectionStart

public int getSelectionStart()
Maps TextComponent.getSelectionStart() through queue


getText

public java.lang.String getText()
Maps TextComponent.getText() through queue


isEditable

public boolean isEditable()
Maps TextComponent.isEditable() through queue


removeTextListener

public void removeTextListener(java.awt.event.TextListener textListener)
Maps TextComponent.removeTextListener(TextListener) through queue


select

public void select(int i,
                   int i1)
Maps TextComponent.select(int, int) through queue


selectAll

public void selectAll()
Maps TextComponent.selectAll() through queue


setCaretPosition

public void setCaretPosition(int i)
Maps TextComponent.setCaretPosition(int) through queue


setEditable

public void setEditable(boolean b)
Maps TextComponent.setEditable(boolean) through queue


setSelectionEnd

public void setSelectionEnd(int i)
Maps TextComponent.setSelectionEnd(int) through queue


setSelectionStart

public void setSelectionStart(int i)
Maps TextComponent.setSelectionStart(int) through queue


setText

public void setText(java.lang.String string)
Maps TextComponent.setText(String) through queue


getTextDriver

protected TextDriver getTextDriver()
Return a TextDriver used by this component.

Returns:
a driver got by the operator during creation.