summaryrefslogtreecommitdiffstats
path: root/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/LectureChangeImage.java
diff options
context:
space:
mode:
authorJonathan Bauer2015-09-08 17:30:15 +0200
committerJonathan Bauer2015-09-08 17:30:15 +0200
commitf7740d220a524de76969b78244656786a18ead42 (patch)
treed371d641bf6c806dd78d52bf07edd0a56ddd79c6 /dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/LectureChangeImage.java
parent[client] refactor PermissionDetaultToCustomLink _> DefaultCustomPerms (diff)
downloadtutor-module-f7740d220a524de76969b78244656786a18ead42.tar.gz
tutor-module-f7740d220a524de76969b78244656786a18ead42.tar.xz
tutor-module-f7740d220a524de76969b78244656786a18ead42.zip
[client] fat refactor to reflect what the current state of the classes actually do
remove 'Custom' from windows in which we can also set default perms TODO: wizards: DefPerms and CustomPerms still split in two pages, so let the "Custom" in the pages class' names as its still the case, but the question is: should it be like this? or do we put the defaults permissions checkboxes also on the last page?
Diffstat (limited to 'dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/LectureChangeImage.java')
-rw-r--r--dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/LectureChangeImage.java143
1 files changed, 143 insertions, 0 deletions
diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/LectureChangeImage.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/LectureChangeImage.java
new file mode 100644
index 00000000..4ba21f86
--- /dev/null
+++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/LectureChangeImage.java
@@ -0,0 +1,143 @@
+package org.openslx.dozmod.gui.window;
+
+import java.awt.Window;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseEvent;
+
+import javax.swing.SwingUtilities;
+import javax.swing.event.ListSelectionEvent;
+import javax.swing.event.ListSelectionListener;
+
+import org.apache.log4j.Logger;
+import org.openslx.bwlp.thrift.iface.ImageSummaryRead;
+import org.openslx.dozmod.gui.Gui;
+import org.openslx.dozmod.gui.control.table.ImageTable;
+import org.openslx.dozmod.gui.helper.MessageType;
+import org.openslx.dozmod.gui.helper.UiFeedback;
+import org.openslx.dozmod.gui.window.layout.LectureChangeImageLayout;
+import org.openslx.dozmod.permissions.ImagePerms;
+
+/**
+ * Window for changing the linked image of a lecture
+ */
+@SuppressWarnings("serial")
+public class LectureChangeImage extends LectureChangeImageLayout implements UiFeedback {
+
+ private static final Logger LOGGER = Logger.getLogger(LectureChangeImage.class);
+
+ private boolean okUsed = false;
+ private ImageTable imageTable;
+
+ private LectureChangeImage me;
+
+ /**
+ * Don't use this constructor, use static function open instead.
+ */
+ protected LectureChangeImage(final Window modalParent) {
+ super(modalParent);
+ me = this;
+
+ /**
+ * initialise the ImageListViewer
+ */
+ imageListViewer.refreshList(false, 1);
+ imageTable = imageListViewer.getImageTable();
+
+ imageTable.setColumnVisible(ImageTable.COL_LASTCHANGE , false);
+ imageTable.setColumnVisible(ImageTable.COL_OS , false);
+ imageTable.setColumnVisible(ImageTable.COL_SIZE , false);
+ imageTable.setColumnVisible(ImageTable.COL_TEMPLATE , false);
+
+ // finally the table listeners
+ imageTable.addMouseListener(new MouseAdapter() {
+ @Override
+ public void mouseClicked(MouseEvent e) {
+
+ }
+ @Override
+ public void mousePressed(MouseEvent e) {
+ processClick(e);
+ }
+ @Override
+ public void mouseReleased(MouseEvent e) {
+ processClick(e);
+ }
+ private void processClick(MouseEvent e) {
+ // left double click => open details
+ if (SwingUtilities.isLeftMouseButton(e) && e.getClickCount() == 2) {
+ ImageSummaryRead image = imageTable.getSelectedItem();
+ if (image.isValid && ImagePerms.canLink(image)) {
+ okUsed = true;
+ dispose();
+ } else {
+ if(!image.isValid)
+ Gui.showMessageBox(me, "Ausgewähltes Image ist ungültig!", MessageType.ERROR, LOGGER , null);
+ else Gui.showMessageBox(me, "Keine Rechte zum verlinken auf das ausgewählte Image.", MessageType.ERROR, LOGGER , null);
+ }
+ }
+
+ }
+ });
+
+
+ imageTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
+ @Override
+ public void valueChanged(ListSelectionEvent e) {
+ ImageSummaryRead image = imageTable.getSelectedItem();
+ btnOk.setEnabled(image.isValid && ImagePerms.canLink(image));
+ }
+ });
+
+ /**
+ * ActionListeners for the buttons.
+ */
+ btnOk.addActionListener(new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ okUsed = true;
+ dispose();
+ }
+ });
+ btnClose.addActionListener(new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent arg0) {
+ dispose();
+ }
+ });
+ }
+
+
+ /**
+ * Set window visible and return resulting ImageSummaryRead
+ * @return ImageSummaryRead of selected Image
+ */
+ private ImageSummaryRead runAndReturn(){
+ setVisible(true);
+ if (okUsed){
+ return imageTable.getSelectedItem();
+ } else {
+ return null;
+ }
+ }
+
+ /**
+ * Create new LectureChangeLinkedImage
+ * @param modalParent parent window of the popup window
+ * @return ImageSummaryRead of selected image or null, if abort has been used
+ */
+ public static ImageSummaryRead open(Window modalParent) {
+ return new LectureChangeImage(modalParent).runAndReturn();
+ }
+
+ @Override
+ public boolean wantConfirmQuit() {
+ return false;
+ }
+
+ @Override
+ public void escapePressed() {
+ dispose();
+ }
+}