Source Code Cross Referenced for OptionsOperator.java in  » IDE-Netbeans » uml » org » netbeans » test » umllib » util » 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 » uml » org.netbeans.test.umllib.util 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003:         *
004:         * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005:         *
006:         * The contents of this file are subject to the terms of either the GNU
007:         * General Public License Version 2 only ("GPL") or the Common
008:         * Development and Distribution License("CDDL") (collectively, the
009:         * "License"). You may not use this file except in compliance with the
010:         * License. You can obtain a copy of the License at
011:         * http://www.netbeans.org/cddl-gplv2.html
012:         * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013:         * specific language governing permissions and limitations under the
014:         * License.  When distributing the software, include this License Header
015:         * Notice in each file and include the License file at
016:         * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
017:         * particular file as subject to the "Classpath" exception as provided
018:         * by Sun in the GPL Version 2 section of the License file that
019:         * accompanied this code. If applicable, add the following below the
020:         * License Header, with the fields enclosed by brackets [] replaced by
021:         * your own identifying information:
022:         * "Portions Copyrighted [year] [name of copyright owner]"
023:         *
024:         * Contributor(s):
025:         *
026:         * The Original Software is NetBeans. The Initial Developer of the Original
027:         * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
028:         * Microsystems, Inc. All Rights Reserved.
029:         *
030:         * If you wish your version of this file to be governed by only the CDDL
031:         * or only the GPL Version 2, indicate your decision by adding
032:         * "[Contributor] elects to include this software in this distribution
033:         * under the [CDDL or GPL Version 2] license." If you do not indicate a
034:         * single choice of license, a recipient has the option to distribute
035:         * your version of this file under either the CDDL, the GPL Version 2 or
036:         * to extend the choice of license to its licensees as provided above.
037:         * However, if you add GPL Version 2 code and therefore, elected the GPL
038:         * Version 2 license, then the option applies only if the new code is
039:         * made subject to such option by the copyright holder.
040:         */
041:
042:        /*
043:         * OptionsOperator.java
044:         *
045:         * Created on March 13, 2006, 6:05 PM
046:         *
047:         * 
048:         */
049:
050:        package org.netbeans.test.umllib.util;
051:
052:        import javax.swing.tree.TreePath;
053:        import org.netbeans.jellytools.MainWindowOperator;
054:        import org.netbeans.jellytools.TreeTableOperator;
055:        import org.netbeans.jellytools.actions.Action;
056:        import org.netbeans.jellytools.properties.Property;
057:        import org.netbeans.jellytools.properties.PropertySheetOperator;
058:        import org.netbeans.jemmy.ComponentChooser;
059:        import org.netbeans.jemmy.EventTool;
060:        import org.netbeans.jemmy.JemmyProperties;
061:        import org.netbeans.jemmy.operators.JButtonOperator;
062:        import org.netbeans.jemmy.operators.JDialogOperator;
063:        import org.netbeans.jemmy.operators.JMenuBarOperator;
064:        import org.netbeans.jemmy.operators.JPopupMenuOperator;
065:        import org.netbeans.jemmy.operators.JTextFieldOperator;
066:        import org.netbeans.test.umllib.exceptions.ElementVerificationException;
067:        import org.netbeans.test.umllib.exceptions.NotFoundException;
068:        import org.netbeans.test.umllib.exceptions.UMLCommonException;
069:
070:        /**
071:         *
072:         * @author sp153251
073:         */
074:        public class OptionsOperator extends JDialogOperator {
075:            //
076:            public static final String STANDART_TITLE = "Options";
077:            public static final String ADVANCED_TITLE = "Advanced Options";
078:            //
079:            private static final String BUTTON_TO_ADVANCED = ADVANCED_TITLE;
080:            private static final String BUTTON_TO_STANDART = "Basic Options";
081:            private static final String COMMON_INVOKE_MENU = "Tools|Options";
082:            private static final String MAC_INVOKE_MENU = "NetBeans|Preferences...";
083:            //
084:            private static final String SEARCH_MAC_BY = "mac";
085:            //
086:            private boolean advanced;
087:            private TreeTableOperator _treeTable;
088:
089:            /** Creates a new instance of OptionsOperator
090:             * Tries to find either advanced or standart options dialog
091:             */
092:            public OptionsOperator() {
093:                super (new ChooseOptionDialog());
094:                advanced = ADVANCED_TITLE.equals(getTitle());
095:                waitComponentShowing(true);
096:                waitComponentVisible(true);
097:            }
098:
099:            /**
100:             * @return returns true if current OptionsOperator represent advanced options dialog
101:             */
102:            boolean isAdvanced() {
103:                return advanced && isShowing();
104:            }
105:
106:            /**
107:             * Close options dialog with applying options (OK in standart and Close in advanced)
108:             */
109:            public void close() {
110:                String btnName = "OK";
111:                if (advanced)
112:                    btnName = "Close";
113:                new JButtonOperator(this , btnName).push();
114:            }
115:
116:            /**
117:             * Press "Advanced Options" in standart options dialog or do nothing in advanced dialog
118:             * @return returns OptionsOperator for advanced dialog
119:             */
120:            public OptionsOperator invokeAdvanced() {
121:                if (advanced)
122:                    return this ;
123:                new JButtonOperator(this , BUTTON_TO_ADVANCED).pushNoBlock();
124:                //WORKAROUND BUG ??
125:                long tmp = JemmyProperties
126:                        .getCurrentTimeout("DialogWaiter.WaitDialogTimeout");
127:                long tmp2 = JemmyProperties
128:                        .getCurrentTimeout("ComponentOperator.WaitComponentTimeout");
129:                JemmyProperties.setCurrentTimeout(
130:                        "DialogWaiter.WaitDialogTimeout", 1000);
131:                JemmyProperties.setCurrentTimeout(
132:                        "ComponentOperator.WaitComponentTimeout", 1000);
133:                try {
134:                    new JButtonOperator(new JDialogOperator("Question"), "Yes")
135:                            .pushNoBlock();
136:                } catch (Exception ex) {
137:                }
138:                JemmyProperties.setCurrentTimeout(
139:                        "ComponentOperator.WaitComponentTimeout", tmp2);
140:                JemmyProperties.setCurrentTimeout(
141:                        "DialogWaiter.WaitDialogTimeout", tmp);
142:                //WORKAROUN FINISHED
143:                waitClosed();
144:                return new OptionsOperator();
145:            }
146:
147:            /**
148:             * Press "Basic Options" in advanced options dialog or do nothing in standart dialog
149:             * @return returns OptionsOperator for standart dialog
150:             */
151:            public OptionsOperator invokeBasic() {
152:                if (!advanced)
153:                    return this ;
154:                new JButtonOperator(this , BUTTON_TO_STANDART).push();
155:                waitClosed();
156:                advanced = false;
157:                return new OptionsOperator();
158:            }
159:
160:            /** Getter for table containing property list and
161:             * property definition levels.
162:             * @return TreeTableOperator instance
163:             */
164:            public TreeTableOperator treeTable() {
165:                if (_treeTable == null) {
166:                    _treeTable = new TreeTableOperator(this );
167:                }
168:                return _treeTable;
169:            }
170:
171:            /**
172:             * Open Options dialog by main menu
173:             * @return OptionsOperator representing Options  Dialog
174:             */
175:            public static OptionsOperator invoke() {
176:                MainWindowOperator mw = MainWindowOperator.getDefault();
177:                JMenuBarOperator mainbar = new JMenuBarOperator(mw);
178:                //
179:                boolean macOs = System.getProperty("os.name").toLowerCase()
180:                        .indexOf(SEARCH_MAC_BY) > -1;
181:                //menu depends on platform
182:                String menuName = "";
183:                if (macOs) {
184:                    new Action(null, null, new Action.Shortcut(',', 4))
185:                            .perform();
186:                } else {
187:                    mainbar.pushMenu(COMMON_INVOKE_MENU);
188:                }
189:                new EventTool().waitNoEvent(500);
190:                return new OptionsOperator();
191:            }
192:
193:            /**
194:             * set values to option in advanced view
195:             * @param keys - array of key in format {{nodePath,key1,key2..},{..
196:             * @param values - array of values in format {{null,value1,value2...},..
197:             * @throw qa.uml.exceptions.UMLCommonException in case if there is no advanced options active
198:             */
199:            public void setAdvancedValues(String[][] keys, String[][] values) {
200:                if (!isAdvanced())
201:                    throw new UMLCommonException(
202:                            "Advanced options isn't active.");
203:                int i = 0, j = 1;
204:                int minLen = Math.min(keys.length, values.length);
205:                while (i < minLen) {
206:                    String path = keys[i][0];
207:                    //
208:                    if (keys[i].length > 1 && values[i].length > 1) {
209:                        setAdvancedValue(path, keys[i][j], values[i][j]);
210:                        //
211:                    }
212:                    //
213:                    j++;
214:                    int min2 = Math.min(keys[i].length, values[i].length);
215:                    if (j >= min2) {
216:                        j = 1;
217:                        i++;
218:                    }
219:                }
220:
221:            }
222:
223:            /**
224:             * set values to option in advanced view
225:             * @param path - nodePath
226:             * @param key - name of propety
227:             * @param value - value to be set
228:             * @throw qa.uml.exceptions.UMLCommonException in case if there is no advanced options active
229:             */
230:            public void setAdvancedValue(String path, String key, String value) {
231:                if (!isAdvanced())
232:                    throw new UMLCommonException(
233:                            "Advanced options isn't active.");
234:                //
235:                TreePath pth = treeTable().tree().findPath(path);
236:                if (pth == null)
237:                    throw new NotFoundException("Can't find " + path);
238:                //
239:                JPopupMenuOperator f;
240:                //
241:                if (!pth.equals(treeTable().tree().getSelectionPath())) {
242:                    treeTable().tree().scrollToPath(pth);
243:                    treeTable().tree().selectPath(pth);
244:                    treeTable().tree().waitSelected(pth);
245:                }
246:                //
247:                new EventTool().waitNoEvent(1000);
248:                PropertySheetOperator ps = new PropertySheetOperator(this );
249:                //
250:                Property pr = new Property(ps, key);
251:                if (pr.getValue() == null)
252:                    throw new ElementVerificationException("Bad value in "
253:                            + path + "|" + key);
254:                //set property
255:                pr.setValue(value);
256:                //change focus
257:                treeTable().tree().clickOnPath(pth);
258:            }
259:
260:            /**
261:             * set values to option in advanced view
262:             * @param path - nodePath
263:             * @param key - name of propety
264:             * @return value
265:             * @throw qa.uml.exceptions.UMLCommonException in case if there is no advanced options active
266:             */
267:            public String getAdvancedValue(String path, String key) {
268:                if (!isAdvanced())
269:                    throw new UMLCommonException(
270:                            "Advanced options isn't active.");
271:                //
272:                TreePath pth = treeTable().tree().findPath(path);
273:                if (pth == null)
274:                    throw new NotFoundException("Can't find " + path);
275:                //
276:                JPopupMenuOperator f;
277:                //
278:                if (!pth.equals(treeTable().tree().getSelectionPath())) {
279:                    treeTable().tree().scrollToPath(pth);
280:                    treeTable().tree().selectPath(pth);
281:                    treeTable().tree().waitSelected(pth);
282:                }
283:                //
284:                new EventTool().waitNoEvent(1000);
285:                PropertySheetOperator ps = new PropertySheetOperator(this );
286:                //
287:                Property pr = new Property(ps, key);
288:                if (pr.getValue() == null)
289:                    throw new ElementVerificationException("Bad value in "
290:                            + path + "|" + key);
291:                //
292:                return pr.getValue();
293:            }
294:
295:            public static class ChooseOptionDialog implements  ComponentChooser {
296:                /**
297:                 * 
298:                 * @param component 
299:                 * @return 
300:                 */
301:                public boolean checkComponent(java.awt.Component component) {
302:                    if (component instanceof  java.awt.Dialog) {
303:                        java.awt.Dialog dlg = (java.awt.Dialog) component;
304:                        return OptionsOperator.STANDART_TITLE.equals(dlg
305:                                .getTitle())
306:                                || OptionsOperator.ADVANCED_TITLE.equals(dlg
307:                                        .getTitle());
308:                    } else
309:                        return false;
310:                }
311:
312:                /**
313:                 * 
314:                 * @return 
315:                 */
316:                public String getDescription() {
317:                    return "Find dialog with '"
318:                            + OptionsOperator.STANDART_TITLE + "' or '"
319:                            + OptionsOperator.ADVANCED_TITLE + "' title.";
320:                }
321:
322:            }
323:
324:            /**
325:             * all uml options items (0) with default (1) and other possible values
326:             * avoid changing order, tests may refer to items by index
327:             * TBD
328:             */
329:            /*public static final HashMap<String,String[][]> UML_OPTIONS=new HashMap<String,String[][]>();
330:            {
331:                 UML_OPTIONS.put("UML",
332:                         new String[][]
333:                               {
334:                                   {"Automatically Hide Modeling Window","Yes","No"},
335:                                   {"Delete File when Deleting Artifacts","Ask Me","Always","Naver"},
336:                                   {"Show Aliases","No","Yes"},
337:                                   {"Prompt to Save Diagram","Yes","No"},
338:                                   {"Prompt to Save Project","Yes","No"},
339:                                   {"Don't Show Filter Warning Dialog","Ask Me","Always"}
340:                                });
341:                 UML_OPTIONS.put("UML|Code Generation",
342:                         new String[][]
343:                                {
344:                                    {"Show Process Output","Yes","No"}
345:                                });
346:                 UML_OPTIONS.put("UML|Design Center",
347:                         new String[][]{});
348:                 UML_OPTIONS.put
349:                                ("UML|Design Center|Design Pattern Catalog",
350:                         new String[][]
351:                                {
352:                                    {"Overwrite Existing Participants","Ask Me","Always","Never"}
353:                                });
354:                 UML_OPTIONS.put("UML|Diagrams",
355:                         new String[][]
356:                                {
357:                                    {"Ask Before Layout"},
358:                                    {"Automatically Size Elements"},
359:                                    {"Display Compartment Titles"},
360:                                    {"Display Edit Control Tooltips"},
361:                                    {"Display Empty Lists"},
362:                                    {"Reconnect to Presentation Boundary"},
363:                                    {"Resize with Show Aliases Mode"},
364:                                    {"Show Stereotype Icons"}
365:                                });
366:                 UML_OPTIONS.put("UML|Diagrams|Activity",
367:                         new String[][]
368:                                {
369:                                    {"Indicate Interruptible Edges"}
370:                                });
371:                 UML_OPTIONS.put("UML|Diagrams|Collaboration",
372:                         new String[][]
373:                                {
374:                                    "Delete Connector Messages",
375:                                    "Show Message Numbers"
376:                                });
377:                 UML_OPTIONS.put("UML|Diagrams|Sequence",
378:                         new String[][]
379:                                {
380:                                    "Automatically Create Classifiers",
381:                                    "Classifier Type to Create",
382:                                    "Delete Combined Fragment Messages",
383:                                    "Group Operations by Classifier",
384:                                    "New Message Action",
385:                                    "Move Invoked Operation",
386:                                    "Show Interaction Boundary as Created",
387:                                    "Show Message Numbers"
388:                                });
389:                 UML_OPTIONS.put("UML|Display",
390:                         new String[][]
391:                                {
392:                                    "Tagged Values"
393:                                });
394:                 UML_OPTIONS.put("UML|Expansion variables",
395:                         new String[][]
396:                                {
397:                                    "Configuration Location"
398:                                });
399:                 UML_OPTIONS.put("UML|Find Dialog",
400:                         new String[][]
401:                                {
402:                                    "Allow Lengthy Searches"
403:                                });
404:                 UML_OPTIONS.put("UML|Find Dialog|Displayed Columns",
405:                         new String[][]
406:                                {
407:                                    "Alias",
408:                                    "Fully Scoped Name",
409:                                    "Icon",
410:                                    "ID",
411:                                    "Name",
412:                                    "Project",
413:                                    "Type"
414:                                });
415:                 UML_OPTIONS.put("UML|Information Logging",
416:                         new String[][]
417:                                {
418:                                    "Log File Name and Location",
419:                                    "Log Messages",
420:                                    "Log Errors",
421:                                    "Log Exceptions",
422:                                    "Log Informational Messages",
423:                                    "Log Method Entry",
424:                                    "Log Method Exit"
425:                                });
426:                 UML_OPTIONS.put("UML|New Project",
427:                         new String[][]
428:                                {
429:                                    "Create New Diagram",
430:                                    "Default Diagram Name",
431:                                    "Default Element Name"
432:                                });
433:                 UML_OPTIONS.put("UML|New Project|Unknown Classifier",
434:                         new String[][]
435:                                {
436:                                    "Create Classifier",
437:                                    "Type to Create"
438:                                });
439:                 UML_OPTIONS.put("UML|New Project|Unknown Stereotype",
440:                         new String[][]
441:                                {
442:                                    "Automatically Create"
443:                                });
444:                 UML_OPTIONS.put("UML|Notify When Namespace is Deleted",
445:                         new String[][]
446:                                {
447:                                    "Actor Elements",
448:                                    "Association Class Elements",
449:                                    "Class Elements",
450:                                    "Design Pattern Role Elements",
451:                                    "Interface Elements",
452:                                    "Package Elements",
453:                                    "Use Case Elements"
454:                                });
455:                 UML_OPTIONS.put("UML|Presentation",
456:                         new String[][]
457:                                {
458:                                    "Documentation Font",
459:                                    "Grid Font",
460:                                    "Set Global Colors and Fonts"
461:                                });
462:                 UML_OPTIONS.put("UML|Reverse Engineering",
463:                         new String[][]
464:                                {
465:                                    "Show Process Output"
466:                                });
467:                 UML_OPTIONS.put("UML|Reverse Engineering|Operation Elements",
468:                         new String[][]
469:                                {
470:                                    "Create New Operation",
471:                                    "Prompt for Source Folders",
472:                                    "Source Folders Config File"
473:                                });
474:                 UML_OPTIONS.put("UML|Code Engineering",
475:                         new String[][]
476:                                {
477:                                    "Replace Conflicting Elements",
478:                                    "Transform When Code May Be Lost",
479:                                    "Warn When Impacted Count Reaches"
480:                                });
481:                 UML_OPTIONS.put("UML|Code Engineering|Elements",
482:                         new String[][]
483:                                {
484:                                    "Aggregation",
485:                                    "Association",
486:                                    "Association End",
487:                                    "Attribute",
488:                                    "Class",
489:                                    "Generalization",
490:                                    "Implementation",
491:                                    "Interface",
492:                                    "Multiplicity",
493:                                    "Multiplicity Range",
494:                                    "Navigable End",
495:                                    "Operation",
496:                                    "Package",
497:                                    "Parameter",
498:                                    "Project",
499:                                    "Template Parameter",
500:                                    "Enumeration",
501:                                    "Enumeration Literal"
502:                                });
503:                 UML_OPTIONS.put("UML|Code Engineering|Java",
504:                         new String[][]
505:                                {
506:                                    "Capitalize Attribute Name in Accessors",
507:                                    "Create Accessor Methods",
508:                                    "Create Constructor Methods",
509:                                    "Create Finalize Methods",
510:                                    "Display Duplicate Operation Dialog",
511:                                    "Modify Redefined Operations",
512:                                    "Name Navigable Ends",
513:                                    "Prefix for Member Attributes",
514:                                    "Prefix for Read Accessors",
515:                                    "Prefix for Write Accessors",
516:                                    "Remove Prefix from Accessor Names",
517:                                    "Collection Override"
518:                                });
519:                 UML_OPTIONS.put("UML|UML Properties Pane",
520:                         new String[][]
521:                                {
522:                                    "Default Filter",
523:                                    "Display Type Fully Scoped Name",
524:                                    "Maximum Display"
525:                                });
526:            }*/
527:
528:            public void addWebBrowser(String name, String process) {
529:                invokeBasic();
530:                (new JButtonOperator(this , "Edit...")).pushNoBlock();
531:                JDialogOperator webBrowerDialog = new JDialogOperator(
532:                        "Web Browsers");
533:                (new JButtonOperator(webBrowerDialog, "Add...")).pushNoBlock();
534:                JTextFieldOperator nameField = new JTextFieldOperator(
535:                        webBrowerDialog, 0);
536:                nameField.clearText();
537:                nameField.typeText(name);
538:                JTextFieldOperator processField = new JTextFieldOperator(
539:                        webBrowerDialog, 1);
540:                processField.clearText();
541:                processField.typeText(process);
542:                try {
543:                    Thread.sleep(1000);
544:                } catch (Exception ex) {
545:                }
546:                (new JButtonOperator(webBrowerDialog, "OK")).pushNoBlock();
547:                try {
548:                    Thread.sleep(1000);
549:                } catch (Exception ex) {
550:                }
551:
552:            }
553:
554:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.