*
* @param event
*/
public void s3ServiceEventPerformed(DownloadObjectsEvent event) {
if (ServiceEvent.EVENT_STARTED == event.getEventCode()) {
ThreadWatcher watcher = event.getThreadWatcher();
// Show percentage of bytes transferred, if this info is available.
if (watcher.isBytesTransferredInfoAvailable()) {
startProgressDialog("Downloaded " +
byteFormatter.formatByteSize(watcher.getBytesTransferred())
+ " of " + byteFormatter.formatByteSize(watcher.getBytesTotal()),
"", 0, 100, "Cancel Download",
event.getThreadWatcher().getCancelEventListener());
// ... otherwise just show the number of completed threads.
} else {
startProgressDialog("Downloaded " + event.getThreadWatcher().getCompletedThreads()
+ " of " + event.getThreadWatcher().getThreadCount() + " objects",
"", 0, (int) event.getThreadWatcher().getThreadCount(), "Cancel Download",
event.getThreadWatcher().getCancelEventListener());
}
}
else if (ServiceEvent.EVENT_IN_PROGRESS == event.getEventCode()) {
ThreadWatcher watcher = event.getThreadWatcher();
// Show percentage of bytes transferred, if this info is available.
if (watcher.isBytesTransferredInfoAvailable()) {
String bytesCompletedStr = byteFormatter.formatByteSize(watcher.getBytesTransferred());
String bytesTotalStr = byteFormatter.formatByteSize(watcher.getBytesTotal());
String statusText = "Downloaded " + bytesCompletedStr + " of " + bytesTotalStr;
String detailsText = formatTransferDetails(watcher);
int percentage = (int)
(((double)watcher.getBytesTransferred() / watcher.getBytesTotal()) * 100);
updateProgressDialog(statusText, detailsText, percentage);
}
// ... otherwise just show the number of completed threads.
else {
ThreadWatcher progressStatus = event.getThreadWatcher();
String statusText = "Downloaded " + progressStatus.getCompletedThreads()
+ " of " + progressStatus.getThreadCount() + " objects";
updateProgressDialog(statusText, "", (int) progressStatus.getCompletedThreads());
}
} else if (ServiceEvent.EVENT_COMPLETED == event.getEventCode()) {
stopProgressDialog();
}
else if (ServiceEvent.EVENT_CANCELLED == event.getEventCode()) {