Source Code Cross Referenced for DbConnWin.java in  » Report » datavision-1.1.0 » jimm » datavision » gui » sql » 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 » datavision 1.1.0 » jimm.datavision.gui.sql 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package jimm.datavision.gui.sql;
002:
003:        import jimm.datavision.*;
004:        import jimm.datavision.gui.*;
005:        import jimm.datavision.source.sql.Database;
006:        import jimm.datavision.gui.cmd.DbConnCommand;
007:        import jimm.util.StringUtils;
008:        import jimm.util.I18N;
009:        import java.awt.BorderLayout;
010:        import java.awt.event.*;
011:        import javax.swing.*;
012:
013:        /**
014:         * A database connection editing dialog box. The user can either enter
015:         * separate values or copy values from an existing report XML file.
016:         *
017:         * @see DbConnReader
018:         * @author Jim Menard, <a href="mailto:jimm@io.com">jimm@io.com</a>
019:         */
020:        public class DbConnWin extends EditWin implements  ActionListener {
021:
022:            protected static final int TEXT_FIELD_COLS = 32;
023:
024:            protected Report report;
025:            protected JTextField driverClassNameField;
026:            protected JTextField connInfoField;
027:            protected JTextField dbNameField;
028:            protected JTextField userNameField;
029:            protected JPasswordField passwordField;
030:
031:            /**
032:             * Constructor.
033:             *
034:             * @param designer the window to which this dialog belongs
035:             * @param report the report
036:             * @param modal if <code>true</code>, this window is modal
037:             */
038:            public DbConnWin(Designer designer, Report report, boolean modal) {
039:                super (designer, I18N.get("DbConnWin.title"),
040:                        "DbConnCommand.name", modal);
041:
042:                this .report = report;
043:
044:                buildWindow();
045:                pack();
046:                setVisible(true);
047:            }
048:
049:            /**
050:             * Builds the window contents.
051:             */
052:            protected void buildWindow() {
053:                JPanel editorPanel = buildEditor();
054:
055:                // OK, Apply, Revert, and Cancel Buttons
056:                JPanel buttonPanel = closeButtonPanel();
057:
058:                // Add values and buttons to window
059:                getContentPane().add(editorPanel, BorderLayout.CENTER);
060:                getContentPane().add(buttonPanel, BorderLayout.SOUTH);
061:
062:                new FocusSetter(driverClassNameField);
063:            }
064:
065:            protected JPanel buildEditor() {
066:                Database db = (Database) report.getDataSource();
067:                EditFieldLayout efl = new EditFieldLayout();
068:                efl.setBorder(20);
069:
070:                driverClassNameField = efl.addTextField(I18N
071:                        .get("DbConnWin.driver_class_name"), db == null ? ""
072:                        : db.getDriverClassName(), TEXT_FIELD_COLS);
073:                connInfoField = efl.addTextField(I18N
074:                        .get("DbConnWin.connection_info"), db == null ? "" : db
075:                        .getConnectionInfo(), TEXT_FIELD_COLS);
076:                dbNameField = efl.addTextField(I18N
077:                        .get("DbConnWin.database_name"), db == null ? "" : db
078:                        .getName(), TEXT_FIELD_COLS);
079:                userNameField = efl.addTextField(I18N
080:                        .get("DbConnWin.user_name"), db == null ? "" : db
081:                        .getUserName(), TEXT_FIELD_COLS);
082:                String password = (db == null ? "" : db.getPassword());
083:                if (password == null)
084:                    password = "";
085:                passwordField = efl.addPasswordField(I18N
086:                        .get("DbConnWin.password"), password, TEXT_FIELD_COLS);
087:
088:                // Click to copy info from another report
089:                JButton copyButton = new JButton(I18N
090:                        .get("DbConnWin.copy_settings"));
091:                copyButton.addActionListener(this );
092:                JPanel copyPanel = new JPanel();
093:                copyPanel.add(copyButton);
094:                efl.add(null, copyPanel);
095:
096:                return efl.getPanel();
097:            }
098:
099:            protected void fillEditFields() {
100:                Database db = (Database) report.getDataSource();
101:                if (db == null) {
102:                    driverClassNameField.setText("");
103:                    connInfoField.setText("");
104:                    dbNameField.setText("");
105:                    userNameField.setText("");
106:                } else {
107:                    driverClassNameField.setText(db.getDriverClassName());
108:                    connInfoField.setText(db.getConnectionInfo());
109:                    dbNameField.setText(db.getName());
110:                    userNameField.setText(db.getUserName());
111:                }
112:                passwordField.setText("");
113:            }
114:
115:            /**
116:             * Handles the "Copy Settings..." button.
117:             *
118:             * @param e action event
119:             */
120:            public void actionPerformed(ActionEvent e) {
121:                String cmd = e.getActionCommand();
122:                if (I18N.get("DbConnWin.copy_settings").equals(cmd)) {
123:                    JFileChooser chooser = Designer.getChooser();
124:                    Designer.setPrefsDir(chooser, null);
125:                    int returnVal = chooser.showOpenDialog(this );
126:                    if (returnVal == JFileChooser.APPROVE_OPTION) {
127:                        DbConnReader reader = new DbConnReader();
128:                        try {
129:                            reader.read(chooser.getSelectedFile());
130:                            driverClassNameField.setText(reader
131:                                    .getDriverClassName());
132:                            connInfoField.setText(reader.getConnectionInfo());
133:                            dbNameField.setText(reader.getDbName());
134:                            userNameField.setText(reader.getUserName());
135:                        } catch (Exception ex) {
136:                            ErrorHandler.error(
137:                                    I18N.get("DbConnWin.copy_error"), ex);
138:                        }
139:                    }
140:                } else
141:                    super .actionPerformed(e);
142:            }
143:
144:            protected void doSave() {
145:                DbConnCommand cmd = new DbConnCommand(report, StringUtils
146:                        .nullOrTrimmed(driverClassNameField.getText()),
147:                        StringUtils.nullOrTrimmed(connInfoField.getText()),
148:                        StringUtils.nullOrTrimmed(dbNameField.getText()),
149:                        StringUtils.nullOrTrimmed(userNameField.getText()),
150:                        StringUtils.nullOrTrimmed(new String(passwordField
151:                                .getPassword())));
152:                cmd.perform();
153:                commands.add(cmd);
154:            }
155:
156:            protected void doRevert() {
157:                fillEditFields();
158:            }
159:
160:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.