Source Code Cross Referenced for WindowOpened.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.ActionEventRecordable;
029:        import jacareto.record.FocusEventRecordable;
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:        import java.util.Vector;
039:
040:        /**
041:         * A window has been opened. A structure element can parse a part of a record.
042:         *
043:         * @author <a href="mailto:cspannagel@web.de">Christian Spannagel</a>
044:         * @version 1.01
045:         */
046:        public class WindowOpened extends StructureElement {
047:            /** The name of the window. */
048:            private String windowName;
049:
050:            /** The title of the window. */
051:            private String windowTitle;
052:
053:            /**
054:             * Creates a new "window opened" structure element. One of the direct children must be a window
055:             * event recordable with the id WINDOW_OPENED
056:             *
057:             * @param env the environment
058:             * @param children the child structure elements
059:             */
060:            public WindowOpened(Environment env, StructureElement[] children) {
061:                super (env, children);
062:
063:                for (int i = 0; i < children.length; i++) {
064:                    if (children[i] instanceof  WindowEventRecordable) {
065:                        this .windowName = ((WindowEventRecordable) children[i])
066:                                .getWindowName();
067:                        this .windowTitle = ((WindowEventRecordable) children[i])
068:                                .getWindowTitle();
069:
070:                        break;
071:                    }
072:                }
073:            }
074:
075:            /**
076:             * Creates a new "window opened" structure element.
077:             *
078:             * @param env the environment
079:             * @param children the child structure elements
080:             * @param windowName the name of the window
081:             * @param windowTitle the title of the window
082:             */
083:            public WindowOpened(Environment env, StructureElement[] children,
084:                    String windowName, String windowTitle) {
085:                super (env, children);
086:                this .windowName = windowName;
087:                this .windowTitle = windowTitle;
088:            }
089:
090:            /**
091:             * Parses a record which is tokenized by the given record tokenizer.
092:             *
093:             * @param env DOCUMENT ME!
094:             * @param recordTokenizer the record tokenizer
095:             *
096:             * @return a structure element, or <code>null</code> if this class cannot parse the record at
097:             *         the current position
098:             */
099:            public static StructureElement parse(Environment env,
100:                    RecordTokenizer recordTokenizer) {
101:                StructureElement result = null;
102:
103:                RecordTokenizerState rtState = recordTokenizer.saveState();
104:
105:                // Window activation change, (motion), window opened, (focus change)
106:                try {
107:                    WindowActivationChange actChange = (WindowActivationChange) WindowActivationChange
108:                            .parse(env, recordTokenizer);
109:
110:                    if (actChange == null) {
111:                        throw new Exception();
112:                    }
113:
114:                    MouseEntered entered = null;
115:                    StructureElement motion = MouseMotionOverComponents.parse(
116:                            env, recordTokenizer);
117:
118:                    if (motion == null) {
119:                        entered = (MouseEntered) MouseEntered.parse(env,
120:                                recordTokenizer);
121:                        motion = MouseMotion.parse(env, recordTokenizer);
122:                    }
123:
124:                    WindowEventRecordable window = (WindowEventRecordable) recordTokenizer
125:                            .next();
126:                    FocusEventRecordable focus = null;
127:
128:                    StructureElement tmp = recordTokenizer.get();
129:
130:                    if ((tmp != null) && tmp instanceof  FocusEventRecordable) {
131:                        focus = (FocusEventRecordable) tmp;
132:                        recordTokenizer.forward();
133:                    }
134:
135:                    boolean cond = window.getID() == WindowEvent.WINDOW_OPENED;
136:                    cond = cond
137:                            && ((focus == null) || (focus.getID() == FocusEvent.FOCUS_GAINED));
138:
139:                    if (cond) {
140:                        Vector addedChildren = new Vector(5);
141:                        addedChildren.add(actChange);
142:
143:                        if (entered != null) {
144:                            addedChildren.add(entered);
145:                        }
146:
147:                        if (motion != null) {
148:                            addedChildren.add(motion);
149:                        }
150:
151:                        addedChildren.add(window);
152:
153:                        if (focus != null) {
154:                            addedChildren.add(focus);
155:                        }
156:
157:                        //result = new WindowOpened (env, vectorToArray (addedChildren));
158:                        result = new WindowOpened(env,
159:                                vectorToArray(addedChildren), window
160:                                        .getWindowName(), window
161:                                        .getWindowTitle());
162:                    } else {
163:                        throw new Exception();
164:                    }
165:                } catch (Throwable t) {
166:                    recordTokenizer.restoreState(rtState);
167:                }
168:
169:                // opening a JCombo Box window
170:                // mouse pressed, focus change, window opened, mouse released, mouse clicked, action event
171:                if (result == null) {
172:                    try {
173:                        MouseEventRecordable mousePressed = (MouseEventRecordable) recordTokenizer
174:                                .get();
175:
176:                        if ((mousePressed != null)
177:                                && (mousePressed.getID() == MouseEvent.MOUSE_PRESSED)) {
178:                            recordTokenizer.forward();
179:                        } else {
180:                            throw new Exception();
181:                        }
182:
183:                        FocusChange focusChange = (FocusChange) FocusChange
184:                                .parse(env, recordTokenizer);
185:
186:                        if (focusChange == null) {
187:                            throw new Exception();
188:                        }
189:
190:                        WindowEventRecordable windowOpened = (WindowEventRecordable) recordTokenizer
191:                                .get();
192:
193:                        if ((windowOpened != null)
194:                                && (windowOpened.getID() == WindowEvent.WINDOW_OPENED)) {
195:                            recordTokenizer.forward();
196:                        } else {
197:                            throw new Exception();
198:                        }
199:
200:                        MouseEventRecordable mouseReleased = (MouseEventRecordable) recordTokenizer
201:                                .get();
202:
203:                        if ((mouseReleased != null)
204:                                && (mouseReleased.getID() == MouseEvent.MOUSE_RELEASED)) {
205:                            recordTokenizer.forward();
206:                        } else {
207:                            throw new Exception();
208:                        }
209:
210:                        MouseEventRecordable mouseClicked = (MouseEventRecordable) recordTokenizer
211:                                .get();
212:
213:                        if ((mouseClicked != null)
214:                                && (mouseClicked.getID() == MouseEvent.MOUSE_CLICKED)) {
215:                            recordTokenizer.forward();
216:                        } else {
217:                            throw new Exception();
218:                        }
219:
220:                        ActionEventRecordable action = (ActionEventRecordable) recordTokenizer
221:                                .get();
222:
223:                        if (mousePressed != null) {
224:                            recordTokenizer.forward();
225:                        } else {
226:                            throw new Exception();
227:                        }
228:
229:                        StructureElement[] mouseClickChildren = new StructureElement[3];
230:                        mouseClickChildren[0] = mousePressed;
231:                        mouseClickChildren[1] = mouseReleased;
232:                        mouseClickChildren[2] = mouseClicked;
233:
234:                        MouseClick mouseClick = new MouseClick(env,
235:                                mouseClickChildren);
236:
237:                        StructureElement[] children = new StructureElement[4];
238:                        children[0] = mouseClick;
239:                        children[1] = focusChange;
240:                        children[2] = windowOpened;
241:                        children[3] = action;
242:
243:                        result = new WindowOpened(env, children, windowOpened
244:                                .getWindowName(), windowOpened.getWindowTitle());
245:                    } catch (Throwable t) {
246:                        recordTokenizer.restoreState(rtState);
247:                    }
248:                }
249:
250:                return result;
251:            }
252:
253:            /**
254:             * Returns the name of the element.
255:             *
256:             * @return the name
257:             */
258:            public String getElementName() {
259:                return language.getString("Structures.WindowOpened.Name");
260:            }
261:
262:            /**
263:             * Returns a description of the element.
264:             *
265:             * @return the description
266:             */
267:            public String getElementDescription() {
268:                return language
269:                        .getString("Structures.WindowOpened.Description");
270:            }
271:
272:            /**
273:             * Returns a String which describes the content of the element shortly.
274:             *
275:             * @return a string with a short description of the element
276:             */
277:            public String toShortString() {
278:                String result = getElementName();
279:
280:                if (windowName != null) {
281:                    String windowIdentifier = (((windowTitle == null) || windowTitle
282:                            .equals("")) ? windowName : windowTitle);
283:                    String insertedText = ((windowIdentifier.length() < 40) ? windowIdentifier
284:                            : (windowIdentifier.substring(0, 37) + "..."));
285:                    result += (" (" + insertedText + ")");
286:                }
287:
288:                return result;
289:            }
290:
291:            /**
292:             * Returns the name of the window
293:             *
294:             * @return DOCUMENT ME!
295:             */
296:            public String getWindowName() {
297:                return windowName;
298:            }
299:
300:            /**
301:             * Returns the title of the window
302:             *
303:             * @return DOCUMENT ME!
304:             */
305:            public String getWindowTitle() {
306:                return windowTitle;
307:            }
308:
309:            /**
310:             * Clones the element.
311:             *
312:             * @return DOCUMENT ME!
313:             */
314:            public Object clone() {
315:                StructureElement[] clonedChildren = getClonedChildren();
316:
317:                return new WindowOpened(env, clonedChildren, windowName,
318:                        windowTitle);
319:            }
320:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.