summaryrefslogtreecommitdiffstats
path: root/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/ImageListWindow.java
diff options
context:
space:
mode:
authorJonathan Bauer2015-08-19 17:25:49 +0200
committerJonathan Bauer2015-08-19 17:25:49 +0200
commit08459a77137fc0bf84827f2680dd6d1b3435c9d7 (patch)
treeb63283bee68d796b3cf281e4c6cebf0732252a16 /dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/ImageListWindow.java
parent[client] improved question txt if download filename already exists (diff)
downloadtutor-module-08459a77137fc0bf84827f2680dd6d1b3435c9d7.tar.gz
tutor-module-08459a77137fc0bf84827f2680dd6d1b3435c9d7.tar.xz
tutor-module-08459a77137fc0bf84827f2680dd6d1b3435c9d7.zip
[client] chagned deleteLatestVersion of imagelistwindow to use ThriftActions
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.java54
1 files changed, 11 insertions, 43 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 8265f701..9b00451b 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
@@ -34,9 +34,9 @@ import org.openslx.dozmod.gui.wizard.LectureWizard;
import org.openslx.dozmod.permissions.ImagePerms;
import org.openslx.dozmod.thrift.Session;
import org.openslx.dozmod.thrift.ThriftActions;
+import org.openslx.dozmod.thrift.ThriftActions.DeleteCallback;
import org.openslx.dozmod.thrift.ThriftActions.DownloadCallback;
import org.openslx.dozmod.thrift.cache.ImageCache;
-import org.openslx.thrifthelper.ThriftManager;
import org.openslx.util.QuickTimer;
import org.openslx.util.QuickTimer.Task;
@@ -46,7 +46,7 @@ import org.openslx.util.QuickTimer.Task;
*
*/
@SuppressWarnings("serial")
-public class ImageListWindow extends ImageListWindowLayout implements DownloadCallback {
+public class ImageListWindow extends ImageListWindowLayout implements DownloadCallback, DeleteCallback {
private final static Logger LOGGER = Logger.getLogger(ImageListWindow.class);
@@ -109,7 +109,7 @@ public class ImageListWindow extends ImageListWindowLayout implements DownloadCa
performImageDownload(imageTable.getSelectedItem());
}
if (e.getSource().equals(popupItemDelete)) {
-
+ deleteLatestVersion(getSelectedImage());
}
}
});
@@ -201,14 +201,12 @@ public class ImageListWindow extends ImageListWindowLayout implements DownloadCa
@Override
public void actionPerformed(ActionEvent e) {
performImageDownload(imageTable.getSelectedItem());
- // TODO refresh
}
});
deleteButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent ae) {
deleteLatestVersion(getSelectedImage());
- // TODO refresh
}
});
backButton.addActionListener(new ActionListener() {
@@ -253,6 +251,7 @@ public class ImageListWindow extends ImageListWindowLayout implements DownloadCa
*
* @return the image selected in the table, null if there is no selection
*/
+ // TODO either use this everywhere or delete this method
private final ImageSummaryRead getSelectedImage() {
final ImageSummaryRead image = imageTable.getSelectedItem();
if (image == null) {
@@ -399,49 +398,18 @@ public class ImageListWindow extends ImageListWindowLayout implements DownloadCa
private void deleteLatestVersion(final ImageSummaryRead image) {
if (!hasLatestVersion(image))
return;
- // requires confirmation of the user
- if (!Gui.showMessageBox(me, "Wollen Sie die letzte Version dieses Images wirklich löschen?",
- MessageType.QUESTION_YESNO, LOGGER, null))
- return;
- // try to actually delete this version of the image
- QuickTimer.scheduleOnce(new Task() {
- boolean success = false;
- Exception error = null;
-
- @Override
- public void fire() {
- try {
- ThriftManager.getSatClient().deleteImageVersion(Session.getSatelliteToken(),
- image.getLatestVersionId());
- LOGGER.info("Deleted version '" + image.getLatestVersionId() + "' of image '"
- + image.getImageBaseId() + "'.");
- success = true;
- } catch (Exception e) {
- error = e;
- }
- Gui.asyncExec(new Runnable() {
- @Override
- public void run() {
- deletedLatestVersion(success, error);
- }
- });
- }
- });
+ ThriftActions.deleteImageVersion(JOptionPane.getFrameForComponent(this), image.getImageBaseId(),
+ image.getLatestVersionId(), this);
}
/**
- * Async callback when image was deleted
+ * Callback when download initialized
*
- * @param success true if the latest image version was deleted, false
- * otherwise
+ * @param success true if downloading, false otherwise
*/
- public void deletedLatestVersion(boolean success, Exception e) {
- if (e != null) {
- Gui.showMessageBox(me, "Fehler", MessageType.ERROR, LOGGER, e);
- }
- if (success) {
- refreshList(true, 1000);
- }
+ @Override
+ public void isDeleted(boolean success) {
+ refreshList(success, 1000);
}
/********************************************************************************