Source Code Cross Referenced for JComponentRecorder.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.AWTEvent;
004:        import java.awt.event.KeyEvent;
005:
006:        import javax.swing.*;
007:
008:        import abbot.Log;
009:        import abbot.script.*;
010:
011:        /**
012:         * Record basic semantic events you might find on an JComponent. <p>
013:         * 
014:         * Watches for events that trigger an action from the component's action map.  
015:         * As of 1.3.1, KEY_TYPED and KEY_RELEASED events can trigger an action.
016:         */
017:        public class JComponentRecorder extends ContainerRecorder {
018:
019:            private JComponent target;
020:            private String actionKey;
021:
022:            public static final int SE_ACTION_MAP = 20;
023:
024:            public JComponentRecorder(Resolver resolver) {
025:                super (resolver);
026:            }
027:
028:            protected void init(int rtype) {
029:                super .init(rtype);
030:                target = null;
031:                actionKey = null;
032:            }
033:
034:            /** Add handling for JComponent input-mapped actions. */
035:            public boolean accept(AWTEvent event) {
036:                boolean accepted;
037:                if ((event instanceof  KeyEvent)
038:                        && (event.getSource() instanceof  JComponent)
039:                        && isMappedEvent((KeyEvent) event)) {
040:                    init(SE_ACTION_MAP);
041:                    accepted = true;
042:                } else {
043:                    accepted = super .accept(event);
044:                }
045:                return accepted;
046:            }
047:
048:            protected javax.swing.Action getAction(KeyEvent ke) {
049:                KeyStroke ks = KeyStroke.getKeyStrokeForEvent(ke);
050:                JComponent comp = (JComponent) ke.getComponent();
051:                Object binding = comp.getInputMap().get(ks);
052:                return binding != null ? comp.getActionMap().get(binding)
053:                        : null;
054:            }
055:
056:            protected boolean isMappedEvent(KeyEvent ke) {
057:                return getAction(ke) != null;
058:            }
059:
060:            /** Add handling for JComponent input-mapped actions. */
061:            public boolean parse(AWTEvent event) {
062:                boolean consumed = true;
063:                switch (getRecordingType()) {
064:                case SE_ACTION_MAP:
065:                    consumed = parseActionMapEvent(event);
066:                    break;
067:                default:
068:                    consumed = super .parse(event);
069:                    break;
070:                }
071:                return consumed;
072:            }
073:
074:            /** Add handling for JComponent input-mapped actions. */
075:            protected boolean parseActionMapEvent(AWTEvent event) {
076:                if (target == null) {
077:                    target = (JComponent) event.getSource();
078:                    KeyStroke ks = KeyStroke
079:                            .getKeyStrokeForEvent((KeyEvent) event);
080:                    Object binding = target.getInputMap().get(ks);
081:                    Log.debug("Binding is " + binding + " ("
082:                            + binding.getClass() + ")");
083:                    if (binding instanceof  String) {
084:                        actionKey = (String) binding;
085:                    } else {
086:                        // 1.3 and prior sometimes used the actions themselves
087:                        // as the key
088:                        javax.swing.Action action = target.getActionMap().get(
089:                                binding);
090:                        actionKey = (String) action
091:                                .getValue(javax.swing.Action.NAME);
092:                    }
093:                    Log.debug("Keystroke '" + ks + "' mapped to " + actionKey);
094:                }
095:                // Make sure the entire KEY_PRESSED/KEY_TYPED/KEY_RELEASED
096:                // sequence is eaten
097:                // NOTE: This assumes that no component expects to respond to both the
098:                // key shortcut AND accept the key input.
099:                if (event.getID() == KeyEvent.KEY_RELEASED) {
100:                    setFinished(true);
101:                }
102:                return true;
103:            }
104:
105:            /** Add handling for JComponent input-mapped actions. */
106:            protected Step createStep() {
107:                Step step;
108:                switch (getRecordingType()) {
109:                case SE_ACTION_MAP:
110:                    step = createActionMap(target, actionKey);
111:                    break;
112:                default:
113:                    step = super .createStep();
114:                    break;
115:                }
116:                return step;
117:            }
118:
119:            /** Create a JComponent input-mapped action invocation. */
120:            protected Step createActionMap(JComponent target, String actionKey) {
121:                ComponentReference cr = getResolver().addComponent(target);
122:                return new abbot.script.Action(getResolver(), null,
123:                        "actionActionMap",
124:                        new String[] { cr.getID(), actionKey },
125:                        JComponent.class);
126:            }
127:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.