diff options
author | Jonathan Bauer | 2015-08-26 14:42:48 +0200 |
---|---|---|
committer | Jonathan Bauer | 2015-08-26 14:42:48 +0200 |
commit | 10a8e8dff7b96f233d26fd576ccd9306531247bc (patch) | |
tree | 142075aa3c316a98d83a212ee2b257199e28b78a /dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/ImageListWindow.java | |
parent | [client] refactor: ImageWizard -> ImageCreationWizard & UpdateWizard -> Image... (diff) | |
download | tutor-module-10a8e8dff7b96f233d26fd576ccd9306531247bc.tar.gz tutor-module-10a8e8dff7b96f233d26fd576ccd9306531247bc.tar.xz tutor-module-10a8e8dff7b96f233d26fd576ccd9306531247bc.zip |
[client] add "View/Edit" button to button panel and popup menu in ImageList
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.java | 59 |
1 files changed, 28 insertions, 31 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 05161094..b19ff6c0 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 @@ -52,6 +52,7 @@ public class ImageListWindow extends ImageListWindowLayout implements DownloadCa * Popup menu items */ private final JMenuItem popupItemNewLecture = new JMenuItem("Neue Veranstaltung"); + private final JMenuItem popupItemEdit = new JMenuItem("Bearbeiten"); private final JMenuItem popupItemDelete = new JMenuItem("Löschen"); private final JMenuItem popupItemDownload = new JMenuItem("Download"); @@ -69,17 +70,21 @@ public class ImageListWindow extends ImageListWindowLayout implements DownloadCa if (e.getSource().equals(popupItemNewLecture)) { startLectureWizard(imageTable.getSelectedItem()); } + if (e.getSource().equals(popupItemEdit)) { + openImageDetails(imageTable.getSelectedItem()); + } if (e.getSource().equals(popupItemDownload)) { performImageDownload(imageTable.getSelectedItem()); } if (e.getSource().equals(popupItemDelete)) { - deleteLatestVersion(getSelectedImage()); + deleteBaseImage(imageTable.getSelectedItem()); } } }); // add them to the popup menu pop.addMenuItem(popupItemNewLecture); + pop.addMenuItem(popupItemEdit); pop.addMenuItem(popupItemDownload); pop.addSeparator(); pop.addMenuItem(popupItemDelete); @@ -108,15 +113,7 @@ public class ImageListWindow extends ImageListWindowLayout implements DownloadCa @Override public void mouseClicked(MouseEvent e) { if (SwingUtilities.isLeftMouseButton(e) && e.getClickCount() == 2) { - final ImageSummaryRead image = getSelectedImage(); - if (image == null) - return; - ImageDetailsWindow.open((JFrame) SwingUtilities.getWindowAncestor(me), - image.getImageBaseId(), new ImageUpdatedCallback() { - public void updated() { - imageListViewer.refreshList(true, 100); - } - }); + openImageDetails(imageTable.getSelectedItem()); } processClick(e); } @@ -161,6 +158,12 @@ public class ImageListWindow extends ImageListWindowLayout implements DownloadCa startLectureWizard(imageTable.getSelectedItem()); } }); + editButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + openImageDetails(imageTable.getSelectedItem()); + } + }); downloadButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { @@ -170,7 +173,7 @@ public class ImageListWindow extends ImageListWindowLayout implements DownloadCa deleteButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { - deleteLatestVersion(getSelectedImage()); + deleteBaseImage(imageTable.getSelectedItem()); } }); backButton.addActionListener(new ActionListener() { @@ -189,25 +192,6 @@ public class ImageListWindow extends ImageListWindowLayout implements DownloadCa * ********************************************************************************/ - - - /** - * Helper to return the selected image from the table or show an error to - * the user if none is selected - * - * @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) { - Gui.showMessageBox(this, "Kein Image ausgewählt!", MessageType.ERROR, LOGGER, null); - return null; - } else { - return image; - } - } - /** * Helper to check if the given image has a latest version * @@ -235,10 +219,13 @@ public class ImageListWindow extends ImageListWindowLayout implements DownloadCa boolean isValid = item != null && item.getLatestVersionId() != null; boolean download = isValid && ImagePerms.canDownload(item); boolean link = isValid && ImagePerms.canLink(item); + boolean edit = ImagePerms.canEdit(item); boolean admin = ImagePerms.canAdmin(item); + editButton.setText(edit ? "Bearbeiten" : "Ansehen"); downloadButton.setEnabled(download); newLectureButton.setEnabled(link); deleteButton.setEnabled(admin); + popupItemEdit.setText(edit ? "Bearbeiten" : "Ansehen"); popupItemDownload.setEnabled(download); popupItemNewLecture.setEnabled(link); popupItemDelete.setEnabled(admin); @@ -261,6 +248,16 @@ public class ImageListWindow extends ImageListWindowLayout implements DownloadCa new LectureWizard(SwingUtilities.getWindowAncestor(this), image, image.getLatestVersionId()).setVisible(true); } + private void openImageDetails(ImageSummaryRead image) { + if (image == null) + return; + ImageDetailsWindow.open((JFrame) SwingUtilities.getWindowAncestor(me), + image.getImageBaseId(), new ImageUpdatedCallback() { + public void updated() { + imageListViewer.refreshList(true, 100); + } + }); + } /** * Triggers a download of the given image's latest version * @@ -291,7 +288,7 @@ public class ImageListWindow extends ImageListWindowLayout implements DownloadCa * * @param image image to delete */ - private void deleteLatestVersion(final ImageSummaryRead image) { + private void deleteBaseImage(final ImageSummaryRead image) { ThriftActions.deleteBaseImage(JOptionPane.getFrameForComponent(this), image.getImageBaseId(), this); } |