summaryrefslogtreecommitdiffstats
path: root/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/ImageListWindow.java
diff options
context:
space:
mode:
authorSimon Rettberg2015-08-11 19:19:03 +0200
committerSimon Rettberg2015-08-11 19:19:03 +0200
commit3946cc23a61fdb4bc830a64e5993817abf055b1b (patch)
tree9dbd00563e2e0d55804381217677054116f29476 /dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/ImageListWindow.java
parent[client] Back off with reconnects for file transfers if it fails too often (diff)
downloadtutor-module-3946cc23a61fdb4bc830a64e5993817abf055b1b.tar.gz
tutor-module-3946cc23a61fdb4bc830a64e5993817abf055b1b.tar.xz
tutor-module-3946cc23a61fdb4bc830a64e5993817abf055b1b.zip
[client] Add DownloadPanel to show progress of images being downloaded
Diffstat (limited to 'dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/ImageListWindow.java')
-rw-r--r--dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/ImageListWindow.java22
1 files changed, 12 insertions, 10 deletions
diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/ImageListWindow.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/ImageListWindow.java
index c8385cd3..1bdf5507 100644
--- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/ImageListWindow.java
+++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/ImageListWindow.java
@@ -86,7 +86,7 @@ public class ImageListWindow extends ImageListWindowLayout {
startLectureWizard();
}
if (e.getSource().equals(popupItemDownload)) {
- performImageDownload(imageTable.getSelectedItem().getLatestVersionId());
+ performImageDownload(imageTable.getSelectedItem());
LOGGER.debug("Download image clicked");
}
if (e.getSource().equals(popupItemDelete)) {
@@ -156,10 +156,7 @@ public class ImageListWindow extends ImageListWindowLayout {
downloadButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
- ImageSummaryRead item = imageTable.getSelectedItem();
- if (item == null)
- return;
- performImageDownload(item.latestVersionId);
+ performImageDownload(imageTable.getSelectedItem());
}
});
@@ -255,8 +252,10 @@ public class ImageListWindow extends ImageListWindowLayout {
refreshList(false);
}
- private void performImageDownload(String versionId) {
- if (versionId == null) {
+ private void performImageDownload(ImageSummaryRead image) {
+ if (image == null)
+ return;
+ if (image.latestVersionId == null) {
Gui.showMessageBox(this, "Das ausgewählte Image hat keine gültige Version", MessageType.ERROR,
null, null);
return;
@@ -268,7 +267,8 @@ public class ImageListWindow extends ImageListWindowLayout {
return;
TransferInformation transInf = null;
try {
- transInf = ThriftManager.getSatClient().requestDownload(Session.getSatelliteToken(), versionId);
+ transInf = ThriftManager.getSatClient().requestDownload(Session.getSatelliteToken(),
+ image.latestVersionId);
} catch (TException e) {
LOGGER.error("Failed to get transfer information: ", e);
return;
@@ -278,11 +278,13 @@ public class ImageListWindow extends ImageListWindowLayout {
try {
file.getAbsoluteFile().mkdirs();
+ File destFile = new File(file.getAbsolutePath(), "Hans.vmdk"); // TODO: Name sanitized from display name
+ // TODO: Check if file exists
DownloadTask dlTask = new DownloadTask(Session.getSatelliteAddress(), transInf.getPlainPort(),
- transInf.getToken(), new File(file.getAbsolutePath(), "Hans"),
- imageTable.getSelectedItem().getFileSize(), null);
+ transInf.getToken(), destFile, image.fileSize, null);
new Thread(dlTask).start();
Config.setDownloadPath(file.getAbsolutePath());
+ MainWindow.addDownload(image.imageName, destFile.getName(), dlTask);
} catch (FileNotFoundException e) {
LOGGER.error("Got transfer information but failed to download: ", e);
return;