|
|||||||||||||||||||
Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
JTextComponentMouseEventDataTagHandler.java | 50% | 100% | 100% | 92.3% |
|
1 |
package junit.extensions.jfcunit.eventdata;
|
|
2 |
|
|
3 |
import junit.extensions.xml.IXMLTestCase;
|
|
4 |
import junit.extensions.xml.XMLException;
|
|
5 |
|
|
6 |
import org.w3c.dom.Element;
|
|
7 |
|
|
8 |
import javax.swing.text.JTextComponent;
|
|
9 |
|
|
10 |
|
|
11 |
/**
|
|
12 |
* This is a extension of the click and drag elements. Where the
|
|
13 |
* type specified is JTextComponentMouseEventData.
|
|
14 |
*
|
|
15 |
* <h3>Description</h3>
|
|
16 |
* <p>
|
|
17 |
* Nothing is invoked directly by this tag handler. The click and drag elements
|
|
18 |
* use this tag handler to customize the data specificly for the type JTextComponent.
|
|
19 |
* </p>
|
|
20 |
* <p>
|
|
21 |
* If the index attribute is used then positioning is overridden and based upon
|
|
22 |
* the text index into the component. Otherwise, the positioning is based on the
|
|
23 |
* screen area which is occupied by the component.
|
|
24 |
* </p>
|
|
25 |
*
|
|
26 |
* <h3>Parameters</h3>
|
|
27 |
* <table border="1" cellpadding="2" cellspacing="0">
|
|
28 |
* <tr>
|
|
29 |
* <td valign="top"><b>Attribute</b></td>
|
|
30 |
* <td valign="top"><b>Description</b></td>
|
|
31 |
* <td align="center" valign="top"><b>Required</b></td>
|
|
32 |
* <td valign="top"><b>Default</b></td>
|
|
33 |
* <td valign="top"><b>Values</b></td>
|
|
34 |
* </tr>
|
|
35 |
* <tr>
|
|
36 |
* <td valign="top">type</td>
|
|
37 |
* <td valign="top">For this element the type must be set to JTextComponentMouseEventData</td>
|
|
38 |
* <td valign="top" align="center">Yes</td>
|
|
39 |
* <td valign="top">N/A</td>
|
|
40 |
* <td valign="top">N/A</td>
|
|
41 |
* </tr>
|
|
42 |
* <tr>
|
|
43 |
* <td valign="top">refid</td>
|
|
44 |
* <td valign="top">Id of a object reference which has been previously found.</td>
|
|
45 |
* <td valign="top" align="center">Yes</td>
|
|
46 |
* <td valign="top">N/A</td>
|
|
47 |
* <td valign="top">N/A</td>
|
|
48 |
* </tr>
|
|
49 |
* <tr>
|
|
50 |
* <td valign="top">index</td>
|
|
51 |
* <td valign="top">Index into the text component.</td>
|
|
52 |
* <td valign="top" align="center">Yes</td>
|
|
53 |
* <td valign="top">N/A</td>
|
|
54 |
* <td valign="top">N/A</td>
|
|
55 |
* </tr>
|
|
56 |
* <tr>
|
|
57 |
* <td valign="top">clicks</td>
|
|
58 |
* <td valign="top">The number of clicks to be executed.</td>
|
|
59 |
* <td valign="top" align="center">No</td>
|
|
60 |
* <td valign="top">1</td>
|
|
61 |
* <td valign="top">Positive Integer</td>
|
|
62 |
* </tr>
|
|
63 |
* <tr>
|
|
64 |
* <td valign="top">modifiers</td>
|
|
65 |
* <td valign="top">The modifiers to be used for this event.</td>
|
|
66 |
* <td valign="top" align="center">No</td>
|
|
67 |
* <td valign="top">Button1 if popup is false otherwise Button3</td>
|
|
68 |
* <td valign="top">alt altgr control meta shift button1 button2 button3</td>
|
|
69 |
* </tr>
|
|
70 |
* <tr>
|
|
71 |
* <td valign="top">popup</td>
|
|
72 |
* <td valign="top">True if this is event is using the popup button.</td>
|
|
73 |
* <td valign="top" align="center">No</td>
|
|
74 |
* <td valign="top">false</td>
|
|
75 |
* <td valign="top">true false</td>
|
|
76 |
* </tr>
|
|
77 |
* <tr>
|
|
78 |
* <td valign="top">sleeptime</td>
|
|
79 |
* <td valign="top">Maximum sleep time</td>
|
|
80 |
* <td valign="top" align="center">No</td>
|
|
81 |
* <td valign="top">500</td>
|
|
82 |
* <td valign="top">Positive Integer representing the milli-seconds</td>
|
|
83 |
* </tr>
|
|
84 |
* <tr>
|
|
85 |
* <td valign="top">position</td>
|
|
86 |
* <td valign="top">Positioning of the mouse within the bounds of the component.</td>
|
|
87 |
* <td valign="top" align="center">No</td>
|
|
88 |
* <td valign="top">center</td>
|
|
89 |
* <td valign="top">center north northeast east southeast south southwest west northwest custom percentage</td>
|
|
90 |
* </tr>
|
|
91 |
* <tr>
|
|
92 |
* <td valign="top">reference</td>
|
|
93 |
* <td valign="top">Reference point or number for position calculation.</td>
|
|
94 |
* <td valign="top" align="center">No</td>
|
|
95 |
* <td valign="top">null</td>
|
|
96 |
* <td valign="top">integers "x,y"</td>
|
|
97 |
* </tr>
|
|
98 |
*
|
|
99 |
* </table>
|
|
100 |
* <h3>Example</h3>
|
|
101 |
* <blockquote><pre>
|
|
102 |
* <click
|
|
103 |
* type="JTextComponentMouseEventData"
|
|
104 |
* refid="TextComponent"
|
|
105 |
* index="4"
|
|
106 |
* />
|
|
107 |
* </pre></blockquote>
|
|
108 |
* <p>
|
|
109 |
* The above clicks once between the 4th and 5th characters of the
|
|
110 |
* text component.
|
|
111 |
* </p>
|
|
112 |
* @see junit.extensions.jfcunit.eventdata.JTextComponentMouseEventData
|
|
113 |
* @author Kevin Wilson
|
|
114 |
*/
|
|
115 |
public class JTextComponentMouseEventDataTagHandler |
|
116 |
extends BaseEventDataTagHandler {
|
|
117 |
/**
|
|
118 |
* Constructor for JTextComponentMouseEventDataTagHandler.
|
|
119 |
*
|
|
120 |
* @param element The element to be processed
|
|
121 |
* @param testCase The IXMLTestCase that uses this element
|
|
122 |
*/
|
|
123 | 5 |
public JTextComponentMouseEventDataTagHandler(final Element element,
|
124 |
final IXMLTestCase testCase) { |
|
125 | 5 |
super(element, testCase);
|
126 |
} |
|
127 |
|
|
128 |
/**
|
|
129 |
* @see junit.extensions.xml.elements.AbstractTagHandler#processElement()
|
|
130 |
* @throws XMLException provided for contract only.
|
|
131 |
*/
|
|
132 | 5 |
public void processElement() throws XMLException { |
133 | 5 |
validateElement(); |
134 |
|
|
135 | 5 |
int position = getPosition();
|
136 | 5 |
int offset = getOffset();
|
137 |
|
|
138 | 5 |
if (offset != INVALID_TEXT_OFFSET) {
|
139 | 5 |
position = OFFSET; |
140 |
} |
|
141 |
|
|
142 | 5 |
setEventData( |
143 |
new JTextComponentMouseEventData(
|
|
144 |
getJFCTestCase(), |
|
145 |
(JTextComponent) getComponent(), |
|
146 |
getClicks(), |
|
147 |
getModifiers(), |
|
148 |
getPopupTrigger(), |
|
149 |
getSleepTime(), |
|
150 |
position, |
|
151 |
getReference(), |
|
152 |
offset)); |
|
153 |
} |
|
154 |
|
|
155 |
/**
|
|
156 |
* @see junit.extensions.xml.elements.AbstractTagHandler#validateElement()
|
|
157 |
* @throws XMLException provided for contract only.
|
|
158 |
*/
|
|
159 | 5 |
public void validateElement() throws XMLException { |
160 |
// do the default validations from the super class
|
|
161 | 5 |
super.validateElement();
|
162 |
} |
|
163 |
} |
|
164 |
|
|