Source Code Cross Referenced for CodeHelpBuilder.java in  » Database-Client » DBBrowser » org » dbbrowser » ui » panel » dbbrowserwindow » 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 » DBBrowser » org.dbbrowser.ui.panel.dbbrowserwindow 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.dbbrowser.ui.panel.dbbrowserwindow;
002:
003:        import infrastructure.logging.Log;
004:        import java.awt.event.ActionListener;
005:        import java.util.*;
006:        import javax.swing.JMenu;
007:        import javax.swing.JMenuItem;
008:        import javax.swing.JPopupMenu;
009:        import javax.swing.event.ChangeEvent;
010:        import javax.swing.event.ChangeListener;
011:        import org.dbbrowser.db.engine.exception.DBEngineException;
012:        import org.dbbrowser.db.engine.model.ColumnInfo;
013:        import org.dbbrowser.ui.UIControllerForQueries;
014:
015:        public class CodeHelpBuilder extends Thread {
016:            private UIControllerForQueries uiController = null;
017:            private ActionListener actionListenerForPopupMenu = null;
018:            private ChangeListener changeListener = null;
019:            private ChangeListener processCompletedListener = null;
020:
021:            private JPopupMenu codeHelp = null;
022:            private int counter = 0;
023:
024:            public CodeHelpBuilder(UIControllerForQueries uiController,
025:                    ActionListener actionListenerForPopupMenu,
026:                    ChangeListener changeListener,
027:                    ChangeListener processCompletedListener) {
028:                this .uiController = uiController;
029:                this .actionListenerForPopupMenu = actionListenerForPopupMenu;
030:                this .changeListener = changeListener;
031:                this .processCompletedListener = processCompletedListener;
032:            }
033:
034:            public JPopupMenu getJPopupMenu() {
035:                return codeHelp;
036:            }
037:
038:            public void run() {
039:
040:                Map mapOfSchemaNamesToListOfTableNames = null;
041:                Map mapOfTableNamesToListOfColumnInfos = null;
042:
043:                //Get the map of tablespaceNames to list of tablenames
044:                try {
045:                    mapOfSchemaNamesToListOfTableNames = buildMapOfSchemaNamesToListOfTableNames();
046:                    mapOfTableNamesToListOfColumnInfos = buildMapOfTableNamesToListOfColumnInfos(mapOfSchemaNamesToListOfTableNames
047:                            .keySet());
048:                } catch (DBEngineException exc) {
049:                    Log.getInstance().fatalMessage(
050:                            "*** Serious error while retrieving list of schema names *** - "
051:                                    + exc.getMessage(),
052:                            this .getClass().getName());
053:                    //Dont do anything, use null values
054:                }
055:
056:                if (mapOfSchemaNamesToListOfTableNames != null) {
057:                    //Iterate through the map and build the pop up menu
058:                    codeHelp = new JPopupMenu();
059:                    Iterator i = mapOfSchemaNamesToListOfTableNames.keySet()
060:                            .iterator();
061:                    while (i.hasNext()) {
062:                        String schemaName = (String) i.next();
063:                        List listOfTableNames = (List) mapOfSchemaNamesToListOfTableNames
064:                                .get(schemaName);
065:
066:                        //Build the popup menu
067:                        JMenu jMenuForSchemaName = new JMenu(schemaName);
068:                        JMenuItem jMenuItemForSchemName = new JMenuItem(" - "
069:                                + schemaName + " - ");
070:                        jMenuItemForSchemName.setActionCommand(schemaName);
071:                        jMenuItemForSchemName
072:                                .addActionListener(actionListenerForPopupMenu);
073:                        jMenuForSchemaName.add(jMenuItemForSchemName);
074:
075:                        //Build a jmenu item for each table in the tablspace
076:                        Iterator iteratorForListOfTableNames = listOfTableNames
077:                                .iterator();
078:                        while (iteratorForListOfTableNames.hasNext()) {
079:                            String tablename = (String) iteratorForListOfTableNames
080:                                    .next();
081:                            JMenu jMenuForTableName = new JMenu(tablename);
082:                            jMenuForTableName
083:                                    .addActionListener(actionListenerForPopupMenu);
084:                            JMenuItem jMenuItemForTableName = new JMenuItem(
085:                                    " - " + tablename + " - ");
086:                            jMenuItemForTableName.setActionCommand(tablename);
087:                            jMenuItemForTableName
088:                                    .addActionListener(actionListenerForPopupMenu);
089:                            jMenuForTableName.add(jMenuItemForTableName);
090:                            jMenuForSchemaName.add(jMenuForTableName);
091:
092:                            //Build a jmenu item for each column in the table
093:                            Object o = mapOfTableNamesToListOfColumnInfos
094:                                    .get(tablename);
095:                            if (o != null) {
096:                                List listOfColumnInfos = (List) o;
097:                                Iterator iteratorForListOfColumnInfos = listOfColumnInfos
098:                                        .iterator();
099:                                while (iteratorForListOfColumnInfos.hasNext()) {
100:                                    ColumnInfo ci = (ColumnInfo) iteratorForListOfColumnInfos
101:                                            .next();
102:                                    String columnInfoString = ci
103:                                            .getColumnName()
104:                                            + " - "
105:                                            + ci.getColumnTypeName()
106:                                            + " - "
107:                                            + ci.getColumnDisplaySize()
108:                                                    .intValue();
109:                                    JMenuItem jmenuItemForColumnName = new JMenuItem(
110:                                            columnInfoString);
111:                                    jmenuItemForColumnName.setActionCommand(ci
112:                                            .getColumnName());
113:                                    jmenuItemForColumnName
114:                                            .addActionListener(actionListenerForPopupMenu);
115:                                    jMenuForTableName
116:                                            .add(jmenuItemForColumnName);
117:
118:                                    counter++;
119:                                    this .changeListener
120:                                            .stateChanged(new ChangeEvent(
121:                                                    new Integer(counter)));
122:                                }
123:                            }
124:                        }
125:
126:                        codeHelp.add(jMenuForSchemaName);
127:                    }
128:                }
129:
130:                this .processCompletedListener.stateChanged(new ChangeEvent(
131:                        "Process complete"));
132:            }
133:
134:            private Map buildMapOfSchemaNamesToListOfTableNames()
135:                    throws DBEngineException {
136:                Map mapOfSchemaNamesToListOfTableNames = new TreeMap();
137:                List listOfSchemas = this .uiController.listSchemas();
138:
139:                Iterator i = listOfSchemas.iterator();
140:                while (i.hasNext()) {
141:                    String schemaName = (String) i.next();
142:
143:                    //Get all the tables in the tablespace
144:                    List listOfTablesInSchema = this .uiController
145:                            .listTablesInSchema(schemaName);
146:
147:                    //Add to map
148:                    mapOfSchemaNamesToListOfTableNames.put(schemaName,
149:                            listOfTablesInSchema);
150:
151:                    counter++;
152:                    this .changeListener.stateChanged(new ChangeEvent(
153:                            new Integer(counter)));
154:                }
155:
156:                return mapOfSchemaNamesToListOfTableNames;
157:            }
158:
159:            private Map buildMapOfTableNamesToListOfColumnInfos(Set setOfSchemas)
160:                    throws DBEngineException {
161:                Map mapOfTableNamesToListOfColumnInfos = new TreeMap();
162:                Iterator i = setOfSchemas.iterator();
163:                while (i.hasNext()) {
164:                    String schemaName = (String) i.next();
165:
166:                    //Get all the tables in the tablespace
167:                    List listOfTablesInSchema = this .uiController
168:                            .listTablesInSchema(schemaName);
169:
170:                    //Get the list of columns in each table
171:                    Iterator ii = listOfTablesInSchema.iterator();
172:                    while (ii.hasNext()) {
173:                        String tableName = (String) ii.next();
174:
175:                        try {
176:                            List listOfColumnInfos = this .uiController
177:                                    .listColumnsInATable(schemaName, tableName);
178:                            mapOfTableNamesToListOfColumnInfos.put(tableName,
179:                                    listOfColumnInfos);
180:                        } catch (DBEngineException exc) {
181:                            Log.getInstance().infoMessage(
182:                                    exc.getMessage() + " - " + schemaName + "."
183:                                            + tableName,
184:                                    this .getClass().getName());
185:                        }
186:
187:                        counter++;
188:                        this .changeListener.stateChanged(new ChangeEvent(
189:                                new Integer(counter)));
190:                    }
191:                }
192:
193:                return mapOfTableNamesToListOfColumnInfos;
194:            }
195:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.