Class JComboBoxOperator

All Implemented Interfaces:
Outputable, Timeoutable

public class JComboBoxOperator extends JComponentOperator implements Timeoutable, Outputable


Timeouts used:
JComboBoxOperator.BeforeSelectingTimeout - time to sleep after list opened and before item selected
JComboBoxOperator.WaitListTimeout - time to wait list opened
ComponentOperator.WaitComponentTimeout - time to wait component displayed
ComponentOperator.WaitComponentEnabledTimeout - time to wait component enabled
ComponentOperator.WaitStateTimeout - time to wait for item to be selected
AbstractButtonOperator.PushButtonTimeout - time between combo button pressing and releasing
ComponentOperator.MouseClickTimeout - time between mouse pressing and releasing during item selecting
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
.
Author:
Alexandre Iline (alexandre.iline@sun.com)
See Also:
  • Field Details

  • Constructor Details

    • JComboBoxOperator

      public JComboBoxOperator(JComboBox b)
      Constructs a JComboBoxOperator object.
      Parameters:
      b - a component
    • JComboBoxOperator

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

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

      public JComboBoxOperator(ContainerOperator cont, String text, int index)
      Constructor. Waits component in container first. Uses cont's timeout and output for waiting and to init operator.
      Parameters:
      cont - a container
      text - Text of item which is currently selected.
      index - Ordinal component index.
      Throws:
      TimeoutExpiredException
      See Also:
    • JComboBoxOperator

      public JComboBoxOperator(ContainerOperator cont, String text)
      Constructor. Waits component in container first. Uses cont's timeout and output for waiting and to init operator.
      Parameters:
      cont - a container
      text - Text of item which is currently selected.
      Throws:
      TimeoutExpiredException
      See Also:
    • JComboBoxOperator

      public JComboBoxOperator(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
    • JComboBoxOperator

      public JComboBoxOperator(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 Details

    • findJComboBox

      public static JComboBox findJComboBox(Container cont, ComponentChooser chooser, int index)
      Searches JComboBox in container.
      Parameters:
      cont - Container to search component in.
      chooser - org.netbeans.jemmy.ComponentChooser implementation.
      index - Ordinal component index.
      Returns:
      JComboBox instance or null if component was not found.
    • findJComboBox

      public static JComboBox findJComboBox(Container cont, ComponentChooser chooser)
      Searches 0'th JComboBox in container.
      Parameters:
      cont - Container to search component in.
      chooser - org.netbeans.jemmy.ComponentChooser implementation.
      Returns:
      JComboBox instance or null if component was not found.
    • findJComboBox

      public static JComboBox findJComboBox(Container cont, String text, boolean ce, boolean ccs, int itemIndex, int index)
      Searches JComboBox by item.
      Parameters:
      cont - Container to search component in.
      text - Item text. If null, contents is not checked.
      ce - Compare text exactly.
      ccs - Compare text case sensitively.
      itemIndex - Index of item to compare text. If -1, selected item is checked.
      index - Ordinal component index.
      Returns:
      JComboBox instance or null if component was not found.
      See Also:
    • findJComboBox

      public static JComboBox findJComboBox(Container cont, String text, boolean ce, boolean ccs, int itemIndex)
      Searches JComboBox by item.
      Parameters:
      cont - Container to search component in.
      text - Item text. If null, contents is not checked.
      ce - Compare text exactly.
      ccs - Compare text case sensitively.
      itemIndex - Index of item to compare text. If -1, selected item is checked.
      Returns:
      JComboBox instance or null if component was not found.
      See Also:
    • waitJComboBox

      public static JComboBox waitJComboBox(Container cont, ComponentChooser chooser, int index)
      Waits JComboBox in container.
      Parameters:
      cont - Container to search component in.
      chooser - org.netbeans.jemmy.ComponentChooser implementation.
      index - Ordinal component index.
      Returns:
      JComboBox instance or null if component was not found.
      Throws:
      TimeoutExpiredException
    • waitJComboBox

      public static JComboBox waitJComboBox(Container cont, ComponentChooser chooser)
      Waits 0'th JComboBox in container.
      Parameters:
      cont - Container to search component in.
      chooser - org.netbeans.jemmy.ComponentChooser implementation.
      Returns:
      JComboBox instance or null if component was not found.
      Throws:
      TimeoutExpiredException
    • waitJComboBox

      public static JComboBox waitJComboBox(Container cont, String text, boolean ce, boolean ccs, int itemIndex, int index)
      Waits JComboBox by item.
      Parameters:
      cont - Container to search component in.
      text - Item text. If null, contents is not checked.
      ce - Compare text exactly.
      ccs - Compare text case sensitively.
      itemIndex - Index of item to compare text. If -1, selected item is checked.
      index - Ordinal component index.
      Returns:
      JComboBox instance or null if component was not found.
      Throws:
      TimeoutExpiredException
      See Also:
    • waitJComboBox

      public static JComboBox waitJComboBox(Container cont, String text, boolean ce, boolean ccs, int itemIndex)
      Waits JComboBox by item.
      Parameters:
      cont - Container to search component in.
      text - Item text. If null, contents is not checked.
      ce - Compare text exactly.
      ccs - Compare text case sensitively.
      itemIndex - Index of item to compare text. If -1, selected item is checked.
      Returns:
      JComboBox instance or null if component was not found.
      Throws:
      TimeoutExpiredException
      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 JComponentOperator
      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 JComponentOperator
      Returns:
      the collection of current timeout assignments.
      See Also:
    • setOutput

      public void setOutput(TestOut output)
      Description copied from interface: Outputable
      Defines print output streams or writers.
      Specified by:
      setOutput in interface Outputable
      Overrides:
      setOutput in class JComponentOperator
      Parameters:
      output - 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 JComponentOperator
      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.
    • findJButton

      public JButton findJButton()
      Searches JButton inside component.
      Returns:
      JButton which is used to expand this JComboBox.
    • findJTextField

      public JTextField findJTextField()
      Searches JTextField inside component.
      Returns:
      JTextField if JComboBox is editable, null otherwise.
    • getButton

      public JButtonOperator getButton()
      Creates an operator for button returned by findJButton() method.
      Returns:
      new JButtonOperator instance.
    • getTextField

      public JTextFieldOperator getTextField()
      Creates an operator for button returned by findJTextField() method.
      Returns:
      new JTextField instance.
    • waitList

      public JList waitList()
      Waits combobox's list to be displayed.
      Returns:
      JList object if it was displayed in JComboBoxOperator.WaitListTimeout millisecont, null otherwise.
      Throws:
      TimeoutExpiredException
    • pushComboButton

      public void pushComboButton()
      Push combobox's button to expand or collapse combobox.
      Throws:
      TimeoutExpiredException
    • findItemIndex

      public int findItemIndex(String item, Operator.StringComparator comparator)
      Finds an item between list items.
      Parameters:
      item - a text pattern.
      comparator - a searching criteria.
      Returns:
      an item index.
    • waitItem

      public int waitItem(String item, Operator.StringComparator comparator)
      Waits for an item available between list items.
      Parameters:
      item - a text pattern.
      comparator - a searching criteria.
      Returns:
      an item index or throws TimeoutExpiredException if item not found.
    • waitItem

      public int waitItem(int itemIndex)
      Waits for an item of given index available between list items.
      Parameters:
      itemIndex - index of desired item
      Returns:
      an item index or throws TimeoutExpiredException if item not found.
    • selectItem

      public void selectItem(String item, Operator.StringComparator comparator)
      Selects an item by text.
      Parameters:
      item - a text pattern.
      comparator - a searching criteria.
    • selectItem

      public void selectItem(String item, boolean ce, boolean cc)
      Deprecated.
      Use selectItem(String) or selectItem(String, StringComparator)
      Selects combobox item.
      Parameters:
      item - Item text.
      ce - Compare exactly.
      cc - Compare case sensitivelly.
      Throws:
      TimeoutExpiredException
      See Also:
    • selectItem

      public void selectItem(String item)
      Selects combobox item. Uses StringComparator assigned to this object.
      Parameters:
      item - Item text.
      Throws:
      TimeoutExpiredException
    • selectItem

      public void selectItem(int index)
      Selects combobox item. If verification mode is on, checks that right item has been selected.
      Parameters:
      index - Item index.
      Throws:
      TimeoutExpiredException
    • typeText

      public void typeText(String text)
      Types text in the editable combobox. If combobox has no focus, does simple mouse click on it first.
      Parameters:
      text - text to type.
      Throws:
      TimeoutExpiredException
    • clearText

      public void clearText()
      Clears text in the editable combobox using left-arrow and delete keys. If combobox has no focus, does simple mouse click on it first.
      Throws:
      TimeoutExpiredException
    • 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
    • waitItemSelected

      public void waitItemSelected(int index)
      Waits for item to be selected.
      Parameters:
      index - Item index.
    • waitItemSelected

      public void waitItemSelected(String item)
      Waits for item to be selected. Uses getComparator() comparator.
      Parameters:
      item - wait an item to be selected.
    • getDump

      public Hashtable getDump()
      Returns information about component.
      Overrides:
      getDump in class JComponentOperator
      Returns:
      a Hashtable containing name-value pairs.
    • actionPerformed

      public void actionPerformed(ActionEvent actionEvent)
      Maps JComboBox.actionPerformed(ActionEvent) through queue
    • addActionListener

      public void addActionListener(ActionListener actionListener)
      Maps JComboBox.addActionListener(ActionListener) through queue
    • addItem

      public void addItem(Object object)
      Maps JComboBox.addItem(Object) through queue
    • addItemListener

      public void addItemListener(ItemListener itemListener)
      Maps JComboBox.addItemListener(ItemListener) through queue
    • configureEditor

      public void configureEditor(ComboBoxEditor comboBoxEditor, Object object)
      Maps JComboBox.configureEditor(ComboBoxEditor, Object) through queue
    • contentsChanged

      public void contentsChanged(ListDataEvent listDataEvent)
      Maps JComboBox.contentsChanged(ListDataEvent) through queue
    • getActionCommand

      public String getActionCommand()
      Maps JComboBox.getActionCommand() through queue
    • getEditor

      public ComboBoxEditor getEditor()
      Maps JComboBox.getEditor() through queue
    • getItemAt

      public Object getItemAt(int i)
      Maps JComboBox.getItemAt(int) through queue
    • getItemCount

      public int getItemCount()
      Maps JComboBox.getItemCount() through queue
    • getKeySelectionManager

      public JComboBox.KeySelectionManager getKeySelectionManager()
      Maps JComboBox.getKeySelectionManager() through queue
    • getMaximumRowCount

      public int getMaximumRowCount()
      Maps JComboBox.getMaximumRowCount() through queue
    • getModel

      public ComboBoxModel getModel()
      Maps JComboBox.getModel() through queue
    • getRenderer

      public ListCellRenderer getRenderer()
      Maps JComboBox.getRenderer() through queue
    • getSelectedIndex

      public int getSelectedIndex()
      Maps JComboBox.getSelectedIndex() through queue
    • getSelectedItem

      public Object getSelectedItem()
      Maps JComboBox.getSelectedItem() through queue
    • getSelectedObjects

      public Object[] getSelectedObjects()
      Maps JComboBox.getSelectedObjects() through queue
    • getUI

      public ComboBoxUI getUI()
      Maps JComboBox.getUI() through queue
    • hidePopup

      public void hidePopup()
      Maps JComboBox.hidePopup() through queue
    • insertItemAt

      public void insertItemAt(Object object, int i)
      Maps JComboBox.insertItemAt(Object, int) through queue
    • intervalAdded

      public void intervalAdded(ListDataEvent listDataEvent)
      Maps JComboBox.intervalAdded(ListDataEvent) through queue
    • intervalRemoved

      public void intervalRemoved(ListDataEvent listDataEvent)
      Maps JComboBox.intervalRemoved(ListDataEvent) through queue
    • isEditable

      public boolean isEditable()
      Maps JComboBox.isEditable() through queue
    • isLightWeightPopupEnabled

      public boolean isLightWeightPopupEnabled()
      Maps JComboBox.isLightWeightPopupEnabled() through queue
    • isPopupVisible

      public boolean isPopupVisible()
      Maps JComboBox.isPopupVisible() through queue
    • processKeyEvent

      public void processKeyEvent(KeyEvent keyEvent)
      Maps JComboBox.processKeyEvent(KeyEvent) through queue
    • removeActionListener

      public void removeActionListener(ActionListener actionListener)
      Maps JComboBox.removeActionListener(ActionListener) through queue
    • removeAllItems

      public void removeAllItems()
      Maps JComboBox.removeAllItems() through queue
    • removeItem

      public void removeItem(Object object)
      Maps JComboBox.removeItem(Object) through queue
    • removeItemAt

      public void removeItemAt(int i)
      Maps JComboBox.removeItemAt(int) through queue
    • removeItemListener

      public void removeItemListener(ItemListener itemListener)
      Maps JComboBox.removeItemListener(ItemListener) through queue
    • selectWithKeyChar

      public boolean selectWithKeyChar(char c)
      Maps JComboBox.selectWithKeyChar(char) through queue
    • setActionCommand

      public void setActionCommand(String string)
      Maps JComboBox.setActionCommand(String) through queue
    • setEditable

      public void setEditable(boolean b)
      Maps JComboBox.setEditable(boolean) through queue
    • setEditor

      public void setEditor(ComboBoxEditor comboBoxEditor)
      Maps JComboBox.setEditor(ComboBoxEditor) through queue
    • setKeySelectionManager

      public void setKeySelectionManager(JComboBox.KeySelectionManager keySelectionManager)
      Maps JComboBox.setKeySelectionManager(KeySelectionManager) through queue
    • setLightWeightPopupEnabled

      public void setLightWeightPopupEnabled(boolean b)
      Maps JComboBox.setLightWeightPopupEnabled(boolean) through queue
    • setMaximumRowCount

      public void setMaximumRowCount(int i)
      Maps JComboBox.setMaximumRowCount(int) through queue
    • setModel

      public void setModel(ComboBoxModel comboBoxModel)
      Maps JComboBox.setModel(ComboBoxModel) through queue
    • setPopupVisible

      public void setPopupVisible(boolean b)
      Maps JComboBox.setPopupVisible(boolean) through queue
    • setRenderer

      public void setRenderer(ListCellRenderer listCellRenderer)
      Maps JComboBox.setRenderer(ListCellRenderer) through queue
    • setSelectedIndex

      public void setSelectedIndex(int i)
      Maps JComboBox.setSelectedIndex(int) through queue
    • setSelectedItem

      public void setSelectedItem(Object object)
      Maps JComboBox.setSelectedItem(Object) through queue
    • setUI

      public void setUI(ComboBoxUI comboBoxUI)
      Maps JComboBox.setUI(ComboBoxUI) through queue
    • showPopup

      public void showPopup()
      Maps JComboBox.showPopup() through queue