Class ButtonOperator

  • All Implemented Interfaces:
    Outputable, Timeoutable

    public class ButtonOperator
    extends ComponentOperator
    implements Timeoutable, Outputable


    Timeouts used:
    ButtonOperator.PushButtonTimeout - time between button pressing and releasing
    ComponentOperator.WaitComponentTimeout - time to wait button displayed
    ComponentOperator.WaitComponentEnabledTimeout - time to wait button enabled
    .
    Author:
    Alexandre Iline (alexandre.iline@sun.com)
    See Also:
    Timeouts
    • Constructor Detail

      • ButtonOperator

        public ButtonOperator​(Button b)
        Constructor.
        Parameters:
        b - The java.awt.Button managed by this instance.
      • ButtonOperator

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

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

        public ButtonOperator​(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.Button 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 button.
        text - Button text.
        index - Ordinal component index. The first component has index 0.
        Throws:
        TimeoutExpiredException
        See Also:
        Operator.isCaptionEqual(String, String, boolean, boolean)
      • ButtonOperator

        public ButtonOperator​(ContainerOperator cont,
                              String text)
        Constructor. Waits for a component in a container to show. The component is identified as the first java.awt.Button 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 button.
        text - Button text.
        Throws:
        TimeoutExpiredException
        See Also:
        Operator.isCaptionEqual(String, String, boolean, boolean)
    • Method Detail

      • findButton

        public static Button findButton​(Container cont,
                                        ComponentChooser chooser,
                                        int index)
        Searches Button 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:
        Button instance or null if component was not found.
      • findButton

        public static Button findButton​(Container cont,
                                        ComponentChooser chooser)
        Searches for the first Button 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:
        Button instance or null if component was not found.
      • findButton

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

        public static Button findButton​(Container cont,
                                        String text,
                                        boolean ce,
                                        boolean ccs)
        Searches Button by text.
        Parameters:
        cont - Container to search component in.
        text - Button text. If null, contents is not checked.
        ce - Compare text exactly.
        ccs - Compare text case sensitively.
        Returns:
        Button instance or null if component was not found.
        See Also:
        Operator.isCaptionEqual(String, String, boolean, boolean)
      • waitButton

        public static Button waitButton​(Container cont,
                                        ComponentChooser chooser,
                                        int index)
        Waits Button in container.
        Parameters:
        cont - Container to search component in.
        chooser - org.netbeans.jemmy.ComponentChooser implementation.
        index - Ordinal component index.
        Returns:
        Button instance.
        Throws:
        TimeoutExpiredException
      • waitButton

        public static Button waitButton​(Container cont,
                                        ComponentChooser chooser)
        Waits 0'th Button in container.
        Parameters:
        cont - Container to search component in.
        chooser - org.netbeans.jemmy.ComponentChooser implementation.
        Returns:
        Button 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.
      • pushNoBlock

        public void pushNoBlock()
        Runs push() method in a separate thread.
      • getDump

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

        public void addActionListener​(ActionListener actionListener)
        Maps Button.addActionListener(ActionListener) through queue
      • getActionCommand

        public String getActionCommand()
        Maps Button.getActionCommand() through queue
      • getLabel

        public String getLabel()
        Maps Button.getLabel() through queue
      • removeActionListener

        public void removeActionListener​(ActionListener actionListener)
        Maps Button.removeActionListener(ActionListener) through queue
      • setActionCommand

        public void setActionCommand​(String string)
        Maps Button.setActionCommand(String) through queue
      • setLabel

        public void setLabel​(String string)
        Maps Button.setLabel(String) through queue