Source Code Cross Referenced for PropertiesEditorTestCase.java in  » IDE-Netbeans » properties » lib » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » IDE Netbeans » properties » lib 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


0001:        /*
0002:         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
0003:         *
0004:         * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
0005:         *
0006:         * The contents of this file are subject to the terms of either the GNU
0007:         * General Public License Version 2 only ("GPL") or the Common
0008:         * Development and Distribution License("CDDL") (collectively, the
0009:         * "License"). You may not use this file except in compliance with the
0010:         * License. You can obtain a copy of the License at
0011:         * http://www.netbeans.org/cddl-gplv2.html
0012:         * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
0013:         * specific language governing permissions and limitations under the
0014:         * License.  When distributing the software, include this License Header
0015:         * Notice in each file and include the License file at
0016:         * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
0017:         * particular file as subject to the "Classpath" exception as provided
0018:         * by Sun in the GPL Version 2 section of the License file that
0019:         * accompanied this code. If applicable, add the following below the
0020:         * License Header, with the fields enclosed by brackets [] replaced by
0021:         * your own identifying information:
0022:         * "Portions Copyrighted [year] [name of copyright owner]"
0023:         *
0024:         * Contributor(s):
0025:         *
0026:         * The Original Software is NetBeans. The Initial Developer of the Original
0027:         * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
0028:         * Microsystems, Inc. All Rights Reserved.
0029:         *
0030:         * If you wish your version of this file to be governed by only the CDDL
0031:         * or only the GPL Version 2, indicate your decision by adding
0032:         * "[Contributor] elects to include this software in this distribution
0033:         * under the [CDDL or GPL Version 2] license." If you do not indicate a
0034:         * single choice of license, a recipient has the option to distribute
0035:         * your version of this file under either the CDDL, the GPL Version 2 or
0036:         * to extend the choice of license to its licensees as provided above.
0037:         * However, if you add GPL Version 2 code and therefore, elected the GPL
0038:         * Version 2 license, then the option applies only if the new code is
0039:         * made subject to such option by the copyright holder.
0040:         */
0041:
0042:        /*
0043:         * File PropertiesEditorOperator.java
0044:         *
0045:         * Created on 24.9.02 18:18
0046:         *
0047:         * Description :
0048:         *
0049:         * This is operator used in autometed tests. Operator has been
0050:         * writed in Jelly2
0051:         *
0052:         */
0053:
0054:        package lib;
0055:
0056:        import java.io.File;
0057:        import java.util.*;
0058:        import javax.swing.*;
0059:        import org.netbeans.jellytools.*;
0060:        import org.netbeans.jellytools.actions.*;
0061:        import org.netbeans.jellytools.nodes.*;
0062:        import org.netbeans.jellytools.nodes.Node;
0063:        import org.netbeans.jellytools.properties.*;
0064:        import org.netbeans.jemmy.*;
0065:        import org.netbeans.jemmy.operators.*;
0066:        import org.netbeans.junit.NbTestCase;
0067:        import org.netbeans.junit.ide.ProjectSupport;
0068:
0069:        /** Class implementing all necessary methods for handling Property sheet in Editor window.
0070:         * This class is used for automated tests of properties module.
0071:         * @author Petr Felenda ( e-mail petr.felenda@sun.com )
0072:         * @version 1
0073:         */
0074:        public class PropertiesEditorTestCase extends JellyTestCase {
0075:
0076:            protected static final String defaultProjectName = "properties_test";
0077:            private String projectName;
0078:            private String treeSubPackagePathToFile;
0079:            protected String treeSeparator = "|";
0080:            protected String menuSeparator = "#";
0081:            protected String defaultPackage = "<default package>";
0082:            protected final String WIZARD_CATEGORY = "Standard";
0083:            protected final String WIZARD_CATEGORY_FILE = "Other";
0084:            protected final String WIZARD_FILE_TYPE = "Properties File";
0085:            protected final String WIZARD_DEFAULT_PROPERTIES_FILE_NAME = "newproperties";
0086:
0087:            /*
0088:             * declaration of members variables
0089:             */
0090:            private final String TITLE_ADD_LOCALE_DIALOG = "";//Bundle.getStringTrimmed("org.netbeans.modules.properties.Bundle", "CTL_NewLocaleTitle");    // String : New Locale
0091:            private final String TITLE_NEW_PROPERTY_DIALOG = "";//Bundle.getStringTrimmed("org.netbeans.modules.properties.Bundle", "CTL_NewPropertyTitle");    // String : New Property
0092:            private final String TITLE_HELP_DIALOG = "Help";
0093:            private final String TITLE_ERROR_DIALOG = "";//Bundle.getStringTrimmed("org.openide.Bundle", "NTF_ErrorTitle");  // String : Error
0094:            private final String TITLE_SAVE_QUESTION_DIALOG = "";//Bundle.getStringTrimmed("org.openide.text.Bundle", "LBL_SaveFile_Title");    // String : Question
0095:            private final String TITLE_QUESTION_DIALOG = "Question"; // String : Question
0096:            private final String TITLE_CUSTOMIZE_LOCALES_DIALOG = "";//Bundle.getStringTrimmed("org.netbeans.core.Bundle", "CTL_Customizer_dialog_title");  // String : Customizer Dialog
0097:            private final String TITLE_CUSTOMIZE_PROPERTIES_DIALOG = "";//Bundle.getStringTrimmed("org.netbeans.core.Bundle", "CTL_Customizer_dialog_title");   // The same string as last one
0098:            private final String TITLE_DIALOG_CONFIRM_OBJECT_DELETION = "";//Bundle.getStringTrimmed("org.openide.explorer.Bundle", "MSG_ConfirmDeleteObjectTitle");    // String : Confirm Object deletion
0099:            private final String TITLE_DELETE_MORE_LOCALES_CONFIRMATION_DIALOG = "";//Bundle.getStringTrimmed("org.openide.explorer.Bundle", "MSG_ConfirmDeleteObjectsTitle");    // String : Confirm Multiple Object Deletion
0100:            private final String TITLE_WELCOME = "";//Bundle.getStringTrimmed("org.netbeans.modules.welcome.Bundle", "LBL_Tab_Title"); // String Welcome
0101:            private final String TITLE_PROPERTIES_WINDOW_TABLE = "";//Bundle.getStringTrimmed("org.netbeans.core.Bundle", "CTL_FMT_GlobalProperties");  // String : Properties of
0102:            private final String TITLE_PROPERTIES_WINDOW_TAB = "";//Bundle.getStringTrimmed("org.openide.nodes.Bundle", "Properties");    // String : Properties
0103:
0104:            private final String BUTTON_NAME_NEW_PROPERTY = "";//Bundle.getStringTrimmed("org.netbeans.modules.properties.Bundle", "LBL_AddPropertyButton"); // String : New Property
0105:            private final String BUTTON_NAME_REMOVE_PROPERTY = "";//Bundle.getStringTrimmed("org.netbeans.modules.properties.Bundle", "LBL_RemovePropertyButton");   // String : Remove Property
0106:            private final String BUTTON_NAME_REMOVE_LOCALE = "";//Bundle.getStringTrimmed("org.netbeans.modules.properties.Bundle", "CTL_RemoveLocale");   // String : Remove Locale
0107:            private final String BUTTON_NAME_ADD_LOCALE = "";//Bundle.getStringTrimmed("org.netbeans.modules.properties.Bundle", "CTL_AddLocale"); // String : Add Locale
0108:            private final String BUTTON_NAME_ADD_KEY = "";//Bundle.getStringTrimmed("org.netbeans.modules.properties.Bundle", "CTL_AddKey");   // String : Add Key
0109:            private final String BUTTON_NAME_REMOVE_KEY = "";//Bundle.getStringTrimmed("org.netbeans.modules.properties.Bundle", "CTL_RemoveKey"); // String : Remove Key
0110:            private final String BUTTON_NAME_YES = "";//Bundle.getStringTrimmed("org.netbeans.core.Bundle", "YES_OPTION_CAPTION");   // String : Yes
0111:            private final String BUTTON_NAME_NO = "";//Bundle.getStringTrimmed("org.netbeans.core.Bundle", "NO_OPTION_CAPTION"); // String : No
0112:            private final String BUTTON_NAME_DISCARD = "Discard";
0113:
0114:            private final String POPUP_MENU_ADD_LOCALE = "";//Bundle.getStringTrimmed("org.openide.actions.Bundle", "NewArg")+Bundle.getStringTrimmed("org.netbeans.modules.properties.Bundle", "LAB_NewLocaleAction");   // String : Add Locale...
0115:            private final String POPUP_MENU_CUSTOMIZE = "";//Bundle.getStringTrimmed("org.openide.actions.Bundle", "Customize");    // String : Customize
0116:            private final String POPUP_MENU_ADD_PROPERTY = "";//Bundle.getStringTrimmed("org.openide.actions.Bundle", "NewArg")+Bundle.getStringTrimmed("org.netbeans.modules.properties.Bundle", "LAB_NewPropertyAction");  // String : Add Property
0117:            private final String POPUP_MENU_DELETE_LOCALE = "";//Bundle.getStringTrimmed("org.openide.actions.Bundle", "Delete");;   // String : Delete
0118:            private final String POPUP_MENU_EDIT = "";//Bundle.getStringTrimmed("org.openide.actions.Bundle", "Edit");  // String : Edit
0119:
0120:            private final String LABEL_KEY = "";//Bundle.getStringTrimmed("org.netbeans.modules.properties.Bundle", "LBL_KeyLabel"); // String : Key
0121:            private final String LABLE_VALUE = "";//Bundle.getStringTrimmed("org.netbeans.modules.properties.Bundle", "LBL_ValueLabel"); // String : Value
0122:            private final String RESOURCE_BUNDLE_COMMENT = " Sample ResourceBundle properties file\n\n";
0123:
0124:            private final String EXCEPTION_TEXT = "Text typing";
0125:
0126:            private final String WIZARD_TREE_STRING = "";//Bundle.getStringTrimmed("org.netbeans.modules.text.Bundle", "Templates/Other")+"|"+Bundle.getStringTrimmed("org.netbeans.modules.properties.Bundle", "Templates/Other/properties.properties"); // String : "Other|Properties File";
0127:
0128:            /** This constructor only creates operator's object and then does nothing. */
0129:            public PropertiesEditorTestCase(String testMethodName) {
0130:                super (testMethodName);
0131:            }
0132:
0133:            /** This method open project.
0134:             * 1) It is checked if the project is open
0135:             * before the project is opened.
0136:             * 2) open project
0137:             * 3) check if project is open
0138:             * @param projectName is name of the project stored in .../editor/test/qa-functional/data/ directory.
0139:             */
0140:            protected void openProject(String projectName) {
0141:                this .projectName = projectName;
0142:                File projectPath = new File(this .getDataDir() + "/projects/",
0143:                        projectName);
0144:                log("data dir = " + this .getDataDir().toString());
0145:                log("project path = " + projectPath.toString());
0146:
0147:                /* 1. check if project is open  */
0148:                ProjectsTabOperator pto = new ProjectsTabOperator();
0149:                pto.invoke();
0150:                log("treecount before = "
0151:                        + pto.tree().getChildCount(pto.tree().getRoot()));
0152:                int childCount = pto.tree().getChildCount(pto.tree().getRoot());
0153:                for (int i = 0; i < childCount; i++) {
0154:                    String str = pto.tree().getChild(pto.tree().getRoot(), i)
0155:                            .toString();
0156:                    log("Found existed project in ProjectView: " + str);
0157:                    if (str.equals(projectName)) {
0158:                        log("Project " + projectName
0159:                                + " is open, but shoud not be!");
0160:                        return;
0161:                    }
0162:                }
0163:
0164:                /* 2. open project */
0165:                Object prj = ProjectSupport.openProject(projectPath);
0166:                log("treecount after  = "
0167:                        + pto.tree().getChildCount(pto.tree().getRoot()));
0168:
0169:                /* 3. check the project name */
0170:                pto.invoke();
0171:                childCount = pto.tree().getChildCount(pto.tree().getRoot());
0172:                for (int i = 0; i < childCount; i++) {
0173:                    String str = pto.tree().getChild(pto.tree().getRoot(), i)
0174:                            .toString();
0175:                    if (str.equals(projectName)) {
0176:                        log("Project " + projectName + " is open. (Ok)");
0177:                        return;
0178:                    }
0179:                }
0180:                log("Project is not open, but should be!");
0181:                fail("Project is not open");
0182:            }
0183:
0184:            protected void openDefaultProject() {
0185:                openProject(defaultProjectName);
0186:            }
0187:
0188:            protected Node getDefaultPackageNode() {
0189:                ProjectsTabOperator pto = new ProjectsTabOperator();
0190:                pto.invoke();
0191:                ProjectRootNode prn = pto.getProjectRootNode(projectName);
0192:                prn.select();
0193:                Node node = new Node(prn, defaultPackage);
0194:                return node;
0195:            }
0196:
0197:            protected Node getNode(String packageName) {
0198:                ProjectsTabOperator pto = new ProjectsTabOperator();
0199:                pto.invoke();
0200:                ProjectRootNode prn = pto.getProjectRootNode(projectName);
0201:                prn.select();
0202:                Node node = new Node(prn, "Source Packages" + treeSeparator
0203:                        + packageName);
0204:                return node;
0205:            }
0206:
0207:            /** This method opens file in editor. There is used popup menu in explorer.<br>
0208:             * Usage :<br>
0209:             * FilesystemNode filesystemNode = new FilesystemNode(<br>
0210:             *      System.getProperty("netbeans.user") + <br>
0211:             *       File.separator + <br>
0212:             *       "sampledir");<br>
0213:             * <br>
0214:             * openExistedPropertiesFile(filesystemNode.getPath()+"|"+"myFile");<br>
0215:             * @param filePath of existed file in explorer ( without extension )
0216:             */
0217:            // public void openExistedPropertiesFile(String filePath) {
0218:            public void openExistedPropertiesFile(
0219:                    String treeSubPackagePathToFile, String fileName) {
0220:                this .treeSubPackagePathToFile = "Source Packages"
0221:                        + this .treeSeparator + treeSubPackagePathToFile;
0222:                ProjectsTabOperator pto = new ProjectsTabOperator();
0223:                pto.invoke();
0224:                ProjectRootNode prn = pto.getProjectRootNode(projectName);
0225:                prn.select();
0226:                Node node = new Node(prn, treeSubPackagePathToFile
0227:                        + treeSeparator + fileName);
0228:                node.performPopupAction("Open");
0229:            }
0230:
0231:            /** This method opens file in editor. There is used popup menu in explorer for this action.
0232:             * @param filesystemNode of mounted directory ( without extension )
0233:             * @param filePath of file in explorer tree
0234:             */
0235:            public void openExistedPropetiesFileInClassicEditor(
0236:                    Node filesystemNode, String filePath) {
0237:                new EditAction()
0238:                        .performPopup(new Node(filesystemNode, filePath));
0239:            }
0240:
0241:            /** It creates new property file. There is used popup menu from explorer.
0242:             * @param filesystemNode node of tree, where file will be created
0243:             * @param filePath of file without extension
0244:             */
0245:            public void createNewPropertiesFile(Node node) {
0246:                NewFileWizardOperator newWizard = NewFileWizardOperator.invoke(
0247:                        node, this .WIZARD_CATEGORY, this .WIZARD_FILE_TYPE);
0248:                newWizard.finish();
0249:            }
0250:
0251:            /** It clicks to the 'New property' button in properties editor ( table view ) */
0252:            public void propertiesEditorClickNewPropertyButton(String fileName) {
0253:                JButtonOperator jButtonOperator = new JButtonOperator(
0254:                        new TopComponentOperator(fileName),
0255:                        this .BUTTON_NAME_NEW_PROPERTY);
0256:                jButtonOperator.pushNoBlock();
0257:                new EventTool().waitNoEvent(250);
0258:
0259:            }
0260:
0261:            /** This pushs 'Remove property' button in properties editor form. */
0262:            public void propertiesEditorClickRemovePropertyButton(
0263:                    String fileName) {
0264:                JButtonOperator jButtonOperator = new JButtonOperator(
0265:                        new TopComponentOperator(fileName),
0266:                        this .BUTTON_NAME_REMOVE_PROPERTY);
0267:                jButtonOperator.pushNoBlock();
0268:            }
0269:
0270:            /** This opens popup menu over tab in properties file and chooses close item from it. */
0271:            public void propertiesEditorCloseFromTabPane() throws Exception {
0272:                throw new Exception(
0273:                        "Do not use this method. Not defined in Operator yet");
0274:            }
0275:
0276:            /** This deletes properties file from disk. There is used popup menu in Explorer.
0277:             * @param filesystemNode of tree, where file is stored ( without file name )
0278:             * @param filePath of file to delete
0279:             */
0280:            public void deletePropertiesFileFromExplorer(Node filesystemNode,
0281:                    String filePath) {
0282:                PropertiesNode propNode = new PropertiesNode(filesystemNode,
0283:                        filePath);
0284:                propNode.delete();
0285:                new NbDialogOperator(this .TITLE_DIALOG_CONFIRM_OBJECT_DELETION)
0286:                        .yes();
0287:
0288:            }
0289:
0290:            /** This closes properties file. There is used popup menu in Explorer.
0291:             * @param filesystemNode of tree, where file is stored ( without file name )
0292:             * @param filePath of file to delete
0293:             */
0294:            public void closePropertiesFile(String fileName) {
0295:                EditorOperator eo = new EditorOperator(fileName);
0296:                eo.close();
0297:            }
0298:
0299:            /** This close all files in editor. This method should be called in teardown method
0300:             */
0301:            public void closeFiles() {
0302:                EditorOperator.closeDiscardAll();
0303:            }
0304:
0305:            /** This fill three textafields in 'New property' dialog.
0306:             * @param key which will be filled to appeared dialog 'New property'
0307:             * @param value of key, which will be filled to appeared dialog 'New property'
0308:             * @param comment of key, which will be filles to appeared dialog 'New property'
0309:             * @throws Exception is throws if appeared
0310:             */
0311:            public void newPropertyDialogFill(String fileName, String key,
0312:                    String value, String comment) throws Exception {
0313:                new EventTool().waitNoEvent(250);
0314:                boolean finished = false;
0315:                do {
0316:                    NbDialogOperator nbDialogOperator = new NbDialogOperator(
0317:                            this .TITLE_NEW_PROPERTY_DIALOG);
0318:                    ContainerOperator containerOperator = new ContainerOperator(
0319:                            nbDialogOperator);
0320:                    int limit = 0;
0321:                    try {
0322:
0323:                        JTextFieldOperator jTextFieldOperator = null;
0324:                        if (key != null) {
0325:                            jTextFieldOperator = new JTextFieldOperator(
0326:                                    containerOperator, 0);
0327:                            jTextFieldOperator.typeText(key);
0328:                        }
0329:                        if (value != null) {
0330:                            jTextFieldOperator = new JTextFieldOperator(
0331:                                    containerOperator, 1);
0332:                            jTextFieldOperator.typeText(value);
0333:                        }
0334:                        if (comment != null) {
0335:                            jTextFieldOperator = new JTextFieldOperator(
0336:                                    containerOperator, 2);
0337:                            jTextFieldOperator.typeText(comment);
0338:                        }
0339:
0340:                        finished = true;
0341:
0342:                    } catch (TimeoutExpiredException ex) {
0343:                        //if ( ex.getMessage().equals(this.EXCEPTION_TEXT) == false )
0344:                        //    throw new Exception(ex.getMessage());
0345:                        // if  problems occurs then use this code to wake up dialog anyway
0346:                        // close the dialog and open it anyway
0347:                        newPropertyDialogClickCancelButton();
0348:                        propertiesEditorClickNewPropertyButton(fileName);
0349:                    }
0350:
0351:                    JButtonOperator bo = new JButtonOperator(containerOperator);
0352:                    bo.requestFocus();
0353:
0354:                    if (limit++ >= 3)
0355:                        finished = true;
0356:
0357:                } while (finished == false);
0358:            }
0359:
0360:            /** This closes 'New property' dialog. There is used close button for this action in
0361:             * this dialog. ( dialog must be open )
0362:             */
0363:            public void newPropertyDialogClickCloseButton() {
0364:                NbDialogOperator nbDialogOperator = new NbDialogOperator(
0365:                        this .TITLE_NEW_PROPERTY_DIALOG);
0366:                //nbDialogOperator.btOK().requestFocus();
0367:                //nbDialogOperator.btOK().pushNoBlock();
0368:                nbDialogOperator.ok();
0369:                System.out.println(">> Ok button pushed");
0370:            }
0371:
0372:            /** This closes dialog as in previous method, but there is used no block action for closing dialog. */
0373:            public void newPropertyDialogClickOkButtonNoBlock() {
0374:                NbDialogOperator nbDialogOperator = new NbDialogOperator(
0375:                        this .TITLE_NEW_PROPERTY_DIALOG);
0376:                //nbDialogOperator.btOK().pushNoBlock();
0377:                nbDialogOperator.ok();
0378:            }
0379:
0380:            /** There will be found adequte key in property sheet and then will be checked value and comment. If kye will not found then method fail.
0381:             * @param key which will be compared with key in properties file
0382:             * @param value of key which will be compared with value in properties file
0383:             * @param comment of key witch will be compared with comment in propertiies file
0384:             * @param rowOfCheckedProperty is number of compared propererty in properties file (row position >=0)
0385:             * @param localeCount is count of locales in properties file, new file has 1 locale (default)
0386:             * @param rowCount is count of rows (properties) in properties file
0387:             * @throws Exception if an appeared
0388:             */
0389:            public void checkPropertiesInSheet(String fileName, String key,
0390:                    String value, String comment, int rowOfCheckedProperty,
0391:                    int localeCount, int rowCount) throws Exception {
0392:
0393:                if (key == null)
0394:                    key = "";
0395:                if (value == null)
0396:                    value = "";
0397:                if (comment == null)
0398:                    comment = "";
0399:
0400:                // Checking texfields ( Comment and Key ) under table.
0401:                // ==================================================
0402:
0403:                TopComponentOperator tco = new TopComponentOperator(fileName);
0404:                JTable jTable = JTableOperator.findJTable(tco
0405:                        .getContainer(ComponentSearcher.getTrueChooser("")),
0406:                        ComponentSearcher.getTrueChooser(""));
0407:
0408:                if (rowOfCheckedProperty == 1) {
0409:                    // first row is not normal bacause there is comment of file in it + comment of the property
0410:                    comment = this .RESOURCE_BUNDLE_COMMENT.concat(comment);
0411:                }
0412:
0413:                // click to key field in table
0414:
0415:                // WA the next two rows are work around of jemmy because the action clickOnCell+waitEmpty is not
0416:                // WA the same as user event called from mouse, keyboard
0417:                new JTableOperator(jTable).clickOnCell(
0418:                        rowOfCheckedProperty - 1, 1);
0419:                new EventTool().waitNoEvent(500);
0420:                // END OF WA
0421:
0422:                new JTableOperator(jTable).clickOnCell(
0423:                        rowOfCheckedProperty - 1, 0);
0424:
0425:                JTextArea jTextArea = JTextAreaOperator.findJTextArea(tco
0426:                        .getContainer(ComponentSearcher.getTrueChooser("")),
0427:                        ComponentSearcher.getTrueChooser(""), 0);
0428:
0429:                if (jTextArea == null)
0430:                    System.out.println("> Comment textarea is null");
0431:                else {
0432:                    System.out.println("> Comment textarea is found.");
0433:
0434:                    if (!jTextArea.getText().equals(comment)) {
0435:                        System.out.println("textarea == string : \""
0436:                                + jTextArea.getText() + "\" == \"" + comment
0437:                                + "\"");
0438:                        throw new Exception(
0439:                                "Comment is not equal to the specified string. (comparing in textarea under the table)");
0440:                    } else
0441:                        System.out
0442:                                .println("> Comment is Ok in textarea under the table.");
0443:                }
0444:
0445:                if (rowCount == 0) {
0446:                    // if label == key then compare key else comapre value
0447:                    JLabel jLabel = JLabelOperator.findJLabel(
0448:                            tco.getContainer(ComponentSearcher
0449:                                    .getTrueChooser("")), ComponentSearcher
0450:                                    .getTrueChooser(""), 1);
0451:                    String label = jLabel.getText();
0452:                    System.out.println("> label = " + label);
0453:                    if (this .LABEL_KEY.equals(label)) {
0454:                        jTextArea = JTextAreaOperator.findJTextArea(tco
0455:                                .getContainer(ComponentSearcher
0456:                                        .getTrueChooser("")), ComponentSearcher
0457:                                .getTrueChooser(""), 1);
0458:                        if (jTextArea == null)
0459:                            System.out.println("> Key textarea is null");
0460:                        else {
0461:                            System.out.println("> Key textarea is found.");
0462:                            if (!jTextArea.getText().equals(key)) {
0463:                                System.out.println("textarea == string : "
0464:                                        + jTextArea.getText() + " == " + key);
0465:                                throw new Exception(
0466:                                        "Key is not equal to the specified string. (comparing in textarea under the table)");
0467:                            } else
0468:                                System.out
0469:                                        .println("> Key is Ok in textarea under the table.");
0470:                        }
0471:                    } else if (this .LABLE_VALUE.equals(label)) {
0472:                        jTextArea = JTextAreaOperator.findJTextArea(tco
0473:                                .getContainer(ComponentSearcher
0474:                                        .getTrueChooser("")), ComponentSearcher
0475:                                .getTrueChooser(""), 1);
0476:                        if (jTextArea == null)
0477:                            System.out.println("> Value textarea is null");
0478:                        else {
0479:                            System.out.println("> Value textarea is found.");
0480:                            if (!jTextArea.getText().equals(value)) {
0481:                                System.out.println("textarea == string : "
0482:                                        + jTextArea.getText() + " == " + value);
0483:                                throw new Exception(
0484:                                        "Value is not equal to the specified string. (comparing in textarea under the table)");
0485:                            } else
0486:                                System.out
0487:                                        .println("> Value is Ok in textarea under the table.");
0488:                        }
0489:
0490:                    } else
0491:                        throw new Exception(
0492:                                "Label of Key or Value textarea is corrupted!");
0493:
0494:                } else {
0495:                    System.out.println("More rows in table (rows>0)");
0496:                    // comapre key and then compare value
0497:                    System.out.println(">Click to row" + rowOfCheckedProperty);
0498:                    // click to value field in table
0499:                    new JTableOperator(jTable).clickOnCell(
0500:                            rowOfCheckedProperty - 1, 1);
0501:
0502:                    jTextArea = JTextAreaOperator.findJTextArea(
0503:                            tco.getContainer(ComponentSearcher
0504:                                    .getTrueChooser("")), ComponentSearcher
0505:                                    .getTrueChooser(""), 1);
0506:                    if (jTextArea == null)
0507:                        System.out.println("> Value textarea is null");
0508:                    else {
0509:                        System.out.println("> Value textarea is found.");
0510:                        if (!jTextArea.getText().equals(value)) {
0511:                            System.out.println("textarea == string : "
0512:                                    + jTextArea.getText() + " == " + value);
0513:                            throw new Exception(
0514:                                    "Value is not equal to the specified string. (comparing in textarea under the table)");
0515:                        } else
0516:                            System.out
0517:                                    .println("> Value is Ok in textarea under the table.");
0518:                    }
0519:                    // click to key fild in table
0520:                    new JTableOperator(jTable).clickOnCell(
0521:                            rowOfCheckedProperty - 1, 0);
0522:
0523:                    jTextArea = JTextAreaOperator.findJTextArea(
0524:                            tco.getContainer(ComponentSearcher
0525:                                    .getTrueChooser("")), ComponentSearcher
0526:                                    .getTrueChooser(""), 1);
0527:                    if (jTextArea == null)
0528:                        System.out.println("> Key textarea is null");
0529:                    else {
0530:                        System.out.println("> Key textarea is found.");
0531:                        if (!jTextArea.getText().equals(key)) {
0532:                            System.out.println("textarea == string : "
0533:                                    + jTextArea.getText() + " == " + key);
0534:                            throw new Exception(
0535:                                    "Key is not equal to the specified string. (comparing in textarea under the table)");
0536:                        } else
0537:                            System.out
0538:                                    .println("> Key is Ok in textarea under the table.");
0539:                    }
0540:
0541:                }
0542:
0543:                // Checking table
0544:
0545:                new EventTool().waitNoEvent(250);
0546:
0547:                // find in table if any key which matchs to the parametr
0548:                int index = -1;
0549:
0550:                if (jTable != null) {
0551:
0552:                    if (jTable.getRowCount() == rowCount && rowCount == 0) {
0553:                        System.out.println("> There is no rows in table. (OK)");
0554:                        return;
0555:                    } else if (rowCount == 0)
0556:                        System.out
0557:                                .println("> Table shouldn't have any row!(There is "
0558:                                        + jTable.getRowCount() + " rows)");
0559:
0560:                    if (key != null)
0561:                        for (int ii = 0; ii < jTable.getModel().getRowCount(); ii++) {
0562:                            // check if is the key in properties file more times
0563:                            new EventTool().waitNoEvent(250);
0564:                            if (index >= 0
0565:                                    && jTable.getModel().getValueAt(ii, 0)
0566:                                            .toString().equals(key) == true) {
0567:                                throw new Exception(
0568:                                        "The added key is more times in properties sheet.");
0569:                            }
0570:
0571:                            if (index == -1
0572:                                    && jTable.getModel().getValueAt(ii, 0)
0573:                                            .toString().toString().equals(key) == true) {
0574:                                index = ii;
0575:                                // check value of property if is equal to the value
0576:                                if (jTable.getModel().getValueAt(ii, 1)
0577:                                        .toString().toString().equals(value) == false)
0578:                                    throw new Exception("Value doesn't match. "
0579:                                            + ii
0580:                                            + " - ("
0581:                                            + value
0582:                                            + " not equals "
0583:                                            + jTable.getCellEditor(ii, 1)
0584:                                                    .getCellEditorValue()
0585:                                                    .toString());
0586:                                // check comment
0587:                                new JTableOperator(jTable).clickOnCell(ii, 0);
0588:                                new EventTool().waitNoEvent(250);
0589:
0590:                                // check comment of property if is equal to the comment
0591:                                if (new JTextAreaOperator(
0592:                                        new ContainerOperator(tco
0593:                                                .getContainer(ComponentSearcher
0594:                                                        .getTrueChooser(""))),
0595:                                        0).getText().equals(comment) == false)
0596:                                    throw new Exception(
0597:                                            "Comment doesn't match. "
0598:                                                    + ii
0599:                                                    + " : \n>"
0600:                                                    + comment
0601:                                                    + "< not equals with : >"
0602:                                                    + new JTextAreaOperator(
0603:                                                            new ContainerOperator(
0604:                                                                    tco
0605:                                                                            .getContainer(ComponentSearcher
0606:                                                                                    .getTrueChooser(""))),
0607:                                                            0).getText()
0608:                                                    + "<\n");
0609:
0610:                                if (ii + 1 != rowOfCheckedProperty)
0611:                                    throw new Exception(
0612:                                            "Property is not in the right row in property sheet.");
0613:                            }
0614:
0615:                        }
0616:
0617:                    if (index < 0 && rowOfCheckedProperty >= 0)
0618:                        throw new Exception("Key not found in properties sheet");
0619:
0620:                    if (localeCount >= 0
0621:                            && localeCount != jTable.getModel()
0622:                                    .getColumnCount() - 1) {
0623:                        int locales = jTable.getModel().getColumnCount() - 1;
0624:                        throw new Exception(
0625:                                "Count of locales (columns-1) doesn't match. ("
0626:                                        + localeCount + "<>" + locales + ")");
0627:                    }
0628:
0629:                    if (rowCount >= 0
0630:                            && rowCount != jTable.getModel().getRowCount())
0631:                        throw new Exception(
0632:                                "Count of properties (rows) doesn't match. ("
0633:                                        + rowCount + "<>"
0634:                                        + jTable.getModel().getRowCount() + ")");
0635:
0636:                } else
0637:                    throw new Exception("Cann't find JTable in Editor Window");
0638:            }
0639:
0640:            /** This method check pleces of keys, values and comments in properties file (in
0641:             * text mode)
0642:             * @throws Exception if an appeared
0643:             */
0644:            public void checkPropertiesFileIntegrityInClassicEditor(
0645:                    String fileName) throws Exception {
0646:                // open properties file in classic editor and them chek spaces, comments, keys, values
0647:                // and their positions
0648:                EditorOperator eo = new EditorOperator(fileName);
0649:                String content = eo.getText();
0650:                StringTokenizer strT = new StringTokenizer(content, "\n", true);
0651:                String row = "";
0652:                try {
0653:                    for (int ii = 0; ii < strT.countTokens(); ii++) {
0654:                        // comment of file
0655:                        if (ii == 0) {
0656:                            row = strT.nextToken();
0657:
0658:                            if (row.charAt(0) != '#')
0659:                                throw new Exception(
0660:                                        "Structure of properties file has been corrupted");
0661:                            // end row
0662:                            row = strT.nextToken();
0663:
0664:                            try {
0665:                                // free row or end of file
0666:                                row = strT.nextToken();
0667:                            } catch (NoSuchElementException ex) {
0668:                                // no properties in file
0669:                                return;
0670:                            }
0671:
0672:                        }
0673:
0674:                        // comment of property
0675:                        row = strT.nextToken();
0676:
0677:                        // comment of property
0678:                        if (row.charAt(0) != '#')
0679:                            throw new Exception(
0680:                                    "Structure of properties file has been corrupted");
0681:
0682:                        // end row
0683:                        row = strT.nextToken();
0684:
0685:                        // key and value of property
0686:                        row = strT.nextToken();
0687:                        StringTokenizer strT2 = new StringTokenizer(row);
0688:                        String key = strT2.nextToken("=\n");
0689:                        String value = strT2.nextToken("=\n");
0690:                        if (key == null || value == null)
0691:                            throw new Exception(
0692:                                    "Structure of properties file has been corrupted");
0693:                    }
0694:                } catch (NoSuchElementException ex) {
0695:                    throw new Exception(
0696:                            "Structure of properties file has been corrupted");
0697:                }
0698:
0699:            }
0700:
0701:            /** It clicks on 'Help' button in 'New property' dialog. */
0702:            public void newPropertyDialogClickHelpButton() {
0703:                NbDialogOperator nbDialogOperator = new NbDialogOperator(
0704:                        this .TITLE_NEW_PROPERTY_DIALOG);
0705:                nbDialogOperator.help();
0706:            }
0707:
0708:            /** Closes 'Help' window. */
0709:            public void closeHelp() {
0710:                NbDialogOperator nbDialogOperator = new NbDialogOperator(
0711:                        this .TITLE_HELP_DIALOG);
0712:                nbDialogOperator.close();
0713:            }
0714:
0715:            /** Closes 'Error' dialog. This dialog appeared after property is added with existed key. (Key which
0716:             * exists in properties file)
0717:             */
0718:            public void errorDialogClickOkButton() {
0719:                NbDialogOperator nbDialogOperator = new NbDialogOperator(
0720:                        this .TITLE_ERROR_DIALOG);
0721:                nbDialogOperator.ok();
0722:            }
0723:
0724:            /** Closes 'New property' dialog. There is used 'Cancel' button. */
0725:            public void newPropertyDialogClickCancelButton() {
0726:                NbDialogOperator nbDialogOperator = new NbDialogOperator(
0727:                        this .TITLE_NEW_PROPERTY_DIALOG);
0728:                nbDialogOperator.cancel();
0729:            }
0730:
0731:            /** This selectes row in sheet of properties in properties editor.
0732:             * @param rowNumber is number of row in property sheet
0733:             * @throws Exception if an appeared
0734:             */
0735:            public void selectPropertiesFileItem(String fileName, int rowNumber)
0736:                    throws Exception {
0737:                TopComponentOperator tco = new TopComponentOperator(fileName);
0738:
0739:                JTable jTable = JTableOperator.findJTable(tco
0740:                        .getContainer(ComponentSearcher.getTrueChooser("")),
0741:                        ComponentSearcher.getTrueChooser(""));
0742:                new EventTool().waitNoEvent(250);
0743:                // find in table if any key match to the parametr
0744:
0745:                if (jTable != null) {
0746:                    JTableOperator jTableOperator = new JTableOperator(jTable);
0747:                    jTableOperator.getTimeouts().setTimeout(
0748:                            "JScrollBarOperator.WholeScrollTimeout", 240000);
0749:                    jTableOperator.clickOnCell(rowNumber, 1);
0750:                    return;
0751:                }
0752:                throw new Exception(
0753:                        "Info : Cannot select item id properties table.");
0754:            }
0755:
0756:            /** There will be counted rows in property sheet in properties editor.
0757:             * @return counts of rows in property sheet
0758:             *
0759:             * @throws Exception if an appeared
0760:             */
0761:            public int getPropertiesFileItemsCount(String fileName)
0762:                    throws Exception {
0763:                TopComponentOperator tco = new TopComponentOperator(fileName);
0764:
0765:                JTable jTable = JTableOperator.findJTable(tco
0766:                        .getContainer(ComponentSearcher.getTrueChooser("")),
0767:                        ComponentSearcher.getTrueChooser(""));
0768:                new EventTool().waitNoEvent(250);
0769:                // find in table if any key match to the parametr
0770:
0771:                if (jTable != null)
0772:                    return jTable.getModel().getRowCount();
0773:                return -1;
0774:
0775:            }
0776:
0777:            /** Clicks to button 'Ok' in Quiestion dialog. This dialog appeared after pushing 'Remove Property' button. */
0778:            public void questionDialogClickOkButton() {
0779:                NbDialogOperator nbDialogOperator = new NbDialogOperator(
0780:                        this .TITLE_SAVE_QUESTION_DIALOG);
0781:                nbDialogOperator.ok();
0782:            }
0783:
0784:            public void questionDialogClickDiscardButton() {
0785:                QuestionDialogOperator qdo = new QuestionDialogOperator(
0786:                        TITLE_QUESTION_DIALOG);
0787:                JButtonOperator jbo = new JButtonOperator(qdo,
0788:                        BUTTON_NAME_DISCARD);
0789:                jbo.pushNoBlock();
0790:            }
0791:
0792:            /** Clicks to 'Cancel' button in 'Question' dialog. This dialog appeared after pushing 'Remove Property' button in
0793:             * properties editor.
0794:             */
0795:            public void questionDialogClickCancelButton() {
0796:                NbDialogOperator nbDialogOperator = new NbDialogOperator(
0797:                        this .TITLE_SAVE_QUESTION_DIALOG);
0798:                nbDialogOperator.cancel();
0799:            }
0800:
0801:            /** Method createNewPropertiesFileToClassicEditor()
0802:             * @param filesystemNode is node of filesystem in which is file located in Explorer
0803:             * @param fileName is name of file
0804:             */
0805:            public void createNewPropertiesFileAndOpenInClassicEditor(
0806:                    Node node, String fileName) {
0807:                // create new file
0808:                NewFileWizardOperator newWizard = NewFileWizardOperator.invoke(
0809:                        node, this .WIZARD_CATEGORY, this .WIZARD_FILE_TYPE);
0810:                new NewFileNameLocationStepOperator().setName(fileName);
0811:                newWizard.finish();
0812:
0813:                new EventTool().waitNoEvent(250);
0814:
0815:                // close Properties Editor
0816:                TopComponentOperator tco = new TopComponentOperator(fileName);
0817:                tco.close();
0818:                // There is problem while writing tests becasuse we must have opened some source files.
0819:                //new EditorWindowOperator().close();
0820:                /*
0821:                JTabbedPaneOperator jTabbedPaneOperator = new EditorWindowOperator().tbpEditorTabbedPane();
0822:                if ( jTabbedPaneOperator != null && jTabbedPaneOperator.findPage(this.TITLE_WELCOME) < 0 ) {
0823:                    CloseViewAction cva = new CloseViewAction();
0824:                    //jTabbedPaneOperator.selectPage(fileName);
0825:                    cva.performPopup(jTabbedPaneOperator);
0826:                } else {
0827:                    // close whole editor becase there is no tabs in editor
0828:                    new EditorWindowOperator().close();
0829:                }
0830:                 */
0831:                // open classic editor from popup menu in Explorer window
0832:                //ExplorerOperator explorerOperator = new ExplorerOperator();
0833:                //RepositoryTabOperator eplorer = new RepositoryTabOperator();
0834:                ProjectsTabOperator pto = new ProjectsTabOperator();
0835:                pto.invoke();
0836:                ProjectRootNode prn = pto.getProjectRootNode(projectName);
0837:                prn.select();
0838:                String packageName = node.getPath();
0839:                new Node(prn, "Source Packages" + this .treeSeparator
0840:                        + packageName + this .treeSeparator + fileName)
0841:                        .performPopupAction(this .POPUP_MENU_EDIT);
0842:
0843:            }
0844:
0845:            /** Open 'Add Locale..' dialog and do nothing
0846:             * @param filesystemNode is node of filesystem in which is file located in Explorer
0847:             * @param filePath is path to file in tree in Explorer
0848:             */
0849:            public void openAddLocaleDialogFromExplorer(Node filesystemNode,
0850:                    String filePath) {
0851:                new ActionNoBlock(null, this .POPUP_MENU_ADD_LOCALE)
0852:                        .performPopup(new Node(filesystemNode, filePath));
0853:            }
0854:
0855:            /** Fills values to 'Add Locale...' dialog. ( use null values if nothig to be filed )
0856:             * @param languageCode is Language Code e.g. cs, de, en or other staff
0857:             * @param countryCode is Country Code e.g. CZ, DE, US or other stuff
0858:             * @param variant is variant of locale, this should be empty or should will have value e.g. EURO
0859:             * @param filesystemNode is node of tree in explorer
0860:             * @param fileName is name of file
0861:             * @throws Exception if an appeared
0862:             */
0863:            public void addLocaleDialogFill(String languageCode,
0864:                    String countryCode, String variant, Node filesystemNode,
0865:                    String fileName) throws Exception {
0866:                new EventTool().waitNoEvent(250);
0867:                boolean finished = false;
0868:                do {
0869:                    try {
0870:                        NbDialogOperator nbDialogOperator = new NbDialogOperator(
0871:                                this .TITLE_ADD_LOCALE_DIALOG);
0872:                        //ContainerOperator containerOperator = new ContainerOperator(nbDialogOperator);
0873:                        JComboBoxOperator jComboBoxOperator;
0874:                        jComboBoxOperator = new JComboBoxOperator(
0875:                                nbDialogOperator, 0);
0876:                        if (languageCode != null) {
0877:                            jComboBoxOperator.typeText(languageCode);
0878:                        } else {
0879:                            jComboBoxOperator.typeText("");
0880:                        }
0881:                        jComboBoxOperator = new JComboBoxOperator(
0882:                                nbDialogOperator, 1);
0883:                        if (countryCode != null) {
0884:                            jComboBoxOperator.typeText(countryCode);
0885:                        } else {
0886:                            jComboBoxOperator.typeText("");
0887:                        }
0888:                        jComboBoxOperator = new JComboBoxOperator(
0889:                                nbDialogOperator, 2);
0890:                        if (variant != null) {
0891:                            jComboBoxOperator.typeText(variant);
0892:                        } else {
0893:                            jComboBoxOperator.typeText("");
0894:                        }
0895:                        finished = true;
0896:                        System.out.println("Set languge: "
0897:                                + new JComboBoxOperator(nbDialogOperator, 0)
0898:                                        .getTextField().getText());
0899:                        System.out.println("Set country: "
0900:                                + new JComboBoxOperator(nbDialogOperator, 1)
0901:                                        .getTextField().getText());
0902:                        //nbDialogOperator.ge
0903:                    } catch (TimeoutExpiredException ex) {
0904:                        if (ex.getMessage().equals(this .EXCEPTION_TEXT) == false)
0905:                            throw new Exception(ex.getMessage());
0906:                        // if  problems occurs then use this code to wake up dialog anyway
0907:                        // close the dialog and open it anyway
0908:                        addLocaleDialogClickCancelButton();
0909:                        openAddLocaleDialogFromExplorer(filesystemNode,
0910:                                fileName);
0911:                    }
0912:
0913:                } while (finished == false);
0914:                new EventTool().waitNoEvent(250);
0915:
0916:            }
0917:
0918:            /** Clicks to 'Help' button in 'Add Locale...' dialog. */
0919:            public void addLocaleDialogClickHelpButton() {
0920:                NbDialogOperator nbDialogOperator = new NbDialogOperator(
0921:                        this .TITLE_ADD_LOCALE_DIALOG);
0922:                nbDialogOperator.help();
0923:            }
0924:
0925:            /** Clicks to 'Ok' button in 'Add Locale...' dialog. */
0926:            public void addLocaleDialogClickOkButtonNoBlock() {
0927:                NbDialogOperator nbDialogOperator = new NbDialogOperator(
0928:                        this .TITLE_ADD_LOCALE_DIALOG);
0929:                //nbDialogOperator.btOK().requestFocus();
0930:                //nbDialogOperator.btOK().pushNoBlock();
0931:                nbDialogOperator.ok();
0932:            }
0933:
0934:            /** Clicks to 'Cancel' button in 'Add Locale...' dialog. */
0935:            public void addLocaleDialogClickCancelButton() {
0936:                NbDialogOperator nbDialogOperator = new NbDialogOperator(
0937:                        this .TITLE_ADD_LOCALE_DIALOG);
0938:                nbDialogOperator.cancel();
0939:            }
0940:
0941:            /** Opens Customizer dialog.
0942:             * @param filesystemNode node of filesystem in tree in explorer
0943:             * @param path to the object you can customize
0944:             */
0945:            public void openCustomizeLocalesDialogFromExplorer(
0946:                    Node filesystemNode, String path) {
0947:                new ActionNoBlock(null, this .POPUP_MENU_CUSTOMIZE)
0948:                        .performPopup(new Node(filesystemNode, path));
0949:            }
0950:
0951:            /** Clicks to 'Add Locale...' button in customizer. */
0952:            public void customizeLocalesDialogClickAddLocaleButton() {
0953:                NbDialogOperator nbDialogOperator = new NbDialogOperator(
0954:                        this .TITLE_CUSTOMIZE_LOCALES_DIALOG);
0955:                JButtonOperator jButtonOperator = new JButtonOperator(
0956:                        new ContainerOperator(nbDialogOperator),
0957:                        this .BUTTON_NAME_ADD_LOCALE);
0958:                jButtonOperator.pushNoBlock();
0959:            }
0960:
0961:            /** Clicks to 'Remove Locale' button in customizer. */
0962:            public void customizeLocalesDialogClickRemoveLocaleButton() {
0963:                NbDialogOperator nbDialogOperator = new NbDialogOperator(
0964:                        this .TITLE_CUSTOMIZE_LOCALES_DIALOG);
0965:                JButtonOperator jButtonOperator = new JButtonOperator(
0966:                        new ContainerOperator(nbDialogOperator),
0967:                        this .BUTTON_NAME_REMOVE_LOCALE);
0968:                jButtonOperator.pushNoBlock();
0969:            }
0970:
0971:            /** Clicks to 'Help' button in customizer. */
0972:            public void customizeLocalesDialogClickHelpButton() {
0973:                NbDialogOperator nbDialogOperator = new NbDialogOperator(
0974:                        this .TITLE_CUSTOMIZE_LOCALES_DIALOG);
0975:                //nbDialogOperator.btHelp().pushNoBlock();
0976:                nbDialogOperator.help();
0977:            }
0978:
0979:            /** Clicks to 'Close' button in customizer. */
0980:            public void customizeLocalesDialogClickCloseButton() {
0981:                NbDialogOperator nbDialogOperator = new NbDialogOperator(
0982:                        this .TITLE_CUSTOMIZE_LOCALES_DIALOG);
0983:                //nbDialogOperator.btClose().pushNoBlock();
0984:                nbDialogOperator.close();
0985:            }
0986:
0987:            /** Selects focus adequate to locale in customizer
0988:             * @param row of locale you wish to select
0989:             */
0990:            public void customizeLocalesDialogSelectLocale(int row) {
0991:                NbDialogOperator nbDialogOperator = new NbDialogOperator(
0992:                        this .TITLE_CUSTOMIZE_LOCALES_DIALOG);
0993:                JListOperator jListOperator = new JListOperator(
0994:                        new ContainerOperator(nbDialogOperator));
0995:                jListOperator.selectItem(row - 1);
0996:            }
0997:
0998:            /** This checks if has been selected 'Remove Locale' button.
0999:             * @return true if locale button has been selected
1000:             */
1001:            public boolean customizeLocalesDialogIsEnabledRemoveLocaleButton() {
1002:                NbDialogOperator nbDialogOperator = new NbDialogOperator(
1003:                        this .TITLE_CUSTOMIZE_LOCALES_DIALOG);
1004:                JButtonOperator jButtonOperator = new JButtonOperator(
1005:                        new ContainerOperator(nbDialogOperator),
1006:                        this .BUTTON_NAME_REMOVE_LOCALE);
1007:                return jButtonOperator.isEnabled();
1008:            }
1009:
1010:            /** Opens 'Add Property' dialog from explorer.
1011:             * @param filesystemNode is node of tree in explorer
1012:             * @param path of file in tree in explorer
1013:             */
1014:            public void openAddPropertyDialogFromExplorer(Node filesystemNode,
1015:                    String path) {
1016:                new ActionNoBlock(null, this .POPUP_MENU_ADD_PROPERTY)
1017:                        .performPopup(new Node(filesystemNode, path));
1018:            }
1019:
1020:            public void openCustomizePropertiesDialogFromExplorer(
1021:                    Node fileNode, String path) {
1022:                new ActionNoBlock(null, this .POPUP_MENU_CUSTOMIZE)
1023:                        .performPopup(new Node(fileNode, path));
1024:            }
1025:
1026:            public void customizePropertiesDialogClickHelpButton() {
1027:                NbDialogOperator nbDialogOperator = new NbDialogOperator(
1028:                        this .TITLE_CUSTOMIZE_PROPERTIES_DIALOG);
1029:                //nbDialogOperator.btHelp().pushNoBlock();
1030:                nbDialogOperator.help();
1031:            }
1032:
1033:            public void customizePropertiesDialogClickCloseButton() {
1034:                NbDialogOperator nbDialogOperator = new NbDialogOperator(
1035:                        this .TITLE_CUSTOMIZE_PROPERTIES_DIALOG);
1036:                //nbDialogOperator.btClose().pushNoBlock();
1037:                nbDialogOperator.close();
1038:            }
1039:
1040:            public void customizePropertiesDialogClickAddKeyButton() {
1041:                NbDialogOperator nbDialogOperator = new NbDialogOperator(
1042:                        this .TITLE_CUSTOMIZE_PROPERTIES_DIALOG);
1043:                JButtonOperator jButtonOperator = new JButtonOperator(
1044:                        new ContainerOperator(nbDialogOperator),
1045:                        this .BUTTON_NAME_ADD_KEY);
1046:                jButtonOperator.pushNoBlock();
1047:            }
1048:
1049:            public void customizePropertiesDialogClickRemovePropertyButton() {
1050:                NbDialogOperator nbDialogOperator = new NbDialogOperator(
1051:                        this .TITLE_CUSTOMIZE_PROPERTIES_DIALOG);
1052:                JButtonOperator jButtonOperator = new JButtonOperator(
1053:                        new ContainerOperator(nbDialogOperator),
1054:                        this .BUTTON_NAME_REMOVE_KEY);
1055:                jButtonOperator.requestFocus();
1056:                jButtonOperator.pushNoBlock();
1057:            }
1058:
1059:            public boolean customizePropertiesDialogIsEnableRemovePropertyButton() {
1060:                NbDialogOperator nbDialogOperator = new NbDialogOperator(
1061:                        this .TITLE_CUSTOMIZE_PROPERTIES_DIALOG);
1062:                JButtonOperator jButtonOperator = new JButtonOperator(
1063:                        new ContainerOperator(nbDialogOperator),
1064:                        this .BUTTON_NAME_REMOVE_KEY);
1065:                return jButtonOperator.isEnabled();
1066:
1067:            }
1068:
1069:            public void customizePropertiesDialogSelectProperty(int row) {
1070:                NbDialogOperator nbDialogOperator = new NbDialogOperator(
1071:                        this .TITLE_CUSTOMIZE_PROPERTIES_DIALOG);
1072:                JListOperator jListOperator = new JListOperator(
1073:                        new ContainerOperator(nbDialogOperator));
1074:                jListOperator.selectItem(row - 1);
1075:            }
1076:
1077:            public void deleteLocaleFromExplorer(Node fileNode, String path) {
1078:                new ActionNoBlock(null, this .POPUP_MENU_DELETE_LOCALE)
1079:                        .performPopup(new Node(fileNode, path));
1080:            }
1081:
1082:            public void confirmationDeleteteLocaleDialogClickYes() {
1083:                NbDialogOperator nbDialogOperator = new NbDialogOperator(
1084:                        this .TITLE_DIALOG_CONFIRM_OBJECT_DELETION);
1085:                JButtonOperator jButtonOperator = new JButtonOperator(
1086:                        new ContainerOperator(nbDialogOperator),
1087:                        this .BUTTON_NAME_YES);
1088:                jButtonOperator.pushNoBlock();
1089:            }
1090:
1091:            public void confirmationDeleteteMoreLocalesDialogClickYes() {
1092:                NbDialogOperator nbDialogOperator = new NbDialogOperator(
1093:                        this .TITLE_DELETE_MORE_LOCALES_CONFIRMATION_DIALOG);
1094:                JButtonOperator jButtonOperator = new JButtonOperator(
1095:                        new ContainerOperator(nbDialogOperator),
1096:                        this .BUTTON_NAME_YES);
1097:                jButtonOperator.pushNoBlock();
1098:            }
1099:
1100:            public void confirmationDeleteteLocaleDialogClickNo() {
1101:                NbDialogOperator nbDialogOperator = new NbDialogOperator(
1102:                        this .TITLE_DIALOG_CONFIRM_OBJECT_DELETION);
1103:                JButtonOperator jButtonOperator = new JButtonOperator(
1104:                        new ContainerOperator(nbDialogOperator),
1105:                        this .BUTTON_NAME_NO);
1106:                jButtonOperator.pushNoBlock();
1107:            }
1108:
1109:            public int checkEditorTabCount() {
1110:                return -1;
1111:            }
1112:
1113:            public void deleteMoreLocalesInExplorer(String[] Languages,
1114:                    String[] Countres, String[] Varians, Node fileNode,
1115:                    String path_to_group) {
1116:
1117:                Node[] nodes = new Node[Languages.length];
1118:                for (int ii = 0; ii < Languages.length; ii++) {
1119:                    String path = path_to_group.concat("|").concat(
1120:                            Languages[ii]).concat("_").concat(Countres[ii]);
1121:                    System.out.println(">> path = " + path);
1122:                    nodes[ii] = new Node(fileNode, path);
1123:                }
1124:                new DeleteAction().performPopup(nodes);
1125:
1126:            }
1127:
1128:            public void explorerSelectPath(String treePath, Node filesystemNode) {
1129:                Node node = new Node(filesystemNode, treePath);
1130:                node.select();
1131:            }
1132:
1133:            public void propertiesWindowChangeProperty(String objectName,
1134:                    String propertyName, String newValue) {
1135:                PropertySheetOperator.invoke();
1136:                PropertySheetOperator pso = new PropertySheetOperator(
1137:                        this .TITLE_PROPERTIES_WINDOW_TABLE.concat(objectName));
1138:                //PropertySheetTabOperator psto = new PropertySheetTabOperator(pso, this.TITLE_PROPERTIES_WINDOW_TAB);
1139:                StringProperty pr = new StringProperty(pso, propertyName);
1140:                pr.setValue(newValue);
1141:                new EventTool().waitNoEvent(250);
1142:                /*        StringCustomEditorOperator stringCustomizerEditorOperator = pr.setinvokeCustomizer();
1143:                 stringCustomizerEditorOperator.setStringValue(newValue);
1144:                 new EventTool().waitNoEvent(250);
1145:                 stringCustomizerEditorOperator.btOK().requestFocus();
1146:                 new EventTool().waitNoEvent(250);
1147:                 stringCustomizerEditorOperator.btOK().pushNoBlock();
1148:                 new EventTool().waitNoEvent(250);*/
1149:            }
1150:
1151:            public void checkLocalesInExplorer(java.lang.String[] locales,
1152:                    Node filesystemNode, java.lang.String fileName)
1153:                    throws Exception {
1154:                new EventTool().waitNoEvent(300);
1155:                //org.openide.filesystems.FileSystem fileSytem = org.openide.filesystems.Repository.getDefault().findFileSystem(filesystemNode.getPath());
1156:                ProjectsTabOperator pto = new ProjectsTabOperator();
1157:                pto.invoke();
1158:                ProjectRootNode prn = pto.getProjectRootNode(projectName);
1159:                prn.select();
1160:                Node node = new Node(prn, "Source Packages"
1161:                        + this .treeSeparator + fileName);
1162:                String[] strs = node.getChildren();
1163:                if (strs.length != locales.length) {
1164:                    throw new Exception(
1165:                            "> There is bad count of locales in Explorer window. ("
1166:                                    + strs.length + "<>" + locales.length + ")");
1167:                }
1168:                for (int ii = 0; ii < locales.length; ii++)
1169:                    if (strs[ii].compareTo(locales[ii]) != 0)
1170:                        throw new Exception(
1171:                                "> There is bad locale name in Explorer window. ("
1172:                                        + strs[ii] + "<>" + locales[ii] + ")");
1173:
1174:            }
1175:
1176:            public boolean existsFileInExplorer(String packageName,
1177:                    String fileName) {
1178:                try {
1179:                    log("Testing name of file in Explorer : \"" + fileName
1180:                            + "\"");
1181:                    ProjectsTabOperator pto = ProjectsTabOperator.invoke();
1182:                    //ProjectRootNode prn = pto.getProjectRootNode(projectName);
1183:                    //prn.select();
1184:                    //Node node = new Node(prn,treeSubPackagePathToFile+treeSeparator+fileName);
1185:                    SourcePackagesNode sourcePackagesNode = new SourcePackagesNode(
1186:                            defaultProjectName);
1187:                    log("source node:" + sourcePackagesNode.getPath());
1188:                    Node packageNode = new Node(sourcePackagesNode, packageName);
1189:                    log("package node:" + packageNode.getPath());
1190:                    Node fileNode = new Node(packageNode, fileName);
1191:
1192:                    log("Log: Found node " + fileNode.getText());
1193:                    return true;
1194:                } catch (TimeoutExpiredException ex) {
1195:                    return false;
1196:                }
1197:            }
1198:
1199:            public void requestFocusEditorPane(String nameOfTab) {
1200:                TopComponentOperator tco = new TopComponentOperator(nameOfTab);
1201:                tco.requestFocus();
1202:                /*EditorWindowOperator ewo = new EditorWindowOperator();
1203:                EditorOperator eo =  ewo.getEditor(nameOfTab);
1204:                eo.requestFocus();*/
1205:            }
1206:
1207:            public void tableViewClickTo(String fileName, int row, int column) {
1208:                TopComponentOperator tco = new TopComponentOperator(fileName);
1209:                JTable jTable = JTableOperator.findJTable(tco
1210:                        .getContainer(ComponentSearcher.getTrueChooser("")),
1211:                        ComponentSearcher.getTrueChooser(""));
1212:                new JTableOperator(jTable).clickOnCell(row, column);
1213:
1214:            }
1215:
1216:            /** Check if file exists in Editor. This method compare the title name of
1217:             * tab in editor window.
1218:             */
1219:            public boolean existsFileInEditor(String fileName) {
1220:                try {
1221:                    log("Testing name of file in tab of Editor window : \""
1222:                            + fileName + "\"");
1223:                    EditorOperator ewo = new EditorOperator(fileName);
1224:                    ewo.close();
1225:                    return true;
1226:                } catch (TimeoutExpiredException ex) {
1227:                    return false;
1228:                }
1229:
1230:            }
1231:
1232:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.