View Javadoc

1   /*
2       Jagacy plug-in - A TN3270 plug-in for Jameleon.
3       Copyright (C) 2007 Michael Parker (mipar@users.sourceforge.net)
4   
5       This library is free software; you can redistribute it and/or
6       modify it under the terms of the GNU Lesser General Public
7       License as published by the Free Software Foundation; either
8       version 2.1 of the License, or (at your option) any later version.
9   
10      This library is distributed in the hope that it will be useful,
11      but WITHOUT ANY WARRANTY; without even the implied warranty of
12      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13      Lesser General Public License for more details.
14  
15      You should have received a copy of the GNU Lesser General Public
16      License along with this library; if not, write to the Free Software
17      Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
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  }