diff options
author | Stephan Schwaer | 2015-10-27 17:45:37 +0100 |
---|---|---|
committer | Stephan Schwaer | 2015-10-27 17:45:37 +0100 |
commit | c1e86bdfb57a71fbe1a90100b03964bf05f0aea1 (patch) | |
tree | a799fcd7aa04920213de8000ebbbabb59e49f7c9 /dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/LectureListWindow.java | |
parent | [client] Add two floppy drives to vmx of downloaded VM (diff) | |
download | tutor-module-c1e86bdfb57a71fbe1a90100b03964bf05f0aea1.tar.gz tutor-module-c1e86bdfb57a71fbe1a90100b03964bf05f0aea1.tar.xz tutor-module-c1e86bdfb57a71fbe1a90100b03964bf05f0aea1.zip |
[client] Clean up deleteLectures and improve it's user feadback.
Diffstat (limited to 'dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/LectureListWindow.java')
-rw-r--r-- | dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/LectureListWindow.java | 54 |
1 files changed, 22 insertions, 32 deletions
diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/LectureListWindow.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/LectureListWindow.java index d81ed319..882309d6 100644 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/LectureListWindow.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/LectureListWindow.java @@ -11,6 +11,7 @@ import java.util.ArrayList; import java.util.Calendar; import java.util.Date; import java.util.List; +import java.util.Map; import java.util.regex.Pattern; import java.util.regex.PatternSyntaxException; @@ -28,6 +29,7 @@ import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; import org.apache.log4j.Logger; +import org.apache.thrift.TException; import org.openslx.bwlp.thrift.iface.ImageDetailsRead; import org.openslx.bwlp.thrift.iface.ImageVersionDetails; import org.openslx.bwlp.thrift.iface.LectureSummary; @@ -380,43 +382,31 @@ public class LectureListWindow extends LectureListWindowLayout { } /** - * Deletes the given lecture - */ - private void deleteLecture(final LectureSummary lecture) { - if (lecture == null) - return; - ThriftActions.deleteLecture(JOptionPane.getFrameForComponent(me), lecture.getLectureId(), - new DeleteLectureCallback() { - @Override - public void deleted(boolean success) { - refreshList(success); - } - }); - } - - /** * Delete a list of lectures and display the lectures, which couldn't be * deleted. * - * @param lectureList the images to be deleted. + * @param lectureList the lectures to be deleted. */ private void deleteLectures(List<LectureSummary> lectureList) { - boolean failedToDeleteAll = false; - StringBuilder builder = new StringBuilder(); - for (LectureSummary lecture : lectureList) { - if (LecturePerms.canAdmin(lecture)) { - deleteLecture(lecture); - } else { - failedToDeleteAll = true; - builder.append('\n'); - builder.append(lecture.lectureName); - } - } - if (failedToDeleteAll) { - Gui.showMessageBox( - "Folgende Veranstaltungen konnten nicht gelöscht werden: " + builder.toString(), - MessageType.INFO, LOGGER, null); - } + + ThriftActions.deleteLecture(JOptionPane.getFrameForComponent(me), lectureList, + new DeleteLectureCallback() { + @Override + public void deleted(Map<LectureSummary, TException> fLectures) { + refreshList(true); + if (fLectures.size() > 0) { + StringBuilder builder = new StringBuilder(); + for (LectureSummary lecture : fLectures.keySet()) { + builder.append('\n'); + builder.append(lecture.lectureName); + LOGGER.error("Couldn't delete lecture " + lecture.lectureName + ", reason:", fLectures.get(lecture) ); + // TODO Should the exception be printed in the debugger or is this to much information? + } + Gui.showMessageBox("Folgende Veranstaltungen konnten nicht gelöscht werden: " + + builder.toString(), MessageType.INFO, LOGGER, null); + } + } + }); } /** |