Source Code Cross Referenced for ChoiceRecorder.java in  » Testing » abbot-1.0.1 » abbot » editor » recorder » 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 » Testing » abbot 1.0.1 » abbot.editor.recorder 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package abbot.editor.recorder;
002:
003:        import java.awt.*;
004:        import java.awt.event.*;
005:
006:        import abbot.Log;
007:        import abbot.script.*;
008:
009:        /**
010:         * Record basic semantic events you might find on an Choice component. <p>
011:         */
012:        public class ChoiceRecorder extends ComponentRecorder {
013:
014:            private Choice choice = null;
015:            /** If selection is null when finished, no step will be generated. */
016:            private String selection = null;
017:            private ItemListener listener = null;
018:
019:            public ChoiceRecorder(Resolver resolver) {
020:                super (resolver);
021:            }
022:
023:            protected void init(int recordingType) {
024:                super .init(recordingType);
025:                choice = null;
026:                selection = null;
027:                listener = null;
028:            }
029:
030:            /** Also accept ItemEvents, since the ChoiceTester will not generate any
031:                explicit clicks to control the component. */
032:            protected boolean isClick(AWTEvent e) {
033:                if (e instanceof  ItemEvent) {
034:                    return true;
035:                }
036:                return super .isClick(e);
037:            }
038:
039:            /** Track click -> select ->click, cancelable by ESC or by clicking away
040:                from the component.<p>
041:                NOTE: press->drag->release produces an identical set of events<br>
042:                OSX 1.3.1:<br>
043:                MOUSE_PRESSED<br>
044:                (ITEM_STATE_CHANGED)|MOUSE_RELEASED|KEY_RELEASED<br>
045:                The ItemEvent never makes it to the AWT listener.
046:             */
047:            protected boolean parseClick(AWTEvent event) {
048:                // Have to check here since we handle the ItemEvent artificially
049:                if (isFinished()) {
050:                    Log.debug("already finished");
051:                    return false;
052:                }
053:
054:                if (choice == null) {
055:                    // Parse immediate selections (programmatic/tester driven)
056:                    if (event instanceof  ItemEvent) {
057:                        choice = (Choice) event.getSource();
058:                        selection = ((ItemEvent) event).getItem().toString();
059:                        Log.debug("selection=" + selection);
060:                        setFinished(true);
061:                    } else {
062:                        choice = (Choice) event.getSource();
063:                        listener = new ItemListener() {
064:                            public void itemStateChanged(ItemEvent ev) {
065:                                Log.debug("item event");
066:                                if (ev.getStateChange() == ItemEvent.SELECTED) {
067:                                    selection = ev.getItem().toString();
068:                                    Log.debug("selection=" + selection);
069:                                    choice.removeItemListener(this );
070:                                    setFinished(true);
071:                                }
072:                            }
073:                        };
074:                        choice.addItemListener(listener);
075:                        setStatus("Waiting for selection");
076:                    }
077:                } else if (event.getID() == KeyEvent.KEY_RELEASED
078:                        && (((KeyEvent) event).getKeyCode() == KeyEvent.VK_SPACE || ((KeyEvent) event)
079:                                .getKeyCode() == KeyEvent.VK_ENTER)) {
080:                    Log.debug("enter");
081:                    setFinished(true);
082:                } else if (event.getID() == KeyEvent.KEY_RELEASED
083:                        && ((KeyEvent) event).getKeyCode() == KeyEvent.VK_ESCAPE) {
084:                    Log.debug("cancel");
085:                    selection = null;
086:                    setFinished(true);
087:                } else {
088:                    Log.debug("Event ignored");
089:                }
090:
091:                if (isFinished() && choice != null) {
092:                    choice.removeItemListener(listener);
093:                    listener = null;
094:                }
095:
096:                // Events are always consumed by the Choice
097:                return true;
098:            }
099:
100:            protected Step createStep() {
101:                Step step = null;
102:                if (getRecordingType() == SE_CLICK) {
103:                    if (selection != null)
104:                        step = createSelection(choice, selection);
105:                } else {
106:                    step = super .createStep();
107:                }
108:                return step;
109:            }
110:
111:            protected Step createSelection(Choice target, String selection) {
112:                ComponentReference cr = getResolver().addComponent(choice);
113:                return new Action(getResolver(), null, "actionSelectItem",
114:                        new String[] { cr.getID(), selection },
115:                        java.awt.Choice.class);
116:            }
117:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.