Source Code Cross Referenced for QueryTreeModel.java in  » Database-Client » squirrel-sql-2.6.5a » net » sourceforge » squirrel_sql » plugins » favs » 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 » Database Client » squirrel sql 2.6.5a » net.sourceforge.squirrel_sql.plugins.favs 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package net.sourceforge.squirrel_sql.plugins.favs;
002:
003:        /*
004:         * Copyright (C) 2001 Colin Bell
005:         * colbell@users.sourceforge.net
006:         *
007:         * This program is free software; you can redistribute it and/or
008:         * modify it under the terms of the GNU General Public License
009:         * as published by the Free Software Foundation; either version 2
010:         * of the License, or any later version.
011:         *
012:         * This program is distributed in the hope that it will be useful,
013:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
014:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
015:         * GNU General Public License for more details.
016:         *
017:         * You should have received a copy of the GNU General Public License
018:         * along with this program; if not, write to the Free Software
019:         * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
020:         */
021:        import javax.swing.JPanel;
022:        import javax.swing.event.TreeModelEvent;
023:        import javax.swing.event.TreeModelListener;
024:        import javax.swing.tree.DefaultTreeModel;
025:
026:        import net.sourceforge.squirrel_sql.client.IApplication;
027:        import net.sourceforge.squirrel_sql.fw.util.log.ILogger;
028:        import net.sourceforge.squirrel_sql.fw.util.log.LoggerController;
029:
030:        final class QueryTreeModel extends DefaultTreeModel {
031:
032:            /** Logger for this class. */
033:            private static ILogger s_log = LoggerController
034:                    .createLogger(QueryTreeModel.class);
035:
036:            private IApplication _app;
037:            private FoldersCache _cache;
038:
039:            private JPanel _emptyPnl = new JPanel();
040:
041:            private MyModelListener _modelListener = new MyModelListener();
042:
043:            QueryTreeModel(IApplication app, FoldersCache cache)
044:                    throws IllegalArgumentException {
045:                super (new FolderNode(new Folder(null, "Root")));
046:                if (app == null) {
047:                    throw new IllegalArgumentException(
048:                            "Null IApplication passed");
049:                }
050:                if (cache == null) {
051:                    throw new IllegalArgumentException(
052:                            "Null FoldersCache passed");
053:                }
054:                addTreeModelListener(_modelListener);
055:                _app = app;
056:                _cache = cache;
057:                loadTree();
058:            }
059:
060:            private void loadTree() {
061:                _modelListener.stopListening();
062:                try {
063:                    Folder rootFolder = _cache.getRootFolder();
064:                    if (rootFolder != null) {
065:                        FolderNode rootNode = new FolderNode(rootFolder);
066:                        setRoot(rootNode);
067:                        loadSubFolders(rootNode);
068:                    } else {
069:                        rootFolder = new Folder(null, "Root");
070:                        setRoot(new FolderNode(rootFolder));
071:                        _cache.setRootFolder(rootFolder);
072:                    }
073:                    reload();
074:                } finally {
075:                    _modelListener.startListening();
076:                }
077:            }
078:
079:            private void loadSubFolders(FolderNode node) {
080:                Folder[] subFolders = node.getFolder().getSubFolders();
081:                for (int i = 0; i < subFolders.length; ++i) {
082:                    FolderNode childNode = new FolderNode(subFolders[i]);
083:                    node.add(childNode);
084:                    loadSubFolders(childNode);
085:                }
086:            }
087:
088:            private static class MyModelListener implements  TreeModelListener {
089:                private boolean _listening = true;
090:
091:                public void treeStructureChanged(TreeModelEvent evt) {
092:                    s_log.debug("treeStructureChanged");
093:                }
094:
095:                public void treeNodesInserted(TreeModelEvent evt) {
096:                    s_log.debug("treeNodesInserted");
097:                }
098:
099:                public void treeNodesChanged(TreeModelEvent evt) {
100:                    s_log.debug("treeNodesChanged");
101:                    Object objs[] = evt.getChildren();
102:                    if (objs != null) {
103:                        for (int i = 0; i < objs.length; ++i) {
104:                            FolderNode node = (FolderNode) objs[i];
105:                            Folder folder = node.getFolder();
106:                            String newName = node.toString();
107:                            String oldName = folder.getName();
108:                            s_log.debug(oldName);
109:                            if (!newName.equals(oldName)) {
110:                                try {
111:                                    folder.setName(newName);
112:                                } catch (Exception ex) {
113:                                    s_log.error("Error", ex); // ??
114:                                }
115:                            }
116:                        }
117:                    }
118:                }
119:
120:                public void treeNodesRemoved(TreeModelEvent evt) {
121:                    s_log.debug("treeNodesRemoved");
122:                }
123:
124:                void startListening() {
125:                    _listening = true;
126:                }
127:
128:                void stopListening() {
129:                    _listening = false;
130:                }
131:            }
132:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.