com.cbse.jeasy
Class JEAutomation

java.lang.Object
  extended by java.awt.Robot
      extended by com.cbse.jeasy.JEAutomation
All Implemented Interfaces:
java.lang.Runnable

public class JEAutomation
extends java.awt.Robot
implements java.lang.Runnable

The JEAutomation offers a script interface in XML.

See the Robot class of the jdk. Example:

 <?xml version='1.0' ?>
        <jeasy>
          <automationScript id="test1">
                <automation method="setDelayFactor" param1="1"/>
                <automation method="smoothMouse" param1="true"/>
                <automation method="mouseMove" param1="RB_Radio1"/>
                <automation method="mouseClickLeft"/>
                <automation method="mouseMove" param1="BT_Button"/>
                <automation method="mouseClickLeft"/>
                <automation method="mouseMove" param1="DF_Datafield"/>
                <automation method="mouseClickLeft"/>
                <automation method="typeString" param1="azAZ1234567890,.-;:_ß?\+*#'äöüÄÖÜ@"/>
                <automation method="mouseMove" param1="CB_Combobox"/>
                <automation method="mouseClickLeft"/>
                <methodinvocation>
                        <id>MC_DB_Country1</id>
                        <JEObject>CB_Combobox</JEObject>
                        <method>setSelectedIndex(int)</method>
                        <param1Class>int</param1Class>
                        <param1Value>5</param1Value>
                </methodinvocation>
          </automationScript>
        </jeasy>

 The following methods are defined in JEasy script language:
        mouseMove(param1);          // moves the mouse to the center of the of the jeasy object param1
        delay(param1);              // milliseconds to wait
        keyPress(param1);           // keycode to be pressed
        keyRelease(param1);         // keycode to be released
        mousePress(param1);         // mouse button to be pressed InputEvent.BUTTON1/2/3_MASK
        mouseRelease(param1);       // mouse button to be released InputEvent.BUTTON1/2/3_MASK
        mouseClickLeft();           // click left mouse button. Presses and releases the left button
        mouseClickRight();          // click right mouse button. Presses and releases the left button
        mouseMove(param1, param2);  // moves the mouse to position x=param1  y=param2
        mouseMove(param1;                       // moves the mouse to to the given JEasyId
        mouseMove(param1, param2, param3);  // moves the mouse to the table given by the JEasyID in row=param2  col=param3
        mouseMove(param1, param2, param3, param4);  // moves the mouse to the table given by the JEasyID=param1 looking in col=param2  
                                                                                                // for string=param3 and position in col=param4
        setAutoDelay(param1);       // sleeps param1 milliseconds after generating an event
        setAutoWaitForIdle(param1); // sets whether this Robot automatically invokes waitForIdle after generating an event
                                    // param1 may be true or false
        setDelayFactor(param1);     // param1 between 0 and 10. Higher value means increasing the autoDelay
        smoothMouse(param1);        // setting param1 to true moves the mouse to next position
                                    // setting param1 to false changes the mouse position
        typeString(param1);         // generates keyPress and keyRelease events to type the string param1
                                    // be sure to have the cursor in an inputfield
                                                                // some special characters are definied: /t = tab  /n = CRLF  /u = cursor up  /d = cursor down
        waitForIdle();              // Waits until all events currently on the event queue have been processed

 The script understands the XML tag methodinvocation. This syntax enables to invoke
 each object method defined in jeasy classes.
 

Version:
%I%, %G%
Author:
H.Pfohl

Constructor Summary
JEAutomation()
           
JEAutomation(java.lang.Object caller)
           
 
Method Summary
 void automate(java.lang.String xmlAutomate)
          Call this method directly to perform the automation not using a thread.
 void automateAsThread(java.lang.String xmlAutomate)
          Performs one xml automation tag as a thread Example: <automation method="mouseMove" param1="RB_Radio1"/>
 void doXMLScript(java.io.BufferedReader din)
          Reads the automation tags out of the BufferedReader and performs them.
 void doXMLScriptAsThread(java.io.BufferedReader din)
          Reads the automation tags out of the BufferedReader and performs them as a thread.
 void doXMLScriptAsThread(java.io.BufferedReader din, java.lang.String automationScriptId)
          Reads the automation tags from the XMLtag out of the BufferedReader and performs them as a thread.
 boolean isComponent(int x, int y)
          Chekcs if
 void mouseClickLeft()
          Presses and releases the left mouse button with an delay of 300 ms.
 void mouseClickRight()
          Presses and releases the righ mouse button with an delay of 300 ms.
 void mouseMove(int fromx, int fromy, int tox, int toy)
          Moves the mouse smoothly.
 void mouseMove(java.lang.String JEObjectId)
          Move the mouse to the middle of the JEasy object.
 void mouseMove(java.lang.String JEObjectId, int row, int col)
          Move the mouse to the table to row and column.
 void mouseMove(java.lang.String JEObjectId, int colLookUp, java.lang.String search, int column)
          Move the mouse to the table to row (where saerch is found in col colLookUp) and column.
 void run()
          Call this method directly to perform the automation not as a thread.
 void setDelayFactor(int delayFact)
          A value between 1 and 10 which is a multiplier of 10 ms for the autoDelay()
 void typeString(java.lang.String s)
          Generates keyPress and KeyRelease events related to the given string.
 
Methods inherited from class java.awt.Robot
createScreenCapture, delay, getAutoDelay, getPixelColor, isAutoWaitForIdle, keyPress, keyRelease, mouseMove, mousePress, mouseRelease, mouseWheel, setAutoDelay, setAutoWaitForIdle, toString, waitForIdle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

JEAutomation

public JEAutomation()
             throws java.awt.AWTException
Throws:
java.awt.AWTException

JEAutomation

public JEAutomation(java.lang.Object caller)
             throws java.awt.AWTException
Throws:
java.awt.AWTException
Method Detail

automateAsThread

public void automateAsThread(java.lang.String xmlAutomate)
Performs one xml automation tag as a thread Example: <automation method="mouseMove" param1="RB_Radio1"/>

Parameters:
s - xml String
See Also:
JE#PropertyString

run

public void run()
Call this method directly to perform the automation not as a thread. The method will return after finishing the automation methods. You have to set the xml String or the Buffered Reader first

Specified by:
run in interface java.lang.Runnable

automate

public void automate(java.lang.String xmlAutomate)
              throws java.io.IOException
Call this method directly to perform the automation not using a thread. The method will return after finishing the automation methods The XMLString should be in the form <automation method="methodname" param1="param"/>

Throws:
java.io.IOException

mouseClickLeft

public void mouseClickLeft()
Presses and releases the left mouse button with an delay of 300 ms.


mouseClickRight

public void mouseClickRight()
Presses and releases the righ mouse button with an delay of 300 ms.


setDelayFactor

public void setDelayFactor(int delayFact)
A value between 1 and 10 which is a multiplier of 10 ms for the autoDelay()


doXMLScriptAsThread

public void doXMLScriptAsThread(java.io.BufferedReader din,
                                java.lang.String automationScriptId)
Reads the automation tags from the XMLtag out of the BufferedReader and performs them as a thread. The methos returns at once.


doXMLScriptAsThread

public void doXMLScriptAsThread(java.io.BufferedReader din)
Reads the automation tags out of the BufferedReader and performs them as a thread. The methos returns at once.


doXMLScript

public void doXMLScript(java.io.BufferedReader din)
                 throws java.io.IOException
Reads the automation tags out of the BufferedReader and performs them. The method returns after finishing the script.

Throws:
java.io.IOException

mouseMove

public void mouseMove(java.lang.String JEObjectId)
Move the mouse to the middle of the JEasy object. The method returns at once.


mouseMove

public void mouseMove(java.lang.String JEObjectId,
                      int row,
                      int col)
Move the mouse to the table to row and column. The method returns at once.


mouseMove

public void mouseMove(java.lang.String JEObjectId,
                      int colLookUp,
                      java.lang.String search,
                      int column)
Move the mouse to the table to row (where saerch is found in col colLookUp) and column. The method returns at once.

Parameters:
JEObjectId -
colLookUp -
search -
col -

isComponent

public boolean isComponent(int x,
                           int y)
Chekcs if

Parameters:
x -
y -
Returns:

mouseMove

public void mouseMove(int fromx,
                      int fromy,
                      int tox,
                      int toy)
Moves the mouse smoothly.


typeString

public void typeString(java.lang.String s)
Generates keyPress and KeyRelease events related to the given string.