Changeset 3024 for DataCleaner
- Timestamp:
- 01/13/12 15:12:44 (4 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
DataCleaner/trunk/core/src/main/java/org/eobjects/datacleaner/windows/JdbcDatastoreDialog.java
r3023 r3024 27 27 import java.awt.event.ActionListener; 28 28 import java.awt.event.KeyEvent; 29 import java.sql.Connection; 29 30 import java.util.ArrayList; 30 31 import java.util.List; … … 32 33 import javax.inject.Inject; 33 34 import javax.inject.Provider; 35 import javax.sql.DataSource; 34 36 import javax.swing.AbstractAction; 35 37 import javax.swing.Action; … … 37 39 import javax.swing.Icon; 38 40 import javax.swing.JButton; 39 import javax.swing.JCheckBox;40 41 import javax.swing.JComponent; 41 42 import javax.swing.JLabel; … … 48 49 import javax.swing.KeyStroke; 49 50 50 import org.eobjects.analyzer.connection.DatastoreConnection;51 51 import org.eobjects.analyzer.connection.JdbcDatastore; 52 import org.eobjects.analyzer.connection.UpdateableDatastoreConnection;53 52 import org.eobjects.analyzer.util.StringUtils; 54 53 import org.eobjects.datacleaner.bootstrap.WindowContext; … … 62 61 import org.eobjects.datacleaner.util.WidgetFactory; 63 62 import org.eobjects.datacleaner.util.WidgetUtils; 63 import org.eobjects.datacleaner.widgets.DCCheckBox; 64 64 import org.eobjects.datacleaner.widgets.DCComboBox; 65 65 import org.eobjects.datacleaner.widgets.DCComboBox.Listener; 66 66 import org.eobjects.datacleaner.widgets.DCLabel; 67 import org.eobjects.metamodel.util.FileHelper; 67 68 import org.jdesktop.swingx.JXTextField; 68 69 … … 88 89 private final JXTextField _usernameTextField; 89 90 private final JPasswordField _passwordField; 90 private final JCheckBox_multipleConnectionsCheckBox;91 private final DCCheckBox<Object> _multipleConnectionsCheckBox; 91 92 private final DCComboBox<Object> _databaseDriverComboBox; 92 93 private final Provider<OptionsDialog> _optionsDialogProvider; … … 105 106 _databaseDriverCatalog = databaseDriverCatalog; 106 107 107 _multipleConnectionsCheckBox = new JCheckBox("Allow multiple concurrent connections", true);108 _multipleConnectionsCheckBox = new DCCheckBox<Object>("Allow multiple concurrent connections", true); 108 109 _multipleConnectionsCheckBox 109 110 .setToolTipText("Indicates whether multiple connections (aka. connection pooling) may be created or not. " … … 346 347 row++; 347 348 348 final JButton testButton = WidgetFactory.createButton( "Test connection", "images/actions/refresh.png");349 final JButton testButton = WidgetFactory.createButton(getTestButtonText(), "images/actions/refresh.png"); 349 350 testButton.addActionListener(new ActionListener() { 350 351 … … 352 353 public void actionPerformed(ActionEvent event) { 353 354 JdbcDatastore datastore = createDatastore(); 354 final List<DatastoreConnection> connections = new ArrayList<DatastoreConnection>(); 355 356 final List<Connection> connections = new ArrayList<Connection>(); 357 355 358 try { 356 for (int i = 0; i < TEST_CONNECTION_COUNT; i++) { 357 UpdateableDatastoreConnection connection = datastore.openConnection(); 358 connections.add(connection); 359 if (datastore.isMultipleConnections()) { 360 DataSource ds = datastore.createDataSource(); 361 for (int i = 0; i < TEST_CONNECTION_COUNT; i++) { 362 Connection connection = ds.getConnection(); 363 connections.add(connection); 364 } 365 } else { 366 Connection connnection = datastore.createConnection(); 367 connections.add(connnection); 359 368 } 360 369 } catch (Throwable e) { … … 362 371 return; 363 372 } finally { 364 for ( DatastoreConnection connection : connections) {365 connection.close();373 for (Connection connection : connections) { 374 FileHelper.safeClose(connection); 366 375 } 367 376 } 368 377 369 378 JOptionPane.showMessageDialog(JdbcDatastoreDialog.this, "Connection successful!"); 379 } 380 }); 381 _multipleConnectionsCheckBox.addListener(new DCCheckBox.Listener<Object>() { 382 @Override 383 public void onItemSelected(Object item, boolean selected) { 384 testButton.setText(getTestButtonText()); 370 385 } 371 386 }); … … 393 408 394 409 return panel; 410 } 411 412 private String getTestButtonText() { 413 if (_multipleConnectionsCheckBox.isSelected()) { 414 return "Test connections"; 415 } 416 return "Test connection"; 395 417 } 396 418
Note: See TracChangeset
for help on using the changeset viewer.
