if (event.getSource().equals(finishedButton)) {
// Hack to update the logging status of a bucket before exiting the dialog
// if the prefix string has changed
String bucketName = (String) loggedBucketComboBox.getSelectedItem();
if (loggingStatusMap.containsKey(bucketName)) {
S3BucketLoggingStatus loggingStatus =
(S3BucketLoggingStatus) loggingStatusMap.get(bucketName);
if (!prefixTextField.getText().equals(loggingStatus.getLogfilePrefix())
&& loggedToBucketComboBox.getSelectedIndex() != 0)
{
loggedToBucketComboBox.setSelectedIndex(loggedToBucketComboBox.getSelectedIndex());
}
}
this.setVisible(false);
} else if (event.getSource().equals(loggedBucketComboBox)) {
prefixTextField.setEnabled(false);
loggedToBucketComboBox.setEnabled(false);
if (loggedBucketComboBox.getSelectedIndex() == 0) {
prefixTextField.setText("");
loggedToBucketComboBox.setSelectedIndex(0);
} else {
final String bucketName = (String) loggedBucketComboBox.getSelectedItem();
if (loggingStatusMap.containsKey(bucketName)) {
S3BucketLoggingStatus loggingStatus =
(S3BucketLoggingStatus) loggingStatusMap.get(bucketName);
displayBucketLoggingStatus(loggingStatus);
} else {
(new Thread() {
public void run() {
final ProgressDialog progressDialog =
new ProgressDialog(ownerFrame, "Bucket Logging", null);
SwingUtilities.invokeLater(new Runnable() {
public void run() {
progressDialog.startDialog("Retrieving bucket logging status",
null, 0, 0, null, null);
}
});
try {
S3BucketLoggingStatus loggingStatus =
s3Service.getBucketLoggingStatus(bucketName);
loggingStatusMap.put(bucketName, loggingStatus);
displayBucketLoggingStatus(loggingStatus);
} catch (Exception e) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
progressDialog.stopDialog();
}
});
ErrorDialog.showDialog(ownerFrame, null,
"Unable to retrieve bucket logging status for " + bucketName, e);
}
SwingUtilities.invokeLater(new Runnable() {
public void run() {
progressDialog.stopDialog();
}
});
}
}).start();
}
}
} else if (event.getSource().equals(loggedToBucketComboBox)) {
if (!loggedToBucketComboBox.isEnabled()) {
// Ignore this event, it is internally generated.
return;
}
final String loggedBucketName = (String) loggedBucketComboBox.getSelectedItem();
final String[] loggedToBucketName = new String[1];
final String[] loggingFilePrefix = new String[1];
if (loggedToBucketComboBox.getSelectedIndex() == 0) {
// Logging is being disabled, leave values as null.
} else {
if (prefixTextField.getText().length() == 0) {
ErrorDialog.showDialog(ownerFrame, null,
"A log file name prefix must be provided to log buckets", null);
loggedToBucketComboBox.setSelectedIndex(0);
return;
}
loggedToBucketName[0] = (String) loggedToBucketComboBox.getSelectedItem();
loggingFilePrefix[0] = prefixTextField.getText();
}
(new Thread(new Runnable() {
public void run() {
final ProgressDialog progressDialog =
new ProgressDialog(ownerFrame, "Bucket Logging", null);
SwingUtilities.invokeLater(new Runnable() {
public void run() {
progressDialog.startDialog("Setting bucket logging status",
null, 0, 0, null, null);
}
});
try {
S3BucketLoggingStatus loggingStatus =
new S3BucketLoggingStatus(loggedToBucketName[0], loggingFilePrefix[0]);
s3Service.setBucketLoggingStatus(loggedBucketName, loggingStatus, true);
loggingStatusMap.put(loggedBucketName, loggingStatus);
} catch (Exception e) {
SwingUtilities.invokeLater(new Runnable() {