Source Code Cross Referenced for MenuOpened.java in  » Testing » jacareto » jacareto » struct » 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 » jacareto » jacareto.struct 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Jacareto Copyright (c) 2002-2005
003:         * Applied Computer Science Research Group, Darmstadt University of
004:         * Technology, Institute of Mathematics & Computer Science,
005:         * Ludwigsburg University of Education, and Computer Based
006:         * Learning Research Group, Aachen University. All rights reserved.
007:         *
008:         * Jacareto is free software; you can redistribute it and/or
009:         * modify it under the terms of the GNU General Public
010:         * License as published by the Free Software Foundation; either
011:         * version 2 of the License, or (at your option) any later version.
012:         *
013:         * Jacareto is distributed in the hope that it will be useful,
014:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
015:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
016:         * General Public License for more details.
017:         *
018:         * You should have received a copy of the GNU General Public
019:         * License along with Jacareto; if not, write to the Free
020:         * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
021:         *
022:         */
023:
024:        package jacareto.struct;
025:
026:        import jacareto.parse.RecordTokenizer;
027:        import jacareto.parse.RecordTokenizerState;
028:        import jacareto.record.FocusEventRecordable;
029:        import jacareto.record.ItemEventRecordable;
030:        import jacareto.record.MouseEventRecordable;
031:        import jacareto.record.WindowEventRecordable;
032:        import jacareto.system.Environment;
033:
034:        import java.awt.event.FocusEvent;
035:        import java.awt.event.MouseEvent;
036:        import java.awt.event.WindowEvent;
037:
038:        /**
039:         * This structure element stands for a "menu opened" structure element.
040:         *
041:         * @author <a href="mailto:cspannagel@web.de">Christian Spannagel</a>
042:         * @version 1.0
043:         */
044:        public class MenuOpened extends StructureElement {
045:            /**
046:             * Creates a new "menu opened" structure element.
047:             *
048:             * @param env the environment
049:             * @param children the child structure elements
050:             */
051:            public MenuOpened(Environment env, StructureElement[] children) {
052:                super (env, children);
053:            }
054:
055:            /**
056:             * Parses a record which is tokenized by the given record tokenizer.
057:             *
058:             * @param env DOCUMENT ME!
059:             * @param recordTokenizer the record tokenizer
060:             *
061:             * @return a structure element, or <code>null</code> if this class cannot parse the record at
062:             *         the current position
063:             */
064:            public static StructureElement parse(Environment env,
065:                    RecordTokenizer recordTokenizer) {
066:                StructureElement result = null;
067:
068:                RecordTokenizerState rtState = recordTokenizer.saveState();
069:
070:                // item state change on a menu
071:                try {
072:                    ItemStateChange item = (ItemStateChange) ItemStateChange
073:                            .parse(env, recordTokenizer);
074:
075:                    boolean cond = item.getSourceClass().equals(
076:                            "javax.swing.JMenu");
077:                    cond = cond && item.isSelected();
078:
079:                    if (cond) {
080:                        StructureElement[] children = new StructureElement[1];
081:                        children[0] = item;
082:                        result = new MenuOpened(env, children);
083:                    } else {
084:                        throw new Exception();
085:                    }
086:                } catch (Throwable t) {
087:                    recordTokenizer.restoreState(rtState);
088:                }
089:
090:                // mouse pressed, item selected, window opened, focus change, mouse released, mouse clicked
091:                if (result == null) {
092:                    try {
093:                        MouseEventRecordable mousePressed = (MouseEventRecordable) recordTokenizer
094:                                .next();
095:                        ItemEventRecordable itemSelected = (ItemEventRecordable) recordTokenizer
096:                                .next();
097:                        WindowEventRecordable windowOpened = (WindowEventRecordable) recordTokenizer
098:                                .next();
099:                        FocusChange focusChange = (FocusChange) FocusChange
100:                                .parse(env, recordTokenizer);
101:
102:                        if (focusChange == null) {
103:                            throw new Exception();
104:                        }
105:
106:                        MouseEventRecordable mouseReleased = (MouseEventRecordable) recordTokenizer
107:                                .next();
108:                        MouseEventRecordable mouseClicked = (MouseEventRecordable) recordTokenizer
109:                                .next();
110:
111:                        boolean cond = (mousePressed.getID() == MouseEvent.MOUSE_PRESSED)
112:                                && (mouseReleased.getID() == MouseEvent.MOUSE_RELEASED)
113:                                && (mouseClicked.getID() == MouseEvent.MOUSE_CLICKED)
114:                                && (windowOpened.getID() == WindowEvent.WINDOW_OPENED)
115:                                && itemSelected.getSourceClass().equals(
116:                                        "javax.swing.JMenu");
117:
118:                        if (cond) {
119:                            StructureElement[] mouseChildren = new StructureElement[3];
120:                            mouseChildren[0] = mousePressed;
121:                            mouseChildren[1] = mouseReleased;
122:                            mouseChildren[2] = mouseClicked;
123:
124:                            MouseClick mouseClick = new MouseClick(env,
125:                                    mouseChildren);
126:                            StructureElement[] children = new StructureElement[4];
127:                            children[0] = mouseClick;
128:                            children[1] = focusChange;
129:                            children[2] = itemSelected;
130:                            children[3] = windowOpened;
131:                            result = new MenuOpened(env, children);
132:                        } else {
133:                            throw new Exception();
134:                        }
135:                    } catch (Exception e) {
136:                        recordTokenizer.restoreState(rtState);
137:                    }
138:                }
139:
140:                // mouse pressed, focus gained, focus change, item selected, window opened, mouse released, mouse clicked
141:                if (result == null) {
142:                    try {
143:                        MouseEventRecordable mousePressed = (MouseEventRecordable) recordTokenizer
144:                                .next();
145:                        FocusEventRecordable focusEvent = (FocusEventRecordable) recordTokenizer
146:                                .next();
147:                        FocusChange focusChange = (FocusChange) FocusChange
148:                                .parse(env, recordTokenizer);
149:
150:                        if (focusChange == null) {
151:                            throw new Exception();
152:                        }
153:
154:                        ItemEventRecordable itemSelected = (ItemEventRecordable) recordTokenizer
155:                                .next();
156:                        WindowEventRecordable windowOpened = (WindowEventRecordable) recordTokenizer
157:                                .next();
158:                        MouseEventRecordable mouseReleased = (MouseEventRecordable) recordTokenizer
159:                                .next();
160:                        MouseEventRecordable mouseClicked = (MouseEventRecordable) recordTokenizer
161:                                .next();
162:
163:                        boolean cond = (mousePressed.getID() == MouseEvent.MOUSE_PRESSED)
164:                                && (mouseReleased.getID() == MouseEvent.MOUSE_RELEASED)
165:                                && (mouseClicked.getID() == MouseEvent.MOUSE_CLICKED)
166:                                && (windowOpened.getID() == WindowEvent.WINDOW_OPENED)
167:                                && itemSelected.getSourceClass().equals(
168:                                        "javax.swing.JMenu")
169:                                && (focusEvent.getID() == FocusEvent.FOCUS_GAINED);
170:
171:                        if (cond) {
172:                            StructureElement[] mouseChildren = new StructureElement[3];
173:                            mouseChildren[0] = mousePressed;
174:                            mouseChildren[1] = mouseReleased;
175:                            mouseChildren[2] = mouseClicked;
176:
177:                            MouseClick mouseClick = new MouseClick(env,
178:                                    mouseChildren);
179:                            StructureElement[] children = new StructureElement[5];
180:                            children[0] = mouseClick;
181:                            children[1] = focusEvent;
182:                            children[2] = focusChange;
183:                            children[3] = itemSelected;
184:                            children[4] = windowOpened;
185:                            result = new MenuOpened(env, children);
186:                        } else {
187:                            throw new Exception();
188:                        }
189:                    } catch (Exception e) {
190:                        recordTokenizer.restoreState(rtState);
191:                    }
192:                }
193:
194:                // mouse pressed, item selected, window opened, focus change, mouse drag, mouse clicked
195:                if (result == null) {
196:                    try {
197:                        MouseEventRecordable mousePressed = (MouseEventRecordable) recordTokenizer
198:                                .next();
199:                        ItemEventRecordable itemSelected = (ItemEventRecordable) recordTokenizer
200:                                .next();
201:                        WindowEventRecordable windowOpened = (WindowEventRecordable) recordTokenizer
202:                                .next();
203:                        FocusChange focusChange = (FocusChange) FocusChange
204:                                .parse(env, recordTokenizer);
205:
206:                        if (focusChange == null) {
207:                            throw new Exception();
208:                        }
209:
210:                        MouseDrag mouseDrag = (MouseDrag) MouseDrag.parse(env,
211:                                recordTokenizer);
212:
213:                        if (mouseDrag == null) {
214:                            throw new Exception();
215:                        }
216:
217:                        MouseEventRecordable mouseReleased = (MouseEventRecordable) recordTokenizer
218:                                .next();
219:
220:                        boolean cond = (mousePressed.getID() == MouseEvent.MOUSE_PRESSED)
221:                                && (mouseReleased.getID() == MouseEvent.MOUSE_RELEASED)
222:                                && (windowOpened.getID() == WindowEvent.WINDOW_OPENED)
223:                                && itemSelected.getSourceClass().equals(
224:                                        "javax.swing.JMenu");
225:
226:                        if (cond) {
227:                            StructureElement[] children = new StructureElement[6];
228:                            children[0] = mousePressed;
229:                            children[1] = mouseDrag;
230:                            children[2] = mouseReleased;
231:                            children[3] = focusChange;
232:                            children[4] = itemSelected;
233:                            children[5] = windowOpened;
234:                            result = new MenuOpened(env, children);
235:                        } else {
236:                            throw new Exception();
237:                        }
238:                    } catch (Exception e) {
239:                        recordTokenizer.restoreState(rtState);
240:                    }
241:                }
242:
243:                return result;
244:            }
245:
246:            /**
247:             * Returns the name of the element.
248:             *
249:             * @return the name
250:             */
251:            public String getElementName() {
252:                return language.getString("Structures.MenuOpened.Name");
253:            }
254:
255:            /**
256:             * Returns a description of the element.
257:             *
258:             * @return the description
259:             */
260:            public String getElementDescription() {
261:                return language.getString("Structures.MenuOpened.Description");
262:            }
263:
264:            /**
265:             * Returns a String which describes the content of the element shortly.
266:             *
267:             * @return a string with a short description of the element
268:             */
269:            public String toShortString() {
270:                return getElementName();
271:            }
272:
273:            /**
274:             * Clones the element.
275:             *
276:             * @return DOCUMENT ME!
277:             */
278:            public Object clone() {
279:                StructureElement[] clonedChildren = getClonedChildren();
280:
281:                return new MenuOpened(env, clonedChildren);
282:            }
283:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.