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


001:        package org.dbbrowser.ui.panel.connectioninformationwindow;
002:
003:        import java.awt.Dimension;
004:        import java.awt.GridLayout;
005:        import java.awt.event.ActionEvent;
006:        import java.awt.event.ActionListener;
007:        import java.io.File;
008:        import java.io.IOException;
009:        import java.util.ArrayList;
010:        import java.util.Enumeration;
011:        import java.util.List;
012:        import java.util.jar.JarFile;
013:        import infrastructure.internationalization.InternationalizationManager;
014:        import infrastructure.logging.Log;
015:        import infrastructure.propertymanager.PropertyManager;
016:        import javax.swing.*;
017:        import javax.swing.event.ChangeEvent;
018:        import javax.swing.event.ChangeListener;
019:        import org.dbbrowser.drivermanager.ConnectionInfo;
020:        import org.dbbrowser.drivermanager.JDBCDriverSearchUtility;
021:        import org.dbbrowser.security.AsymmetricEncryptionEngine;
022:        import org.dbbrowser.security.EncryptionEngineException;
023:        import org.dbbrowser.ui.helper.JarFileFilter;
024:        import org.dbbrowser.ui.UIControllerForQueries;
025:        import org.dbbrowser.ui.panel.ButtonsPanel;
026:        import org.dbbrowser.ui.widget.Button;
027:        import org.dbbrowser.ui.widget.ProgressDialog;
028:
029:        public class NewConnectionDetailsPanel extends JPanel implements 
030:                ActionListener, ChangeListener {
031:            private static final long serialVersionUID = UIControllerForQueries.version;
032:
033:            private static final String TITLE = InternationalizationManager
034:                    .getInstance().getMessage("dbbrowser-ui",
035:                            "dbbrowser-ui-dbbrowser-window-title-label", null);;
036:            private static final String SAVE_CHANGES_BUTTON_LABEL = InternationalizationManager
037:                    .getInstance()
038:                    .getMessage(
039:                            "dbbrowser-ui",
040:                            "dbbrowser-ui-new-connections-details-panel-save-changes-button-label",
041:                            null);
042:            private static final String TEST_CONNECTION_BUTTON_LABEL = InternationalizationManager
043:                    .getInstance()
044:                    .getMessage(
045:                            "dbbrowser-ui",
046:                            "dbbrowser-ui-new-connections-details-panel-test-connection-button-label",
047:                            null);
048:
049:            private static final String SAVE_CHANGES_BUTTON_ICON_FILENAME = PropertyManager
050:                    .getInstance()
051:                    .getProperty(
052:                            "dbbrowser-ui-connection-info-window-save-changes-icon");
053:            private static final String TEST_CONNECTION_BUTTON_ICON_FILENAME = PropertyManager
054:                    .getInstance()
055:                    .getProperty(
056:                            "dbbrowser-ui-connection-info-window-test-connection-icon");
057:
058:            private static final String NO_ALGORITHM_SELECTED = null;
059:            private static final String COMBO_BOX_FOR_DBMS_TYPE = "COMBO_BOX_FOR_DBMS_TYPE";
060:
061:            private ButtonsPanel buttons = null;
062:            private String[] dbmsTypes = { UIControllerForQueries.ORACLE_DBMS,
063:                    UIControllerForQueries.MYSQL_DBMS,
064:                    UIControllerForQueries.MSSQL_DBMS };
065:
066:            private JLabel labelForName = new JLabel();
067:            private JTextField textFieldForName = new JTextField();
068:
069:            private JLabel labelForDBMSType = new JLabel();
070:            private JComboBox comboBoxForDBMSType = new JComboBox(dbmsTypes);
071:
072:            private static final String BUTTON_FOR_JDBC_JAR_LOCATION = "BUTTON_FOR_JDBC_JAR_LOCATION";
073:            private JLabel labelForJarFileLocation = new JLabel();
074:            private JButton buttonForJarFileLocation = null;
075:
076:            private JLabel labelForDatabaseURL = new JLabel();
077:            private JTextField textFieldForDatabaseURL = new JTextField();
078:
079:            private JLabel labelForJDBCDriverClassName = new JLabel();
080:            private JComboBox comboBoxForJDBCDriverClassName = new JComboBox();
081:            private JDBCDriverClassNameComboBoxModel jdbcDriverClassNameComboBoxModel = new JDBCDriverClassNameComboBoxModel();
082:
083:            private JLabel labelForUsername = new JLabel();
084:            private JTextField textFieldForUsername = new JTextField();
085:
086:            private JLabel labelForPassword = new JLabel();
087:            private JPasswordField passwordFieldForPassword = new JPasswordField();
088:
089:            private JLabel labelForEncryptionAlgorithm = new JLabel();
090:            private JComboBox comboBoxForEncryptionAlgorithm = new JComboBox();
091:            private EncryptionAlgorithmComboBoxModel encryptionAlgorithmComboBoxModel = new EncryptionAlgorithmComboBoxModel(
092:                    ConnectionInfo.LIST_OF_ENCRYPTION_ALGORITHMS);
093:
094:            private JLabel labelForCheckSumAlgorithm = new JLabel();
095:            private JComboBox comboBoxForCheckSumAlgorithm = new JComboBox();
096:            private CheckSumAlgorithmComboBoxModel checkSumAlgorithmComboBoxModel = new CheckSumAlgorithmComboBoxModel(
097:                    ConnectionInfo.LIST_OF_CHECKSUM_ALGORITHMS);
098:
099:            private String jarFileLocation = null;
100:            private ProgressDialog progressDialog = null;
101:            private JDBCDriverSearchUtility jdbcDriverSearchUtility = null;
102:
103:            private JPanel panelForFormFields = new JPanel();
104:
105:            public NewConnectionDetailsPanel(ActionListener listener) {
106:                String panelTitle = InternationalizationManager
107:                        .getInstance()
108:                        .getMessage(
109:                                "dbbrowser-ui",
110:                                "dbbrowser-ui-new-connection-details-panel-title",
111:                                null);
112:                this .setBorder(BorderFactory.createTitledBorder(panelTitle));
113:                this .setLayout(new BoxLayout(this , BoxLayout.PAGE_AXIS));
114:
115:                this .initialize();
116:
117:                //Setup buttons panel
118:                Button saveChangesButton = new Button(
119:                        SAVE_CHANGES_BUTTON_LABEL, listener,
120:                        SAVE_CHANGES_BUTTON_LABEL, new ImageIcon(
121:                                SAVE_CHANGES_BUTTON_ICON_FILENAME),
122:                        Boolean.FALSE);
123:                Button testConnectionButton = new Button(
124:                        TEST_CONNECTION_BUTTON_LABEL, listener,
125:                        TEST_CONNECTION_BUTTON_LABEL, new ImageIcon(
126:                                TEST_CONNECTION_BUTTON_ICON_FILENAME),
127:                        Boolean.FALSE);
128:
129:                ArrayList listOfButtons = new ArrayList();
130:                listOfButtons.add(saveChangesButton);
131:                listOfButtons.add(testConnectionButton);
132:                this .buttons = new ButtonsPanel(listOfButtons);
133:
134:                this .add(this .buttons);
135:            }
136:
137:            private void initialize() {
138:                //Setup labels and fields
139:                panelForFormFields.setPreferredSize(new Dimension(100, 100));
140:                panelForFormFields.setLayout(new GridLayout(9, 2));
141:
142:                //Label and text field for name
143:                String labelForNameLabel = InternationalizationManager
144:                        .getInstance()
145:                        .getMessage(
146:                                "dbbrowser-ui",
147:                                "dbbrowser-ui-new-connections-details-panel-name-label",
148:                                null);
149:                this .labelForName.setText(labelForNameLabel + ":");
150:                panelForFormFields.add(this .labelForName);
151:                panelForFormFields.add(this .textFieldForName);
152:
153:                //Label and combo box for dbms type
154:                String labelStringForDBMSType = InternationalizationManager
155:                        .getInstance()
156:                        .getMessage(
157:                                "dbbrowser-ui",
158:                                "dbbrowser-ui-new-connections-details-panel-dbms-type-label",
159:                                null);
160:                this .labelForDBMSType.setText(labelStringForDBMSType + ":");
161:                panelForFormFields.add(this .labelForDBMSType);
162:                panelForFormFields.add(this .comboBoxForDBMSType);
163:                this .comboBoxForDBMSType.addActionListener(this );
164:
165:                //Label and button for jar file location
166:                String labelForJarFileLocationLabel = InternationalizationManager
167:                        .getInstance()
168:                        .getMessage(
169:                                "dbbrowser-ui",
170:                                "dbbrowser-ui-new-connections-details-panel-jarfile-location-label",
171:                                null);
172:                this .labelForJarFileLocation
173:                        .setText(labelForJarFileLocationLabel + ":");
174:                panelForFormFields.add(this .labelForJarFileLocation);
175:                buttonForJarFileLocation = new JButton();
176:                String labelForJarFileLocationButton = InternationalizationManager
177:                        .getInstance()
178:                        .getMessage(
179:                                "dbbrowser-ui",
180:                                "dbbrowser-ui-new-connections-details-panel-jarfile-location-button-label",
181:                                null);
182:                buttonForJarFileLocation.setText(labelForJarFileLocationButton);
183:                buttonForJarFileLocation
184:                        .setActionCommand(BUTTON_FOR_JDBC_JAR_LOCATION);
185:                buttonForJarFileLocation.addActionListener(this );
186:                panelForFormFields.add(this .buttonForJarFileLocation);
187:
188:                //Label and text field for database url
189:                String labelForDatabaseURLLabel = InternationalizationManager
190:                        .getInstance()
191:                        .getMessage(
192:                                "dbbrowser-ui",
193:                                "dbbrowser-ui-new-connections-details-panel-database-url-label",
194:                                null);
195:                this .labelForDatabaseURL
196:                        .setText(labelForDatabaseURLLabel + ":");
197:                panelForFormFields.add(this .labelForDatabaseURL);
198:                panelForFormFields.add(this .textFieldForDatabaseURL);
199:
200:                //Label and combo box for jdbc driver class name		
201:                String labelForJDBCDriverClassNameLabel = InternationalizationManager
202:                        .getInstance()
203:                        .getMessage(
204:                                "dbbrowser-ui",
205:                                "dbbrowser-ui-new-connections-details-panel-jdbcdriver-classname-label",
206:                                null);
207:                this .labelForJDBCDriverClassName
208:                        .setText(labelForJDBCDriverClassNameLabel + ":");
209:                panelForFormFields.add(this .labelForJDBCDriverClassName);
210:                comboBoxForJDBCDriverClassName.setEditable(false);
211:                comboBoxForJDBCDriverClassName
212:                        .setModel(jdbcDriverClassNameComboBoxModel);
213:                panelForFormFields.add(this .comboBoxForJDBCDriverClassName);
214:
215:                //Label and text field for username
216:                String labelForUsernameLabel = InternationalizationManager
217:                        .getInstance()
218:                        .getMessage(
219:                                "dbbrowser-ui",
220:                                "dbbrowser-ui-new-connections-details-panel-username-label",
221:                                null);
222:                this .labelForUsername.setText(labelForUsernameLabel + ":");
223:                panelForFormFields.add(this .labelForUsername);
224:                panelForFormFields.add(this .textFieldForUsername);
225:
226:                //Label and text field for password
227:                String labelForPasswordLabel = InternationalizationManager
228:                        .getInstance()
229:                        .getMessage(
230:                                "dbbrowser-ui",
231:                                "dbbrowser-ui-new-connections-details-panel-password-label",
232:                                null);
233:                this .labelForPassword.setText(labelForPasswordLabel + ":");
234:                panelForFormFields.add(this .labelForPassword);
235:                panelForFormFields.add(this .passwordFieldForPassword);
236:
237:                //Label and combo box for encryption algorithm		
238:                String labelForEncryptionAlgorithmLabel = InternationalizationManager
239:                        .getInstance()
240:                        .getMessage(
241:                                "dbbrowser-ui",
242:                                "dbbrowser-ui-new-connections-details-panel-encryption-algorithm-label",
243:                                null);
244:                this .labelForEncryptionAlgorithm
245:                        .setText(labelForEncryptionAlgorithmLabel + ":");
246:                panelForFormFields.add(this .labelForEncryptionAlgorithm);
247:                comboBoxForEncryptionAlgorithm.setEditable(false);
248:                comboBoxForEncryptionAlgorithm
249:                        .setModel(encryptionAlgorithmComboBoxModel);
250:                panelForFormFields.add(this .comboBoxForEncryptionAlgorithm);
251:
252:                //Label and combo box for checksum algorithm		
253:                String labelForCheckSumAlgorithmLabel = InternationalizationManager
254:                        .getInstance()
255:                        .getMessage(
256:                                "dbbrowser-ui",
257:                                "dbbrowser-ui-new-connections-details-panel-checksum-algorithm-label",
258:                                null);
259:                this .labelForCheckSumAlgorithm
260:                        .setText(labelForCheckSumAlgorithmLabel + ":");
261:                panelForFormFields.add(this .labelForCheckSumAlgorithm);
262:                comboBoxForCheckSumAlgorithm.setEditable(false);
263:                comboBoxForCheckSumAlgorithm
264:                        .setModel(checkSumAlgorithmComboBoxModel);
265:                panelForFormFields.add(this .comboBoxForCheckSumAlgorithm);
266:
267:                this .add(panelForFormFields);
268:
269:                //Add the action listener for comboBoxForDBMSType
270:                this .comboBoxForDBMSType.addActionListener(this );
271:                this .comboBoxForDBMSType
272:                        .setActionCommand(COMBO_BOX_FOR_DBMS_TYPE);
273:            }
274:
275:            public void setConnectionInfo(ConnectionInfo connectionInfo,
276:                    String masterPassword) {
277:                //Set the name
278:                this .textFieldForName.setText(connectionInfo.getName());
279:
280:                //Set the dbms type
281:                this .comboBoxForDBMSType.setSelectedItem(connectionInfo
282:                        .getDBMSType());
283:
284:                //Set the database url
285:                this .textFieldForDatabaseURL.setText(connectionInfo
286:                        .getDatabaseURL());
287:
288:                //Set the username
289:                this .textFieldForUsername.setText(connectionInfo.getUsername());
290:
291:                //Set the password by decrypting it
292:                try {
293:                    String clearText = AsymmetricEncryptionEngine.decrypt(
294:                            connectionInfo.getPassword(), masterPassword);
295:                    this .passwordFieldForPassword.setText(clearText);
296:                } catch (EncryptionEngineException exc) {
297:                    //Should never happen
298:                    Log.getInstance().debugMessage(exc.getMessage(),
299:                            AsymmetricEncryptionEngine.class.getName());
300:                    exc.printStackTrace();
301:                }
302:
303:                //Set the jdbc driver file name
304:                List listOfJDBCDriverClasses = new ArrayList();
305:                listOfJDBCDriverClasses
306:                        .add(connectionInfo.getDriverClassName());
307:                this .jdbcDriverClassNameComboBoxModel = new JDBCDriverClassNameComboBoxModel(
308:                        listOfJDBCDriverClasses.toArray());
309:                this .comboBoxForJDBCDriverClassName
310:                        .setModel(this .jdbcDriverClassNameComboBoxModel);
311:
312:                //Set the jdbc driver jar file location
313:                this .buttonForJarFileLocation.setText(connectionInfo
314:                        .getJdbcDriverJarFileLocation().getAbsolutePath());
315:                this .jarFileLocation = connectionInfo
316:                        .getJdbcDriverJarFileLocation().getAbsolutePath();
317:
318:                //Set the combobox for algorithms if it is a oracle dbms
319:                if (UIControllerForQueries.ORACLE_DBMS.equals(connectionInfo
320:                        .getDBMSType())) {
321:                    this .comboBoxForEncryptionAlgorithm
322:                            .setSelectedItem(connectionInfo
323:                                    .getEncryptionAlgorithm());
324:                    this .comboBoxForCheckSumAlgorithm
325:                            .setSelectedItem(connectionInfo
326:                                    .getCheckSumAlgorithm());
327:                }
328:            }
329:
330:            public ConnectionInfo getConnectionInfo(String masterPassword) {
331:                ConnectionInfo connectionInfo = null;
332:                String name = this .textFieldForName.getText();
333:                String dbmsType = (String) this .comboBoxForDBMSType
334:                        .getSelectedItem();
335:                String databaseURL = this .textFieldForDatabaseURL.getText();
336:                String username = this .textFieldForUsername.getText();
337:                String clearTextPassword = new String(
338:                        this .passwordFieldForPassword.getPassword());
339:                String driverClassName = (String) this .comboBoxForJDBCDriverClassName
340:                        .getSelectedItem();
341:
342:                if ((name != null) && (databaseURL != null)
343:                        && (username != null) && (clearTextPassword != null)
344:                        && (driverClassName != null)
345:                        && (this .jarFileLocation != null)) {
346:                    if ((!"".equals(name)) && (!"".equals(databaseURL))
347:                            && (!"".equals(username))
348:                            && (!"".equals(clearTextPassword))
349:                            && (!"".equals(driverClassName))
350:                            && (!"".equals(this .jarFileLocation))) {
351:                        try {
352:                            //Encrypt the password
353:                            String encryptedPassword = AsymmetricEncryptionEngine
354:                                    .encrypt(clearTextPassword, masterPassword);
355:
356:                            if (UIControllerForQueries.ORACLE_DBMS
357:                                    .equals(this .comboBoxForDBMSType
358:                                            .getSelectedItem())) {
359:                                //if this is a Oracle DBMS, then get the encyption algorithm and checksum algorithm
360:                                String encryptionAlgorithm = (String) this .comboBoxForEncryptionAlgorithm
361:                                        .getSelectedItem();
362:                                String checksumAlgorithm = (String) this .comboBoxForCheckSumAlgorithm
363:                                        .getSelectedItem();
364:                                connectionInfo = new ConnectionInfo(
365:                                        driverClassName, new File(
366:                                                this .jarFileLocation), name,
367:                                        dbmsType, databaseURL, username,
368:                                        encryptedPassword, encryptionAlgorithm,
369:                                        checksumAlgorithm);
370:                            } else {
371:                                connectionInfo = new ConnectionInfo(
372:                                        driverClassName, new File(
373:                                                this .jarFileLocation), name,
374:                                        dbmsType, databaseURL, username,
375:                                        encryptedPassword, null, null);
376:                            }
377:                        } catch (EncryptionEngineException exc) {
378:                            //Should never happen
379:                            Log.getInstance().debugMessage(exc.getMessage(),
380:                                    AsymmetricEncryptionEngine.class.getName());
381:                            exc.printStackTrace();
382:                        }
383:                    }
384:                }
385:
386:                return connectionInfo;
387:            }
388:
389:            public void clearFields() {
390:                this .textFieldForName.setText("");
391:                this .textFieldForDatabaseURL.setText("");
392:                this .textFieldForUsername.setText("");
393:                this .passwordFieldForPassword.setText("");
394:                this .textFieldForName.setText("");
395:                this .buttonForJarFileLocation
396:                        .setText(InternationalizationManager
397:                                .getInstance()
398:                                .getMessage(
399:                                        "dbbrowser-ui",
400:                                        "dbbrowser-ui-new-connections-details-panel-jarfile-location-label",
401:                                        null));
402:                jdbcDriverClassNameComboBoxModel = new JDBCDriverClassNameComboBoxModel();
403:                this .comboBoxForJDBCDriverClassName
404:                        .setModel(jdbcDriverClassNameComboBoxModel);
405:                this .comboBoxForEncryptionAlgorithm.setSelectedIndex(0);
406:                this .comboBoxForCheckSumAlgorithm.setSelectedIndex(0);
407:            }
408:
409:            public void actionPerformed(ActionEvent e) {
410:                if (COMBO_BOX_FOR_DBMS_TYPE.equals(e.getActionCommand())) {
411:                    String selectedDBMS = (String) this .comboBoxForDBMSType
412:                            .getSelectedItem();
413:                    if (UIControllerForQueries.ORACLE_DBMS.equals(selectedDBMS)) {
414:                        this .panelForFormFields
415:                                .add(this .labelForEncryptionAlgorithm);
416:                        this .panelForFormFields
417:                                .add(this .comboBoxForEncryptionAlgorithm);
418:                        this .panelForFormFields
419:                                .add(this .labelForCheckSumAlgorithm);
420:                        this .panelForFormFields
421:                                .add(this .comboBoxForCheckSumAlgorithm);
422:                    } else {
423:                        this .panelForFormFields
424:                                .remove(this .labelForEncryptionAlgorithm);
425:                        this .panelForFormFields
426:                                .remove(this .comboBoxForEncryptionAlgorithm);
427:                        this .panelForFormFields
428:                                .remove(this .labelForCheckSumAlgorithm);
429:                        this .panelForFormFields
430:                                .remove(this .comboBoxForCheckSumAlgorithm);
431:                    }
432:                    this .updateUI();
433:                }
434:
435:                if (BUTTON_FOR_JDBC_JAR_LOCATION.equals(e.getActionCommand())) {
436:                    JFileChooser jfc = new JFileChooser();
437:                    File currentDirectory = new File(".");
438:                    jfc.setCurrentDirectory(currentDirectory);
439:                    jfc.setMultiSelectionEnabled(false);
440:                    jfc.setFileFilter(new JarFileFilter());
441:                    int selectedOption = jfc.showOpenDialog(null);
442:                    if (selectedOption == JFileChooser.APPROVE_OPTION) {
443:                        File selectedFile = jfc.getSelectedFile();
444:                        this .jarFileLocation = selectedFile.getAbsolutePath();
445:                        this .buttonForJarFileLocation
446:                                .setText(this .jarFileLocation);
447:
448:                        try {
449:                            //Setup the progress dialog
450:                            JarFile jarFile = new JarFile(this .jarFileLocation);
451:                            Enumeration enumeration = jarFile.entries();
452:                            int totalNumberOfFilesInJarFile = 0;
453:                            while (enumeration.hasMoreElements()) {
454:                                totalNumberOfFilesInJarFile++;
455:                                enumeration.nextElement();
456:                            }
457:
458:                            //Setup the progress bar
459:                            String progressBarTitle = InternationalizationManager
460:                                    .getInstance()
461:                                    .getMessage(
462:                                            "dbbrowser-ui",
463:                                            "dbbrowser-ui-dbbrowser-window-title-label",
464:                                            null);
465:                            ;
466:                            String progressBarLabel = InternationalizationManager
467:                                    .getInstance()
468:                                    .getMessage(
469:                                            "dbbrowser-ui",
470:                                            "dbbrowser-ui-known-connections-panel-progress-bar-label",
471:                                            null);
472:                            ;
473:                            progressDialog = new ProgressDialog(
474:                                    progressBarTitle, progressBarLabel,
475:                                    new Integer(0), new Integer(
476:                                            totalNumberOfFilesInJarFile));
477:                            progressDialog.show();
478:
479:                            //Get the list of jdbc drivers in the jar file 
480:                            jdbcDriverSearchUtility = new JDBCDriverSearchUtility(
481:                                    new File(this .jarFileLocation),
482:                                    progressDialog, this );
483:                            jdbcDriverSearchUtility.start();
484:                        } catch (IOException exc) {
485:                            String cannotLoadJarFile = InternationalizationManager
486:                                    .getInstance()
487:                                    .getMessage(
488:                                            "dbbrowser-ui",
489:                                            "dbbrowser-ui-new-connection-details-panel-exception-could-not-load-jdbc-driver-jar-file",
490:                                            null);
491:                            JOptionPane.showMessageDialog(null,
492:                                    cannotLoadJarFile, TITLE,
493:                                    JOptionPane.ERROR_MESSAGE);
494:                        }
495:                    }
496:                }
497:            }
498:
499:            public void stateChanged(ChangeEvent e) {
500:                //Close the progress dialog
501:                this .progressDialog.setValue(this .progressDialog.getMaxValue());
502:                this .progressDialog.close();
503:                this .progressDialog = null;
504:
505:                //Set the values in the combo box
506:                try {
507:                    List listOfDriverClassesInJarFile = this .jdbcDriverSearchUtility
508:                            .getListOfJDBCDriverClasses();
509:
510:                    //if no jdbc drivers found, raise an error message
511:                    if (listOfDriverClassesInJarFile == null
512:                            || listOfDriverClassesInJarFile.isEmpty()) {
513:                        String noJDBCDriverInJARFile = InternationalizationManager
514:                                .getInstance()
515:                                .getMessage(
516:                                        "dbbrowser-ui",
517:                                        "dbbrowser-ui-new-connections-details-panel-no-jdbc-driver-in-jar-file-error-message",
518:                                        null);
519:                        JOptionPane.showMessageDialog(null,
520:                                noJDBCDriverInJARFile, "DBBrowser",
521:                                JOptionPane.ERROR_MESSAGE);
522:                    }
523:
524:                    this .jdbcDriverClassNameComboBoxModel = new JDBCDriverClassNameComboBoxModel(
525:                            listOfDriverClassesInJarFile.toArray());
526:                    this .comboBoxForJDBCDriverClassName
527:                            .setModel(this .jdbcDriverClassNameComboBoxModel);
528:                } catch (IOException exc) {
529:                    String cannotLoadJarFile = InternationalizationManager
530:                            .getInstance()
531:                            .getMessage(
532:                                    "dbbrowser-ui",
533:                                    "dbbrowser-ui-new-connection-details-panel-exception-could-not-load-jdbc-driver-jar-file",
534:                                    null);
535:                    JOptionPane.showMessageDialog(null, cannotLoadJarFile,
536:                            "DBBrowser", JOptionPane.ERROR_MESSAGE);
537:                }
538:            }
539:
540:            private class JDBCDriverClassNameComboBoxModel extends
541:                    DefaultComboBoxModel {
542:                private static final long serialVersionUID = 1l;
543:
544:                public JDBCDriverClassNameComboBoxModel(Object[] items) {
545:                    super (items);
546:                }
547:
548:                public JDBCDriverClassNameComboBoxModel() {
549:                    super ();
550:                }
551:            }
552:
553:            private class EncryptionAlgorithmComboBoxModel extends
554:                    DefaultComboBoxModel {
555:                private static final long serialVersionUID = 1l;
556:
557:                public EncryptionAlgorithmComboBoxModel(Object[] items) {
558:                    super ();
559:
560:                    super .addElement(NO_ALGORITHM_SELECTED);
561:
562:                    for (int i = 0; i < items.length; i++) {
563:                        super .addElement(items[i]);
564:                    }
565:                }
566:
567:                public EncryptionAlgorithmComboBoxModel() {
568:                    super ();
569:                }
570:            }
571:
572:            private class CheckSumAlgorithmComboBoxModel extends
573:                    DefaultComboBoxModel {
574:                private static final long serialVersionUID = 1l;
575:
576:                public CheckSumAlgorithmComboBoxModel(Object[] items) {
577:                    super ();
578:
579:                    super .addElement(NO_ALGORITHM_SELECTED);
580:
581:                    for (int i = 0; i < items.length; i++) {
582:                        super .addElement(items[i]);
583:                    }
584:                }
585:
586:                public CheckSumAlgorithmComboBoxModel() {
587:                    super();
588:                }
589:            }
590:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.