Class JSpinnerOperator

All Implemented Interfaces:
Outputable, Timeoutable
Direct Known Subclasses:
JSpinnerOperator.DateSpinnerOperator, JSpinnerOperator.ListSpinnerOperator, JSpinnerOperator.NumberSpinnerOperator

public class JSpinnerOperator extends JComponentOperator implements Timeoutable, Outputable
Provides methods to work with javax.swing.JSpinner component
Author:
Alexandre Iline (alexandre.iline@sun.com)
See Also:
  • Field Details

  • Constructor Details

    • JSpinnerOperator

      public JSpinnerOperator(JSpinner b)
      Constructor.
      Parameters:
      b - JSpinner component.
    • JSpinnerOperator

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

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

      public JSpinnerOperator(ContainerOperator cont, String text, int index)
      Constructs a JSpinnerOperator object.
      Parameters:
      cont - The operator for a container containing the sought for button.
      text - toString() representation of the current spinner value.
      index - Ordinal component index. The first component has index 0.
    • JSpinnerOperator

      public JSpinnerOperator(ContainerOperator cont, String text)
      Constructs a JSpinnerOperator object.
      Parameters:
      cont - The operator for a container containing the sought for button.
      text - toString() representation of the current spinner value.
    • JSpinnerOperator

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

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

    • findJSpinner

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

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

      public static JSpinner findJSpinner(Container cont, int index)
      Searches JSpinner in container.
      Parameters:
      cont - Container to search component in.
      index - Ordinal component index.
      Returns:
      JSpinner instance or null if component was not found.
    • findJSpinner

      public static JSpinner findJSpinner(Container cont)
      Searches 0'th JSpinner in container.
      Parameters:
      cont - Container to search component in.
      Returns:
      JSpinner instance or null if component was not found.
    • waitJSpinner

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

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

      public static JSpinner waitJSpinner(Container cont, int index)
      Waits JSpinner in container.
      Parameters:
      cont - Container to search component in.
      index - Ordinal component index.
      Returns:
      JSpinner instance or null if component was not displayed.
    • waitJSpinner

      public static JSpinner waitJSpinner(Container cont)
      Waits 0'th JSpinner in container.
      Parameters:
      cont - Container to search component in.
      Returns:
      JSpinner instance or null if component was not displayed.
    • checkModel

      public static void checkModel(JSpinnerOperator oper, Class modelClass)
      Checks operator's model type.
      Parameters:
      oper - an operator to check model
      modelClass - a model class.
      Throws:
      JSpinnerOperator.SpinnerModelException - if an operator's model is not an instance of specified class.
    • 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 JComponentOperator
      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 JComponentOperator
      Returns:
      an object that contains references to objects for printing to output and err streams.
      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:
    • getNumberSpinner

      public JSpinnerOperator.NumberSpinnerOperator getNumberSpinner()
      Returns an instance of NumberSpinnerOperator operator, the operator used for JSpinner having SpinnerNumberModel model.
      Returns:
      a NumberSpinnerOperator created for the same JSpinner as this operator.
      Throws:
      JSpinnerOperator.SpinnerModelException - if an operator's model is not an instance of SpinnerNumberModel
    • getListSpinner

      public JSpinnerOperator.ListSpinnerOperator getListSpinner()
      Returns an instance of ListSpinnerOperator operator, the operator used for JSpinner having SpinnerListModel model.
      Returns:
      a ListSpinnerOperator created for the same JSpinner as this operator.
      Throws:
      JSpinnerOperator.SpinnerModelException - if an operator's model is not an instance of SpinnerListModel
    • getDateSpinner

      public JSpinnerOperator.DateSpinnerOperator getDateSpinner()
      Returns an instance of DateSpinnerOperator operator, the operator used for JSpinner having SpinnerDateModel model.
      Returns:
      a DateSpinnerOperator created for the same JSpinner as this operator.
      Throws:
      JSpinnerOperator.SpinnerModelException - if an operator's model is not an instance of SpinnerDateModel
    • scrollTo

      public void scrollTo(ScrollAdjuster adj)
      Scrolls to reach a condition specified by ScrollAdjuster
      Parameters:
      adj - scrolling criteria.
    • scrollToMaximum

      public void scrollToMaximum()
      Scrolls to maximum value.
      Throws:
      JSpinnerOperator.SpinnerModelException - if an operator's model does not have a maximum value.
    • scrollToMinimum

      public void scrollToMinimum()
      Scrolls to minimum value.
      Throws:
      JSpinnerOperator.SpinnerModelException - if an operator's model does not have a minimum value.
    • scrollToObject

      public void scrollToObject(Object value, int direction)
      Scrolls to exact match of a spinner value to the specified value.
      Parameters:
      value - an value to scroll to.
      direction - a scrolling direction - one of ScrollAdjuster.*_SCROLL_DIRECTION fields.
    • scrollToString

      public void scrollToString(String pattern, Operator.StringComparator comparator, int direction)
      Scrolls to matching of getValue().toString() with the pattern.
      Parameters:
      pattern - a pattern to compare with
      comparator - a string comparision criteria
      direction - a scrolling direction - one of ScrollAdjuster.*_SCROLL_DIRECTION fields.
    • scrollToString

      public void scrollToString(String pattern, int direction)
      Scrolls to matching of getValue().toString() with the pattern. Uses StringComparator assigned to the operator.
      Parameters:
      pattern - a pattern to compare with
      direction - a scrolling direction - one of ScrollAdjuster.*_SCROLL_DIRECTION fields.
    • getIncreaseOperator

      public JButtonOperator getIncreaseOperator()
      Returns an operator for a button used for value increasing.
      Returns:
      an operator for a first JButton inside this spinner.
    • getDecreaseOperator

      public JButtonOperator getDecreaseOperator()
      Returns an operator for a button used for value decreasing.
      Returns:
      an operator for a second JButton inside this spinner.
    • getMinimum

      public Object getMinimum()
      Returns a minimal value. Returns null if model is not one of the following: javax.swing.SpinnerDateModel, javax.swing.SpinnerListModel, javax.swing.SpinnerNumberModel. Also, returns null if the model does not have a minimal value.
      Returns:
      a minimal value.
    • getMaximum

      public Object getMaximum()
      Returns a maximal value. Returns null if model is not one of the following: javax.swing.SpinnerDateModel, javax.swing.SpinnerListModel, javax.swing.SpinnerNumberModel. Also, returns null if the model does not have a maximal value.
      Returns:
      a maximal value.
    • getDump

      public Hashtable getDump()
      Description copied from class: ComponentOperator
      Returns information about component.
      Overrides:
      getDump in class JComponentOperator
      Returns:
      a Hashtable containing name-value pairs.
    • getValue

      public Object getValue()
      Maps JSpinner.getValue() through queue
    • setValue

      public void setValue(Object object)
      Maps JSpinner.setValue(Object) through queue
    • getUI

      public SpinnerUI getUI()
      Maps JSpinner.getUI() through queue
    • setUI

      public void setUI(SpinnerUI spinnerUI)
      Maps JSpinner.setUI(SpinnerUI) through queue
    • setModel

      public void setModel(SpinnerModel spinnerModel)
      Maps JSpinner.setModel(SpinnerModel) through queue
    • getModel

      public SpinnerModel getModel()
      Maps JSpinner.getModel() through queue
    • getNextValue

      public Object getNextValue()
      Maps JSpinner.getNextValue() through queue
    • addChangeListener

      public void addChangeListener(ChangeListener changeListener)
      Maps JSpinner.addChangeListener(ChangeListener) through queue
    • removeChangeListener

      public void removeChangeListener(ChangeListener changeListener)
      Maps JSpinner.removeChangeListener(ChangeListener) through queue
    • getChangeListeners

      public ChangeListener[] getChangeListeners()
      Maps JSpinner.getChangeListeners() through queue
    • getPreviousValue

      public Object getPreviousValue()
      Maps JSpinner.getPreviousValue() through queue
    • setEditor

      public void setEditor(JComponent jComponent)
      Maps JSpinner.setEditor(JComponent) through queue
    • getEditor

      public JComponent getEditor()
      Maps JSpinner.getEditor() through queue
    • commitEdit

      public void commitEdit()
      Maps JSpinner.commitEdit() through queue