|
|||||||||||||||||||
| Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
| JTableMouseEventDataTagHandler.java | - | 85.7% | 100% | 88.2% |
|
||||||||||||||
| 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.JTable;
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
/**
|
|
| 12 |
* This is a extension of the click and drag elements. Where the
|
|
| 13 |
* type specified is JTableMouseEventData.
|
|
| 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 specified.
|
|
| 19 |
* </p>
|
|
| 20 |
*
|
|
| 21 |
* <h3>Parameters</h3>
|
|
| 22 |
* <table border="1" cellpadding="2" cellspacing="0">
|
|
| 23 |
* <tr>
|
|
| 24 |
* <td valign="top"><b>Attribute</b></td>
|
|
| 25 |
* <td valign="top"><b>Description</b></td>
|
|
| 26 |
* <td align="center" valign="top"><b>Required</b></td>
|
|
| 27 |
* <td valign="top"><b>Default</b></td>
|
|
| 28 |
* <td valign="top"><b>Values</b></td>
|
|
| 29 |
* </tr>
|
|
| 30 |
* <tr>
|
|
| 31 |
* <td valign="top">type</td>
|
|
| 32 |
* <td valign="top">For this element the type must be set to JTableMouseEventData</td>
|
|
| 33 |
* <td valign="top" align="center">Yes</td>
|
|
| 34 |
* <td valign="top">N/A</td>
|
|
| 35 |
* <td valign="top">N/A</td>
|
|
| 36 |
* </tr>
|
|
| 37 |
* <tr>
|
|
| 38 |
* <td valign="top">refid</td>
|
|
| 39 |
* <td valign="top">Id of a object reference which has been previously found.</td>
|
|
| 40 |
* <td valign="top" align="center">Yes</td>
|
|
| 41 |
* <td valign="top">N/A</td>
|
|
| 42 |
* <td valign="top">N/A</td>
|
|
| 43 |
* </tr>
|
|
| 44 |
* <tr>
|
|
| 45 |
* <td valign="top">row</td>
|
|
| 46 |
* <td valign="top">Row index of the row.</td>
|
|
| 47 |
* <td valign="top" align="center">Yes</td>
|
|
| 48 |
* <td valign="top">N/A</td>
|
|
| 49 |
* <td valign="top">Zero is the first row.</td>
|
|
| 50 |
* </tr>
|
|
| 51 |
* <tr>
|
|
| 52 |
* <td valign="top">column</td>
|
|
| 53 |
* <td valign="top">Column index of the column.</td>
|
|
| 54 |
* <td valign="top" align="center">Yes</td>
|
|
| 55 |
* <td valign="top">N/A</td>
|
|
| 56 |
* <td valign="top">Zero is the first column.</td>
|
|
| 57 |
* </tr>
|
|
| 58 |
* <tr>
|
|
| 59 |
* <td valign="top">clicks</td>
|
|
| 60 |
* <td valign="top">The number of clicks to be executed.</td>
|
|
| 61 |
* <td valign="top" align="center">No</td>
|
|
| 62 |
* <td valign="top">1</td>
|
|
| 63 |
* <td valign="top">Positive Integer</td>
|
|
| 64 |
* </tr>
|
|
| 65 |
* <tr>
|
|
| 66 |
* <td valign="top">modifiers</td>
|
|
| 67 |
* <td valign="top">The modifiers to be used for this event.</td>
|
|
| 68 |
* <td valign="top" align="center">No</td>
|
|
| 69 |
* <td valign="top">Button1 if popup is false otherwise Button3</td>
|
|
| 70 |
* <td valign="top">alt altgr control meta shift button1 button2 button3</td>
|
|
| 71 |
* </tr>
|
|
| 72 |
* <tr>
|
|
| 73 |
* <td valign="top">popup</td>
|
|
| 74 |
* <td valign="top">True if this is event is using the popup button.</td>
|
|
| 75 |
* <td valign="top" align="center">No</td>
|
|
| 76 |
* <td valign="top">false</td>
|
|
| 77 |
* <td valign="top">true false</td>
|
|
| 78 |
* </tr>
|
|
| 79 |
* <tr>
|
|
| 80 |
* <td valign="top">sleeptime</td>
|
|
| 81 |
* <td valign="top">Maximum sleep time</td>
|
|
| 82 |
* <td valign="top" align="center">No</td>
|
|
| 83 |
* <td valign="top">500</td>
|
|
| 84 |
* <td valign="top">Positive Integer representing the milli-seconds</td>
|
|
| 85 |
* </tr>
|
|
| 86 |
* <tr>
|
|
| 87 |
* <td valign="top">position</td>
|
|
| 88 |
* <td valign="top">Positioning of the mouse within the bounds of the component.</td>
|
|
| 89 |
* <td valign="top" align="center">No</td>
|
|
| 90 |
* <td valign="top">center</td>
|
|
| 91 |
* <td valign="top">center north northeast east southeast south southwest west northwest custom percentage</td>
|
|
| 92 |
* </tr>
|
|
| 93 |
* <tr>
|
|
| 94 |
* <td valign="top">reference</td>
|
|
| 95 |
* <td valign="top">Reference point or number for position calculation.</td>
|
|
| 96 |
* <td valign="top" align="center">No</td>
|
|
| 97 |
* <td valign="top">null</td>
|
|
| 98 |
* <td valign="top">integers "x,y"</td>
|
|
| 99 |
* </tr>
|
|
| 100 |
*
|
|
| 101 |
* </table>
|
|
| 102 |
* <h3>Example</h3>
|
|
| 103 |
* <blockquote><pre>
|
|
| 104 |
* <click
|
|
| 105 |
* type="JTableMouseEventData"
|
|
| 106 |
* refid="Table"
|
|
| 107 |
* row="1"
|
|
| 108 |
* column="4"
|
|
| 109 |
* />
|
|
| 110 |
* </pre></blockquote>
|
|
| 111 |
* <p>
|
|
| 112 |
* The above clicks once on the center of the cell located at (1,4) of the table specified
|
|
| 113 |
* by the component identified by Table. This would be the 2nd row and 5th column.
|
|
| 114 |
* </p>
|
|
| 115 |
* @see junit.extensions.jfcunit.eventdata.JTableMouseEventData
|
|
| 116 |
* @author Kevin Wilson
|
|
| 117 |
*/
|
|
| 118 |
public class JTableMouseEventDataTagHandler extends BaseEventDataTagHandler { |
|
| 119 |
/**
|
|
| 120 |
* Constructor for JTableMouseEventDataTagHandler.
|
|
| 121 |
*
|
|
| 122 |
* @param element The element to be processed
|
|
| 123 |
* @param testCase The IXMLTestCase that uses this element
|
|
| 124 |
*/
|
|
| 125 | 67 |
public JTableMouseEventDataTagHandler(final Element element,
|
| 126 |
final IXMLTestCase testCase) {
|
|
| 127 | 67 |
super(element, testCase);
|
| 128 |
} |
|
| 129 |
|
|
| 130 |
/**
|
|
| 131 |
* @see junit.extensions.xml.elements.AbstractTagHandler#processElement()
|
|
| 132 |
* @throws XMLException if the node cannot be processed.
|
|
| 133 |
*/
|
|
| 134 | 67 |
public void processElement() throws XMLException { |
| 135 | 67 |
validateElement(); |
| 136 |
|
|
| 137 | 67 |
int row;
|
| 138 | 67 |
int column;
|
| 139 |
|
|
| 140 | 67 |
try {
|
| 141 | 67 |
row = getInt(ROW, -1); |
| 142 |
} catch (NumberFormatException nfe) {
|
|
| 143 | 0 |
throw new NumberFormatException("Row not specified properly"); |
| 144 |
} |
|
| 145 |
|
|
| 146 | 67 |
try {
|
| 147 | 67 |
column = getInt(COLUMN, -1); |
| 148 |
} catch (NumberFormatException nfe) {
|
|
| 149 | 0 |
throw new NumberFormatException("Column not specified properly"); |
| 150 |
} |
|
| 151 |
|
|
| 152 | 67 |
setEventData( |
| 153 |
new JTableMouseEventData(
|
|
| 154 |
getJFCTestCase(), |
|
| 155 |
(JTable) getComponent(), |
|
| 156 |
row, |
|
| 157 |
column, |
|
| 158 |
getClicks(), |
|
| 159 |
getModifiers(), |
|
| 160 |
getPopupTrigger(), |
|
| 161 |
getSleepTime(), |
|
| 162 |
getPosition(), |
|
| 163 |
getReference())); |
|
| 164 |
} |
|
| 165 |
|
|
| 166 |
/**
|
|
| 167 |
* @see junit.extensions.xml.elements.AbstractTagHandler#validateElement()
|
|
| 168 |
* @throws XMLException if the node cannot be processed.
|
|
| 169 |
*/
|
|
| 170 | 67 |
public void validateElement() throws XMLException { |
| 171 |
// do the default validations from the super class
|
|
| 172 | 67 |
super.validateElement();
|
| 173 |
|
|
| 174 |
// reqd attribute: row
|
|
| 175 | 67 |
checkRequiredAttribute(ROW); |
| 176 |
|
|
| 177 |
// reqd attribute: row
|
|
| 178 | 67 |
checkRequiredAttribute(COLUMN); |
| 179 |
} |
|
| 180 |
} |
|
| 181 |
|
|
||||||||||