final JFileChooser destinationLogFileChooser = new JFileChooser(); //choose out folder for the log file
if (e.getSource() instanceof JButton)
{
DatabaseConnectionFactory dsf = new DatabaseConnectionFactory();
try{
/* Set the target database and initialize the logging system (if the user has enabled it) */
if (e.getActionCommand().equals("Set Database"))
{
String driver = this.driverValue.getText().trim();
String host = this.dbHostValue.getText().trim();
String port = this.dbPortValue.getText().trim();
String dbname = this.dbNameValue.getText().trim();
String user = this.dbUserValue.getText().trim();
String password = this.dbPasswordValue.getText().trim();
if(host.equalsIgnoreCase("") || port.equalsIgnoreCase("") || dbname.equalsIgnoreCase("") || user.equalsIgnoreCase(""))
throw new Exception("Invalid input !");
DataPumpDatabaseConnection dataPumpDatabaseConnection = new DataPumpDatabaseConnection(driver,host,port,dbname,user,password);
dsf.initializeFactory(dataPumpDatabaseConnection);
operationResultLabel.setText(""); //clean old messages
databaseConnectionTester = new DatabaseConnectionTester();
databaseConnectionTester.testConnection();
operationResultLabel.setForeground(Color.GREEN);
operationResultLabel.setText("Test Connection executed: Target DB set successfully !");
/* Clean some old table names list (ie the list is a static field) about a previous target DB */
DatabaseTableUtils.setTableNamesList(null);
}
if (e.getActionCommand().equals("Close"))
{
if (mainFrame.isDisplayable()) {
DatabaseConnectionFactory.closeDataSource();
mainFrame.dispose();
}
}
/* ----- Manage the action coming from the sub-panel LogConfigurationPanel ----- */
/* Choose the destination log file */
if (e.getActionCommand().equals("Browse"))
{
destinationLogFileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
destinationLogFileChooser.setFileFilter(new FolderFileFilter());
destinationLogFileChooser.setDialogTitle("Choose the output folder the log file");
int value = destinationLogFileChooser.showOpenDialog(this);
// Return value if approved (ie yes, ok) is chosen.
if (value == JFileChooser.APPROVE_OPTION)
{
File destinationFolder = destinationLogFileChooser.getSelectedFile();
String pathDestinationFolder = destinationFolder.getAbsolutePath();
this.logConfigurationPanel.getOutLogFileField().setText(pathDestinationFolder);
}
}
/* Initialize and Enable the logging system */
if(e.getActionCommand().equals("Enable"))
{
if(this.logConfigurationPanel.getEnableLogCheckBox().isSelected() && !this.logConfigurationPanel.getOutLogFileField().getText().equalsIgnoreCase(""))
{
Log4jManager log4jManager = new Log4jManager();
//set some logging system properties: the chosen path to the output log file and the log level
String logLevel = (String) this.logConfigurationPanel.getLogLevelCombo().getSelectedItem();
log4jManager.initializeLogging(this.logConfigurationPanel.getOutLogFileField().getText()+File.separator+Log4jManager.OUTPUT_FILENAME,logLevel);
this.logConfigurationPanel.getMessageLabel().setForeground(Color.GREEN);
this.logConfigurationPanel.getMessageLabel().setFont(new Font("Serif", Font.BOLD, 15));
this.logConfigurationPanel.getMessageLabel().setText("Logging enabled successfully !");
}else{
this.logConfigurationPanel.getMessageLabel().setForeground(Color.RED);
this.logConfigurationPanel.getMessageLabel().setFont(new Font("Serif", Font.BOLD, 15));
this.logConfigurationPanel.getMessageLabel().setText("Invalid output folder");
}
}
}catch (Exception ex) {
if(Log4jManager.IS_LOGGING_CONFIGURED)
logger.info("Error connecting with DB or configuring logging, cause: ",ex);
operationResultLabel.setForeground(Color.RED);
operationResultLabel.setText(ex.getMessage());
/* Clean some old table names list (ie the list is a static field) about the previous target DB */
DatabaseTableUtils.setTableNamesList(null);
dsf.initializeFactory(null);
}
}
if(e.getSource() instanceof JCheckBox)
{