*
* @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()) {
startProgressPanel(event.getUniqueOperationId(),
"Upload " +
byteFormatterTerse.formatByteSize(watcher.getBytesTransferred())
+ "/" + byteFormatterTerse.formatByteSize(watcher.getBytesTotal()),
100, event.getThreadWatcher().getCancelEventListener());
}
// ... otherwise show the number of completed threads.
else {
startProgressPanel(event.getUniqueOperationId(),
"Upload 0/" + watcher.getThreadCount(),
(int) watcher.getThreadCount(),
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]);
}
}
});
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.
updateProgressPanel(event.getUniqueOperationId(), "Confirming", 100);
} else {
int percentage = (int)
(((double)watcher.getBytesTransferred() / watcher.getBytesTotal()) * 100);
updateProgressPanel(event.getUniqueOperationId(),
"Upload " +
byteFormatterTerse.formatByteSize(watcher.getBytesTransferred())
+ "/" + byteFormatterTerse.formatByteSize(watcher.getBytesTotal())
+ " (" +
byteFormatterTerse.formatByteSize(watcher.getBytesPerSecond()) + "/s, "
+ timeFormatterTerse.formatTime(watcher.getTimeRemaining())
+ ")", percentage);
}
}
// ... otherwise show the number of completed threads.
else {
ThreadWatcher progressStatus = event.getThreadWatcher();
updateProgressPanel(event.getUniqueOperationId(),
"Upload " + progressStatus.getCompletedThreads()
+ "/" + progressStatus.getThreadCount(),
(int) progressStatus.getCompletedThreads());
}
}
else if (ServiceEvent.EVENT_COMPLETED == event.getEventCode()) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {