*
* @param event
*/
public void s3ServiceEventPerformed(final CreateObjectsEvent event) {
if (ServiceEvent.EVENT_STARTED == event.getEventCode()) {
ThreadWatcher watcher = event.getThreadWatcher();
// Show percentage of bytes transferred, if this info is available.
if (watcher.isBytesTransferredInfoAvailable()) {
String bytesTotalStr = byteFormatter.formatByteSize(watcher.getBytesTotal());
String statusText = "Uploaded " +
watcher.getCompletedThreads() + "/" + watcher.getThreadCount() + " - " +
"0 of " + bytesTotalStr;
startProgressDialog(statusText, " ", 0, 100, "Cancel Upload",
event.getThreadWatcher().getCancelEventListener());
}
// ... otherwise show the number of completed threads.
else {
startProgressDialog(
"Uploaded 0 of " + watcher.getThreadCount() + " objects",
"", (int) watcher.getCompletedThreads(), (int) watcher.getThreadCount(),
"Cancel upload", event.getThreadWatcher().getCancelEventListener());
}
}
else if (ServiceEvent.EVENT_IN_PROGRESS == event.getEventCode()) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
for (int i = 0; i < event.getCreatedObjects().length; i++) {
S3Object object = event.getCreatedObjects()[i];
object.setBucketName(getCurrentSelectedBucket().getName());
objectTableModel.addObject(object);
}
if (event.getCreatedObjects().length > 0) {
updateObjectsSummary(true);
}
}
});
ThreadWatcher watcher = event.getThreadWatcher();
// Show percentage of bytes transferred, if this info is available.
if (watcher.isBytesTransferredInfoAvailable()) {
if (watcher.getBytesTransferred() >= watcher.getBytesTotal()) {
// Upload is completed, just waiting on resonse from S3.
String statusText = "Upload completed, awaiting confirmation";
updateProgressDialog(statusText, "", 100);
} else {
String bytesCompletedStr = byteFormatter.formatByteSize(watcher.getBytesTransferred());
String bytesTotalStr = byteFormatter.formatByteSize(watcher.getBytesTotal());
String statusText = "Uploaded " +
watcher.getCompletedThreads() + "/" + watcher.getThreadCount() + " - " +
bytesCompletedStr + " of " + bytesTotalStr;
int percentage = (int)
(((double)watcher.getBytesTransferred() / watcher.getBytesTotal()) * 100);
String detailsText = formatTransferDetails(watcher);
updateProgressDialog(statusText, detailsText, percentage);
}
}
// ... otherwise show the number of completed threads.
else {
ThreadWatcher progressStatus = event.getThreadWatcher();
String statusText = "Uploaded " + progressStatus.getCompletedThreads() +
" of " + progressStatus.getThreadCount() + " objects";
updateProgressDialog(statusText, "", (int) progressStatus.getCompletedThreads());
}
}
else if (ServiceEvent.EVENT_COMPLETED == event.getEventCode()) {
stopProgressDialog();