1 19 20 package org.netbeans.jellytools.modules.junit.dialogs; 21 22 import java.io.PrintStream ; 23 import org.netbeans.jellytools.Bundle; 24 import org.netbeans.jellytools.NbDialogOperator; 25 import org.netbeans.jemmy.operators.*; 26 27 32 public class CreateTestsDialogOperator extends NbDialogOperator { 33 34 36 public CreateTestsDialogOperator() { 37 super(Bundle.getString("org/netbeans/modules/junit/Bundle", "JUnitCfgOfCreate.Title")); 38 } 39 40 private JLabelOperator _lblFileSystem; 41 private JComboBoxOperator _cboFileSystem; 42 private JLabelOperator _lblSuiteClassTemplate; 43 private JLabelOperator _lblTestClass; 44 private JComboBoxOperator _cboSuiteClassTemplate; 45 public static final String ITEM_SIMPLEJUNITTEST = "SimpleJUnitTest"; 46 private JComboBoxOperator _cboTestClass; 47 private JCheckBoxOperator _cbPublicMethods; 48 private JCheckBoxOperator _cbProtectedMethods; 49 private JCheckBoxOperator _cbPackageMethods; 50 private JCheckBoxOperator _cbComments; 51 private JCheckBoxOperator _cbDefaultBodies; 52 private JCheckBoxOperator _cbJavaDoc; 53 private JCheckBoxOperator _cbIncludeExceptionClasses; 54 private JCheckBoxOperator _cbIncludeAbstractClasses; 55 private JCheckBoxOperator _cbGenerateSuites; 56 private JCheckBoxOperator _cbIncludePackagePrivateClasses; 57 private JCheckBoxOperator _cbShowCreateTestsConfigurationDialog; 58 59 60 64 67 public JLabelOperator lblFileSystem() { 68 if (_lblFileSystem==null) { 69 _lblFileSystem = new JLabelOperator(this, Bundle.getString("org/netbeans/modules/junit/Bundle", "JUnitCfgOfCreate.lblFileSystem.text")); 70 } 71 return _lblFileSystem; 72 } 73 74 77 public JComboBoxOperator cboFileSystem() { 78 if (_cboFileSystem==null) { 79 _cboFileSystem = new JComboBoxOperator(this); 80 } 81 return _cboFileSystem; 82 } 83 84 87 public JLabelOperator lblSuiteClass() { 88 if (_lblSuiteClassTemplate==null) { 89 _lblSuiteClassTemplate = new JLabelOperator(this, Bundle.getString("org/netbeans/modules/junit/Bundle", "JUnitCfgOfCreate.lblSuiteClass.text")); 90 } 91 return _lblSuiteClassTemplate; 92 } 93 94 97 public JLabelOperator lblTestClass() { 98 if (_lblTestClass==null) { 99 _lblTestClass = new JLabelOperator(this, Bundle.getString("org/netbeans/modules/junit/Bundle", "JUnitCfgOfCreate.lblTestClass.text")); 100 } 101 return _lblTestClass; 102 } 103 104 107 public JComboBoxOperator cboSuiteClass() { 108 if (_cboSuiteClassTemplate==null) { 109 _cboSuiteClassTemplate = new JComboBoxOperator(this, 1); 110 } 111 return _cboSuiteClassTemplate; 112 } 113 114 117 public JComboBoxOperator cboTestClass() { 118 if (_cboTestClass==null) { 119 _cboTestClass = new JComboBoxOperator(this, 2); 120 } 121 return _cboTestClass; 122 } 123 124 127 public JCheckBoxOperator cbPublicMethods() { 128 if (_cbPublicMethods==null) { 129 _cbPublicMethods = new JCheckBoxOperator(this, Bundle.getString("org/netbeans/modules/junit/Bundle", "JUnitCfgOfCreate.chkPublic.text")); 130 } 131 return _cbPublicMethods; 132 } 133 134 137 public JCheckBoxOperator cbProtectedMethods() { 138 if (_cbProtectedMethods==null) { 139 _cbProtectedMethods = new JCheckBoxOperator(this, Bundle.getString("org/netbeans/modules/junit/Bundle", "JUnitCfgOfCreate.chkProtected.text")); 140 } 141 return _cbProtectedMethods; 142 } 143 144 147 public JCheckBoxOperator cbPackageMethods() { 148 if (_cbPackageMethods==null) { 149 _cbPackageMethods = new JCheckBoxOperator(this, Bundle.getString("org/netbeans/modules/junit/Bundle", "JUnitCfgOfCreate.chkPackage.text")); 150 } 151 return _cbPackageMethods; 152 } 153 154 157 public JCheckBoxOperator cbComments() { 158 if (_cbComments==null) { 159 _cbComments = new JCheckBoxOperator(this, Bundle.getString("org/netbeans/modules/junit/Bundle", "JUnitCfgOfCreate.chkComments.text")); 160 } 161 return _cbComments; 162 } 163 164 167 public JCheckBoxOperator cbDefaultBodies() { 168 if (_cbDefaultBodies==null) { 169 _cbDefaultBodies = new JCheckBoxOperator(this, Bundle.getString("org/netbeans/modules/junit/Bundle", "JUnitCfgOfCreate.chkContent.text")); 170 } 171 return _cbDefaultBodies; 172 } 173 174 177 public JCheckBoxOperator cbJavaDoc() { 178 if (_cbJavaDoc==null) { 179 _cbJavaDoc = new JCheckBoxOperator(this, Bundle.getString("org/netbeans/modules/junit/Bundle", "JUnitCfgOfCreate.chkJavaDoc.text")); 180 } 181 return _cbJavaDoc; 182 } 183 184 187 public JCheckBoxOperator cbIncludeExceptionClasses() { 188 if (_cbIncludeExceptionClasses==null) { 189 _cbIncludeExceptionClasses = new JCheckBoxOperator(this, Bundle.getString("org/netbeans/modules/junit/Bundle", "JUnitCfgOfCreate.chkExceptions.text")); 190 } 191 return _cbIncludeExceptionClasses; 192 } 193 194 197 public JCheckBoxOperator cbIncludeAbstractClasses() { 198 if (_cbIncludeAbstractClasses==null) { 199 _cbIncludeAbstractClasses = new JCheckBoxOperator(this, Bundle.getString("org/netbeans/modules/junit/Bundle", "JUnitCfgOfCreate.chkAbstractImpl.text")); 200 } 201 return _cbIncludeAbstractClasses; 202 } 203 204 207 public JCheckBoxOperator cbGenerateSuites() { 208 if (_cbGenerateSuites==null) { 209 _cbGenerateSuites = new JCheckBoxOperator(this, Bundle.getString("org/netbeans/modules/junit/Bundle", "JUnitCfgOfCreate.chkGenerateSuites.text")); 210 } 211 return _cbGenerateSuites; 212 } 213 214 217 public JCheckBoxOperator cbIncludePackagePrivateClasses() { 218 if (_cbIncludePackagePrivateClasses==null) { 219 _cbIncludePackagePrivateClasses = new JCheckBoxOperator(this, Bundle.getString("org/netbeans/modules/junit/Bundle", "JUnitCfgOfCreate.chkPackagePrivateClasses.text")); 220 } 221 return _cbIncludePackagePrivateClasses; 222 } 223 224 227 public JCheckBoxOperator cbShowCreateTestsConfigurationDialog() { 228 if (_cbShowCreateTestsConfigurationDialog==null) { 229 _cbShowCreateTestsConfigurationDialog = new JCheckBoxOperator(this, Bundle.getString("org/netbeans/modules/junit/Bundle", "JUnitCfgOfCreate.chkEnabled.text")); 230 } 231 return _cbShowCreateTestsConfigurationDialog; 232 } 233 234 235 239 242 public String getSelectedFileSystem() { 243 return cboFileSystem().getSelectedItem().toString(); 244 } 245 246 249 public void selectFileSystem(String item) { 250 cboFileSystem().selectItem(item); 251 } 252 253 256 public void typeFileSystem(String text) { 257 cboFileSystem().typeText(text); 258 } 259 260 263 public String getSelectedSuiteClass() { 264 return cboSuiteClass().getSelectedItem().toString(); 265 } 266 267 270 public void selectSuiteClass(String item) { 271 cboSuiteClass().selectItem(item); 272 } 273 274 277 public void typeSuiteClass(String text) { 278 cboSuiteClass().typeText(text); 279 } 280 281 284 public String getSelectedTestClass() { 285 return cboTestClass().getSelectedItem().toString(); 286 } 287 288 291 public void selectTestClass(String item) { 292 cboTestClass().selectItem(item); 293 } 294 295 298 public void typeTestClass(String text) { 299 cboTestClass().typeText(text); 300 } 301 302 305 public void checkPublicMethods(boolean state) { 306 if (cbPublicMethods().isSelected()!=state) { 307 cbPublicMethods().push(); 308 } 309 } 310 311 314 public void checkProtectedMethods(boolean state) { 315 if (cbProtectedMethods().isSelected()!=state) { 316 cbProtectedMethods().push(); 317 } 318 } 319 320 323 public void checkPackageMethods(boolean state) { 324 if (cbPackageMethods().isSelected()!=state) { 325 cbPackageMethods().push(); 326 } 327 } 328 329 332 public void checkComments(boolean state) { 333 if (cbComments().isSelected()!=state) { 334 cbComments().push(); 335 } 336 } 337 338 341 public void checkDefaultBodies(boolean state) { 342 if (cbDefaultBodies().isSelected()!=state) { 343 cbDefaultBodies().push(); 344 } 345 } 346 347 350 public void checkJavaDoc(boolean state) { 351 if (cbJavaDoc().isSelected()!=state) { 352 cbJavaDoc().push(); 353 } 354 } 355 356 359 public void checkIncludeExceptionClasses(boolean state) { 360 if (cbIncludeExceptionClasses().isSelected()!=state) { 361 cbIncludeExceptionClasses().push(); 362 } 363 } 364 365 368 public void checkIncludeAbstractClasses(boolean state) { 369 if (cbIncludeAbstractClasses().isSelected()!=state) { 370 cbIncludeAbstractClasses().push(); 371 } 372 } 373 374 377 public void checkGenerateSuites(boolean state) { 378 if (cbGenerateSuites().isSelected()!=state) { 379 cbGenerateSuites().push(); 380 } 381 } 382 383 386 public void checkIncludePackagePrivateClasses(boolean state) { 387 if (cbIncludePackagePrivateClasses().isSelected()!=state) { 388 cbIncludePackagePrivateClasses().push(); 389 } 390 } 391 392 395 public void checkShowCreateTestsConfigurationDialog(boolean state) { 396 if (cbShowCreateTestsConfigurationDialog().isSelected()!=state) { 397 cbShowCreateTestsConfigurationDialog().push(); 398 } 399 } 400 401 402 406 408 public void verify() { 409 lblFileSystem(); 410 cboFileSystem(); 411 lblSuiteClass(); 412 lblTestClass(); 413 cboSuiteClass(); 414 cboTestClass(); 415 cbPublicMethods(); 416 cbProtectedMethods(); 417 cbPackageMethods(); 418 cbComments(); 419 cbDefaultBodies(); 420 cbJavaDoc(); 421 cbIncludeExceptionClasses(); 422 cbIncludeAbstractClasses(); 423 cbGenerateSuites(); 424 cbIncludePackagePrivateClasses(); 425 cbShowCreateTestsConfigurationDialog(); 426 } 427 428 431 public static void main(String args[]) { 432 new CreateTestsDialogOperator().verify(); 433 System.out.println("CreateTestsDialogOperator verification finished."); 434 } 435 436 public void dumpAll (PrintStream out, String fs) { 437 Object o = cboFileSystem().getSelectedItem(); 438 String str = (o != null) ? o.toString () : "<NULL_VALUE>"; 439 if (str.startsWith (fs)) 440 str = "<TARGET_FS>" + str.substring (fs.length ()); 441 out.println ("FileSystem: " + str); 442 out.println ("SuiteClass: " + cboSuiteClass().getSelectedItem()); 443 out.println ("TestClass: " + cboTestClass().getSelectedItem()); 444 out.println ("PublicMethod: " + cbPublicMethods().isSelected()); 445 out.println ("ProtectedMethod: " + cbProtectedMethods().isSelected()); 446 out.println ("PackageMethod: " + cbPackageMethods().isSelected()); 447 out.println ("IncludeAbstract: " + cbIncludeAbstractClasses().isSelected()); 448 out.println ("IncludeException: " + cbIncludeExceptionClasses().isSelected()); 449 out.println ("IncludePackagePrivateClass: " + cbIncludePackagePrivateClasses().isSelected()); 450 out.println ("Comments: " + cbComments().isSelected()); 451 out.println ("JavaDoc: " + cbJavaDoc().isSelected()); 452 out.println ("DefaultBodies: " + cbDefaultBodies().isSelected()); 453 out.println ("GenerateSuites: " + cbGenerateSuites().isSelected()); 454 out.println ("ShowDialog: " + cbShowCreateTestsConfigurationDialog().isSelected()); 455 } 456 457 } 458 | Popular Tags |