Source Code Cross Referenced for CustomTreeUtil.java in  » Report » FreeReportBuilder » it » frb » 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 » Report » FreeReportBuilder » it.frb.tree 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright (C) 2004 Giuseppe MANNA
003:         * 
004:         * This file is part of FreeReportBuilder
005:         * 
006:         * FreeReportBuilder is free software; you can redistribute it and/or
007:         * modify it under the terms of the GNU General Public License
008:         * as published by the Free Software Foundation; either version 2
009:         * of the License, or (at your option) any later version.
010:         * 
011:         * This program is distributed in the hope that it will be useful,
012:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
013:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
014:         * GNU General Public License for more details.
015:         * 
016:         * You should have received a copy of the GNU General Public License
017:         * along with this program; if not, write to the Free Software
018:         * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
019:         * 
020:         */
021:
022:        package it.frb.tree;
023:
024:        import it.frb.*;
025:        import javax.swing.tree.DefaultMutableTreeNode;
026:
027:        /** Oggetto che contiene delle funzioni utili
028:         * al treeview.
029:         */
030:        public class CustomTreeUtil {
031:            private java.io.File fl;
032:            private String schema = null;
033:
034:            /** Metodo che ritorna la root di un treeview
035:             * caricato a partire .
036:             * @param path Path di sistema da cui iniziare
037:             * a caricare il treeview.
038:             *
039:             * Inserire "." se si vuole partire
040:             * dalla posizione corrente.
041:             * @param objParent Nodo padre del sottoalbero che
042:             * verra' generato.
043:             *
044:             * Se il sottoalbero che sara' creato
045:             * non ha padre allora settare il parametro a Null.
046:             * @return DefaultMutableTreeNode
047:             */
048:            public DefaultMutableTreeNode getNodeRootDatabaseShema() {
049:                java.sql.Connection conn = null;
050:                java.sql.ResultSet rsTables = null;
051:                DefaultMutableTreeNode root = new DefaultMutableTreeNode(
052:                        "Tables");
053:
054:                java.util.Vector vTables = new java.util.Vector();
055:
056:                try {
057:                    conn = Connessione.getConnessione();
058:
059:                    java.sql.DatabaseMetaData dbMD = conn.getMetaData();
060:
061:                    java.util.Vector vSchemas = new java.util.Vector();
062:
063:                    java.sql.ResultSet rsSchemas = null;
064:
065:                    try {
066:                        rsSchemas = dbMD.getSchemas();
067:
068:                        while (rsSchemas.next()) {
069:                            String schemas = rsSchemas.getString("TABLE_SCHEM");
070:                            vSchemas.add(schemas);
071:                        }
072:
073:                        rsSchemas.close();
074:
075:                        Object[] possibilities = new Object[vSchemas.size()];
076:
077:                        for (int i = 0; i < vSchemas.size(); i++) {
078:                            possibilities[i] = (String) vSchemas.get(i);
079:                        }
080:
081:                        if (vSchemas.size() != 1) {
082:                            schema = (String) javax.swing.JOptionPane
083:                                    .showInputDialog(
084:                                            null,
085:                                            "You choose the scheme.",
086:                                            "Scheme present on the Database",
087:                                            javax.swing.JOptionPane.INFORMATION_MESSAGE,
088:                                            null, possibilities,
089:                                            possibilities[0]);
090:                        }
091:
092:                    } catch (java.sql.SQLException s) {
093:                    }
094:
095:                    if (schema != null) {
096:                        rsTables = dbMD.getTables(null, schema, null, null);
097:                    } else {
098:                        rsTables = dbMD.getTables(null, null, null, null);
099:                    }
100:
101:                    while (rsTables.next()) {
102:                        String tableName = rsTables.getString("TABLE_NAME");
103:                        String ttype = rsTables.getString("TABLE_TYPE");
104:
105:                        if (ttype.equals("TABLE")) {
106:                            DefaultMutableTreeNode nTable = new DefaultMutableTreeNode(
107:                                    tableName);
108:                            DefaultMutableTreeNode nColonne = new DefaultMutableTreeNode(
109:                                    "Colonne");
110:                            DefaultMutableTreeNode nPrimaryKey = new DefaultMutableTreeNode(
111:                                    "Primary Key");
112:                            DefaultMutableTreeNode nPrimaryKeyExp = new DefaultMutableTreeNode(
113:                                    "Primary Exported");
114:                            DefaultMutableTreeNode nForeignKey = new DefaultMutableTreeNode(
115:                                    "Foreign Key");
116:                            DefaultMutableTreeNode nIndexKey = new DefaultMutableTreeNode(
117:                                    "Index");
118:                            nTable.add(nColonne);
119:                            nTable.add(nPrimaryKey);
120:                            nTable.add(nPrimaryKeyExp);
121:                            nTable.add(nForeignKey);
122:                            nTable.add(nIndexKey);
123:
124:                            root.add(nTable);
125:                        }
126:                    }
127:
128:                    rsTables.close();
129:                    boolean bMltStm = ConfigurationProperties.properties()
130:                            .getUseMultiTransaction(false);
131:
132:                    if (!bMltStm) {
133:                        conn.close();
134:                    }
135:
136:                } catch (java.sql.SQLException s) {
137:                    javax.swing.JOptionPane.showMessageDialog(null, s
138:                            .getMessage());
139:
140:                } finally {
141:                    try {
142:                        boolean bMltStm = ConfigurationProperties.properties()
143:                                .getUseMultiTransaction(false);
144:
145:                        if (!bMltStm) {
146:                            conn.close();
147:                        }
148:
149:                    } catch (java.sql.SQLException s) {
150:                        javax.swing.JOptionPane.showMessageDialog(null, s
151:                                .getMessage());
152:                    }
153:                }
154:
155:                return root;
156:            }
157:
158:            public String getSchema() {
159:                return schema;
160:            }
161:
162:            public static javax.swing.tree.TreePath getChildPath(
163:                    javax.swing.JTree jT, javax.swing.tree.TreePath pathParent,
164:                    int nChildIndex) {
165:                javax.swing.tree.TreeModel model = jT.getModel();
166:                return pathParent.pathByAddingChild(model.getChild(pathParent
167:                        .getLastPathComponent(), nChildIndex));
168:            }
169:
170:            public static boolean isRootPath(javax.swing.JTree jT,
171:                    javax.swing.tree.TreePath path) {
172:                return jT.isRootVisible() && jT.getRowForPath(path) == 0;
173:            }
174:
175:            public static void sayWhat(javax.swing.event.TreeModelEvent e) {
176:                System.out.println(e.getTreePath().getLastPathComponent());
177:                int[] nIndex = e.getChildIndices();
178:                for (int i = 0; i < nIndex.length; i++) {
179:                    System.out.println(i + ". " + nIndex[i]);
180:                }
181:            }
182:
183:            /** Fornito un oggetto TreePath, torna il path sotto
184:             * forma di stringa.
185:             * @param asObjTreePath Oggetto TreePath di cui si vuole il path
186:             * in formato stringa.
187:             * @return String
188:             */
189:            public static String getStringFromTreePath(
190:                    javax.swing.tree.TreePath asObjTreePath) {
191:                String path = asObjTreePath.getPathComponent(0).toString();
192:                for (int i = 1; i < asObjTreePath.getPathCount(); i++) {
193:                    if (i == 1) {
194:                        path = path + asObjTreePath.getPathComponent(i);
195:                    } else {
196:                        path = path + "/" + asObjTreePath.getPathComponent(i);
197:                    }
198:                }
199:                return path;
200:            }
201:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.