Source Code Cross Referenced for StructureTreeListener.java in  » Testing » jacareto » jacareto » cleverphl » session » 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.cleverphl.session 
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.cleverphl.session;
025:
026:        import jacareto.replay.Replay;
027:        import jacareto.replay.event.ReplayEvent;
028:        import jacareto.replay.event.ReplayListener;
029:        import jacareto.struct.Structure;
030:        import jacareto.struct.StructureElement;
031:        import jacareto.struct.StructureTree;
032:        import jacareto.system.Environment;
033:        import jacareto.system.EnvironmentMember;
034:        import jacareto.toolkit.HashtableChangeEvent;
035:        import jacareto.toolkit.HashtableChangeListener;
036:
037:        import java.awt.event.KeyEvent;
038:        import java.awt.event.KeyListener;
039:
040:        import javax.swing.tree.TreePath;
041:
042:        /**
043:         * A listener which will be notified of events on the session's structure tree or events which
044:         * should cause changed on the structure tree.
045:         *
046:         * @author <a href="mailto:cspannagel@web.de">Christian Spannagel</a>
047:         * @version 1.0
048:         */
049:        public class StructureTreeListener extends EnvironmentMember implements 
050:                KeyListener, ReplayListener, HashtableChangeListener {
051:            /** The session. */
052:            private Session session;
053:
054:            /** Whether or not the actual position should be shown in the tree during replay. */
055:            private boolean showReplayPosition;
056:
057:            /**
058:             * Creates a new listener instance
059:             *
060:             * @param env the env object
061:             * @param session the session
062:             */
063:            public StructureTreeListener(Environment env, Session session) {
064:                super (env);
065:                this .session = session;
066:                customization.addHashtableChangeListener(this );
067:                applyCustomization();
068:            }
069:
070:            /**
071:             * Called when a key has been pressed on the structure tree.
072:             *
073:             * @param event DOCUMENT ME!
074:             */
075:            public void keyPressed(KeyEvent event) {
076:                if (event.getKeyCode() == KeyEvent.VK_DELETE) {
077:                    session.removeSelectedRecordables();
078:                }
079:            }
080:
081:            /**
082:             * Does nothing.
083:             *
084:             * @param event DOCUMENT ME!
085:             */
086:            public void keyReleased(KeyEvent event) {
087:            }
088:
089:            /**
090:             * Does nothing.
091:             *
092:             * @param event DOCUMENT ME!
093:             */
094:            public void keyTyped(KeyEvent event) {
095:            }
096:
097:            /**
098:             * Called when replay state has changed
099:             *
100:             * @param event DOCUMENT ME!
101:             */
102:            public void replayStateChanged(ReplayEvent event) {
103:                StructureTree tree = session.getStructureTree();
104:
105:                if (showReplayPosition && (tree != null)) {
106:                    int ID = event.getID();
107:                    Replay replay = event.getReplay();
108:                    StructureElement node = replay.getActualElement();
109:
110:                    if (node != null) {
111:                        if (node != null) {
112:                            if (ID == ReplayEvent.ACTUAL_ELEMENT_CHANGED) {
113:                                tree.clearSelection();
114:                                scrollToAndSelect(tree, node);
115:                            } else if (ID == ReplayEvent.STARTED) {
116:                                tree.clearSelection();
117:                                tree.treeDidChange();
118:                            } else if (ID == ReplayEvent.STOPPED) {
119:                                scrollToAndSelect(tree, node);
120:                            } else if (ID == ReplayEvent.PAUSED) {
121:                                scrollToAndSelect(tree, node);
122:                            } else if (ID == ReplayEvent.CONTINUED) {
123:                                tree.clearSelection();
124:                                scrollToAndSelect(tree, node);
125:                            }
126:                        }
127:                    }
128:                }
129:            }
130:
131:            /**
132:             * Scrolls the structure tree to the tree element containing the given node and selects it. If
133:             * the element is in the visible area of the tree, the visualization will not be scrolled. If
134:             * it is not in the visible area, the tree element will be scrolled to the first position of
135:             * the visible area (Buggy; does not work at the moment!). If the tree element is not visible,
136:             * the first parent which is visible will be marked.
137:             *
138:             * @param tree the tree
139:             * @param node the node to be selected
140:             */
141:            private void scrollToAndSelect(StructureTree tree,
142:                    StructureElement node) {
143:                System.out.println("scrollToAndSelect");
144:
145:                StructureElement tmp = node;
146:                StructureElement rootNode = (StructureElement) tree.getModel()
147:                        .getRoot();
148:                Structure structure = node.getStructure();
149:
150:                while (tmp != rootNode) {
151:                    StructureElement parent = (StructureElement) tmp
152:                            .getParent();
153:
154:                    if (parent != null) {
155:                        if (tree.isExpanded(structure.getTreePath(parent))) {
156:                            break;
157:                        } else {
158:                            tmp = parent;
159:                        }
160:                    } else {
161:                        tmp = rootNode;
162:                    }
163:                }
164:
165:                TreePath path = structure.getTreePath(tmp);
166:
167:                if (!tree.isPathSelected(path)) {
168:                    tree.setSelectionPath(path);
169:                    tree.scrollPathToVisible(path);
170:                }
171:            }
172:
173:            /**
174:             * Invoked when the customization has changed.
175:             *
176:             * @param event the hashtable change event
177:             */
178:            public void hashtableChanged(HashtableChangeEvent event) {
179:                applyCustomization();
180:            }
181:
182:            /**
183:             * Applies the customization.
184:             */
185:            private void applyCustomization() {
186:                showReplayPosition = customization.getBoolean(
187:                        "Replay.DisplayActualPosition", false);
188:            }
189:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.