Class JTextComponentOperator

  • All Implemented Interfaces:
    Outputable, Timeoutable
    Direct Known Subclasses:
    JEditorPaneOperator, JTextAreaOperator, JTextFieldOperator

    public class JTextComponentOperator
    extends JComponentOperator
    implements Timeoutable, Outputable
    Class provides basic functions to operate with JTextComponent (selection, typing, deleting)

    Timeouts used:
    JTextComponentOperator.PushKeyTimeout - time between key pressing and releasing during text typing
    JTextComponentOperator.BetweenKeysTimeout - time to sleep between two chars typing
    JTextComponentOperator.ChangeCaretPositionTimeout - maximum time to chenge caret position
    JTextComponentOperator.TypeTextTimeout - maximum time to type text
    ComponentOperator.WaitComponentTimeout - time to wait component displayed
    ComponentOperator.WaitFocusTimeout - time to wait component focus
    ComponentOperator.WaitStateTimeout - time to wait for text
    JScrollBarOperator.OneScrollClickTimeout - time for one scroll click
    JScrollBarOperator.WholeScrollTimeout - time for the whole scrolling
    .
    Author:
    Alexandre Iline (alexandre.iline@sun.com)
    See Also:
    Timeouts
    • Field Detail

      • modifiersPressed

        protected int modifiersPressed
        Deprecated.
        All text operations are performed by TextDriver regitered for this operator type.
        Notifies what modifiers are pressed.
    • Constructor Detail

      • JTextComponentOperator

        public JTextComponentOperator​(JTextComponent b)
        Constructor.
        Parameters:
        b - Component to operate with.
      • JTextComponentOperator

        public JTextComponentOperator​(ContainerOperator cont,
                                      ComponentChooser chooser,
                                      int index)
        Constructs a JTextComponentOperator object.
        Parameters:
        cont - a container
        chooser - a component chooser specifying searching criteria.
        index - an index between appropriate ones.
      • JTextComponentOperator

        public JTextComponentOperator​(ContainerOperator cont,
                                      ComponentChooser chooser)
        Constructs a JTextComponentOperator object.
        Parameters:
        cont - a container
        chooser - a component chooser specifying searching criteria.
      • JTextComponentOperator

        public JTextComponentOperator​(ContainerOperator cont,
                                      int index)
        Constructor. Waits component in container first. Uses cont's timeout and output for waiting and to init operator.
        Parameters:
        cont - a container
        index - Ordinal component index.
        Throws:
        TimeoutExpiredException
      • JTextComponentOperator

        public JTextComponentOperator​(ContainerOperator cont)
        Constructor. Waits component in container first. Uses cont's timeout and output for waiting and to init operator.
        Parameters:
        cont - a container
        Throws:
        TimeoutExpiredException
    • Method Detail

      • findJTextComponent

        public static JTextComponent findJTextComponent​(Container cont,
                                                        ComponentChooser chooser,
                                                        int index)
        Searches JTextComponent in container.
        Parameters:
        cont - Container to search component in.
        chooser - a component chooser specifying searching criteria.
        index - Ordinal component index.
        Returns:
        JTextComponent instance or null if component was not found.
      • findJTextComponent

        public static JTextComponent findJTextComponent​(Container cont,
                                                        ComponentChooser chooser)
        Searches JTextComponent in container.
        Parameters:
        cont - Container to search component in.
        chooser - a component chooser specifying searching criteria.
        Returns:
        JTextComponent instance or null if component was not found.
      • findJTextComponent

        public static JTextComponent findJTextComponent​(Container cont,
                                                        String text,
                                                        boolean ce,
                                                        boolean ccs,
                                                        int index)
        Searches JTextComponent by text.
        Parameters:
        cont - Container to search component in.
        text - Component text.
        ce - Compare text exactly.
        ccs - Compare text case sensitively.
        index - Ordinal component index.
        Returns:
        JTextComponent instance or null if component was not found.
        See Also:
        Operator.isCaptionEqual(String, String, boolean, boolean)
      • findJTextComponent

        public static JTextComponent findJTextComponent​(Container cont,
                                                        String text,
                                                        boolean ce,
                                                        boolean ccs)
        Searches JTextComponent by text.
        Parameters:
        cont - Container to search component in.
        text - Component text.
        ce - Compare text exactly.
        ccs - Compare text case sensitively.
        Returns:
        JTextComponent instance or null if component was not found.
        See Also:
        Operator.isCaptionEqual(String, String, boolean, boolean)
      • waitJTextComponent

        public static JTextComponent waitJTextComponent​(Container cont,
                                                        ComponentChooser chooser,
                                                        int index)
        Waits JTextComponent in container.
        Parameters:
        cont - Container to search component in.
        chooser - a component chooser specifying searching criteria.
        index - Ordinal component index.
        Returns:
        JTextComponent instance.
        Throws:
        TimeoutExpiredException
      • waitJTextComponent

        public static JTextComponent waitJTextComponent​(Container cont,
                                                        ComponentChooser chooser)
        Waits JTextComponent in container.
        Parameters:
        cont - Container to search component in.
        chooser - a component chooser specifying searching criteria.
        Returns:
        JTextComponent instance.
        Throws:
        TimeoutExpiredException
      • 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.
      • getPositionByText

        public int getPositionByText​(String text,
                                     JTextComponentOperator.TextChooser tChooser,
                                     int index)
        Finds start text position.
        Parameters:
        text - Text to be searched.
        tChooser - Additional search criteria.
        index - Index of text instance (first instance has index 0)
        Returns:
        Caret position correspondent to text start.
        See Also:
        JTextComponentOperator.TextChooser
      • getPositionByText

        public int getPositionByText​(String text,
                                     JTextComponentOperator.TextChooser tChooser)
        Finds start text position.
        Parameters:
        text - Text to be searched.
        tChooser - Additional search criteria.
        Returns:
        Caret position correspondent to text start.
      • 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.
      • 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'.
        Throws:
        TimeoutExpiredException
      • scrollToPosition

        public void scrollToPosition​(int position)
        Scrolls to a text poistion.
        Parameters:
        position - a position to scroll.
        Throws:
        TimeoutExpiredException
      • getDisplayedText

        public String getDisplayedText()
        Returns text which is really displayed. Results returned by getText() and getDisplayedText() are different if text component is used to display javax.swing.text.StyledDocument
        Returns:
        the text which is displayed.
      • waitText

        public void waitText​(String text,
                             int position)
        Wait for text to be displayed starting from certain position.
        Parameters:
        text - text to wait.
        position - starting text position.
      • waitText

        public void waitText​(String text)
        Waits for certain text.
        Parameters:
        text - Text to be compared by getComparator() comparator.
      • waitCaretPosition

        public void waitCaretPosition​(int position)
        Wait for caret to be moved to certain position.
        Parameters:
        position - a position which caret supposed to be moved to.
      • addCaretListener

        public void addCaretListener​(CaretListener caretListener)
        Maps JTextComponent.addCaretListener(CaretListener) through queue
      • copy

        public void copy()
        Maps JTextComponent.copy() through queue
      • cut

        public void cut()
        Maps JTextComponent.cut() through queue
      • getActions

        public Action[] getActions()
        Maps JTextComponent.getActions() through queue
      • getCaret

        public Caret getCaret()
        Maps JTextComponent.getCaret() through queue
      • getCaretColor

        public Color getCaretColor()
        Maps JTextComponent.getCaretColor() through queue
      • getCaretPosition

        public int getCaretPosition()
        Maps JTextComponent.getCaretPosition() through queue
      • getDisabledTextColor

        public Color getDisabledTextColor()
        Maps JTextComponent.getDisabledTextColor() through queue
      • getDocument

        public Document getDocument()
        Maps JTextComponent.getDocument() through queue
      • getFocusAccelerator

        public char getFocusAccelerator()
        Maps JTextComponent.getFocusAccelerator() through queue
      • getHighlighter

        public Highlighter getHighlighter()
        Maps JTextComponent.getHighlighter() through queue
      • getKeymap

        public Keymap getKeymap()
        Maps JTextComponent.getKeymap() through queue
      • getMargin

        public Insets getMargin()
        Maps JTextComponent.getMargin() through queue
      • getPreferredScrollableViewportSize

        public Dimension getPreferredScrollableViewportSize()
        Maps JTextComponent.getPreferredScrollableViewportSize() through queue
      • getScrollableBlockIncrement

        public int getScrollableBlockIncrement​(Rectangle rectangle,
                                               int i,
                                               int i1)
        Maps JTextComponent.getScrollableBlockIncrement(Rectangle, int, int) through queue
      • getScrollableTracksViewportHeight

        public boolean getScrollableTracksViewportHeight()
        Maps JTextComponent.getScrollableTracksViewportHeight() through queue
      • getScrollableTracksViewportWidth

        public boolean getScrollableTracksViewportWidth()
        Maps JTextComponent.getScrollableTracksViewportWidth() through queue
      • getScrollableUnitIncrement

        public int getScrollableUnitIncrement​(Rectangle rectangle,
                                              int i,
                                              int i1)
        Maps JTextComponent.getScrollableUnitIncrement(Rectangle, int, int) through queue
      • getSelectedText

        public String getSelectedText()
        Maps JTextComponent.getSelectedText() through queue
      • getSelectedTextColor

        public Color getSelectedTextColor()
        Maps JTextComponent.getSelectedTextColor() through queue
      • getSelectionColor

        public Color getSelectionColor()
        Maps JTextComponent.getSelectionColor() through queue
      • getSelectionEnd

        public int getSelectionEnd()
        Maps JTextComponent.getSelectionEnd() through queue
      • getSelectionStart

        public int getSelectionStart()
        Maps JTextComponent.getSelectionStart() through queue
      • getText

        public String getText()
        Maps JTextComponent.getText() through queue
      • getText

        public String getText​(int i,
                              int i1)
        Maps JTextComponent.getText(int, int) through queue
      • getUI

        public TextUI getUI()
        Maps JTextComponent.getUI() through queue
      • isEditable

        public boolean isEditable()
        Maps JTextComponent.isEditable() through queue
      • modelToView

        public Rectangle modelToView​(int i)
        Maps JTextComponent.modelToView(int) through queue
      • moveCaretPosition

        public void moveCaretPosition​(int i)
        Maps JTextComponent.moveCaretPosition(int) through queue
      • paste

        public void paste()
        Maps JTextComponent.paste() through queue
      • read

        public void read​(Reader reader,
                         Object object)
        Maps JTextComponent.read(Reader, Object) through queue
      • removeCaretListener

        public void removeCaretListener​(CaretListener caretListener)
        Maps JTextComponent.removeCaretListener(CaretListener) through queue
      • replaceSelection

        public void replaceSelection​(String string)
        Maps JTextComponent.replaceSelection(String) through queue
      • select

        public void select​(int i,
                           int i1)
        Maps JTextComponent.select(int, int) through queue
      • selectAll

        public void selectAll()
        Maps JTextComponent.selectAll() through queue
      • setCaret

        public void setCaret​(Caret caret)
        Maps JTextComponent.setCaret(Caret) through queue
      • setCaretColor

        public void setCaretColor​(Color color)
        Maps JTextComponent.setCaretColor(Color) through queue
      • setCaretPosition

        public void setCaretPosition​(int i)
        Maps JTextComponent.setCaretPosition(int) through queue
      • setDisabledTextColor

        public void setDisabledTextColor​(Color color)
        Maps JTextComponent.setDisabledTextColor(Color) through queue
      • setDocument

        public void setDocument​(Document document)
        Maps JTextComponent.setDocument(Document) through queue
      • setEditable

        public void setEditable​(boolean b)
        Maps JTextComponent.setEditable(boolean) through queue
      • setFocusAccelerator

        public void setFocusAccelerator​(char c)
        Maps JTextComponent.setFocusAccelerator(char) through queue
      • setHighlighter

        public void setHighlighter​(Highlighter highlighter)
        Maps JTextComponent.setHighlighter(Highlighter) through queue
      • setKeymap

        public void setKeymap​(Keymap keymap)
        Maps JTextComponent.setKeymap(Keymap) through queue
      • setMargin

        public void setMargin​(Insets insets)
        Maps JTextComponent.setMargin(Insets) through queue
      • setSelectedTextColor

        public void setSelectedTextColor​(Color color)
        Maps JTextComponent.setSelectedTextColor(Color) through queue
      • setSelectionColor

        public void setSelectionColor​(Color color)
        Maps JTextComponent.setSelectionColor(Color) through queue
      • setSelectionEnd

        public void setSelectionEnd​(int i)
        Maps JTextComponent.setSelectionEnd(int) through queue
      • setSelectionStart

        public void setSelectionStart​(int i)
        Maps JTextComponent.setSelectionStart(int) through queue
      • setText

        public void setText​(String string)
        Maps JTextComponent.setText(String) through queue
      • setUI

        public void setUI​(TextUI textUI)
        Maps JTextComponent.setUI(TextUI) through queue
      • viewToModel

        public int viewToModel​(Point point)
        Maps JTextComponent.viewToModel(Point) through queue
      • write

        public void write​(Writer writer)
        Maps JTextComponent.write(Writer) through queue