Source Code Cross Referenced for HyperlinkChosen.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.HyperlinkEventRecordable;
029:        import jacareto.system.Environment;
030:
031:        import java.util.Vector;
032:
033:        /**
034:         * A hyperlink has been entered and activated.
035:         *
036:         * @author <a href="mailto:cspannagel@web.de">Christian Spannagel</a>
037:         * @version 1.01
038:         */
039:        public class HyperlinkChosen extends StructureElement {
040:            /** The url. */
041:            private String URL;
042:
043:            /** The index (just for cloning). */
044:            private int index;
045:
046:            /**
047:             * Creates a new "hyperlink chosen" structure element. One of its children must be a hyperlink
048:             * event recordable of type ACTIVATED.
049:             *
050:             * @param env the environment
051:             * @param children the child structure elements
052:             */
053:            public HyperlinkChosen(Environment env, StructureElement[] children) {
054:                super (env, children);
055:
056:                for (int i = 0; i < children.length; i++) {
057:                    if ((children[i] instanceof  HyperlinkEventRecordable)
058:                            && ((HyperlinkEventRecordable) children[i])
059:                                    .getType().equals("ACTIVATED")) {
060:                        URL = ((HyperlinkEventRecordable) children[i]).getURL();
061:                        index = i;
062:
063:                        break;
064:                    }
065:                }
066:            }
067:
068:            /**
069:             * Creates a new "hyperlink chosen" structure element.
070:             *
071:             * @param env the environment
072:             * @param children the child structure elements
073:             * @param activatedIndex the index of the "Hyperlink activated" recordable
074:             */
075:            public HyperlinkChosen(Environment env,
076:                    StructureElement[] children, int activatedIndex) {
077:                super (env, children);
078:                this .index = activatedIndex;
079:                this .URL = ((HyperlinkEventRecordable) children[activatedIndex])
080:                        .getURL();
081:            }
082:
083:            /**
084:             * Parses a record which is tokenized by the given record tokenizer.
085:             *
086:             * @param env DOCUMENT ME!
087:             * @param recordTokenizer the record tokenizer
088:             *
089:             * @return a structure element, or <code>null</code> if this class cannot parse the record at
090:             *         the current position
091:             */
092:            public static StructureElement parse(Environment env,
093:                    RecordTokenizer recordTokenizer) {
094:                StructureElement result = null;
095:                StructureElement[] children = null;
096:
097:                RecordTokenizerState rtState = recordTokenizer.saveState();
098:
099:                // (hyper link entered,mouse motion), focus change | mouse click, hyperlink activated, (mouse motion, hyperlink exited)
100:                try {
101:                    // Entering the link
102:                    HyperlinkEventRecordable entered = null;
103:                    MouseMotion motion = null;
104:                    RecordTokenizerState stateBeforeEnter = recordTokenizer
105:                            .saveState();
106:
107:                    try {
108:                        entered = (HyperlinkEventRecordable) recordTokenizer
109:                                .next();
110:                        motion = (MouseMotion) MouseMotion.parse(env,
111:                                recordTokenizer);
112:                    } catch (Exception e) {
113:                        recordTokenizer.restoreState(stateBeforeEnter);
114:                    }
115:
116:                    // Click and activate
117:                    StructureElement fm = FocusChange.parse(env,
118:                            recordTokenizer);
119:
120:                    if (fm == null) {
121:                        fm = MouseClick.parse(env, recordTokenizer);
122:                    }
123:
124:                    HyperlinkEventRecordable activated = (HyperlinkEventRecordable) recordTokenizer
125:                            .next();
126:
127:                    // Exiting the link
128:                    MouseMotion motion2 = null;
129:                    HyperlinkEventRecordable exited = null;
130:                    RecordTokenizerState stateBeforeExit = recordTokenizer
131:                            .saveState();
132:
133:                    try {
134:                        motion2 = (MouseMotion) MouseMotion.parse(env,
135:                                recordTokenizer);
136:                        exited = (HyperlinkEventRecordable) recordTokenizer
137:                                .next();
138:                    } catch (Exception e) {
139:                        recordTokenizer.restoreState(stateBeforeExit);
140:                    }
141:
142:                    boolean cond = activated.getType().equals("ACTIVATED")
143:                            && ((entered == null) || (entered.getURL().equals(
144:                                    activated.getURL()) && entered.getType()
145:                                    .equals("ENTERED")))
146:                            && ((exited == null) || exited.getType().equals(
147:                                    "EXITED"));
148:
149:                    // (The url of the exited event must not be equal to the activated url, because the mouse pointer
150:                    // could be on another hyperlink on the activated page.)
151:                    if (cond) {
152:                        Vector addedChildren = new Vector(6);
153:
154:                        if (entered != null) {
155:                            addedChildren.add(entered);
156:                        }
157:
158:                        if (motion != null) {
159:                            addedChildren.add(motion);
160:                        }
161:
162:                        if (fm != null) {
163:                            addedChildren.add(fm);
164:                        }
165:
166:                        addedChildren.add(activated);
167:
168:                        if (motion2 != null) {
169:                            addedChildren.add(motion2);
170:                        }
171:
172:                        if (exited != null) {
173:                            addedChildren.add(exited);
174:                        }
175:
176:                        children = vectorToArray(addedChildren);
177:
178:                        //result = new HyperlinkChosen (env, children);
179:                        result = new HyperlinkChosen(env, children,
180:                                addedChildren.indexOf(activated));
181:                    } else {
182:                        throw new Exception();
183:                    }
184:                } catch (Throwable t) {
185:                    recordTokenizer.restoreState(rtState);
186:                }
187:
188:                return result;
189:            }
190:
191:            /**
192:             * Returns the name of the element.
193:             *
194:             * @return the name
195:             */
196:            public String getElementName() {
197:                return language.getString("Structures.HyperlinkChosen.Name");
198:            }
199:
200:            /**
201:             * Returns a description of the element.
202:             *
203:             * @return the description
204:             */
205:            public String getElementDescription() {
206:                return language
207:                        .getString("Structures.HyperlinkChosen.Description");
208:            }
209:
210:            /**
211:             * Returns a String which describes the content of the element shortly.
212:             *
213:             * @return a string with a short description of the element
214:             */
215:            public String toShortString() {
216:                String insertedText = null;
217:
218:                if (getURL().length() < 40) {
219:                    insertedText = getURL();
220:                } else {
221:                    int length = getURL().length();
222:                    insertedText = getURL().substring(0, 9) + "..."
223:                            + getURL().substring(length - 28, length - 1);
224:                }
225:
226:                return getElementName() + " (" + insertedText + ")";
227:            }
228:
229:            /**
230:             * Returns the URL.
231:             *
232:             * @return DOCUMENT ME!
233:             */
234:            public String getURL() {
235:                return URL;
236:            }
237:
238:            /**
239:             * Clones the element.
240:             *
241:             * @return DOCUMENT ME!
242:             */
243:            public Object clone() {
244:                StructureElement[] clonedChildren = getClonedChildren();
245:
246:                return new HyperlinkChosen(env, clonedChildren, index);
247:            }
248:
249:            public boolean hasProcTime() {
250:                return true;
251:            }
252:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.