1 19 20 31 32 33 package lib; 34 35 36 import java.io.File ; 37 import java.util.*; 38 import javax.swing.*; 39 import org.netbeans.jellytools.*; 40 import org.netbeans.jellytools.actions.*; 41 import org.netbeans.jellytools.nodes.*; 42 import org.netbeans.jellytools.nodes.Node; 43 import org.netbeans.jellytools.properties.*; 44 import org.netbeans.jemmy.*; 45 import org.netbeans.jemmy.operators.*; 46 import org.netbeans.junit.NbTestCase; 47 import org.netbeans.junit.ide.ProjectSupport; 48 49 50 55 public class PropertiesEditorTestCase extends JellyTestCase { 56 57 protected static final String defaultProjectName = "properties_test"; 58 private String projectName; 59 private String treeSubPackagePathToFile; 60 protected String treeSeparator = "|"; 61 protected String menuSeparator = "#"; 62 protected String defaultPackage = "<default package>"; 63 protected final String WIZARD_CATEGORY = "Standard"; 64 protected final String WIZARD_CATEGORY_FILE = "Other"; 65 protected final String WIZARD_FILE_TYPE = "Properties File"; 66 protected final String WIZARD_DEFAULT_PROPERTIES_FILE_NAME = "newproperties"; 67 68 71 private final String TITLE_ADD_LOCALE_DIALOG = ""; private final String TITLE_NEW_PROPERTY_DIALOG = ""; private final String TITLE_HELP_DIALOG = "Help"; 74 private final String TITLE_ERROR_DIALOG = ""; private final String TITLE_SAVE_QUESTION_DIALOG = ""; private final String TITLE_QUESTION_DIALOG = "Question"; private final String TITLE_CUSTOMIZE_LOCALES_DIALOG = ""; private final String TITLE_CUSTOMIZE_PROPERTIES_DIALOG = ""; private final String TITLE_DIALOG_CONFIRM_OBJECT_DELETION = ""; private final String TITLE_DELETE_MORE_LOCALES_CONFIRMATION_DIALOG = ""; private final String TITLE_WELCOME = ""; private final String TITLE_PROPERTIES_WINDOW_TABLE = ""; private final String TITLE_PROPERTIES_WINDOW_TAB = ""; 85 private final String BUTTON_NAME_NEW_PROPERTY = ""; private final String BUTTON_NAME_REMOVE_PROPERTY = ""; private final String BUTTON_NAME_REMOVE_LOCALE = ""; private final String BUTTON_NAME_ADD_LOCALE = ""; private final String BUTTON_NAME_ADD_KEY = ""; private final String BUTTON_NAME_REMOVE_KEY = ""; private final String BUTTON_NAME_YES = ""; private final String BUTTON_NAME_NO = ""; private final String BUTTON_NAME_DISCARD = "Discard"; 94 95 private final String POPUP_MENU_ADD_LOCALE = ""; private final String POPUP_MENU_CUSTOMIZE = ""; private final String POPUP_MENU_ADD_PROPERTY = ""; private final String POPUP_MENU_DELETE_LOCALE = ""; private final String POPUP_MENU_EDIT = ""; 101 private final String LABEL_KEY = ""; private final String LABLE_VALUE = ""; private final String RESOURCE_BUNDLE_COMMENT = " Sample ResourceBundle properties file\n\n"; 104 105 private final String EXCEPTION_TEXT = "Text typing"; 106 107 private final String WIZARD_TREE_STRING = ""; 109 110 111 public PropertiesEditorTestCase(String testMethodName) { 112 super(testMethodName); 113 } 114 115 116 117 124 protected void openProject(String projectName) { 125 this.projectName = projectName; 126 File projectPath = new File (this.getDataDir() + "/projects/", projectName); 127 log("data dir = "+this.getDataDir().toString()); 128 log("project path = "+projectPath.toString()); 129 130 131 ProjectsTabOperator pto = new ProjectsTabOperator(); 132 pto.invoke(); 133 log("treecount before = "+pto.tree().getChildCount(pto.tree().getRoot())); 134 int childCount = pto.tree().getChildCount(pto.tree().getRoot()); 135 for ( int i=0; i < childCount; i++ ) { 136 String str = pto.tree().getChild(pto.tree().getRoot(),i).toString(); 137 log("Found existed project in ProjectView: "+str); 138 if ( str.equals(projectName) ) { 139 log("Project "+projectName+" is open, but shoud not be!"); 140 return; 141 } 142 } 143 144 145 Object prj= ProjectSupport.openProject(projectPath); 146 log("treecount after = "+pto.tree().getChildCount(pto.tree().getRoot())); 147 148 149 pto.invoke(); 150 childCount = pto.tree().getChildCount(pto.tree().getRoot()); 151 for ( int i=0; i < childCount; i++ ) { 152 String str = pto.tree().getChild(pto.tree().getRoot(),i).toString(); 153 if ( str.equals(projectName) ) { 154 log("Project "+projectName+" is open. (Ok)"); 155 return; 156 } 157 } 158 log("Project is not open, but should be!"); 159 fail("Project is not open"); 160 } 161 162 163 protected void openDefaultProject() { 164 openProject(defaultProjectName); 165 } 166 167 168 protected Node getDefaultPackageNode() { 169 ProjectsTabOperator pto = new ProjectsTabOperator(); 170 pto.invoke(); 171 ProjectRootNode prn = pto.getProjectRootNode(projectName); 172 prn.select(); 173 Node node = new Node(prn,defaultPackage); 174 return node; 175 } 176 177 protected Node getNode(String packageName) { 178 ProjectsTabOperator pto = new ProjectsTabOperator(); 179 pto.invoke(); 180 ProjectRootNode prn = pto.getProjectRootNode(projectName); 181 prn.select(); 182 Node node = new Node(prn,"Source Packages"+treeSeparator+packageName); 183 return node; 184 } 185 186 196 public void openExistedPropertiesFile(String treeSubPackagePathToFile, String fileName) { 198 this.treeSubPackagePathToFile = "Source Packages"+this.treeSeparator+treeSubPackagePathToFile; 199 ProjectsTabOperator pto = new ProjectsTabOperator(); 200 pto.invoke(); 201 ProjectRootNode prn = pto.getProjectRootNode(projectName); 202 prn.select(); 203 Node node = new Node(prn,treeSubPackagePathToFile+treeSeparator+fileName); 204 node.performPopupAction("Open"); 205 } 206 207 208 212 public void openExistedPropetiesFileInClassicEditor(Node filesystemNode, String filePath) { 213 new EditAction().performPopup(new Node(filesystemNode,filePath)); 214 } 215 216 217 221 public void createNewPropertiesFile(Node node) { 222 NewFileWizardOperator newWizard = NewFileWizardOperator.invoke(node, this.WIZARD_CATEGORY, this.WIZARD_FILE_TYPE); 223 newWizard.finish(); 224 } 225 226 227 228 public void propertiesEditorClickNewPropertyButton(String fileName) { 229 JButtonOperator jButtonOperator = new JButtonOperator(new TopComponentOperator(fileName),this.BUTTON_NAME_NEW_PROPERTY); 230 jButtonOperator.pushNoBlock(); 231 new EventTool().waitNoEvent(250); 232 233 } 234 235 236 237 public void propertiesEditorClickRemovePropertyButton(String fileName) { 238 JButtonOperator jButtonOperator = new JButtonOperator(new TopComponentOperator(fileName),this.BUTTON_NAME_REMOVE_PROPERTY); 239 jButtonOperator.pushNoBlock(); 240 } 241 242 243 244 public void propertiesEditorCloseFromTabPane() throws Exception { 245 throw new Exception ("Do not use this method. Not defined in Operator yet"); 246 } 247 248 249 253 public void deletePropertiesFileFromExplorer(Node filesystemNode, String filePath) { 254 PropertiesNode propNode = new PropertiesNode(filesystemNode, filePath); 255 propNode.delete(); 256 new NbDialogOperator(this.TITLE_DIALOG_CONFIRM_OBJECT_DELETION).yes(); 257 258 } 259 260 261 265 public void closePropertiesFile(String fileName) { 266 EditorOperator eo = new EditorOperator(fileName); 267 eo.close(); 268 } 269 270 272 public void closeFiles() { 273 EditorOperator.closeDiscardAll(); 274 } 275 276 277 283 public void newPropertyDialogFill(String fileName, String key, String value, String comment) throws Exception { 284 new EventTool().waitNoEvent(250); 285 boolean finished = false; 286 do { 287 NbDialogOperator nbDialogOperator = new NbDialogOperator(this.TITLE_NEW_PROPERTY_DIALOG); 288 ContainerOperator containerOperator = new ContainerOperator(nbDialogOperator); 289 int limit = 0; 290 try { 291 292 JTextFieldOperator jTextFieldOperator = null; 293 if ( key != null ) { 294 jTextFieldOperator = new JTextFieldOperator(containerOperator, 0); 295 jTextFieldOperator.typeText(key); 296 } 297 if ( value != null ){ 298 jTextFieldOperator = new JTextFieldOperator(containerOperator, 1); 299 jTextFieldOperator.typeText(value); 300 } 301 if ( comment != null ){ 302 jTextFieldOperator = new JTextFieldOperator(containerOperator, 2); 303 jTextFieldOperator.typeText(comment); 304 } 305 306 finished = true; 307 308 } catch ( TimeoutExpiredException ex) { 309 newPropertyDialogClickCancelButton(); 314 propertiesEditorClickNewPropertyButton(fileName); 315 } 316 317 JButtonOperator bo = new JButtonOperator(containerOperator); 318 bo.requestFocus(); 319 320 if ( limit++ >= 3 ) 321 finished = true; 322 323 } while ( finished == false ); 324 } 325 326 327 330 public void newPropertyDialogClickCloseButton() { 331 NbDialogOperator nbDialogOperator = new NbDialogOperator(this.TITLE_NEW_PROPERTY_DIALOG); 332 nbDialogOperator.ok(); 335 System.out.println(">> Ok button pushed"); 336 } 337 338 339 340 public void newPropertyDialogClickOkButtonNoBlock() { 341 NbDialogOperator nbDialogOperator = new NbDialogOperator(this.TITLE_NEW_PROPERTY_DIALOG); 342 nbDialogOperator.ok(); 344 } 345 346 347 356 public void checkPropertiesInSheet(String fileName, String key, String value, String comment, int rowOfCheckedProperty, int localeCount, int rowCount) throws Exception { 357 358 if ( key == null ) 359 key = ""; 360 if ( value == null ) 361 value = ""; 362 if ( comment == null ) 363 comment = ""; 364 365 368 TopComponentOperator tco = new TopComponentOperator(fileName); 369 JTable jTable = JTableOperator.findJTable(tco.getContainer(ComponentSearcher.getTrueChooser("")),ComponentSearcher.getTrueChooser("")); 370 371 if ( rowOfCheckedProperty == 1 ) { 372 comment = this.RESOURCE_BUNDLE_COMMENT.concat(comment); 374 } 375 376 378 new JTableOperator(jTable).clickOnCell(rowOfCheckedProperty-1 ,1); 381 new EventTool().waitNoEvent(500); 382 384 new JTableOperator(jTable).clickOnCell(rowOfCheckedProperty-1 ,0); 385 386 JTextArea jTextArea = JTextAreaOperator.findJTextArea(tco.getContainer(ComponentSearcher.getTrueChooser("")),ComponentSearcher.getTrueChooser(""),0); 387 388 if ( jTextArea == null ) 389 System.out.println("> Comment textarea is null"); 390 else { 391 System.out.println("> Comment textarea is found."); 392 393 if ( ! jTextArea.getText().equals(comment) ) { 394 System.out.println("textarea == string : \""+jTextArea.getText()+"\" == \""+comment+"\""); 395 throw new Exception ("Comment is not equal to the specified string. (comparing in textarea under the table)"); 396 } else 397 System.out.println("> Comment is Ok in textarea under the table."); 398 } 399 400 if ( rowCount == 0 ) { 401 JLabel jLabel = JLabelOperator.findJLabel(tco.getContainer(ComponentSearcher.getTrueChooser("")),ComponentSearcher.getTrueChooser(""),1); 403 String label = jLabel.getText(); 404 System.out.println("> label = "+label); 405 if ( this.LABEL_KEY.equals(label) ) { 406 jTextArea = JTextAreaOperator.findJTextArea(tco.getContainer(ComponentSearcher.getTrueChooser("")),ComponentSearcher.getTrueChooser(""),1); 407 if ( jTextArea == null ) 408 System.out.println("> Key textarea is null"); 409 else { 410 System.out.println("> Key textarea is found."); 411 if ( ! jTextArea.getText().equals(key) ) { 412 System.out.println("textarea == string : "+jTextArea.getText()+" == "+key); 413 throw new Exception ("Key is not equal to the specified string. (comparing in textarea under the table)"); 414 } else 415 System.out.println("> Key is Ok in textarea under the table."); 416 } 417 } else if ( this.LABLE_VALUE.equals(label) ) { 418 jTextArea = JTextAreaOperator.findJTextArea(tco.getContainer(ComponentSearcher.getTrueChooser("")),ComponentSearcher.getTrueChooser(""),1); 419 if ( jTextArea == null ) 420 System.out.println("> Value textarea is null"); 421 else { 422 System.out.println("> Value textarea is found."); 423 if ( ! jTextArea.getText().equals(value) ) { 424 System.out.println("textarea == string : "+jTextArea.getText()+" == "+value); 425 throw new Exception ("Value is not equal to the specified string. (comparing in textarea under the table)"); 426 } else 427 System.out.println("> Value is Ok in textarea under the table."); 428 } 429 430 } else 431 throw new Exception ("Label of Key or Value textarea is corrupted!"); 432 433 434 } else { 435 System.out.println("More rows in table (rows>0)"); 436 System.out.println(">Click to row"+rowOfCheckedProperty); 438 new JTableOperator(jTable).clickOnCell(rowOfCheckedProperty-1,1); 440 441 jTextArea = JTextAreaOperator.findJTextArea(tco.getContainer(ComponentSearcher.getTrueChooser("")),ComponentSearcher.getTrueChooser(""),1); 442 if ( jTextArea == null ) 443 System.out.println("> Value textarea is null"); 444 else { 445 System.out.println("> Value textarea is found."); 446 if ( ! jTextArea.getText().equals(value) ) { 447 System.out.println("textarea == string : "+jTextArea.getText()+" == "+value); 448 throw new Exception ("Value is not equal to the specified string. (comparing in textarea under the table)"); 449 } else 450 System.out.println("> Value is Ok in textarea under the table."); 451 } 452 new JTableOperator(jTable).clickOnCell(rowOfCheckedProperty-1 ,0); 454 455 jTextArea = JTextAreaOperator.findJTextArea(tco.getContainer(ComponentSearcher.getTrueChooser("")),ComponentSearcher.getTrueChooser(""),1); 456 if ( jTextArea == null ) 457 System.out.println("> Key textarea is null"); 458 else { 459 System.out.println("> Key textarea is found."); 460 if ( ! jTextArea.getText().equals(key) ) { 461 System.out.println("textarea == string : "+jTextArea.getText()+" == "+key); 462 throw new Exception ("Key is not equal to the specified string. (comparing in textarea under the table)"); 463 } else 464 System.out.println("> Key is Ok in textarea under the table."); 465 } 466 467 } 468 469 471 new EventTool().waitNoEvent(250); 472 473 int index = -1; 475 476 if ( jTable != null ) { 477 478 if ( jTable.getRowCount() == rowCount && rowCount == 0 ) { 479 System.out.println("> There is no rows in table. (OK)"); 480 return; 481 } else 482 if ( rowCount == 0 ) 483 System.out.println("> Table shouldn't have any row!(There is "+jTable.getRowCount()+" rows)"); 484 485 if ( key != null ) 486 for ( int ii = 0; ii < jTable.getModel().getRowCount(); ii++) { 487 new EventTool().waitNoEvent(250); 489 if ( index >= 0 && jTable.getModel().getValueAt(ii,0).toString().equals(key) == true ) { 490 throw new Exception ("The added key is more times in properties sheet."); 491 } 492 493 if ( index == -1 && jTable.getModel().getValueAt(ii,0).toString().toString().equals(key) == true ) { 494 index = ii; 495 if ( jTable.getModel().getValueAt(ii,1).toString().toString().equals(value) == false ) 497 throw new Exception ("Value doesn't match. "+ ii +" - ("+ value + " not equals "+ jTable.getCellEditor(ii, 1).getCellEditorValue().toString() ); 498 new JTableOperator(jTable).clickOnCell(ii,0); 500 new EventTool().waitNoEvent(250); 501 502 if ( new JTextAreaOperator(new ContainerOperator(tco.getContainer(ComponentSearcher.getTrueChooser(""))),0).getText().equals(comment) == false ) 504 throw new Exception ("Comment doesn't match. "+ ii +" : \n>"+ comment + "< not equals with : >"+ new JTextAreaOperator(new ContainerOperator(tco.getContainer(ComponentSearcher.getTrueChooser(""))),0).getText()+"<\n" ); 505 506 if ( ii+1 != rowOfCheckedProperty ) 507 throw new Exception ("Property is not in the right row in property sheet."); 508 } 509 510 } 511 512 if ( index < 0 && rowOfCheckedProperty >= 0) 513 throw new Exception ("Key not found in properties sheet"); 514 515 if ( localeCount >= 0 && localeCount != jTable.getModel().getColumnCount() - 1 ) { 516 int locales = jTable.getModel().getColumnCount()-1; 517 throw new Exception ("Count of locales (columns-1) doesn't match. ("+ localeCount +"<>"+ locales +")"); 518 } 519 520 if ( rowCount >= 0 && rowCount != jTable.getModel().getRowCount() ) 521 throw new Exception ("Count of properties (rows) doesn't match. ("+rowCount+"<>"+jTable.getModel().getRowCount()+")"); 522 523 } else 524 throw new Exception ("Cann't find JTable in Editor Window"); 525 } 526 527 528 532 public void checkPropertiesFileIntegrityInClassicEditor(String fileName) throws Exception { 533 EditorOperator eo = new EditorOperator(fileName); 536 String content = eo.getText(); 537 StringTokenizer strT = new StringTokenizer(content,"\n",true); 538 String row = ""; 539 try { 540 for ( int ii = 0; ii < strT.countTokens(); ii++ ) { 541 if ( ii == 0 ) { 543 row = strT.nextToken(); 544 545 if ( row.charAt(0) != '#' ) 546 throw new Exception ("Structure of properties file has been corrupted"); 547 row = strT.nextToken(); 549 550 try { 551 row = strT.nextToken(); 553 } catch ( NoSuchElementException ex ) { 554 return; 556 } 557 558 } 559 560 row = strT.nextToken(); 562 563 if ( row.charAt(0) != '#' ) 565 throw new Exception ("Structure of properties file has been corrupted"); 566 567 row = strT.nextToken(); 569 570 571 row = strT.nextToken(); 573 StringTokenizer strT2 = new StringTokenizer(row); 574 String key = strT2.nextToken("=\n"); 575 String value = strT2.nextToken("=\n"); 576 if ( key == null || value == null ) 577 throw new Exception ("Structure of properties file has been corrupted"); 578 } 579 } catch ( NoSuchElementException ex ) { 580 throw new Exception ("Structure of properties file has been corrupted"); 581 } 582 583 } 584 585 586 587 public void newPropertyDialogClickHelpButton() { 588 NbDialogOperator nbDialogOperator = new NbDialogOperator(this.TITLE_NEW_PROPERTY_DIALOG); 589 nbDialogOperator.help(); 590 } 591 592 593 594 public void closeHelp() { 595 NbDialogOperator nbDialogOperator = new NbDialogOperator(this.TITLE_HELP_DIALOG); 596 nbDialogOperator.close(); 597 } 598 599 600 603 public void errorDialogClickOkButton() { 604 NbDialogOperator nbDialogOperator = new NbDialogOperator(this.TITLE_ERROR_DIALOG); 605 nbDialogOperator.ok(); 606 } 607 608 609 610 public void newPropertyDialogClickCancelButton() { 611 NbDialogOperator nbDialogOperator = new NbDialogOperator(this.TITLE_NEW_PROPERTY_DIALOG); 612 nbDialogOperator.cancel(); 613 } 614 615 616 620 public void selectPropertiesFileItem(String fileName, int rowNumber) throws Exception { 621 TopComponentOperator tco = new TopComponentOperator(fileName); 622 623 JTable jTable = JTableOperator.findJTable(tco.getContainer(ComponentSearcher.getTrueChooser("")),ComponentSearcher.getTrueChooser("")); 624 new EventTool().waitNoEvent(250); 625 627 if ( jTable != null ) { 628 JTableOperator jTableOperator = new JTableOperator(jTable); 629 jTableOperator.getTimeouts().setTimeout("JScrollBarOperator.WholeScrollTimeout", 240000); 630 jTableOperator.clickOnCell(rowNumber,1); 631 return; 632 } 633 throw new Exception ("Info : Cannot select item id properties table."); 634 } 635 636 637 642 public int getPropertiesFileItemsCount(String fileName) throws Exception { 643 TopComponentOperator tco = new TopComponentOperator(fileName); 644 645 JTable jTable = JTableOperator.findJTable(tco.getContainer(ComponentSearcher.getTrueChooser("")),ComponentSearcher.getTrueChooser("")); 646 new EventTool().waitNoEvent(250); 647 649 if ( jTable != null ) 650 return jTable.getModel().getRowCount(); 651 return -1; 652 653 } 654 655 656 657 public void questionDialogClickOkButton() { 658 NbDialogOperator nbDialogOperator = new NbDialogOperator(this.TITLE_SAVE_QUESTION_DIALOG); 659 nbDialogOperator.ok(); 660 } 661 662 public void questionDialogClickDiscardButton() { 663 QuestionDialogOperator qdo = new QuestionDialogOperator(TITLE_QUESTION_DIALOG); 664 JButtonOperator jbo = new JButtonOperator(qdo,BUTTON_NAME_DISCARD); 665 jbo.pushNoBlock(); 666 } 667 668 671 public void questionDialogClickCancelButton() { 672 NbDialogOperator nbDialogOperator = new NbDialogOperator(this.TITLE_SAVE_QUESTION_DIALOG); 673 nbDialogOperator.cancel(); 674 } 675 676 677 681 public void createNewPropertiesFileAndOpenInClassicEditor(Node node, String fileName) { 682 NewFileWizardOperator newWizard = NewFileWizardOperator.invoke(node, this.WIZARD_CATEGORY, this.WIZARD_FILE_TYPE); 684 new NewFileNameLocationStepOperator().setName(fileName); 685 newWizard.finish(); 686 687 new EventTool().waitNoEvent(250); 688 689 TopComponentOperator tco = new TopComponentOperator(fileName); 691 tco.close(); 692 705 ProjectsTabOperator pto = new ProjectsTabOperator(); 709 pto.invoke(); 710 ProjectRootNode prn = pto.getProjectRootNode(projectName); 711 prn.select(); 712 String packageName = node.getPath(); 713 new Node(prn, "Source Packages"+this.treeSeparator+packageName+this.treeSeparator+fileName).performPopupAction(this.POPUP_MENU_EDIT); 714 715 } 716 717 718 722 public void openAddLocaleDialogFromExplorer(Node filesystemNode,String filePath) { 723 new ActionNoBlock(null,this.POPUP_MENU_ADD_LOCALE).performPopup(new Node(filesystemNode,filePath)); 724 } 725 726 727 735 public void addLocaleDialogFill(String languageCode, String countryCode, String variant, Node filesystemNode, String fileName) throws Exception { 736 new EventTool().waitNoEvent(250); 737 boolean finished = false; 738 do { 739 try { 740 NbDialogOperator nbDialogOperator = new NbDialogOperator(this.TITLE_ADD_LOCALE_DIALOG); 741 JComboBoxOperator jComboBoxOperator; 743 jComboBoxOperator = new JComboBoxOperator(nbDialogOperator, 0); 744 if ( languageCode != null ) { 745 jComboBoxOperator.typeText(languageCode); 746 } else { 747 jComboBoxOperator.typeText(""); 748 } 749 jComboBoxOperator = new JComboBoxOperator(nbDialogOperator, 1); 750 if ( countryCode != null ){ 751 jComboBoxOperator.typeText(countryCode); 752 } else { 753 jComboBoxOperator.typeText(""); 754 } 755 jComboBoxOperator = new JComboBoxOperator(nbDialogOperator, 2); 756 if ( variant != null ){ 757 jComboBoxOperator.typeText(variant); 758 } else { 759 jComboBoxOperator.typeText(""); 760 } 761 finished = true; 762 System.out.println("Set languge: "+new JComboBoxOperator(nbDialogOperator, 0).getTextField().getText()); 763 System.out.println("Set country: "+new JComboBoxOperator(nbDialogOperator, 1).getTextField().getText()); 764 } catch ( TimeoutExpiredException ex) { 766 if ( ex.getMessage().equals(this.EXCEPTION_TEXT) == false ) 767 throw new Exception (ex.getMessage()); 768 addLocaleDialogClickCancelButton(); 771 openAddLocaleDialogFromExplorer(filesystemNode, fileName); 772 } 773 774 } while ( finished == false ); 775 new EventTool().waitNoEvent(250); 776 777 } 778 779 780 781 public void addLocaleDialogClickHelpButton() { 782 NbDialogOperator nbDialogOperator = new NbDialogOperator(this.TITLE_ADD_LOCALE_DIALOG); 783 nbDialogOperator.help(); 784 } 785 786 787 788 public void addLocaleDialogClickOkButtonNoBlock() { 789 NbDialogOperator nbDialogOperator = new NbDialogOperator(this.TITLE_ADD_LOCALE_DIALOG); 790 nbDialogOperator.ok(); 793 } 794 795 796 797 public void addLocaleDialogClickCancelButton() { 798 NbDialogOperator nbDialogOperator = new NbDialogOperator(this.TITLE_ADD_LOCALE_DIALOG); 799 nbDialogOperator.cancel(); 800 } 801 802 803 807 public void openCustomizeLocalesDialogFromExplorer(Node filesystemNode,String path) { 808 new ActionNoBlock(null,this.POPUP_MENU_CUSTOMIZE).performPopup(new Node(filesystemNode,path)); 809 } 810 811 812 813 public void customizeLocalesDialogClickAddLocaleButton() { 814 NbDialogOperator nbDialogOperator = new NbDialogOperator(this.TITLE_CUSTOMIZE_LOCALES_DIALOG); 815 JButtonOperator jButtonOperator = new JButtonOperator( new ContainerOperator(nbDialogOperator),this.BUTTON_NAME_ADD_LOCALE); 816 jButtonOperator.pushNoBlock(); 817 } 818 819 820 821 public void customizeLocalesDialogClickRemoveLocaleButton() { 822 NbDialogOperator nbDialogOperator = new NbDialogOperator(this.TITLE_CUSTOMIZE_LOCALES_DIALOG); 823 JButtonOperator jButtonOperator = new JButtonOperator( new ContainerOperator(nbDialogOperator),this.BUTTON_NAME_REMOVE_LOCALE); 824 jButtonOperator.pushNoBlock(); 825 } 826 827 828 829 public void customizeLocalesDialogClickHelpButton() { 830 NbDialogOperator nbDialogOperator = new NbDialogOperator(this.TITLE_CUSTOMIZE_LOCALES_DIALOG); 831 nbDialogOperator.help(); 833 } 834 835 836 837 public void customizeLocalesDialogClickCloseButton() { 838 NbDialogOperator nbDialogOperator = new NbDialogOperator(this.TITLE_CUSTOMIZE_LOCALES_DIALOG); 839 nbDialogOperator.close(); 841 } 842 843 844 847 public void customizeLocalesDialogSelectLocale(int row) { 848 NbDialogOperator nbDialogOperator = new NbDialogOperator(this.TITLE_CUSTOMIZE_LOCALES_DIALOG); 849 JListOperator jListOperator = new JListOperator( new ContainerOperator(nbDialogOperator) ); 850 jListOperator.selectItem(row-1); 851 } 852 853 854 857 public boolean customizeLocalesDialogIsEnabledRemoveLocaleButton() { 858 NbDialogOperator nbDialogOperator = new NbDialogOperator(this.TITLE_CUSTOMIZE_LOCALES_DIALOG); 859 JButtonOperator jButtonOperator = new JButtonOperator( new ContainerOperator(nbDialogOperator),this.BUTTON_NAME_REMOVE_LOCALE); 860 return jButtonOperator.isEnabled(); 861 } 862 863 864 868 public void openAddPropertyDialogFromExplorer(Node filesystemNode, String path) { 869 new ActionNoBlock(null,this.POPUP_MENU_ADD_PROPERTY).performPopup(new Node(filesystemNode,path)); 870 } 871 872 873 public void openCustomizePropertiesDialogFromExplorer(Node fileNode, String path) { 874 new ActionNoBlock(null,this.POPUP_MENU_CUSTOMIZE).performPopup(new Node(fileNode,path)); 875 } 876 877 878 public void customizePropertiesDialogClickHelpButton() { 879 NbDialogOperator nbDialogOperator = new NbDialogOperator(this.TITLE_CUSTOMIZE_PROPERTIES_DIALOG); 880 nbDialogOperator.help(); 882 } 883 884 885 public void customizePropertiesDialogClickCloseButton() { 886 NbDialogOperator nbDialogOperator = new NbDialogOperator(this.TITLE_CUSTOMIZE_PROPERTIES_DIALOG); 887 nbDialogOperator.close(); 889 } 890 891 892 public void customizePropertiesDialogClickAddKeyButton() { 893 NbDialogOperator nbDialogOperator = new NbDialogOperator(this.TITLE_CUSTOMIZE_PROPERTIES_DIALOG); 894 JButtonOperator jButtonOperator = new JButtonOperator( new ContainerOperator(nbDialogOperator),this.BUTTON_NAME_ADD_KEY); 895 jButtonOperator.pushNoBlock(); 896 } 897 898 899 public void customizePropertiesDialogClickRemovePropertyButton(){ 900 NbDialogOperator nbDialogOperator = new NbDialogOperator(this.TITLE_CUSTOMIZE_PROPERTIES_DIALOG); 901 JButtonOperator jButtonOperator = new JButtonOperator( new ContainerOperator(nbDialogOperator),this.BUTTON_NAME_REMOVE_KEY); 902 jButtonOperator.requestFocus(); 903 jButtonOperator.pushNoBlock(); 904 } 905 906 907 public boolean customizePropertiesDialogIsEnableRemovePropertyButton() { 908 NbDialogOperator nbDialogOperator = new NbDialogOperator(this.TITLE_CUSTOMIZE_PROPERTIES_DIALOG); 909 JButtonOperator jButtonOperator = new JButtonOperator( new ContainerOperator(nbDialogOperator),this.BUTTON_NAME_REMOVE_KEY); 910 return jButtonOperator.isEnabled(); 911 912 } 913 914 public void customizePropertiesDialogSelectProperty(int row) { 915 NbDialogOperator nbDialogOperator = new NbDialogOperator(this.TITLE_CUSTOMIZE_PROPERTIES_DIALOG); 916 JListOperator jListOperator = new JListOperator( new ContainerOperator(nbDialogOperator) ); 917 jListOperator.selectItem(row-1); 918 } 919 920 921 public void deleteLocaleFromExplorer(Node fileNode, String path) { 922 new ActionNoBlock(null,this.POPUP_MENU_DELETE_LOCALE).performPopup(new Node(fileNode,path)); 923 } 924 925 926 public void confirmationDeleteteLocaleDialogClickYes() { 927 NbDialogOperator nbDialogOperator = new NbDialogOperator(this.TITLE_DIALOG_CONFIRM_OBJECT_DELETION); 928 JButtonOperator jButtonOperator = new JButtonOperator( new ContainerOperator(nbDialogOperator),this.BUTTON_NAME_YES); 929 jButtonOperator.pushNoBlock(); 930 } 931 932 933 public void confirmationDeleteteMoreLocalesDialogClickYes() { 934 NbDialogOperator nbDialogOperator = new NbDialogOperator(this.TITLE_DELETE_MORE_LOCALES_CONFIRMATION_DIALOG); 935 JButtonOperator jButtonOperator = new JButtonOperator( new ContainerOperator(nbDialogOperator),this.BUTTON_NAME_YES); 936 jButtonOperator.pushNoBlock(); 937 } 938 939 940 public void confirmationDeleteteLocaleDialogClickNo() { 941 NbDialogOperator nbDialogOperator = new NbDialogOperator(this.TITLE_DIALOG_CONFIRM_OBJECT_DELETION); 942 JButtonOperator jButtonOperator = new JButtonOperator( new ContainerOperator(nbDialogOperator),this.BUTTON_NAME_NO); 943 jButtonOperator.pushNoBlock(); 944 } 945 946 947 public int checkEditorTabCount() { 948 return -1; 949 } 950 951 952 public void deleteMoreLocalesInExplorer(String [] Languages, String [] Countres, String [] Varians, Node fileNode, String path_to_group) { 953 954 Node[] nodes = new Node[Languages.length]; 955 for ( int ii = 0; ii < Languages.length; ii++ ) { 956 String path = path_to_group.concat("|").concat(Languages[ii]).concat("_").concat(Countres[ii]); 957 System.out.println(">> path = "+ path); 958 nodes[ii] = new Node(fileNode, path); 959 } 960 new DeleteAction().performPopup(nodes); 961 962 } 963 964 965 public void explorerSelectPath(String treePath, Node filesystemNode) { 966 Node node = new Node(filesystemNode,treePath); 967 node.select(); 968 } 969 970 971 public void propertiesWindowChangeProperty(String objectName, String propertyName, String newValue) { 972 PropertySheetOperator.invoke(); 973 PropertySheetOperator pso = new PropertySheetOperator(this.TITLE_PROPERTIES_WINDOW_TABLE.concat(objectName)); 974 StringProperty pr = new StringProperty(pso, propertyName); 976 pr.setValue(newValue); 977 new EventTool().waitNoEvent(250); 978 985 } 986 987 988 public void checkLocalesInExplorer(java.lang.String [] locales, Node filesystemNode, java.lang.String fileName) throws Exception { 989 new EventTool().waitNoEvent(300); 990 ProjectsTabOperator pto = new ProjectsTabOperator(); 992 pto.invoke(); 993 ProjectRootNode prn = pto.getProjectRootNode(projectName); 994 prn.select(); 995 Node node = new Node(prn,"Source Packages"+this.treeSeparator+fileName); 996 String [] strs = node.getChildren(); 997 if ( strs.length != locales.length ) { 998 throw new Exception ("> There is bad count of locales in Explorer window. ("+strs.length+"<>"+locales.length+")"); 999 } 1000 for ( int ii = 0 ; ii < locales.length; ii++) 1001 if ( strs[ii].compareTo(locales[ii]) != 0 ) 1002 throw new Exception ("> There is bad locale name in Explorer window. ("+strs[ii]+"<>"+locales[ii]+")"); 1003 1004 } 1005 1006 1007 public boolean existsFileInExplorer(String packageName, String fileName) { 1008 try { 1009 log("Testing name of file in Explorer : \""+fileName+"\""); 1010 ProjectsTabOperator pto = ProjectsTabOperator.invoke(); 1011 SourcePackagesNode sourcePackagesNode = new SourcePackagesNode(defaultProjectName); 1015 log("source node:"+sourcePackagesNode.getPath()); 1016 Node packageNode = new Node(sourcePackagesNode,packageName); 1017 log("package node:"+packageNode.getPath()); 1018 Node fileNode = new Node(packageNode,fileName); 1019 1020 log("Log: Found node "+fileNode.getText()); 1021 return true; 1022 } catch (TimeoutExpiredException ex) { 1023 return false; 1024 } 1025 } 1026 1027 public void requestFocusEditorPane(String nameOfTab) { 1028 TopComponentOperator tco = new TopComponentOperator(nameOfTab); 1029 tco.requestFocus(); 1030 1033 } 1034 1035 public void tableViewClickTo(String fileName, int row, int column) { 1036 TopComponentOperator tco = new TopComponentOperator(fileName); 1037 JTable jTable = JTableOperator.findJTable(tco.getContainer(ComponentSearcher.getTrueChooser("")),ComponentSearcher.getTrueChooser("")); 1038 new JTableOperator(jTable).clickOnCell(row,column); 1039 1040 } 1041 1042 1043 1044 1047 public boolean existsFileInEditor(String fileName) { 1048 try { 1049 log("Testing name of file in tab of Editor window : \""+fileName+"\""); 1050 EditorOperator ewo = new EditorOperator(fileName); 1051 ewo.close(); 1052 return true; 1053 } catch (TimeoutExpiredException ex) { 1054 return false; 1055 } 1056 1057 } 1058 1059} 1060 1061 | Popular Tags |