@@ -17,9 +17,11 @@ public abstract class ASwElement implements ISwElement<Component> {
1717
1818 public static String paramCommand = "command" ;
1919
20- public Component component ;
20+ public static long TIMEOUT_FOR_EXECUTION_IN_SECONDS = 10 ;
2121
22+ public Component component ;
2223 public TafProperties properties ;
24+
2325 // public String tagName;
2426 public long tid ;
2527
@@ -39,67 +41,8 @@ public ASwElement(long tid, Component component) {
3941 fillProperties ();
4042 }
4143
42- protected void addProperty (String key , int value ) {
43- addProperty (key , new Integer (value ).toString ());
44- }
45-
46- protected void addProperty (String key , long value ) {
47- addProperty (key , new Long (value ).toString ());
48- }
49-
50- protected void addProperty (String key , String value ) {
51- if ((key != null ) && (value != null )) {
52- properties .putObject (key , value );
53- }
54- }
55-
56- protected String asEscaped (String s ) {
57- if (s == null ) {
58- return s ;
59- }
60- return asEscapedString (s );
61- }
62-
63- protected String asEscapedXml (String s ) {
64- if (s == null ) {
65- return s ;
66- }
67- return asEscapedXmlString (s );
68- }
69-
7044 public abstract TafProperties basicExecCommand (TafProperties props );
7145
72- // protected void click(Component c, int mask) {
73- // if (c != null) {
74- // if (c.getBounds().isEmpty()) {
75- // System.out.println("Can't click --> has no bounds!");
76- // return;
77- // }
78- // waitUntilReady();
79- // Point upperLeft = c.getLocationOnScreen();
80- // Rectangle bounds = new Rectangle(upperLeft.x, upperLeft.y, c.getWidth(), c.getHeight());
81- // Point p = new Point(new Double(bounds.getCenterX()).intValue(), new Double(bounds.getCenterY()).intValue());
82- // click(p, mask);
83- // }
84- // }
85- //
86- // protected void click(Point p, int mask) {
87- // while (Toolkit.getDefaultToolkit().getSystemEventQueue().peekEvent() != null) {};
88- // try {
89- // System.out.println("Click auf " + p);
90- // Robot robot = new Robot();
91- // robot.mouseMove(p.x, p.y);
92- // robot.mousePress(mask);
93- // robot.delay(100);
94- // robot.mouseRelease(mask);
95- // }
96- // catch (Exception e) {
97- // e.printStackTrace();
98- // }
99- // }
100-
101- public static long TIMEOUT_FOR_EXECUTION_IN_SECONDS = 10 ;
102-
10346 public TafProperties execCommand (TafProperties props ) {
10447 boolean timedOut = false ;
10548 long time = System .currentTimeMillis ();
@@ -109,8 +52,8 @@ public TafProperties execCommand(TafProperties props) {
10952 System .out .println ("ASwElement --> execCommand" );
11053 try {
11154 if (!getType ().equalsIgnoreCase (incomingProps .getString ("type" ))) {
112- return getErrorProperties ("wrong type (expected = " + getType () + ", actual = "
113- + incomingProps .getString ("type" ));
55+ return getErrorProperties (
56+ "wrong type (expected = " + getType () + ", actual = " + incomingProps .getString ("type" ));
11457 }
11558 incomingProps = basicExecCommand (incomingProps );
11659 System .out .println ("ASwElement --> execCommand successfully completed" );
@@ -123,8 +66,7 @@ public TafProperties execCommand(TafProperties props) {
12366 try {
12467 Thread .sleep (200 );
12568 }
126- catch (Exception e2 ) {
127- }
69+ catch (Exception e2 ) {}
12870 }
12971 if (System .currentTimeMillis () > time + (TIMEOUT_FOR_EXECUTION_IN_SECONDS * 1000 )) {
13072 System .out .println ("ASwElement --> execCommand --> TIMED OUT" );
@@ -136,16 +78,6 @@ public TafProperties execCommand(TafProperties props) {
13678
13779 public abstract void fillProperties ();
13880
139- // public String getTagName() {
140- // if (tagName == null) {
141- // return "null-tag";
142- // }
143- // if (tagName.isEmpty()) {
144- // return "empty-tag-" + component.getClass().getSimpleName();
145- // }
146- // return tagName;
147- // }
148-
14981 public <T extends Enum <T >> T getCommand (Class <T > c , String command ) {
15082 if (c != null && command != null ) {
15183 try {
@@ -158,17 +90,34 @@ public <T extends Enum<T>> T getCommand(Class<T> c, String command) {
15890
15991 public abstract Component getComponent ();
16092
161- private TafProperties getDoneProperties (TafProperties props ) {
162- props .putObject ("status" , "done" );
163- return props ;
164- }
165-
166- private TafProperties getErrorProperties (String message ) {
167- TafProperties result = new TafProperties ();
168- result .putObject ("status" , "error" );
169- result .putObject ("message" , message );
170- return result ;
171- }
93+ // protected void click(Component c, int mask) {
94+ // if (c != null) {
95+ // if (c.getBounds().isEmpty()) {
96+ // System.out.println("Can't click --> has no bounds!");
97+ // return;
98+ // }
99+ // waitUntilReady();
100+ // Point upperLeft = c.getLocationOnScreen();
101+ // Rectangle bounds = new Rectangle(upperLeft.x, upperLeft.y, c.getWidth(), c.getHeight());
102+ // Point p = new Point(new Double(bounds.getCenterX()).intValue(), new Double(bounds.getCenterY()).intValue());
103+ // click(p, mask);
104+ // }
105+ // }
106+ //
107+ // protected void click(Point p, int mask) {
108+ // while (Toolkit.getDefaultToolkit().getSystemEventQueue().peekEvent() != null) {};
109+ // try {
110+ // System.out.println("Click auf " + p);
111+ // Robot robot = new Robot();
112+ // robot.mouseMove(p.x, p.y);
113+ // robot.mousePress(mask);
114+ // robot.delay(100);
115+ // robot.mouseRelease(mask);
116+ // }
117+ // catch (Exception e) {
118+ // e.printStackTrace();
119+ // }
120+ // }
172121
173122 public abstract AbstractComponentFixture getFixture ();
174123
@@ -186,6 +135,16 @@ public String getPropertiesAsString() {
186135 return attributes ;
187136 }
188137
138+ // public String getTagName() {
139+ // if (tagName == null) {
140+ // return "null-tag";
141+ // }
142+ // if (tagName.isEmpty()) {
143+ // return "empty-tag-" + component.getClass().getSimpleName();
144+ // }
145+ // return tagName;
146+ // }
147+
189148 @ Override
190149 public Component getReference () {
191150 return component ;
@@ -221,6 +180,46 @@ public String toString() {
221180 return "tagName=" + getType () + " " + component .toString ();
222181 }
223182
183+ protected void addProperty (String key , int value ) {
184+ addProperty (key , Integer .valueOf (value ).toString ());
185+ }
186+
187+ protected void addProperty (String key , long value ) {
188+ addProperty (key , Long .valueOf (value ).toString ());
189+ }
190+
191+ protected void addProperty (String key , String value ) {
192+ if ((key != null ) && (value != null )) {
193+ properties .putObject (key , value );
194+ }
195+ }
196+
197+ protected String asEscaped (String s ) {
198+ if (s == null ) {
199+ return s ;
200+ }
201+ return asEscapedString (s );
202+ }
203+
204+ protected String asEscapedXml (String s ) {
205+ if (s == null ) {
206+ return s ;
207+ }
208+ return asEscapedXmlString (s );
209+ }
210+
211+ private TafProperties getDoneProperties (TafProperties props ) {
212+ props .putObject ("status" , "done" );
213+ return props ;
214+ }
215+
216+ private TafProperties getErrorProperties (String message ) {
217+ TafProperties result = new TafProperties ();
218+ result .putObject ("status" , "error" );
219+ result .putObject ("message" , message );
220+ return result ;
221+ }
222+
224223 // public void waitUntilReady() {
225224 // while (Toolkit.getDefaultToolkit().getSystemEventQueue().peekEvent() != null) {}
226225 // ;
0 commit comments