Source Code Cross Referenced for ExportDialog.java in  » Database-Client » QueryForm » org » glasser » qform » 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 » QueryForm » org.glasser.qform 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /* ====================================================================
002:         * Copyright (c) 1998 - 2003 David F. Glasser.  All rights
003:         * reserved.
004:         *
005:         * This file is part of the QueryForm Database Tool.
006:         *
007:         * The QueryForm Database Tool is free software; you can redistribute it
008:         * and/or modify it under the terms of the GNU General Public License as
009:         * published by the Free Software Foundation; either version 2 of the
010:         * License, or (at your option) any later version.
011:         *
012:         * The QueryForm Database Tool is distributed in the hope that it will
013:         * be useful, but WITHOUT ANY WARRANTY; without even the implied
014:         * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
015:         * See the GNU General Public License for more details.
016:         *
017:         * You should have received a copy of the GNU General Public License
018:         * along with the QueryForm Database Tool; if not, write to:
019:         *
020:         *      The Free Software Foundation, Inc.,
021:         *      59 Temple Place, Suite 330
022:         *      Boston, MA  02111-1307  USA
023:         *
024:         * or visit http://www.gnu.org.
025:         *
026:         * ====================================================================
027:         *
028:         * This product includes software developed by the
029:         * Apache Software Foundation (http://www.apache.org/).
030:         *
031:         * ==================================================================== 
032:         */
033:        package org.glasser.qform;
034:
035:        import javax.swing.*;
036:        import org.glasser.util.Formatter;
037:        import org.glasser.sql.*;
038:        import org.glasser.swing.*;
039:        import java.awt.event.*;
040:        import java.awt.*;
041:        import javax.swing.border.*;
042:        import javax.swing.event.*;
043:        import java.util.HashMap;
044:
045:        public class ExportDialog extends JDialog implements  ActionListener {
046:
047:            static class IndexedCheckBox extends JCheckBox {
048:
049:                public int index = 0;
050:
051:                public IndexedCheckBox(int index) {
052:                    super ();
053:                    this .index = index;
054:                }
055:            }
056:
057:            JPanel topPanel = new JPanel();
058:            JPanel scrollHolder = new JPanel();
059:            JPanel buttonPanel = new JPanel();
060:
061:            JTextField txtTableName = new JTextField();
062:            JTextField txtTerminalChar = new JTextField();
063:
064:            JButton btnOk = new JButton("OK");
065:            JButton btnCancel = new JButton("Cancel");
066:
067:            Object[][] formFields = {
068:                    { txtTableName, "Table Name",
069:                            "Name of the table that will be used in each insert statement." },
070:                    {
071:                            txtTerminalChar,
072:                            "Terminal Character(s)",
073:                            "Optional character(s) that will be appended to the end of each insert statement. (Usually \";\")" } };
074:
075:            Object[][] buttonConfig = {
076:                    { btnOk, "O", "OK", "Export resultset." },
077:                    { btnCancel, "C", "CANCEL", "Cancel the export operation." } };
078:
079:            public ExportDialog(Frame parent) {
080:                super (parent);
081:
082:                JPanel cp = new JPanel();
083:                cp.setLayout(new BorderLayout());
084:
085:                GUIHelper.buildFormPanel(topPanel, formFields, -1, 5, null,
086:                        Color.black, false, -1);
087:
088:                cp.add(topPanel, BorderLayout.NORTH);
089:
090:                cp.add(scrollHolder, BorderLayout.CENTER);
091:
092:                buttonPanel.setLayout(new FlowLayout());
093:                Border defaultBorder = txtTerminalChar.getBorder();
094:                txtTerminalChar.setBorder(new CompoundBorder(defaultBorder,
095:                        new EmptyBorder(0, 15, 0, 0)));
096:                txtTerminalChar.setText(";");
097:                txtTerminalChar.setFont(new Font("Dialog", Font.BOLD, 13));
098:                topPanel.setBorder(new EmptyBorder(10, 10, 0, 10));
099:                scrollHolder.setLayout(new BorderLayout());
100:                scrollHolder.setBorder(new EmptyBorder(10, 10, 10, 10));
101:
102:                for (int j = 0; j < buttonConfig.length; j++) {
103:                    JButton button = (JButton) buttonConfig[j][0];
104:                    button.setMnemonic(((String) buttonConfig[j][1]).charAt(0));
105:                    button.setActionCommand((String) buttonConfig[j][2]);
106:                    button.setToolTipText((String) buttonConfig[j][3]);
107:                    button.addActionListener(this );
108:                    buttonPanel.add(button);
109:                }
110:
111:                //        buttonPanel.setBackground(Color.pink);
112:                //        topPanel.setBackground(Color.pink);
113:                //        cp.setBackground(Color.blue);
114:                cp.add(buttonPanel, BorderLayout.SOUTH);
115:
116:                setContentPane(cp);
117:
118:            }
119:
120:            private String[] columnNames = null;
121:
122:            private Formatter[] formatters = null;
123:
124:            public String[] getColumnNames() {
125:                return columnNames;
126:            }
127:
128:            public Formatter[] getFormatters() {
129:                return formatters;
130:            }
131:
132:            public String getTableName() {
133:                if (columnNames == null)
134:                    return null;
135:                return txtTableName.getText();
136:            }
137:
138:            public String getTerminal() {
139:                if (columnNames == null)
140:                    return null;
141:                return txtTerminalChar.getText();
142:            }
143:
144:            public void actionPerformed(ActionEvent e) {
145:                String command = e.getActionCommand();
146:                if (command.equals("OK")) {
147:                    exportPanel.update();
148:                    columnNames = exportPanel.getColumnNames();
149:                    formatters = exportPanel.getFormatters();
150:                    defaultTerminals[currentExportType] = this .txtTerminalChar
151:                            .getText();
152:                    setVisible(false);
153:                } else if (command.equals("CANCEL")) {
154:
155:                    columnNames = null;
156:                    formatters = null;
157:                    setVisible(false);
158:                }
159:            }
160:
161:            ExportPanel exportPanel = null;
162:
163:            HashMap cachedPanels = new HashMap();
164:
165:            int currentExportType = EXPORT_INSERT_STATEMENTS;
166:
167:            public void openDialog(TableInfo ti, int exportType) {
168:
169:                if (exportType == EXPORT_CSV) {
170:                    topPanel.setVisible(false);
171:                } else {
172:                    topPanel.setVisible(true);
173:                }
174:
175:                columnNames = null;
176:                formatters = null;
177:                currentExportType = exportType;
178:
179:                txtTableName.setText(ti.getQualifiedTableName());
180:                exportPanel = getExportPanel(ti, exportType);
181:
182:                scrollHolder.removeAll();
183:
184:                JScrollPane sp = new JScrollPane(exportPanel);
185:                scrollHolder.add(sp, BorderLayout.CENTER);
186:
187:                this .txtTerminalChar.setText(defaultTerminals[exportType]);
188:
189:                pack();
190:
191:                // don't let the dialog be more than 80% of the screen height
192:                Dimension size = this .getSize();
193:                Dimension screenSize = Toolkit.getDefaultToolkit()
194:                        .getScreenSize();
195:
196:                size = (Dimension) size.clone();
197:                size.height = Math.min((int) (screenSize.height * .8),
198:                        size.height);
199:                setSize(size);
200:                setModal(true);
201:                setVisible(true);
202:            }
203:
204:            public final static int EXPORT_INSERT_STATEMENTS = 0;
205:
206:            public final static int EXPORT_CSV = 1;
207:
208:            HashMap[] panelCaches = { new HashMap(), new HashMap() };
209:
210:            String[] defaultTerminals = { ";", "" };
211:
212:            private ExportPanel getExportPanel(TableInfo ti, int exportType) {
213:
214:                ExportPanel panel = (ExportPanel) panelCaches[exportType]
215:                        .get(ti);
216:                if (panel != null)
217:                    return panel;
218:                switch (exportType) {
219:                case EXPORT_INSERT_STATEMENTS:
220:                    panel = new InsertExportPanel(ti);
221:                    break;
222:                case EXPORT_CSV:
223:                    panel = new CsvExportPanel(ti);
224:                    break;
225:                default: // should never be reached because a NullPointer would already have been thrown
226:                    throw new IllegalArgumentException("Invalid export type: "
227:                            + exportType);
228:                }
229:
230:                // explicitly set the sizes
231:                Dimension d = panel.getPreferredSize();
232:                panel.setMinimumSize((Dimension) d.clone());
233:                panel.setPreferredSize((Dimension) d.clone());
234:
235:                panelCaches[exportType].put(ti, panel);
236:
237:                return panel;
238:
239:            }
240:
241:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.