Source Code Cross Referenced for JDBCConnectionEditor.java in  » Report » iReport-2.0.5 » it » businesslogic » ireport » connection » gui » 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 » iReport 2.0.5 » it.businesslogic.ireport.connection.gui 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * JDBCConnectionEditor.java
003:         *
004:         * Created on March 27, 2007, 10:35 AM
005:         */
006:
007:        package it.businesslogic.ireport.connection.gui;
008:
009:        import it.businesslogic.ireport.IReportConnection;
010:        import it.businesslogic.ireport.connection.JDBCConnection;
011:        import it.businesslogic.ireport.IReportConnectionEditor;
012:        import it.businesslogic.ireport.util.I18n;
013:        import it.businesslogic.ireport.util.Misc;
014:        import javax.swing.DefaultComboBoxModel;
015:
016:        /**
017:         *
018:         * @author  gtoffoli
019:         */
020:        public class JDBCConnectionEditor extends javax.swing.JPanel implements 
021:                IReportConnectionEditor {
022:
023:            private IReportConnection iReportConnection = null;
024:
025:            /** Creates new form JDBCConnectionEditor */
026:            public JDBCConnectionEditor() {
027:                initComponents();
028:                applyI18n();
029:
030:                jComboBoxJDBCDriver
031:                        .setModel(new DefaultComboBoxModel(
032:                                new Object[] {
033:                                        "COM.cloudscape.JDBCDriver",
034:                                        "COM.ibm.db2.jdbc.app.DB2Driver",
035:                                        "com.inet.tds.TdsDriver",
036:                                        "com.informix.jdbc.IfxDriver",
037:                                        "com.ingres.jdbc.IngresDriver",
038:                                        "com.internetcds.jdbc.tds.Driver",
039:                                        "com.merant.datadirect.jdbc.sqlserver.SQLServerDriver",
040:                                        "com.microsoft.jdbc.sqlserver.SQLServerDriver",
041:                                        "com.ms.jdbc.odbc.JdbcOdbcDriver",
042:                                        "com.mysql.jdbc.Driver",
043:                                        "com.sybase.jdbc2.jdbc.SybDriver",
044:                                        "net.sourceforge.jtds.jdbc.Driver",
045:                                        "oracle.jdbc.driver.OracleDriver",
046:                                        "org.gjt.mm.mysql.Driver",
047:                                        "org.hsqldb.jdbcDriver",
048:                                        "org.postgresql.Driver",
049:                                        "sun.jdbc.odbc.JdbcOdbcDriver",
050:                                        "org.sqlite.JDBC" }));
051:
052:                jComboBoxJDBCDriver.setSelectedItem("com.mysql.jdbc.Driver");
053:            }
054:
055:            /** This method is called from within the constructor to
056:             * initialize the form.
057:             * WARNING: Do NOT modify this code. The content of this method is
058:             * always regenerated by the Form Editor.
059:             */
060:            // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
061:            private void initComponents() {
062:                java.awt.GridBagConstraints gridBagConstraints;
063:
064:                jPanelJDBC = new javax.swing.JPanel();
065:                jLabel2 = new javax.swing.JLabel();
066:                jLabel3 = new javax.swing.JLabel();
067:                jComboBoxJDBCDriver = new javax.swing.JComboBox();
068:                jTextFieldJDBCUrl = new javax.swing.JTextField();
069:                jPanel2 = new javax.swing.JPanel();
070:                jLabel14 = new javax.swing.JLabel();
071:                jLabel5 = new javax.swing.JLabel();
072:                jTextFieldDBName = new javax.swing.JTextField();
073:                jTextFieldServerAddress = new javax.swing.JTextField();
074:                jButtonWizard = new javax.swing.JButton();
075:                jLabel6 = new javax.swing.JLabel();
076:                jLabel7 = new javax.swing.JLabel();
077:                jTextFieldPassword = new javax.swing.JPasswordField();
078:                jTextFieldUsername = new javax.swing.JTextField();
079:                jCheckBoxSavePassword = new javax.swing.JCheckBox();
080:                jLabel1 = new javax.swing.JLabel();
081:
082:                setLayout(new java.awt.BorderLayout());
083:
084:                jPanelJDBC.setLayout(new java.awt.GridBagLayout());
085:
086:                jLabel2.setText("JDBC Driver");
087:                gridBagConstraints = new java.awt.GridBagConstraints();
088:                gridBagConstraints.gridx = 0;
089:                gridBagConstraints.gridy = 0;
090:                gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
091:                gridBagConstraints.insets = new java.awt.Insets(2, 6, 0, 0);
092:                jPanelJDBC.add(jLabel2, gridBagConstraints);
093:
094:                jLabel3.setText("JDBC URL");
095:                gridBagConstraints = new java.awt.GridBagConstraints();
096:                gridBagConstraints.gridx = 0;
097:                gridBagConstraints.gridy = 1;
098:                gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
099:                gridBagConstraints.insets = new java.awt.Insets(2, 6, 0, 0);
100:                jPanelJDBC.add(jLabel3, gridBagConstraints);
101:
102:                jComboBoxJDBCDriver.setEditable(true);
103:                jComboBoxJDBCDriver
104:                        .addActionListener(new java.awt.event.ActionListener() {
105:                            public void actionPerformed(
106:                                    java.awt.event.ActionEvent evt) {
107:                                jComboBoxJDBCDriverActionPerformed(evt);
108:                            }
109:                        });
110:
111:                gridBagConstraints = new java.awt.GridBagConstraints();
112:                gridBagConstraints.gridx = 1;
113:                gridBagConstraints.gridy = 0;
114:                gridBagConstraints.gridwidth = 2;
115:                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
116:                gridBagConstraints.insets = new java.awt.Insets(2, 6, 0, 6);
117:                jPanelJDBC.add(jComboBoxJDBCDriver, gridBagConstraints);
118:
119:                gridBagConstraints = new java.awt.GridBagConstraints();
120:                gridBagConstraints.gridx = 1;
121:                gridBagConstraints.gridy = 1;
122:                gridBagConstraints.gridwidth = 2;
123:                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
124:                gridBagConstraints.insets = new java.awt.Insets(2, 6, 0, 6);
125:                jPanelJDBC.add(jTextFieldJDBCUrl, gridBagConstraints);
126:
127:                jPanel2.setLayout(new java.awt.GridBagLayout());
128:
129:                jPanel2.setBorder(javax.swing.BorderFactory
130:                        .createTitledBorder("JDBC URL Wizard"));
131:                jPanel2.setMinimumSize(new java.awt.Dimension(179, 70));
132:                jLabel14.setText("Server Address");
133:                gridBagConstraints = new java.awt.GridBagConstraints();
134:                gridBagConstraints.gridx = 0;
135:                gridBagConstraints.gridy = 0;
136:                gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
137:                gridBagConstraints.insets = new java.awt.Insets(2, 6, 0, 0);
138:                jPanel2.add(jLabel14, gridBagConstraints);
139:
140:                jLabel5.setText("Database");
141:                gridBagConstraints = new java.awt.GridBagConstraints();
142:                gridBagConstraints.gridx = 0;
143:                gridBagConstraints.gridy = 1;
144:                gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
145:                gridBagConstraints.insets = new java.awt.Insets(2, 6, 0, 0);
146:                jPanel2.add(jLabel5, gridBagConstraints);
147:
148:                gridBagConstraints = new java.awt.GridBagConstraints();
149:                gridBagConstraints.gridx = 1;
150:                gridBagConstraints.gridy = 1;
151:                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
152:                gridBagConstraints.weightx = 1.0;
153:                gridBagConstraints.insets = new java.awt.Insets(2, 6, 0, 0);
154:                jPanel2.add(jTextFieldDBName, gridBagConstraints);
155:
156:                gridBagConstraints = new java.awt.GridBagConstraints();
157:                gridBagConstraints.gridx = 1;
158:                gridBagConstraints.gridy = 0;
159:                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
160:                gridBagConstraints.weightx = 1.0;
161:                gridBagConstraints.insets = new java.awt.Insets(2, 6, 0, 0);
162:                jPanel2.add(jTextFieldServerAddress, gridBagConstraints);
163:
164:                jButtonWizard.setText("Wizard");
165:                jButtonWizard.setMargin(new java.awt.Insets(2, 2, 2, 2));
166:                jButtonWizard.setMaximumSize(new java.awt.Dimension(60, 23));
167:                jButtonWizard.setMinimumSize(new java.awt.Dimension(60, 23));
168:                jButtonWizard.setPreferredSize(new java.awt.Dimension(60, 23));
169:                jButtonWizard
170:                        .addActionListener(new java.awt.event.ActionListener() {
171:                            public void actionPerformed(
172:                                    java.awt.event.ActionEvent evt) {
173:                                jButtonWizardActionPerformed(evt);
174:                            }
175:                        });
176:
177:                gridBagConstraints = new java.awt.GridBagConstraints();
178:                gridBagConstraints.gridx = 2;
179:                gridBagConstraints.gridy = 1;
180:                gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
181:                gridBagConstraints.insets = new java.awt.Insets(2, 6, 2, 0);
182:                jPanel2.add(jButtonWizard, gridBagConstraints);
183:
184:                gridBagConstraints = new java.awt.GridBagConstraints();
185:                gridBagConstraints.gridx = 0;
186:                gridBagConstraints.gridy = 4;
187:                gridBagConstraints.gridwidth = 3;
188:                gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
189:                gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
190:                gridBagConstraints.weightx = 1.0;
191:                jPanelJDBC.add(jPanel2, gridBagConstraints);
192:
193:                jLabel6.setText("Username");
194:                gridBagConstraints = new java.awt.GridBagConstraints();
195:                gridBagConstraints.gridx = 0;
196:                gridBagConstraints.gridy = 5;
197:                gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
198:                gridBagConstraints.insets = new java.awt.Insets(2, 6, 0, 0);
199:                jPanelJDBC.add(jLabel6, gridBagConstraints);
200:
201:                jLabel7.setText("Password");
202:                gridBagConstraints = new java.awt.GridBagConstraints();
203:                gridBagConstraints.gridx = 0;
204:                gridBagConstraints.gridy = 6;
205:                gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
206:                gridBagConstraints.insets = new java.awt.Insets(2, 6, 0, 0);
207:                jPanelJDBC.add(jLabel7, gridBagConstraints);
208:
209:                jTextFieldPassword.setFont(new java.awt.Font("Tahoma", 0, 11));
210:                gridBagConstraints = new java.awt.GridBagConstraints();
211:                gridBagConstraints.gridx = 1;
212:                gridBagConstraints.gridy = 6;
213:                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
214:                gridBagConstraints.weightx = 1.0;
215:                gridBagConstraints.insets = new java.awt.Insets(2, 6, 0, 0);
216:                jPanelJDBC.add(jTextFieldPassword, gridBagConstraints);
217:
218:                gridBagConstraints = new java.awt.GridBagConstraints();
219:                gridBagConstraints.gridx = 1;
220:                gridBagConstraints.gridy = 5;
221:                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
222:                gridBagConstraints.weightx = 1.0;
223:                gridBagConstraints.insets = new java.awt.Insets(2, 6, 0, 0);
224:                jPanelJDBC.add(jTextFieldUsername, gridBagConstraints);
225:
226:                jCheckBoxSavePassword.setText("Save password");
227:                gridBagConstraints = new java.awt.GridBagConstraints();
228:                gridBagConstraints.gridx = 2;
229:                gridBagConstraints.gridy = 6;
230:                gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
231:                gridBagConstraints.insets = new java.awt.Insets(2, 6, 0, 6);
232:                jPanelJDBC.add(jCheckBoxSavePassword, gridBagConstraints);
233:
234:                jLabel1
235:                        .setIcon(new javax.swing.ImageIcon(
236:                                getClass()
237:                                        .getResource(
238:                                                "/it/businesslogic/ireport/icons/problems/warning.png")));
239:                jLabel1.setText("jLabel1");
240:                gridBagConstraints = new java.awt.GridBagConstraints();
241:                gridBagConstraints.gridx = 0;
242:                gridBagConstraints.gridwidth = 3;
243:                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
244:                gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH;
245:                gridBagConstraints.weightx = 1.0;
246:                gridBagConstraints.weighty = 1.0;
247:                gridBagConstraints.insets = new java.awt.Insets(4, 4, 4, 4);
248:                jPanelJDBC.add(jLabel1, gridBagConstraints);
249:
250:                add(jPanelJDBC, java.awt.BorderLayout.CENTER);
251:
252:            }// </editor-fold>//GEN-END:initComponents
253:
254:            private void jComboBoxJDBCDriverActionPerformed(
255:                    java.awt.event.ActionEvent evt) {
256:                // Run the wizard to populate Connection URL
257:                jButtonWizardActionPerformed(null);
258:            }
259:
260:            private void jButtonWizardActionPerformed(
261:                    java.awt.event.ActionEvent evt) {
262:
263:                if (jComboBoxJDBCDriver.getSelectedIndex() < 0)
264:                    return;
265:                String driver = "" + jComboBoxJDBCDriver.getSelectedItem();
266:                driver = driver.trim();
267:                if (driver.equals(""))
268:                    return;
269:
270:                String server = jTextFieldServerAddress.getText().trim();
271:                if (server.length() == 0) {
272:                    server = "localhost";
273:                }
274:
275:                String databaseName = jTextFieldDBName.getText().trim();
276:
277:                if (driver.equalsIgnoreCase("org.gjt.mm.mysql.Driver")) {
278:                    String url = "jdbc:mysql://" + server + "/";
279:                    if (databaseName.length() > 0)
280:                        url += databaseName;
281:                    else
282:                        url += "MYDATABASE";
283:                    jTextFieldJDBCUrl.setText(url);
284:                } else if (driver.equalsIgnoreCase("com.mysql.jdbc.Driver")) {
285:                    String url = "jdbc:mysql://" + server + "/";
286:                    if (databaseName.length() > 0)
287:                        url += databaseName;
288:                    else
289:                        url += "MYDATABASE";
290:                    jTextFieldJDBCUrl.setText(url);
291:                } else if (driver
292:                        .equalsIgnoreCase("com.internetcds.jdbc.tds.Driver")) {
293:                    String url = "jdbc:freetds:sqlserver://localhost/";
294:                    if (databaseName.length() > 0)
295:                        url += databaseName;
296:                    else
297:                        url += "MYDATABASE";
298:                    jTextFieldJDBCUrl.setText(url);
299:                } else if (driver
300:                        .equalsIgnoreCase("com.microsoft.jdbc.sqlserver.SQLServerDriver")) {
301:                    String url = "jdbc:microsoft:sqlserver://" + server
302:                            + ":1433;DatabaseName=";
303:                    if (databaseName.length() > 0)
304:                        url += databaseName;
305:                    else
306:                        url += "MYDATABASE";
307:                    jTextFieldJDBCUrl.setText(url);
308:                } else if (driver
309:                        .equalsIgnoreCase("sun.jdbc.odbc.JdbcOdbcDriver")) {
310:                    String url = "jdbc:odbc:";
311:                    if (databaseName.length() > 0)
312:                        url += jTextFieldDBName.getText();
313:                    else
314:                        url += "DSNAME";
315:                    jTextFieldJDBCUrl.setText(url);
316:                } else if (driver
317:                        .equalsIgnoreCase("com.ms.jdbc.odbc.JdbcOdbcDriver")) {
318:                    String url = "jdbc:odbc:";
319:                    if (databaseName.length() > 0)
320:                        url += databaseName;
321:                    else
322:                        url += "DSNAME";
323:                    jTextFieldJDBCUrl.setText(url);
324:                } else if (driver
325:                        .equalsIgnoreCase("oracle.jdbc.driver.OracleDriver")) {
326:                    String url = "jdbc:oracle:thin:@" + server + ":1521:";
327:                    if (databaseName.length() > 0)
328:                        url += databaseName;
329:                    else
330:                        url += "MYDATABASE";
331:                    jTextFieldJDBCUrl.setText(url);
332:                } else if (driver
333:                        .equalsIgnoreCase("COM.ibm.db2.jdbc.app.DB2Driver")) {
334:                    String url = "jdbc:db2:";
335:                    if (databaseName.length() > 0)
336:                        url += databaseName;
337:                    else
338:                        url += "MYDATABASE";
339:                    jTextFieldJDBCUrl.setText(url);
340:                } else if (driver
341:                        .equalsIgnoreCase("com.informix.jdbc.IfxDriver")) {
342:                    String url = "jdbc:informix-sqli://" + server + ":port/";
343:                    if (databaseName.length() > 0)
344:                        url += databaseName;
345:                    else
346:                        url += "MYDATABASE";
347:
348:                    url += ":informixserver=SERVERNAME";
349:                    jTextFieldJDBCUrl.setText(url);
350:                } else if (driver
351:                        .equalsIgnoreCase("com.sybase.jdbc2.jdbc.SybDriver")) {
352:                    String url = "jdbc:sybase:Tds:" + server + ":2638/";
353:                    if (databaseName.length() > 0)
354:                        url += databaseName;
355:                    else
356:                        url += "MYDATABASE";
357:                    jTextFieldJDBCUrl.setText(url);
358:                } else if (driver.equalsIgnoreCase("com.mysql.jdbc.Driver")) {
359:                    String url = "jdbc:mysql://" + server + "/";
360:                    if (databaseName.length() > 0)
361:                        url += databaseName;
362:                    else
363:                        url += "MYDATABASE";
364:                    jTextFieldJDBCUrl.setText(url);
365:                } else if (driver
366:                        .equalsIgnoreCase("com.merant.datadirect.jdbc.sqlserver.SQLServerDriver")) {
367:                    String url = "jdbc:sqlserver://" + server + ":1433/";
368:                    if (databaseName.length() > 0)
369:                        url += databaseName;
370:                    else
371:                        url += "MYDATABASE";
372:                    jTextFieldJDBCUrl.setText(url);
373:                } else if (driver.equalsIgnoreCase("com.inet.tds.TdsDriver")) {
374:                    String url = "jdbc:inetdae7:" + server + ":1433/";
375:                    if (databaseName.length() > 0)
376:                        url += jTextFieldDBName.getText();
377:                    else
378:                        url += "MYDATABASE";
379:                    jTextFieldJDBCUrl.setText(url);
380:                } else if (driver.equalsIgnoreCase("org.postgresql.Driver")) {
381:                    String url = "jdbc:postgresql://" + server + ":5432/";
382:                    if (databaseName.length() > 0)
383:                        url += databaseName;
384:                    else
385:                        url += "MYDATABASE";
386:                    jTextFieldJDBCUrl.setText(url);
387:                } else if (driver.equalsIgnoreCase("org.hsqldb.jdbcDriver")) {
388:                    String url = "jdbc:hsqldb:[PATH_TO_DB_FILES]/";
389:                    if (databaseName.length() > 0)
390:                        url += databaseName;
391:                    else
392:                        url += "MYDATABASE";
393:                    jTextFieldJDBCUrl.setText(url);
394:                } else if (driver
395:                        .equalsIgnoreCase("COM.cloudscape.JDBCDriver ")) {
396:                    String url = "jdbc:cloudscape:/cloudscape/";
397:                    if (databaseName.length() > 0)
398:                        url += databaseName;
399:                    else
400:                        url += "MYDATABASE";
401:                    jTextFieldJDBCUrl.setText(url);
402:                } else if (driver
403:                        .equalsIgnoreCase("net.sourceforge.jtds.jdbc.Driver")) {
404:                    String url = "jdbc:jtds:sqlserver://" + server + "/";
405:                    if (databaseName.length() > 0)
406:                        url += databaseName;
407:                    else
408:                        url += "MYDATABASE";
409:                    url += ";instance=";
410:                    jTextFieldJDBCUrl.setText(url);
411:                } else if (driver
412:                        .equalsIgnoreCase("com.ingres.jdbc.IngresDriver")) {
413:                    String url = "jdbc:ingres://" + server + ":II7/";
414:                    if (databaseName.length() > 0)
415:                        url += databaseName;
416:                    else
417:                        url += "MYDATABASE";
418:                    jTextFieldJDBCUrl.setText(url);
419:                } else if (driver.equalsIgnoreCase("org.sqlite.JDBC")) {
420:                    String url = "jdbc:sqlite:";
421:                    if (databaseName.length() > 0)
422:                        url += databaseName;
423:                    else
424:                        url += "filename";
425:                    jTextFieldJDBCUrl.setText(url);
426:                }
427:
428:            }
429:
430:            public void setIReportConnection(IReportConnection c) {
431:                this .iReportConnection = c;
432:
433:                if (iReportConnection instanceof  JDBCConnection) {
434:                    JDBCConnection con = (JDBCConnection) iReportConnection;
435:                    this .jComboBoxJDBCDriver.setSelectedItem(con
436:                            .getJDBCDriver());
437:                    this .jTextFieldJDBCUrl.setText(con.getUrl());
438:                    this .jTextFieldServerAddress
439:                            .setText(con.getServerAddress());
440:                    this .jTextFieldDBName.setText(con.getDatabase());
441:                    this .jTextFieldUsername.setText(con.getUsername());
442:                    if (con.isSavePassword())
443:                        this .jTextFieldPassword.setText(con.getPassword());
444:                    else
445:                        this .jTextFieldPassword.setText("");
446:                    this .jCheckBoxSavePassword
447:                            .setSelected(con.isSavePassword());
448:                }
449:
450:            }
451:
452:            public IReportConnection getIReportConnection() {
453:
454:                IReportConnection irConn = new JDBCConnection();
455:                //irConn.setName( this.jTextFieldName.getText().trim() );
456:                ((JDBCConnection) irConn)
457:                        .setServerAddress(this .jTextFieldServerAddress
458:                                .getText().trim());
459:                ((JDBCConnection) irConn).setDatabase(this .jTextFieldDBName
460:                        .getText().trim());
461:                ((JDBCConnection) irConn).setUsername(this .jTextFieldUsername
462:                        .getText().trim());
463:                if (jCheckBoxSavePassword.isSelected())
464:                    ((JDBCConnection) irConn).setPassword(new String(
465:                            this .jTextFieldPassword.getPassword()));
466:                else
467:                    ((JDBCConnection) irConn).setPassword("");
468:                ((JDBCConnection) irConn).setSavePassword(jCheckBoxSavePassword
469:                        .isSelected());
470:                ((JDBCConnection) irConn)
471:                        .setJDBCDriver((this .jComboBoxJDBCDriver
472:                                .getSelectedItem() + "").trim());
473:                if ((this .jComboBoxJDBCDriver.getSelectedItem() + "").trim()
474:                        .length() == 0) {
475:                    javax.swing.JOptionPane
476:                            .showMessageDialog(
477:                                    this ,
478:                                    I18n
479:                                            .getString(
480:                                                    "messages.connectionDialog.jdbc.invalidDriver",
481:                                                    "Please insert a valid JDBC driver!"),
482:                                    I18n
483:                                            .getString(
484:                                                    "messages.connectionDialog.jdbc.invalidDriverCaption",
485:                                                    "Invalid driver!"),
486:                                    javax.swing.JOptionPane.WARNING_MESSAGE);
487:                    return null;
488:                }
489:
490:                if (this .jTextFieldJDBCUrl.getText().trim().length() == 0) {
491:                    javax.swing.JOptionPane
492:                            .showMessageDialog(
493:                                    this ,
494:                                    I18n
495:                                            .getString(
496:                                                    "messages.connectionDialog.jdbc.invalidUrl",
497:                                                    "Please insert a valid JDBC URL!"),
498:                                    I18n
499:                                            .getString(
500:                                                    "messages.connectionDialog.jdbc.invalidUrlCaption",
501:                                                    "Invalid url!"),
502:                                    javax.swing.JOptionPane.WARNING_MESSAGE);
503:                    return null;
504:                }
505:                ((JDBCConnection) irConn).setUrl(this .jTextFieldJDBCUrl
506:                        .getText().trim());
507:
508:                iReportConnection = irConn;
509:                return iReportConnection;
510:            }
511:
512:            public void applyI18n() {
513:                // Start autogenerated code ----------------------
514:                jCheckBoxSavePassword.setText(I18n.getString(
515:                        "connectionDialog.checkBoxSavePassword",
516:                        "Save password"));
517:                jButtonWizard.setText(I18n.getString(
518:                        "connectionDialog.buttonWizard", "Wizard"));
519:                jLabel14.setText(I18n.getString("connectionDialog.label14",
520:                        "Server Address"));
521:                jLabel2.setText(I18n.getString("connectionDialog.label2",
522:                        "JDBC Driver"));
523:                jLabel3.setText(I18n.getString("connectionDialog.label3",
524:                        "JDBC URL"));
525:                jLabel5.setText(I18n.getString("connectionDialog.label5",
526:                        "Database"));
527:                jLabel6.setText(I18n.getString("connectionDialog.label6",
528:                        "Username"));
529:                jLabel7.setText(I18n.getString("connectionDialog.label7",
530:                        "Password"));
531:
532:                ((javax.swing.border.TitledBorder) jPanel2.getBorder())
533:                        .setTitle(it.businesslogic.ireport.util.I18n.getString(
534:                                "connectionDialog.panelBorder.jdbcUrlWizard",
535:                                "JDBC URL Wizard"));
536:
537:                jLabel1
538:                        .setText("<html>"
539:                                + I18n
540:                                        .getString(
541:                                                "connectionDialog.textArea1",
542:                                                "ATTENTION! Passwords are stored in clear text. If you dont specify a password now, iReport will ask you for one only when required and will not save it."));
543:
544:            }
545:
546:            // Variables declaration - do not modify//GEN-BEGIN:variables
547:            private javax.swing.JButton jButtonWizard;
548:            private javax.swing.JCheckBox jCheckBoxSavePassword;
549:            private javax.swing.JComboBox jComboBoxJDBCDriver;
550:            private javax.swing.JLabel jLabel1;
551:            private javax.swing.JLabel jLabel14;
552:            private javax.swing.JLabel jLabel2;
553:            private javax.swing.JLabel jLabel3;
554:            private javax.swing.JLabel jLabel5;
555:            private javax.swing.JLabel jLabel6;
556:            private javax.swing.JLabel jLabel7;
557:            private javax.swing.JPanel jPanel2;
558:            private javax.swing.JPanel jPanelJDBC;
559:            private javax.swing.JTextField jTextFieldDBName;
560:            private javax.swing.JTextField jTextFieldJDBCUrl;
561:            private javax.swing.JPasswordField jTextFieldPassword;
562:            private javax.swing.JTextField jTextFieldServerAddress;
563:            private javax.swing.JTextField jTextFieldUsername;
564:            // End of variables declaration//GEN-END:variables
565:
566:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.