Source Code Cross Referenced for SoapUITreeModel.java in  » Web-Services » soapui-1.7.5 » com » eviware » soapui » model » tree » 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 » Web Services » soapui 1.7.5 » com.eviware.soapui.model.tree 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *  soapUI, copyright (C) 2004-2007 eviware.com 
003:         *
004:         *  soapUI is free software; you can redistribute it and/or modify it under the 
005:         *  terms of version 2.1 of the GNU Lesser General Public License as published by 
006:         *  the Free Software Foundation.
007:         *
008:         *  soapUI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without 
009:         *  even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
010:         *  See the GNU Lesser General Public License for more details at gnu.org.
011:         */
012:
013:        package com.eviware.soapui.model.tree;
014:
015:        import java.util.ArrayList;
016:        import java.util.HashMap;
017:        import java.util.HashSet;
018:        import java.util.Iterator;
019:        import java.util.List;
020:        import java.util.Map;
021:        import java.util.Set;
022:
023:        import javax.swing.event.TreeModelEvent;
024:        import javax.swing.event.TreeModelListener;
025:        import javax.swing.tree.TreeModel;
026:        import javax.swing.tree.TreePath;
027:
028:        import org.apache.log4j.Logger;
029:
030:        import com.eviware.soapui.model.ModelItem;
031:        import com.eviware.soapui.model.tree.nodes.WorkspaceTreeNode;
032:        import com.eviware.soapui.model.workspace.Workspace;
033:
034:        /**
035:         * The Navigator TreeModel
036:         * 
037:         * @author Ole.Matzura
038:         */
039:
040:        public class SoapUITreeModel implements  TreeModel {
041:            private Set<TreeModelListener> listeners = new HashSet<TreeModelListener>();
042:            private SoapUITreeNode workspaceNode;
043:            private final static Logger logger = Logger
044:                    .getLogger(SoapUITreeModel.class);
045:            private Map<ModelItem, SoapUITreeNode> modelItemMap = new HashMap<ModelItem, SoapUITreeNode>();
046:
047:            public SoapUITreeModel(Workspace workspace) {
048:                workspaceNode = new WorkspaceTreeNode(workspace, this );
049:                mapModelItem(workspaceNode);
050:            }
051:
052:            public Object getRoot() {
053:                return workspaceNode;
054:            }
055:
056:            public Object getChild(Object parent, int index) {
057:                SoapUITreeNode treeNode = (SoapUITreeNode) parent;
058:                return treeNode.getChildNode(index);
059:            }
060:
061:            public int getChildCount(Object parent) {
062:                SoapUITreeNode treeNode = (SoapUITreeNode) parent;
063:                return treeNode.getChildCount();
064:            }
065:
066:            public boolean isLeaf(Object node) {
067:                SoapUITreeNode treeNode = (SoapUITreeNode) node;
068:                return treeNode.isLeaf();
069:            }
070:
071:            public void valueForPathChanged(TreePath path, Object newValue) {
072:                SoapUITreeNode treeNode = (SoapUITreeNode) path
073:                        .getLastPathComponent();
074:                if (treeNode.valueChanged(newValue)) {
075:                    // not implemented.. need to expose setName in ModelItem
076:                }
077:            }
078:
079:            public int getIndexOfChild(Object parent, Object child) {
080:                SoapUITreeNode treeNode = (SoapUITreeNode) parent;
081:                return treeNode.getIndexOfChild(child);
082:            }
083:
084:            public void addTreeModelListener(TreeModelListener l) {
085:                listeners.add(l);
086:            }
087:
088:            public void removeTreeModelListener(TreeModelListener l) {
089:                listeners.remove(l);
090:            }
091:
092:            public void mapModelItem(SoapUITreeNode soapUITreeNode) {
093:                modelItemMap.put(soapUITreeNode.getModelItem(), soapUITreeNode);
094:            }
095:
096:            public void unmapModelItem(ModelItem modelItem) {
097:                if (modelItemMap.containsKey(modelItem))
098:                    modelItemMap.remove(modelItem);
099:                else
100:                    logger.error("Failed to unmap model item ["
101:                            + modelItem.getName() + "]");
102:            }
103:
104:            public void notifyNodesInserted(TreeModelEvent e) {
105:                Iterator<TreeModelListener> i = listeners.iterator();
106:                while (i.hasNext()) {
107:                    i.next().treeNodesInserted(e);
108:                }
109:            }
110:
111:            public void notifyNodesRemoved(TreeModelEvent e) {
112:                Iterator<TreeModelListener> i = listeners.iterator();
113:                while (i.hasNext()) {
114:                    i.next().treeNodesRemoved(e);
115:                }
116:            }
117:
118:            public void notifyStructureChanged(TreeModelEvent e) {
119:                Iterator<TreeModelListener> i = listeners.iterator();
120:                while (i.hasNext()) {
121:                    i.next().treeStructureChanged(e);
122:                }
123:            }
124:
125:            public void notifyNodesChanged(TreeModelEvent e) {
126:                Iterator<TreeModelListener> i = listeners.iterator();
127:                while (i.hasNext()) {
128:                    i.next().treeNodesChanged(e);
129:                }
130:            }
131:
132:            public TreePath getPath(SoapUITreeNode treeNode) {
133:                //SoapUITreeNode treeNode = modelItemMap.get( modelItem );
134:                //if( treeNode == null )
135:                //	throw new RuntimeException( "Missing mapping for modelItem " + modelItem.getName() );
136:
137:                List<Object> nodes = new ArrayList<Object>();
138:                nodes.add(treeNode);
139:
140:                treeNode = treeNode.getParentTreeNode();
141:                while (treeNode != null) {
142:                    nodes.add(0, treeNode);
143:                    treeNode = treeNode.getParentTreeNode();
144:                }
145:
146:                return new TreePath(nodes.toArray());
147:            }
148:
149:            public void notifyNodeChanged(SoapUITreeNode treeNode) {
150:                SoapUITreeNode parent = treeNode.getParentTreeNode();
151:                if (parent == null) {
152:                    notifyNodesChanged(new TreeModelEvent(this ,
153:                            new Object[] { treeNode }));
154:                    return;
155:                }
156:
157:                int ix = parent.getIndexOfChild(treeNode);
158:
159:                if (ix == -1) {
160:                    logger.error("Changed node [" + treeNode
161:                            + "] not found in parent [" + parent + "]");
162:                    return;
163:                }
164:
165:                notifyNodesChanged(new TreeModelEvent(this , getPath(parent),
166:                        new int[] { ix }, new Object[] { parent
167:                                .getChildNode(ix) }));
168:            }
169:
170:            public void notifyNodeInserted(SoapUITreeNode treeNode) {
171:                SoapUITreeNode parent = treeNode.getParentTreeNode();
172:                int ix = parent.getIndexOfChild(treeNode);
173:
174:                if (ix == -1) {
175:                    logger.error("Inserted node [" + treeNode
176:                            + "] not found in parent [" + parent + "]");
177:                    return;
178:                }
179:
180:                mapModelItem(treeNode);
181:
182:                notifyNodesInserted(new TreeModelEvent(this , getPath(parent),
183:                        new int[] { ix }, new Object[] { parent
184:                                .getChildNode(ix) }));
185:            }
186:
187:            public void notifyNodeRemoved(SoapUITreeNode treeNode) {
188:                SoapUITreeNode parent = treeNode.getParentTreeNode();
189:                int ix = parent.getIndexOfChild(treeNode);
190:
191:                if (ix == -1) {
192:                    logger.error("Removed node [" + treeNode
193:                            + "] not found in parent [" + parent + "]");
194:                    return;
195:                }
196:
197:                notifyNodesRemoved(new TreeModelEvent(this , getPath(parent),
198:                        new int[] { ix }, new Object[] { parent
199:                                .getChildNode(ix) }));
200:
201:                treeNode.release();
202:            }
203:
204:            public SoapUITreeNode getTreeNode(ModelItem parentItem) {
205:                return modelItemMap.get(parentItem);
206:            }
207:
208:            public TreePath getPath(ModelItem modelItem) {
209:                return getPath(modelItemMap.get(modelItem));
210:            }
211:
212:            public void mapModelItems(List<? extends SoapUITreeNode> treeNodes) {
213:                Iterator<? extends SoapUITreeNode> iterator = treeNodes
214:                        .iterator();
215:                while (iterator.hasNext()) {
216:                    SoapUITreeNode item = iterator.next();
217:                    mapModelItem(item);
218:                }
219:            }
220:
221:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.