Class Operator

    • Constructor Detail

      • Operator

        public Operator()
        Inits environment.
    • Method Detail

      • setDefaultVerification

        public static boolean setDefaultVerification​(boolean verification)
        Defines weither newly created operators should perform operation verifications by default.
        Parameters:
        verification - a verification mode to be used by default.
        Returns:
        a prevoius value.
        See Also:
        getDefaultVerification(), setVerification(boolean)
      • getDefaultVerification

        public static boolean getDefaultVerification()
        Says weither newly created operators perform operations verifications by default.
        Returns:
        a verification mode used by default.
        See Also:
        setDefaultVerification(boolean), getVerification()
      • isCaptionEqual

        public static boolean isCaptionEqual​(java.lang.String caption,
                                             java.lang.String match,
                                             boolean ce,
                                             boolean ccs)
        Deprecated.
        use another methods with the same name.
        Compares caption (button text, window title, ...) with a sample text.
        Parameters:
        caption - String to be compared with match. Method returns false, if parameter is null.
        match - Sample to compare with. Method returns true, if parameter is null.
        ce - Compare exactly. If true, text can be a substring of caption.
        ccs - Compare case sensitively. If true, both text and caption are converted to upper case before comparison.
        Returns:
        true is the captions matched the match.
        See Also:
        isCaptionEqual(java.lang.String, java.lang.String, boolean, boolean)
      • isCaptionEqual

        public static boolean isCaptionEqual​(java.lang.String caption,
                                             java.lang.String match,
                                             Operator.StringComparator comparator)
        Compares caption (button text, window title, ...) with a sample text.
        Parameters:
        caption - String to be compared with match
        match - Sample to compare with
        comparator - StringComparator instance.
        Returns:
        true is the captions matched the match.
        See Also:
        isCaptionEqual(java.lang.String, java.lang.String, boolean, boolean)
      • getDefaultMouseButton

        public static int getDefaultMouseButton()
        Returns default mouse button mask.
        Returns:
        InputEvent.BUTTON*_MASK field value
      • getPopupMouseButton

        public static int getPopupMouseButton()
        Returns mask of mouse button which used to popup expanding. (InputEvent.BUTTON3_MASK)
        Returns:
        InputEvent.BUTTON*_MASK field value
      • createOperator

        public static ComponentOperator createOperator​(java.awt.Component comp)
        Creates operator for component. Tries to find class with "operator package"."class name"Operator name, where "operator package" is a package from operator packages list, and "class name" is the name of class or one of its superclasses.
        Parameters:
        comp - Component to create operator for.
        Returns:
        a new operator with default environment.
        See Also:
        addOperatorPackage(String)
      • addOperatorPackage

        public static void addOperatorPackage​(java.lang.String pkgName)
        Adds package to the list of packages containing operators.
        "org.netbeans.jemmy.operators" is in the list by default.
        Parameters:
        pkgName - Package name.
        See Also:
        createOperator(Component)
      • getEnvironmentOperator

        public static Operator getEnvironmentOperator()
        Returns an operator containing default environment.
        Returns:
        an empty operator (not having any component source) having default environment.
      • getSource

        public abstract java.awt.Component getSource()
        Returns object operator is used for.
        Returns:
        an instance of java.awt.Component subclass which this operator was created for.
      • getQueueTool

        public QueueTool getQueueTool()
        Returns QueueTool is used to work with queue.
        Returns:
        a QueueTool.
      • copyEnvironment

        public void copyEnvironment​(Operator anotherOperator)
        Copies all environment (output, timeouts, visualizer) from another operator.
        Parameters:
        anotherOperator - an operator to copy the environment to.
      • setProperties

        public JemmyProperties setProperties​(JemmyProperties properties)
        Assigns a JemmyProperty object to this operator.
        Parameters:
        properties - a properties to assign to this operator.
        Returns:
        previously assigned properties.
        See Also:
        getProperties()
      • setOutput

        public void setOutput​(TestOut out)
        Description copied from interface: Outputable
        Defines print output streams or writers.
        Specified by:
        setOutput in interface Outputable
        Parameters:
        out - Identify the streams or writers used for print output.
        See Also:
        Outputable.getOutput()
      • setPathParser

        public void setPathParser​(Operator.PathParser parser)
        Specifies object which is used for parsing of path-like strings.
        Parameters:
        parser - a parser to use for path parsing.
        See Also:
        getPathParser()
      • getParentPath

        public java.lang.String[] getParentPath​(java.lang.String[] path)
        Creates new array which has all elements from first array, except last element.
        Parameters:
        path - an original array
        Returns:
        new array
      • parseString

        public java.lang.String[] parseString​(java.lang.String path)
        Parses a string to a string array using a PathParser assigned to this operator.
        Parameters:
        path - an original string
        Returns:
        created String array.
      • parseString

        public java.lang.String[] parseString​(java.lang.String path,
                                              java.lang.String delim)
        Parses strings like "1|2|3" into arrays {"1", "2", "3"}.
        Parameters:
        path - an original string
        delim - a delimiter string
        Returns:
        created String array.
      • getCharKey

        public int getCharKey​(char c)
        Returns key code to be pressed for character typing.
        Parameters:
        c - Character to be typed.
        Returns:
        a value of one of the KeyEvent.VK_* fields.
        See Also:
        CharBindingMap
      • getCharModifiers

        public int getCharModifiers​(char c)
        Returns modifiers mask for character typing.
        Parameters:
        c - Character to be typed.
        Returns:
        a combination of InputEvent.*_MASK fields.
        See Also:
        CharBindingMap
      • getCharsKeys

        public int[] getCharsKeys​(char[] c)
        Returns key codes to by pressed for characters typing.
        Parameters:
        c - Characters to be typed.
        Returns:
        an array of KeyEvent.VK_* values.
        See Also:
        CharBindingMap
      • getCharsModifiers

        public int[] getCharsModifiers​(char[] c)
        Returns modifiers masks for characters typing.
        Parameters:
        c - Characters to be typed.
        Returns:
        an array of a combination of InputEvent.*_MASK fields.
        See Also:
        CharBindingMap
      • getCharsKeys

        public int[] getCharsKeys​(java.lang.String s)
        Returns key codes to by pressed for the string typing.
        Parameters:
        s - String to be typed.
        Returns:
        an array of KeyEvent.VK_* values.
        See Also:
        CharBindingMap
      • getCharsModifiers

        public int[] getCharsModifiers​(java.lang.String s)
        Returns modifiers masks for the string typing.
        Parameters:
        s - String to be typed.
        Returns:
        an array of a combination of InputEvent.*_MASK fields.
        See Also:
        CharBindingMap
      • printDump

        public void printDump()
        Prints component information into operator output.
      • getDump

        public java.util.Hashtable getDump()
        Returns information about component. All records marked by simbolic constants defined in public static final *_DPROP fields for each operator type.
        Returns:
        a Hashtable containing name-value pairs.
      • waitState

        public void waitState​(ComponentChooser state)
        Waits a state specified by a ComponentChooser instance.
        Parameters:
        state - a ComponentChooser defining the state criteria.
        Throws:
        TimeoutExpiredException - if the state has not achieved in a value defined by "ComponentOperator.WaitStateTimeout"
      • produceTimeRestricted

        protected java.lang.Object produceTimeRestricted​(Action action,
                                                         java.lang.Object param,
                                                         long wholeTime)
        Performs an operation with time control.
        Parameters:
        action - an action to execute.
        param - an action parameters.
        wholeTime - a time for the action to be finished.
        Returns:
        an action result.
      • produceTimeRestricted

        protected java.lang.Object produceTimeRestricted​(Action action,
                                                         long wholeTime)
        Performs an operation with time control.
        Parameters:
        action - an action to execute.
        wholeTime - a time for the action to be finished.
        Returns:
        an action result.
      • produceNoBlocking

        protected void produceNoBlocking​(Operator.NoBlockingAction action,
                                         java.lang.Object param)
        Performs an operation without time control.
        Parameters:
        action - an action to execute.
        param - an action parameters.
      • produceNoBlocking

        protected void produceNoBlocking​(Operator.NoBlockingAction action)
        Performs an operation without time control.
        Parameters:
        action - an action to execute.
      • lockQueue

        protected void lockQueue()
        Equivalent to getQueue().lock();.
      • unlockQueue

        protected void unlockQueue()
        Equivalent to getQueue().unlock();.
      • unlockAndThrow

        protected void unlockAndThrow​(java.lang.Exception e)
        Unlocks Queue and then throw exception.
        Parameters:
        e - an exception to be thrown.
      • runMapping

        protected java.lang.Object runMapping​(Operator.MapAction action)
        To map nonprimitive type component's method.
        Parameters:
        action - a mapping action.
        Returns:
        an action result.
        See Also:
        Operator.MapAction
      • addToDump

        protected java.lang.String[] addToDump​(java.util.Hashtable table,
                                               java.lang.String title,
                                               java.lang.Object[] items)
        Adds array of objects to dump hashtable. Is used for multiple properties such as list items and tree nodes.
        Parameters:
        table - a table to add properties to.
        title - property names prefix. Property names are constructed by adding a number to the prefix: title + "_" + Iteger.toString("ordinal index")
        items - an array of property values.
        Returns:
        an array of property names (with added numbers).
      • addToDump

        protected java.lang.String[] addToDump​(java.util.Hashtable table,
                                               java.lang.String title,
                                               java.lang.Object[][] items)
        Adds two dimentional array of objects to dump hashtable. Is used for multiple properties such as table cells.
        Parameters:
        table - a table to add properties to.
        title - property names prefix. Property names are constructed by adding two numbers to the prefix: title + "_" + Iteger.toString("row index") + "_" + Iteger.toString("column index")
        items - an array of property values.
        Returns:
        an array of property names (with added numbers).
      • toStringSource

        public java.lang.String toStringSource()
        Returns toString() result from component of this operator. It calls getSource().toString() in dispatch thread.
        Returns:
        toString() result from component of this operator.