summaryrefslogtreecommitdiffstats
path: root/dozentenmodul/src/main/java
diff options
context:
space:
mode:
authorJonathan Bauer2015-08-21 12:39:39 +0200
committerJonathan Bauer2015-08-21 12:39:39 +0200
commit5ce7b1169157edb9cded0b44ae7118a45af9d123 (patch)
tree35061d3909d840ec8fafd4eb382bec90a0e5bb4a /dozentenmodul/src/main/java
parent[client] added LectureCustomPermissionManager and merged ImagePermissionManag... (diff)
downloadtutor-module-5ce7b1169157edb9cded0b44ae7118a45af9d123.tar.gz
tutor-module-5ce7b1169157edb9cded0b44ae7118a45af9d123.tar.xz
tutor-module-5ce7b1169157edb9cded0b44ae7118a45af9d123.zip
[client] support deletion of image base in ThriftActions
Diffstat (limited to 'dozentenmodul/src/main/java')
-rw-r--r--dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/ImageDetailsWindow.java2
-rw-r--r--dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/ImageListWindow.java2
-rw-r--r--dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/ImageWizard.java17
-rw-r--r--dozentenmodul/src/main/java/org/openslx/dozmod/thrift/ThriftActions.java51
4 files changed, 56 insertions, 16 deletions
diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/ImageDetailsWindow.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/ImageDetailsWindow.java
index abbee863..3ca4a90f 100644
--- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/ImageDetailsWindow.java
+++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/ImageDetailsWindow.java
@@ -332,7 +332,7 @@ public class ImageDetailsWindow extends ImageDetailsWindowLayout implements UiFe
* @param version image version to delete
*/
private void deleteVersion(final ImageVersionDetails version) {
- ThriftActions.deleteImageVersion(JOptionPane.getFrameForComponent(this),
+ ThriftActions.deleteImageBaseOrVersion(JOptionPane.getFrameForComponent(this),
image.getImageBaseId(), version.versionId, new DeleteCallback() {
@Override
public void isDeleted(boolean success) {
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 9b00451b..121465bd 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
@@ -398,7 +398,7 @@ public class ImageListWindow extends ImageListWindowLayout implements DownloadCa
private void deleteLatestVersion(final ImageSummaryRead image) {
if (!hasLatestVersion(image))
return;
- ThriftActions.deleteImageVersion(JOptionPane.getFrameForComponent(this), image.getImageBaseId(),
+ ThriftActions.deleteImageBaseOrVersion(JOptionPane.getFrameForComponent(this), image.getImageBaseId(),
image.getLatestVersionId(), this);
}
diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/ImageWizard.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/ImageWizard.java
index 935e2bc7..b1b077ee 100644
--- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/ImageWizard.java
+++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/ImageWizard.java
@@ -158,8 +158,23 @@ public class ImageWizard extends Wizard implements UiFeedback {
@Override
protected boolean onCancelRequest() {
- return Gui.showMessageBox(this, "Möchten Sie den Vorgang wirklich abbrechen?",
+ boolean confirmed = Gui.showMessageBox(this, "Möchten Sie den Vorgang wirklich abbrechen?",
MessageType.QUESTION_YESNO, null, null);
+ if (confirmed) {
+ // TODO: Lösch-Calls am Sat
+ // check the state to see what we did:
+ if (uploadWizardState.uuid != null) {
+ // we created the image, so delete the image base
+ //ThriftActions.deleteImageBase()
+ }
+ if (uploadWizardState.transferInformation != null) {
+ // we started an upload, thus we have a image version
+ }
+ if (uploadWizardState.uploadTask != null) {
+ // an upload is running.
+ }
+ }
+ return confirmed;
}
@Override
diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/thrift/ThriftActions.java b/dozentenmodul/src/main/java/org/openslx/dozmod/thrift/ThriftActions.java
index f45c05c7..8b8ceb90 100644
--- a/dozentenmodul/src/main/java/org/openslx/dozmod/thrift/ThriftActions.java
+++ b/dozentenmodul/src/main/java/org/openslx/dozmod/thrift/ThriftActions.java
@@ -49,6 +49,7 @@ public class ThriftActions {
void downloadInitialized(boolean success);
}
/**
+ * NON-BLOCKING
* Initializes the download of the given imageVersionId saving it to the given
* imageName
*
@@ -307,7 +308,7 @@ public class ThriftActions {
/* *******************************************************************************
*
- * IMAGE VERSION DELETION
+ * IMAGE / VERSION DELETION
*
* Deletes a specific image version
*
@@ -326,33 +327,46 @@ public class ThriftActions {
}
/**
* NON-BLOCKING
- * Deletes the given imageVersionId of the image imageBaseId and calls the given
- * callback method to inform about the outcome of the operation.
+ * Deletes either an image base or an image version depending on the parameters.
+ * To delete an image base, give the imageBaseId and let imageVersionId be null.
+ * To delete an image version, set both imageBaseId and imageVersionId.
+ * The success of the operation will be forwarded to the GUI through the DeleteCallback.
*
* @param frame next parent frame of the caller of this method
* @param imageBaseId uuid of the image that belongs to the version
* @param imageVersionId id of the image version to be deleted
* @param callback called to inform the GUI about the deletion status (see DeleteCallback interface)
*/
- public static void deleteImageVersion(final Frame frame, final String imageBaseId,
+ public static void deleteImageBaseOrVersion(final Frame frame, final String imageBaseId,
final String imageVersionId, final DeleteCallback callback) {
- // requires confirmation of the user
- if (!Gui.showMessageBox(frame, "Wollen Sie diese Image-Version wirklich löschen?",
- MessageType.QUESTION_YESNO, LOGGER, null))
+ String questionText;
+ if (imageBaseId == null) {
+ return;
+ } else {
+ questionText = imageVersionId == null ?
+ "Wollen Sie dieses Image wirklich löschen?" : "Wollen Sie diese Image-Version wirklich löschen?";
+ }
+ if (!userConfirmed(frame, questionText))
return;
- // try to actually delete this version of the image
+
+ // perform the deletion
QuickTimer.scheduleOnce(new Task() {
boolean success = false;
-
@Override
public void fire() {
try {
- ThriftManager.getSatClient().deleteImageVersion(Session.getSatelliteToken(),
- imageVersionId);
- LOGGER.info("Deleted version '" + imageVersionId + "' of image '" + imageBaseId + "'.");
+ if (imageVersionId == null) {
+ // deleting an image base
+ ThriftManager.getSatClient().deleteImageBase(Session.getSatelliteToken(), imageBaseId);
+ LOGGER.info("Deleted image with id '" + imageBaseId + "'");
+ } else {
+ // deleting an image version
+ ThriftManager.getSatClient().deleteImageVersion(Session.getSatelliteToken(), imageVersionId);
+ LOGGER.info("Deleted version '" + imageVersionId + "' of image '" + imageBaseId + "'.");
+ }
success = true;
} catch (TException e) {
- ThriftError.showMessage(frame, LOGGER, e, "Das Löschen der Version ist gescheitert");
+ ThriftError.showMessage(frame, LOGGER, e, "Löschen fehlgeschlagen");
if (callback != null)
callback.isDeleted(success);
return;
@@ -367,4 +381,15 @@ public class ThriftActions {
}
});
}
+
+ /**
+ * Helper to ask the user for confirmation. Returns his choice.
+ *
+ * @param frame frame to show this message box on
+ * @param message question message to display to the user
+ * @return true if the user confirmed (clicked yes), false otherwise
+ */
+ private static boolean userConfirmed(final Frame frame, final String message) {
+ return Gui.showMessageBox(frame, message, MessageType.QUESTION_YESNO, LOGGER, null);
+ }
}