Class 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 (alexandre.iline@sun.com)
See Also:
  • Field Details

  • Constructor Details

    • TextComponentOperator

      public TextComponentOperator(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, 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:
    • TextComponentOperator

      public TextComponentOperator(ContainerOperator cont, 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:
    • 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:
    • 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:
  • Method Details

    • findTextComponent

      public static TextComponent findTextComponent(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 TextComponent findTextComponent(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 TextComponent findTextComponent(Container cont, 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:
    • findTextComponent

      public static TextComponent findTextComponent(Container cont, 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:
    • waitTextComponent

      public static TextComponent waitTextComponent(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 TextComponent waitTextComponent(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 TextComponent waitTextComponent(Container cont, 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:
    • waitTextComponent

      public static TextComponent waitTextComponent(Container cont, 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:
    • 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:
    • 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:
    • 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:
    • 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:
    • 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(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(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(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(String text)
      Types text starting from known position.
      Parameters:
      text - Text to be typed.
    • enterText

      public void enterText(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 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(TextListener textListener)
      Maps TextComponent.addTextListener(TextListener) through queue
    • getCaretPosition

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

      public 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 String getText()
      Maps TextComponent.getText() through queue
    • isEditable

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

      public void removeTextListener(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(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.