Source Code Cross Referenced for UnTreeViewLoader.java in  » J2EE » WiSerFramework » de » ug2t » unifiedGui » loader » 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 » J2EE » WiSerFramework » de.ug2t.unifiedGui.loader 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        // @@
002:        // @@
003:        /*
004:         * Wi.Ser Framework
005:         *
006:         * Version: 1.8.1, 20-September-2007  
007:         * Copyright (C) 2005 Dirk von der Weiden <dvdw@imail.de>
008:         *
009:         * This library is free software; you can redistribute it and/or
010:         * modify it under the terms of the GNU Lesser General Public
011:         * License as published by the Free Software Foundation; either
012:         * version 2 of the License, or (at your option) any later version.
013:         *
014:         * This library is distributed in the hope that it will be useful,
015:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
016:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
017:         * Lesser General Public License for more details.
018:         *
019:         * You should have received a copy of the GNU Lesser General Public
020:         * License along with this library located in LGPL.txt in the 
021:         * license directory; if not, write to the 
022:         * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
023:         * Boston, MA  02111-1307, USA.
024:         * 
025:         * If this agreement does not cover your requirements, please contact us
026:         * via email to get detailed information about the commercial license 
027:         * or our service offerings!
028:         *
029:         */
030:        // @@
031:        package de.ug2t.unifiedGui.loader;
032:
033:        import java.util.*;
034:
035:        import javax.swing.event.*;
036:        import javax.swing.tree.*;
037:
038:        import de.ug2t.kernel.*;
039:        import de.ug2t.unifiedGui.*;
040:        import de.ug2t.unifiedGui.cellRenderer.*;
041:        import de.ug2t.unifiedGui.interfaces.*;
042:
043:        /**
044:         * @author Dirk
045:         * 
046:         * date: 14.02.2005
047:         * 
048:         * <p>
049:         * Purpose:
050:         * </p>
051:         */
052:        public class UnTreeViewLoader extends KeRegisteredObject implements 
053:                IUnLoader, TreeModelListener {
054:            private TreeModel pem_myModel = null;
055:            private IUnTreeView pem_wdg = null;
056:            private IUnTreeItemRenderer pem_renderer = null;
057:            private boolean pem_inTr = false;
058:            private HashMap pem_mapping = new HashMap();
059:            private HashMap pem_mapping2 = new HashMap();
060:            private IKeExecutable pem_postFct = null;
061:
062:            public UnTreeViewLoader(TreeModel xModel, IUnTreeView xWdg) {
063:                super (false);
064:
065:                this .pem_myModel = xModel;
066:                this .pem_wdg = xWdg;
067:
068:                this .pcmf_load();
069:
070:                this .pem_myModel.addTreeModelListener(this );
071:            }
072:
073:            public UnTreeViewLoader(TreeModel xModel, IUnTreeView xWdg,
074:                    IUnTreeItemRenderer xRenderer) {
075:                super (false);
076:
077:                if (xModel == null)
078:                    xModel = new DefaultTreeModel(new ConvertingTreeNode(xWdg
079:                            .pcmf_getRoot()));
080:
081:                this .pem_myModel = xModel;
082:                this .pem_wdg = xWdg;
083:                this .pem_renderer = xRenderer;
084:
085:                this .pcmf_load();
086:
087:                this .pem_myModel.addTreeModelListener(this );
088:            }
089:
090:            public void pcmf_setPostFct(IKeExecutable xPostFct) {
091:                this .pem_postFct = xPostFct;
092:            }
093:
094:            public void pcmf_beginTr() {
095:                this .pem_inTr = true;
096:            }
097:
098:            public void pcmf_commitTr() {
099:                this .pcmf_load();
100:                this .pem_inTr = false;
101:                if (this .pem_postFct != null)
102:                    this .pem_postFct.pcmf_execObj(this .pem_wdg);
103:            }
104:
105:            public void pcmf_disconnectModel() {
106:                this .pem_myModel.removeTreeModelListener(this );
107:            }
108:
109:            public void pcmf_connectModel(Object xModel) {
110:                this .pem_myModel = (TreeModel) xModel;
111:                this .pem_myModel.addTreeModelListener(this );
112:            }
113:
114:            public TreeModel pcmf_getModel() {
115:                return (this .pem_myModel);
116:            }
117:
118:            public void pcmf_load() {
119:                try {
120:                    this .pem_wdg.pcmf_getUnComponent().pcmf_getAppl()
121:                            .pcmf_beginSessionTR();
122:
123:                    KeTreeNode l_rootNode = this .pem_wdg.pcmf_getRoot();
124:                    if (l_rootNode != this .pem_wdg)
125:                        l_rootNode.pcmf_clearAndRelease();
126:
127:                    if (this .pem_wdg != l_rootNode)
128:                        l_rootNode.pcmf_delete();
129:
130:                    this .pem_mapping.clear();
131:                    this .pem_mapping2.clear();
132:
133:                    Object l_root = this .pem_myModel.getRoot();
134:                    KeTreeNode l_newNode = null;
135:                    if (this .pem_renderer != null)
136:                        l_newNode = (KeTreeNode) this .pem_renderer
137:                                .pcmf_getRenderWidget(l_root, false,
138:                                        this .pem_wdg);
139:
140:                    if (l_newNode == null)
141:                        l_newNode = new UnTreeNode(l_root.toString());
142:
143:                    this .pem_mapping.put(l_root, l_newNode);
144:                    this .pem_mapping2.put(l_newNode, l_root);
145:
146:                    this .pcmf_buildTree(l_root, l_newNode);
147:
148:                    this .pem_wdg.pcmf_setRoot(l_newNode);
149:                    this .pem_wdg.pcmf_commitTree();
150:                    this .pem_wdg.pcmf_repaint();
151:                    this .pem_wdg.pcmf_getUnComponent().pcmf_getAppl()
152:                            .pcmf_commitSessionTR();
153:                } catch (Exception e) {
154:                    KeLog.pcmf_logException("ug2t", this , e);
155:                    KeLog.pcmf_log("ug2t", "error loading tree", this ,
156:                            KeLog.ERROR);
157:                    this .pem_wdg.pcmf_getUnComponent().pcmf_getAppl()
158:                            .pcmf_commitSessionTR();
159:                }
160:            }
161:
162:            private void pcmf_buildTree(Object l_node, KeTreeNode l_tNode)
163:                    throws Exception {
164:                int l_cnt = this .pem_myModel.getChildCount(l_node);
165:
166:                for (int i = 0; i < l_cnt; i++) {
167:                    Object l_child = this .pem_myModel.getChild(l_node, i);
168:                    KeTreeNode l_newNode = null;
169:                    if (this .pem_renderer != null)
170:                        l_newNode = (KeTreeNode) this .pem_renderer
171:                                .pcmf_getRenderWidget(l_child, false,
172:                                        this .pem_wdg);
173:
174:                    if (l_newNode == null)
175:                        l_newNode = new UnTreeNode(l_child.toString());
176:
177:                    this .pem_mapping.put(l_child, l_newNode);
178:                    this .pem_mapping2.put(l_newNode, l_child);
179:
180:                    l_tNode.pcmf_addNode(l_child.toString(), l_newNode);
181:                    this .pcmf_buildTree(l_child, l_newNode);
182:                }
183:            }
184:
185:            public void pcmf_setRenderer(IUnTreeItemRenderer xRenderer) {
186:                this .pem_renderer = xRenderer;
187:            }
188:
189:            public Object pcmf_toModelValue(Object xNode) {
190:                return (this .pem_mapping2.get(xNode));
191:            }
192:
193:            public KeTreeNode pcmf_toGuiValue(Object xNode) {
194:                return ((KeTreeNode) this .pem_mapping.get(xNode));
195:            }
196:
197:            public void treeNodesChanged(TreeModelEvent arg0) {
198:                if (this .pem_inTr)
199:                    return;
200:
201:                try {
202:                    Object l_path[] = arg0.getPath();
203:                    KeTreeNode l_rrNode = (KeTreeNode) this .pem_mapping
204:                            .get(l_path[l_path.length - 1]);
205:
206:                    Object l_cnodes[] = arg0.getChildren();
207:
208:                    this .pem_wdg.pcmf_getUnComponent().pcmf_getAppl()
209:                            .pcmf_beginSessionTR();
210:
211:                    for (int i = 0; i < l_cnodes.length; i++) {
212:                        KeTreeNode l_oldNode = (KeTreeNode) this .pem_mapping
213:                                .get(l_cnodes[i]);
214:                        this .pem_mapping2.remove(this .pem_mapping
215:                                .remove(l_cnodes[i]));
216:
217:                        KeTreeNode l_newNode = null;
218:                        if (this .pem_renderer != null)
219:                            l_newNode = (KeTreeNode) this .pem_renderer
220:                                    .pcmf_getRenderWidget(l_cnodes[i], false,
221:                                            this .pem_wdg);
222:
223:                        if (l_newNode == null)
224:                            l_newNode = new UnTreeNode(l_cnodes[i].toString());
225:
226:                        Iterator l_it = l_oldNode.pcmf_getSubIterator();
227:                        while (l_it.hasNext()) {
228:                            KeTreeNode l_nextNode = (KeTreeNode) l_it.next();
229:                            l_oldNode.pcmf_removeNode(l_nextNode);
230:                            l_newNode.pcmf_addNode(l_nextNode.pcmf_getName(),
231:                                    l_nextNode);
232:                        }
233:                        this .pem_mapping.put(l_cnodes[i], l_newNode);
234:                        this .pem_mapping2.put(l_newNode, l_cnodes[i]);
235:
236:                        l_rrNode.pcmf_removeNode(l_oldNode);
237:                        l_rrNode.pcmf_addNode(l_newNode.pcmf_getName(),
238:                                l_newNode);
239:                    }
240:                    this .pem_wdg.pcmf_commitTree();
241:                    this .pem_wdg.pcmf_repaint();
242:
243:                    this .pem_wdg.pcmf_getUnComponent().pcmf_getAppl()
244:                            .pcmf_commitSessionTR();
245:                } catch (Exception e) {
246:                    KeLog.pcmf_log("ug2t", "error changing tree", this ,
247:                            KeLog.ERROR);
248:                    this .pem_wdg.pcmf_getUnComponent().pcmf_getAppl()
249:                            .pcmf_commitSessionTR();
250:                }
251:            }
252:
253:            public void treeNodesInserted(TreeModelEvent arg0) {
254:                if (this .pem_inTr)
255:                    return;
256:
257:                try {
258:                    Object l_path[] = arg0.getPath();
259:                    KeTreeNode l_rrNode = (KeTreeNode) this .pem_mapping
260:                            .get(((TreeNode) l_path[l_path.length - 1]));
261:
262:                    int idxs[] = arg0.getChildIndices();
263:
264:                    this .pem_wdg.pcmf_getUnComponent().pcmf_getAppl()
265:                            .pcmf_beginSessionTR();
266:
267:                    for (int i = 0; i < idxs.length; i++) {
268:                        Object l_newMNode = this .pem_myModel.getChild(
269:                                l_path[l_path.length - 1], idxs[i]);
270:
271:                        KeTreeNode l_newNode = null;
272:                        if (this .pem_renderer != null)
273:                            l_newNode = (KeTreeNode) this .pem_renderer
274:                                    .pcmf_getRenderWidget(l_newMNode, false,
275:                                            this .pem_wdg);
276:
277:                        if (l_newNode == null)
278:                            l_newNode = new UnTreeNode(l_newMNode.toString());
279:
280:                        this .pem_mapping.put(l_newMNode, l_newNode);
281:                        this .pem_mapping2.put(l_newNode, l_newMNode);
282:
283:                        l_rrNode.pcmf_addNode(l_newNode.pcmf_getName(),
284:                                l_newNode, idxs[i]);
285:                    }
286:                    this .pem_wdg.pcmf_commitTree();
287:                    this .pem_wdg.pcmf_repaint();
288:
289:                    this .pem_wdg.pcmf_getUnComponent().pcmf_getAppl()
290:                            .pcmf_commitSessionTR();
291:                } catch (Exception e) {
292:                    KeLog.pcmf_log("ug2t", "error changing tree", this ,
293:                            KeLog.ERROR);
294:                    this .pem_wdg.pcmf_getUnComponent().pcmf_getAppl()
295:                            .pcmf_commitSessionTR();
296:                }
297:            }
298:
299:            public void treeNodesRemoved(TreeModelEvent arg0) {
300:                try {
301:                    Object l_removed[] = arg0.getChildren();
302:
303:                    this .pem_wdg.pcmf_getUnComponent().pcmf_getAppl()
304:                            .pcmf_beginSessionTR();
305:
306:                    for (int i = 0; i < l_removed.length; i++) {
307:                        KeTreeNode l_toRemove = (KeTreeNode) this .pem_mapping
308:                                .remove(l_removed[i]);
309:                        this .pem_mapping2.remove(l_toRemove);
310:                        l_toRemove.pcmf_getParentNode().pcmf_removeNode(
311:                                l_toRemove);
312:                        l_toRemove.pcmf_clearAndRelease();
313:                    }
314:                    this .pem_wdg.pcmf_commitTree();
315:                    this .pem_wdg.pcmf_repaint();
316:
317:                    this .pem_wdg.pcmf_getUnComponent().pcmf_getAppl()
318:                            .pcmf_commitSessionTR();
319:                } catch (Exception e) {
320:                    KeLog.pcmf_log("ug2t", "error changing tree", this ,
321:                            KeLog.ERROR);
322:                    this .pem_wdg.pcmf_getUnComponent().pcmf_getAppl()
323:                            .pcmf_commitSessionTR();
324:                }
325:            }
326:
327:            public void treeStructureChanged(TreeModelEvent arg0) {
328:                if (this .pem_inTr == false)
329:                    this.pcmf_load();
330:            }
331:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.