1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package net.sf.jameleon.plugin.jagacy.tags;
20 import net.sf.jameleon.exception.JameleonScriptException;
21 import com.jagacy.util.JagacyException;
22
23 /***
24 * Sets the value of a field located at the row column coordinates. For example,
25 * if a screen contains an input field at line 7 and row 2 according to the
26 * emulation view of a panel then the the text woud be set at the field found by
27 * getPosition((7)*80+(2),...)
28 *
29 * To support more flexible data driven tests, an empty value doesn't cause an error
30 * but just a trace warning.
31 *
32 * jagacy counts rows and columns starting from 0 !
33 *
34 * @jameleon.function name="jagacy-set-value-at-rowcolumn" type="action"
35 */
36 public class JagacySetValueForFieldAtRowColumnTag extends JagacySendKeyTag {
37 /***
38 * Dummy Key to fullfill JagacySendKey's requirements.
39 *
40 * @jameleon.attribute default="PF8"
41 */
42 protected String key;
43
44 /***
45 * The row of the field
46 *
47 * @jameleon.attribute required="true"
48 */
49 public int row;
50 /***
51 * The column of the field
52 *
53 * @jameleon.attribute required="true"
54 */
55 public int column;
56 /***
57 * The value of the field
58 *
59 * @jameleon.attribute required="false" default=""
60 */
61 protected String value;
62
63 public void testBlock() {
64
65 if (value == null) {
66 traceMsg("not setting value at row/column '" + row + "/" + column
67 + "' because null was passed as the value");
68 return;
69 }
70 int pos = (row) * session.getWidth() + column;
71 traceMsg("Writing field #" + pos + " row/col " + row + "/" + column);
72 try {
73 writeField(session.getPositionField(pos, new int[1], new int[1]),
74 1, value);
75
76 } catch (JagacyException je) {
77
78 throw new JameleonScriptException("Error while setting value "
79 + value + " at " + row + "/" + column, je);
80 }
81
82 }
83 }