Class JListOperator

All Implemented Interfaces:
Outputable, Timeoutable

public class JListOperator extends JComponentOperator implements Outputable


Timeouts used:
ComponentOperator.WaitComponentTimeout - time to wait component displayed
ComponentOperator.WaitStateTimeout - time to wait for item, and for item to be selected
JScrollBarOperator.OneScrollClickTimeout - time for one scroll click
JScrollBarOperator.WholeScrollTimeout - time for the whole scrolling
.
Author:
Alexandre Iline (alexandre.iline@sun.com)
See Also:
  • Field Details

  • Constructor Details

    • JListOperator

      public JListOperator(JList b)
      Constructor.
      Parameters:
      b - a component
    • JListOperator

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

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

      public JListOperator(ContainerOperator cont, String text, int itemIndex, int index)
      Constructor. Waits item text 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.
      itemIndex - Item index.
      index - Ordinal component index.
    • JListOperator

      public JListOperator(ContainerOperator cont, String text, int index)
      Constructor. Waits component by selected item text 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.
      See Also:
    • JListOperator

      public JListOperator(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.
      See Also:
    • JListOperator

      public JListOperator(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.
    • JListOperator

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

    • findJList

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

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

      public static JList findJList(Container cont, String text, boolean ce, boolean ccs, int itemIndex, int index)
      Searches JList 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:
      JList instance or null if component was not found.
      See Also:
    • findJList

      public static JList findJList(Container cont, String text, boolean ce, boolean ccs, int itemIndex)
      Searches JList 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:
      JList instance or null if component was not found.
      See Also:
    • waitJList

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

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

      public static JList waitJList(Container cont, String text, boolean ce, boolean ccs, int itemIndex, int index)
      Waits JList 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:
      JList instance or null if component was not found.
      See Also:
    • waitJList

      public static JList waitJList(Container cont, String text, boolean ce, boolean ccs, int itemIndex)
      Waits JList 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:
      JList instance or null if component was not found.
      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.
    • getClickPoint

      public Point getClickPoint(int itemIndex)
      Gets point to click on itemIndex'th item.
      Parameters:
      itemIndex - an index of an item to click.
      Returns:
      a Point in component's coordinate system.
    • getRenderedComponent

      public Component getRenderedComponent(int itemIndex, boolean isSelected, boolean cellHasFocus)
      Ask renderer for component to be displayed.
      Parameters:
      itemIndex - Item index.
      isSelected - True if the specified cell was selected.
      cellHasFocus - True if the specified cell has the focus.
      Returns:
      Component to be displayed.
    • getRenderedComponent

      public Component getRenderedComponent(int itemIndex)
      Ask renderer for component to be displayed. Uses isSelectedIndex(itemIndex) to determine whether item is selected. Supposes item do not have focus.
      Parameters:
      itemIndex - Item index.
      Returns:
      Component to be displayed.
    • findItemIndex

      public int findItemIndex(JListOperator.ListItemChooser chooser, int index)
      Searches for index'th item good from chooser's point of view.
      Parameters:
      chooser - Item verifying object.
      index - Ordinal item index.
      Returns:
      Item index or -1 if search was insuccessful.
    • findItemIndex

      public int findItemIndex(JListOperator.ListItemChooser chooser)
      Searches for an item good from chooser's point of view.
      Parameters:
      chooser - Item verifying object.
      Returns:
      Item index or -1 if serch was insuccessful.
      See Also:
    • findItemIndex

      public int findItemIndex(String item, Operator.StringComparator comparator, int index)
      Searches for an item good from chooser's point of view.
      Parameters:
      item - a text pattern
      comparator - a string comparision algorithm
      index - Ordinal item index.
      Returns:
      Item index or -1 if serch was insuccessful.
      See Also:
    • findItemIndex

      public int findItemIndex(String item, boolean ce, boolean cc, int index)
      Deprecated.
      Use findItemIndex(String, int) or findItemIndex(String, StringComparator, int)
      Searched for index'th item by text.
      Parameters:
      item - a text pattern
      ce - Compare text exactly.
      cc - Compare text case sensitively.
      index - Ordinal item index.
      Returns:
      Item index or -1 if serch was insuccessful.
      See Also:
    • findItemIndex

      public int findItemIndex(String item, int index)
      Searched for index'th item by text. Uses StringComparator assigned to this object.
      Parameters:
      item - a text pattern
      index - Ordinal item index.
      Returns:
      Item index or -1 if search was insuccessful.
    • findItemIndex

      public int findItemIndex(String item, Operator.StringComparator comparator)
      Searches for an item good from chooser's point of view.
      Parameters:
      item - a text pattern
      comparator - a string comparision algorithm
      Returns:
      Item index or -1 if serch was insuccessful.
      See Also:
    • findItemIndex

      public int findItemIndex(String item, boolean ce, boolean cc)
      Deprecated.
      Use findItemIndex(String) or findItemIndex(String, StringComparator)
      Searched item by text.
      Parameters:
      item - a text pattern
      ce - Compare text exactly.
      cc - Compare text case sensitively.
      Returns:
      Item index or -1 if search was insuccessful.
      See Also:
    • findItemIndex

      public int findItemIndex(String item)
      Searched for first item by text. Uses StringComparator assigned to this object.
      Parameters:
      item - a text pattern
      Returns:
      Item index or -1 if search was insuccessful.
      See Also:
    • findItemIndex

      public int findItemIndex(ComponentChooser chooser, int index)
      Searches for index'th item by rendered component.
      Parameters:
      chooser - Component verifying object.
      index - Ordinal item index.
      Returns:
      Item index or -1 if serch was insuccessful.
      See Also:
    • findItemIndex

      public int findItemIndex(ComponentChooser chooser)
      Searches for an item by rendered component.
      Parameters:
      chooser - Component verifying object.
      Returns:
      Item index or -1 if serch was insuccessful.
      See Also:
    • clickOnItem

      public Object clickOnItem(int itemIndex, int clickCount)
      Clicks on item by item index.
      Parameters:
      itemIndex - Item index.
      clickCount - count click.
      Returns:
      Click point or null if list does not contains itemIndex'th item.
      Throws:
      JListOperator.NoSuchItemException
    • clickOnItem

      public Object clickOnItem(String item, Operator.StringComparator comparator, int clickCount)
      Finds item by item text, and do mouse click on it.
      Parameters:
      item - Item text.
      comparator - a string comparision algorithm
      clickCount - count click.
      Returns:
      Click point or null if list does not contains itemIndex'th item.
      Throws:
      JListOperator.NoSuchItemException
    • clickOnItem

      public Object clickOnItem(String item, boolean ce, boolean cc, int clickCount)
      Deprecated.
      Use clickOnItem(String, int) or clickOnItem(String, StringComparator, int)
      Finds item by item text, and do mouse click on it.
      Parameters:
      item - Item text.
      ce - Compare exactly.
      cc - Compare case sensitively.
      clickCount - count click.
      Returns:
      Click point or null if list does not contains itemIndex'th item.
      Throws:
      JListOperator.NoSuchItemException
    • clickOnItem

      public Object clickOnItem(String item, int clickCount)
      Finds item by item text, and do mouse click on it. Uses StringComparator assigned to this object.
      Parameters:
      item - Item text.
      clickCount - count click.
      Returns:
      Click point or null if list does not contains itemIndex'th item.
      Throws:
      JListOperator.NoSuchItemException
    • clickOnItem

      public Object clickOnItem(String item, Operator.StringComparator comparator)
      Finds item by item text, and do simple mouse click on it. Uses StringComparator assigned to this object.
      Parameters:
      item - Item text.
      comparator - a string comparision algorithm
      Returns:
      Click point or null if list does not contains itemIndex'th item.
      Throws:
      JListOperator.NoSuchItemException
    • clickOnItem

      public Object clickOnItem(String item, boolean ce, boolean cc)
      Deprecated.
      Use clickOnItem(String) or clickOnItem(String, StringComparator)
      Finds item by item text, and do simple mouse click on it.
      Parameters:
      item - Item text.
      ce - Compare exactly.
      cc - Compare case sensitively.
      Returns:
      Click point or null if list does not contains itemIndex'th item.
      Throws:
      JListOperator.NoSuchItemException
    • clickOnItem

      public Object clickOnItem(String item)
      Finds item by item text, and do simple mouse click on it. Uses StringComparator assigned to this object.
      Parameters:
      item - Item text.
      Returns:
      Click point or null if list does not contains itemIndex'th item.
      Throws:
      JListOperator.NoSuchItemException
    • scrollToItem

      public void scrollToItem(int itemIndex)
      Scrolls to an item if the list is on a JScrollPane component.
      Parameters:
      itemIndex - an item index.
      Throws:
      JListOperator.NoSuchItemException
      See Also:
    • scrollToItem

      public void scrollToItem(String item, Operator.StringComparator comparator)
      Scrolls to an item if the list is on a JScrollPane component.
      Parameters:
      item - Item text
      comparator - a string comparision algorithm
      See Also:
    • scrollToItem

      public void scrollToItem(String item, boolean ce, boolean cc)
      Deprecated.
      Use scrollToItem(String) or scrollToItem(String, StringComparator)
      Scrolls to an item if the list is on a JScrollPane component.
      Parameters:
      item - Item text
      ce - Compare exactly.
      cc - Compare case sensitively.
      See Also:
    • selectItem

      public void selectItem(int index)
      Selects an item by index.
      Parameters:
      index - an item index.
    • selectItem

      public void selectItem(String item)
      Selects an item by text.
      Parameters:
      item - an item text.
    • selectItems

      public void selectItems(int[] indices)
      Selects items by indices.
      Parameters:
      indices - item indices.
    • selectItem

      public void selectItem(String[] items)
      Selects items by texts.
      Parameters:
      items - item texts.
    • waitItemsSelection

      public void waitItemsSelection(int[] itemIndices, boolean selected)
      Waits for items to be selected.
      Parameters:
      itemIndices - item indices to be selected
      selected - Selected (true) or unselected (false).
    • waitItemSelection

      public void waitItemSelection(int itemIndex, boolean selected)
      Waits for item to be selected.
      Parameters:
      itemIndex - an item needs to be selected
      selected - Selected (true) or unselected (false).
    • waitItem

      public void waitItem(String item, int itemIndex)
      Waits for item. Uses getComparator() comparator.
      Parameters:
      item - an item text
      itemIndex - Index of item to check or -1 to check selected item.
    • getDump

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

      public void addListSelectionListener(ListSelectionListener listSelectionListener)
      Maps JList.addListSelectionListener(ListSelectionListener) through queue
    • addSelectionInterval

      public void addSelectionInterval(int i, int i1)
      Maps JList.addSelectionInterval(int, int) through queue
    • clearSelection

      public void clearSelection()
      Maps JList.clearSelection() through queue
    • ensureIndexIsVisible

      public void ensureIndexIsVisible(int i)
      Maps JList.ensureIndexIsVisible(int) through queue
    • getAnchorSelectionIndex

      public int getAnchorSelectionIndex()
      Maps JList.getAnchorSelectionIndex() through queue
    • getCellBounds

      public Rectangle getCellBounds(int i, int i1)
      Maps JList.getCellBounds(int, int) through queue
    • getCellRenderer

      public ListCellRenderer getCellRenderer()
      Maps JList.getCellRenderer() through queue
    • getFirstVisibleIndex

      public int getFirstVisibleIndex()
      Maps JList.getFirstVisibleIndex() through queue
    • getFixedCellHeight

      public int getFixedCellHeight()
      Maps JList.getFixedCellHeight() through queue
    • getFixedCellWidth

      public int getFixedCellWidth()
      Maps JList.getFixedCellWidth() through queue
    • getLastVisibleIndex

      public int getLastVisibleIndex()
      Maps JList.getLastVisibleIndex() through queue
    • getLeadSelectionIndex

      public int getLeadSelectionIndex()
      Maps JList.getLeadSelectionIndex() through queue
    • getMaxSelectionIndex

      public int getMaxSelectionIndex()
      Maps JList.getMaxSelectionIndex() through queue
    • getMinSelectionIndex

      public int getMinSelectionIndex()
      Maps JList.getMinSelectionIndex() through queue
    • getModel

      public ListModel getModel()
      Maps JList.getModel() through queue
    • getPreferredScrollableViewportSize

      public Dimension getPreferredScrollableViewportSize()
      Maps JList.getPreferredScrollableViewportSize() through queue
    • getPrototypeCellValue

      public Object getPrototypeCellValue()
      Maps JList.getPrototypeCellValue() through queue
    • getScrollableBlockIncrement

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

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

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

      public int getScrollableUnitIncrement(Rectangle rectangle, int i, int i1)
      Maps JList.getScrollableUnitIncrement(Rectangle, int, int) through queue
    • getSelectedIndex

      public int getSelectedIndex()
      Maps JList.getSelectedIndex() through queue
    • getSelectedIndices

      public int[] getSelectedIndices()
      Maps JList.getSelectedIndices() through queue
    • getSelectedValue

      public Object getSelectedValue()
      Maps JList.getSelectedValue() through queue
    • getSelectedValues

      public Object[] getSelectedValues()
      Maps JList.getSelectedValues() through queue
    • getSelectionBackground

      public Color getSelectionBackground()
      Maps JList.getSelectionBackground() through queue
    • getSelectionForeground

      public Color getSelectionForeground()
      Maps JList.getSelectionForeground() through queue
    • getSelectionMode

      public int getSelectionMode()
      Maps JList.getSelectionMode() through queue
    • getSelectionModel

      public ListSelectionModel getSelectionModel()
      Maps JList.getSelectionModel() through queue
    • getUI

      public ListUI getUI()
      Maps JList.getUI() through queue
    • getValueIsAdjusting

      public boolean getValueIsAdjusting()
      Maps JList.getValueIsAdjusting() through queue
    • getVisibleRowCount

      public int getVisibleRowCount()
      Maps JList.getVisibleRowCount() through queue
    • indexToLocation

      public Point indexToLocation(int i)
      Maps JList.indexToLocation(int) through queue
    • isSelectedIndex

      public boolean isSelectedIndex(int i)
      Maps JList.isSelectedIndex(int) through queue
    • isSelectionEmpty

      public boolean isSelectionEmpty()
      Maps JList.isSelectionEmpty() through queue
    • locationToIndex

      public int locationToIndex(Point point)
      Maps JList.locationToIndex(Point) through queue
    • removeListSelectionListener

      public void removeListSelectionListener(ListSelectionListener listSelectionListener)
      Maps JList.removeListSelectionListener(ListSelectionListener) through queue
    • removeSelectionInterval

      public void removeSelectionInterval(int i, int i1)
      Maps JList.removeSelectionInterval(int, int) through queue
    • setCellRenderer

      public void setCellRenderer(ListCellRenderer listCellRenderer)
      Maps JList.setCellRenderer(ListCellRenderer) through queue
    • setFixedCellHeight

      public void setFixedCellHeight(int i)
      Maps JList.setFixedCellHeight(int) through queue
    • setFixedCellWidth

      public void setFixedCellWidth(int i)
      Maps JList.setFixedCellWidth(int) through queue
    • setListData

      public void setListData(Vector vector)
      Maps JList.setListData(Vector) through queue
    • setListData

      public void setListData(Object[] object)
      Maps JList.setListData(Object[]) through queue
    • setModel

      public void setModel(ListModel listModel)
      Maps JList.setModel(ListModel) through queue
    • setPrototypeCellValue

      public void setPrototypeCellValue(Object object)
      Maps JList.setPrototypeCellValue(Object) through queue
    • setSelectedIndex

      public void setSelectedIndex(int i)
      Maps JList.setSelectedIndex(int) through queue
    • setSelectedIndices

      public void setSelectedIndices(int[] i)
      Maps JList.setSelectedIndices(int[]) through queue
    • setSelectedValue

      public void setSelectedValue(Object object, boolean b)
      Maps JList.setSelectedValue(Object, boolean) through queue
    • setSelectionBackground

      public void setSelectionBackground(Color color)
      Maps JList.setSelectionBackground(Color) through queue
    • setSelectionForeground

      public void setSelectionForeground(Color color)
      Maps JList.setSelectionForeground(Color) through queue
    • setSelectionInterval

      public void setSelectionInterval(int i, int i1)
      Maps JList.setSelectionInterval(int, int) through queue
    • setSelectionMode

      public void setSelectionMode(int i)
      Maps JList.setSelectionMode(int) through queue
    • setSelectionModel

      public void setSelectionModel(ListSelectionModel listSelectionModel)
      Maps JList.setSelectionModel(ListSelectionModel) through queue
    • setUI

      public void setUI(ListUI listUI)
      Maps JList.setUI(ListUI) through queue
    • setValueIsAdjusting

      public void setValueIsAdjusting(boolean b)
      Maps JList.setValueIsAdjusting(boolean) through queue
    • setVisibleRowCount

      public void setVisibleRowCount(int i)
      Maps JList.setVisibleRowCount(int) through queue