diff options
| author | Stephan Schwaer | 2015-10-08 17:47:28 +0200 |
|---|---|---|
| committer | Stephan Schwaer | 2015-10-08 17:47:28 +0200 |
| commit | f95d4dadb306f050ab77730f85154e1bd5959498 (patch) | |
| tree | 54d07ee64d5958dd37f96c46867e605faa285a85 /dozentenmodul/src/main/java | |
| parent | [client] Fixed layout problems in transferPanel with long image names. (diff) | |
| download | tutor-module-f95d4dadb306f050ab77730f85154e1bd5959498.tar.gz tutor-module-f95d4dadb306f050ab77730f85154e1bd5959498.tar.xz tutor-module-f95d4dadb306f050ab77730f85154e1bd5959498.zip | |
[client] Show date of version to be deleted and fix to correctly check permissions when trying to delete.
Diffstat (limited to 'dozentenmodul/src/main/java')
| -rw-r--r-- | dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/ImageDetailsWindow.java | 9 | ||||
| -rw-r--r-- | dozentenmodul/src/main/java/org/openslx/dozmod/thrift/ThriftActions.java | 15 |
2 files changed, 13 insertions, 11 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 5fd53022..d42e9095 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 @@ -229,14 +229,15 @@ public class ImageDetailsWindow extends ImageDetailsWindowLayout implements UiFe pop.addSeparator(); pop.addMenuItem(popupItemDelete); - // keyboard shortcut versionTable.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put( KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0), "delete"); versionTable.getActionMap().put("delete", new AbstractAction() { @Override public void actionPerformed(ActionEvent ae) { - deleteVersions(versionTable.getSelectedItems()); + if (ImagePerms.canEdit(image)) { + deleteVersions(versionTable.getSelectedItems()); + } } }); @@ -280,7 +281,7 @@ public class ImageDetailsWindow extends ImageDetailsWindowLayout implements UiFe popupItemDownload.setEnabled(versionTable.getSelectedItem().isValid && ImagePerms.canDownload(image) && !multiSelection); popupItemDelete.setEnabled(versionTable.getSelectedItem().isValid - && ImagePerms.canAdmin(image)); + && ImagePerms.canEdit(image)); pop.show(e.getComponent(), e.getX(), e.getY()); } } @@ -474,7 +475,7 @@ public class ImageDetailsWindow extends ImageDetailsWindowLayout implements UiFe private void deleteVersion(final ImageVersionDetails version) { if (version == null) return; - ThriftActions.deleteImageVersion(JOptionPane.getFrameForComponent(this), version.versionId, + ThriftActions.deleteImageVersion(JOptionPane.getFrameForComponent(this), version, new DeleteCallback() { @Override public void isDeleted(boolean success) { 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 74d4a601..7f725857 100644 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/thrift/ThriftActions.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/thrift/ThriftActions.java @@ -745,14 +745,15 @@ public class ThriftActions { * * @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 version 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 imageVersionId, + public static void deleteImageVersion(final Frame frame, final ImageVersionDetails version, final DeleteCallback callback) { - if (imageVersionId == null || imageVersionId.isEmpty()) + if (version == null || version.versionId == null || version.versionId.isEmpty()) return; + String versionId = version.versionId; boolean success = false; List<LectureSummary> lectureList = null; try { @@ -770,7 +771,7 @@ public class ThriftActions { boolean matches = false; if (lectureList != null && !lectureList.isEmpty()) { for (LectureSummary lecture : lectureList) { - if (imageVersionId.equals(lecture.getImageVersionId())) { + if (versionId.equals(lecture.getImageVersionId())) { if (!matches) questionText = "Diese Version ist zu folgende Veranstaltungen verknüpft:\n"; matches = true; @@ -781,13 +782,13 @@ public class ThriftActions { questionText += "\nWollen Sie diese Version samt Veranstaltungen löschen?\n"; } if (!matches) - questionText = "Wollen Sie diese Image-Version wirklich löschen?"; + questionText = "Wollen Sie die Image-Version vom " + FormatHelper.shortDate(version.createTime) + " Uhr wirklich löschen?"; if (!userConfirmed(frame, questionText)) return; try { - ThriftManager.getSatClient().deleteImageVersion(Session.getSatelliteToken(), imageVersionId); - LOGGER.info("Deleted version '" + imageVersionId + "'."); + ThriftManager.getSatClient().deleteImageVersion(Session.getSatelliteToken(), versionId); + LOGGER.info("Deleted version '" + versionId + "'."); success = true; } catch (TException e) { ThriftError.showMessage(frame, LOGGER, e, "Fehler beim Löschen der Version"); |
