*
* @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 0 of " + bytesTotalStr;
startProgressDialog(statusText, " ", 0, 100, "Cancel Upload",
event.getThreadWatcher().getCancelEventListener());
}
// ... otherwise show the number of completed threads.
else {
startProgressDialog("Uploading file 0 of " + getCurrentSelectedBucket().getName(),
"", (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++) {
objectTableModel.addObject(event.getCreatedObjects()[i]);
}
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 " + 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 file " + progressStatus.getCompletedThreads() + " of " + progressStatus.getThreadCount();
updateProgressDialog(statusText, "", (int) progressStatus.getCompletedThreads());
}
}
else if (ServiceEvent.EVENT_COMPLETED == event.getEventCode()) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {