summaryrefslogtreecommitdiffstats
path: root/dozentenmodul
diff options
context:
space:
mode:
authorStephan Schwaer2015-08-21 15:17:41 +0200
committerStephan Schwaer2015-08-21 15:17:41 +0200
commitd99d4a7c5f9cdc38459d7ddc69269d4eebfb5ba9 (patch)
tree0366359f2cc75528d43c3c2cdeaa395357e6535e /dozentenmodul
parent[client] ThriftAction in ImageCustomPermissionWindow (diff)
downloadtutor-module-d99d4a7c5f9cdc38459d7ddc69269d4eebfb5ba9.tar.gz
tutor-module-d99d4a7c5f9cdc38459d7ddc69269d4eebfb5ba9.tar.xz
tutor-module-d99d4a7c5f9cdc38459d7ddc69269d4eebfb5ba9.zip
[client] Added customLecturePermission
Diffstat (limited to 'dozentenmodul')
-rw-r--r--dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/ImageDetailsWindow.java3
-rw-r--r--dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/LectureCustomPermissionWindow.java76
-rw-r--r--dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/LectureDetailsWindow.java53
-rw-r--r--dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/LectureCustomPermissionWindowLayout.java68
-rw-r--r--dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/LectureDetailsWindowLayout.java34
5 files changed, 218 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 57264e34..cc778e54 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
@@ -77,6 +77,9 @@ public class ImageDetailsWindow extends ImageDetailsWindowLayout implements UiFe
*/
private ImageDetailsRead image = null;
+ /**
+ * The custom permissions of the image
+ */
private Map<String, ImagePermissions> permissionMap;
/**
diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/LectureCustomPermissionWindow.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/LectureCustomPermissionWindow.java
new file mode 100644
index 00000000..11687086
--- /dev/null
+++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/LectureCustomPermissionWindow.java
@@ -0,0 +1,76 @@
+package org.openslx.dozmod.gui.window;
+
+import java.awt.Frame;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.util.Map;
+
+import org.apache.log4j.Logger;
+import org.apache.thrift.TException;
+import org.openslx.bwlp.thrift.iface.LecturePermissions;
+import org.openslx.dozmod.gui.Gui;
+import org.openslx.dozmod.gui.helper.MessageType;
+import org.openslx.dozmod.gui.window.layout.LectureCustomPermissionWindowLayout;
+import org.openslx.dozmod.thrift.Session;
+import org.openslx.thrifthelper.ThriftManager;
+
+/**
+ * Window for modifying the custom permissions of an lecture.
+ */
+@SuppressWarnings("serial")
+public class LectureCustomPermissionWindow extends LectureCustomPermissionWindowLayout {
+
+ private static final Logger LOGGER = Logger.getLogger(LectureCustomPermissionWindow.class);
+
+ /**
+ * Self-reference
+ */
+ private final LectureCustomPermissionWindow me;
+
+ /**
+ * Don't use this constructor, use static function LectureCustomPermissionWindow.open instead.
+ */
+ protected LectureCustomPermissionWindow(final Frame modalParent, final Map<String, LecturePermissions> permissionMap, final LecturePermissions defaultPermissions, final String lectureBaseId) {
+ super(modalParent);
+ me = this;
+
+ /**
+ * initialise the lecturePermissionManager
+ */
+ lecturePermissionManager.initPanel(permissionMap, defaultPermissions);
+
+ /**
+ * ActionListeners for the buttons.
+ */
+ btnSave.addActionListener(new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ // push permissions to satellite server
+ try {
+ ThriftManager.getSatClient().writeLecturePermissions(Session.getSatelliteToken(),
+ lectureBaseId, lecturePermissionManager.getMap());
+ } catch (TException er) {
+ Gui.showMessageBox(me, "Konnte Berechtigungen nicht an den Satelliten übertragen: ", MessageType.ERROR, LOGGER, er);
+ }
+ dispose();
+ }
+ });
+ btnClose.addActionListener(new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent arg0) {
+ dispose();
+ }
+ });
+ }
+
+ /**
+ * Create new LecturePermissionWindow dialog
+ * @param modalParent parent of the popup window
+ * @param permissionMap the permissions of the lecture
+ * @param defaultPermissions default permissions of the lecture
+ * @param lectureBaseId baseId of the lecture, for which the permissionWindow should be opened
+ */
+ public static void open(Frame modalParent, Map<String, LecturePermissions> permissionMap, LecturePermissions defaultPermissions, String lectureBaseId) {
+ new LectureCustomPermissionWindow(modalParent, permissionMap, defaultPermissions, lectureBaseId).setVisible(true);
+ }
+}
diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/LectureDetailsWindow.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/LectureDetailsWindow.java
index 90de4aed..6c16debd 100644
--- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/LectureDetailsWindow.java
+++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/LectureDetailsWindow.java
@@ -8,6 +8,7 @@ import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import java.util.List;
+import java.util.Map;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JOptionPane;
@@ -15,7 +16,9 @@ import javax.swing.JOptionPane;
import org.apache.log4j.Logger;
import org.apache.thrift.TException;
import org.openslx.bwlp.thrift.iface.ImageDetailsRead;
+import org.openslx.bwlp.thrift.iface.ImagePermissions;
import org.openslx.bwlp.thrift.iface.ImageVersionDetails;
+import org.openslx.bwlp.thrift.iface.LecturePermissions;
import org.openslx.bwlp.thrift.iface.LectureRead;
import org.openslx.bwlp.thrift.iface.UserInfo;
import org.openslx.dozmod.gui.Gui;
@@ -39,48 +42,72 @@ public class LectureDetailsWindow extends LectureDetailsWindowLayout implements
private static final Logger LOGGER = Logger.getLogger(LectureDetailsWindow.class);
+ /**
+ * Self-reference
+ */
private final LectureDetailsWindow me = this;
+ /**
+ * Lecture that this window shows the details of
+ */
private LectureRead lecture = null;
+
+ /**
+ * The custom permissions of the lecture
+ */
+ private Map<String, LecturePermissions> permissionMap;
+
+ /**
+ * Image, that the lecture is linked to.
+ */
private ImageDetailsRead image = null;
+ /**
+ * Constructor
+ *
+ * @param modalParent parent of this popup window
+ */
public LectureDetailsWindow(Frame modalParent) {
super(modalParent);
- // Close button closes window
+ /**
+ * Button listeners
+ */
btnClose.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
dispose();
}
});
-
btnDownloadImage.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
performImageDownload();
}
});
-
btnAutoUpdate.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
cboVersions.setEnabled(!btnAutoUpdate.isSelected());
}
});
-
btnChangeOwner.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
UserListWindow.open(JOptionPane.getFrameForComponent(btnChangeOwner),
new UserAddedCallback() {
- @Override
- public void userAdded(UserInfo user, UserListWindow window) {
- window.dispose();
- setLectureOwner(user);
- }
-
- }, "Besitzer festlegen");
+ @Override
+ public void userAdded(UserInfo user, UserListWindow window) {
+ window.dispose();
+ setLectureOwner(user);
+ }
+ }, "Besitzer festlegen");
+ }
+ });
+ btnCustomPermissions.addActionListener(new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent arg0) {
+ LectureCustomPermissionWindow.open(JOptionPane.getFrameForComponent(me), permissionMap, lecture.defaultPermissions, lecture.lectureId);
}
});
makeEditable(false);
@@ -212,7 +239,7 @@ public class LectureDetailsWindow extends LectureDetailsWindowLayout implements
*/
private void makeEditable(boolean editable) {
editable = editable && LecturePerms.canEdit(lecture);
- //txtTitle.setEnabled(editable);
+ txtTitle.setEditable(editable);
txtDescription.setEditable(editable);
btnLinkImage.setEnabled(editable);
btnIsExam.setEnabled(editable);
@@ -237,7 +264,7 @@ public class LectureDetailsWindow extends LectureDetailsWindowLayout implements
LectureDetailsWindow win = new LectureDetailsWindow(modalParent);
win.setLecture(lectureId);
}
-
+
/**
* Triggers the download of the currently used image version of the lecture
*/
diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/LectureCustomPermissionWindowLayout.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/LectureCustomPermissionWindowLayout.java
new file mode 100644
index 00000000..7fcea518
--- /dev/null
+++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/LectureCustomPermissionWindowLayout.java
@@ -0,0 +1,68 @@
+package org.openslx.dozmod.gui.window.layout;
+
+import java.awt.BorderLayout;
+import java.awt.Container;
+import java.awt.Dimension;
+import java.awt.Frame;
+
+import javax.swing.BorderFactory;
+import javax.swing.Box;
+import javax.swing.BoxLayout;
+import javax.swing.JButton;
+import javax.swing.JDialog;
+import javax.swing.JPanel;
+
+import org.apache.log4j.Logger;
+import org.openslx.dozmod.gui.control.LectureCustomPermissionManager;
+
+
+/**
+ * Layout for the LectureCustomPermissionWindow
+ */
+@SuppressWarnings("serial")
+public class LectureCustomPermissionWindowLayout extends JDialog {
+
+ private static final Logger LOGGER = Logger.getLogger(LectureCustomPermissionWindowLayout.class);
+
+ /**
+ * Buttons
+ */
+ protected final JButton btnSave;
+ protected final JButton btnClose;
+
+ /**
+ * The lecturePermissionManager to use.
+ */
+ protected final LectureCustomPermissionManager lecturePermissionManager;
+
+ /**
+ * The title of the window.
+ */
+ private static String title = "Benutzerdefinierte Berechtigungen";
+
+ protected LectureCustomPermissionWindowLayout(Frame modalParent) {
+ super(modalParent, title, modalParent != null ? ModalityType.APPLICATION_MODAL
+ : ModalityType.MODELESS);
+
+ // create the lecturePermissionManager and add it to the pane.
+ lecturePermissionManager = new LectureCustomPermissionManager();
+ Container contentPane = getContentPane();
+ contentPane.add(lecturePermissionManager, BorderLayout.CENTER);
+
+ // buttons below the contentManager
+ JPanel buttonPane = new JPanel();
+ buttonPane.setLayout(new BoxLayout(buttonPane, BoxLayout.LINE_AXIS));
+ buttonPane.setBorder(BorderFactory.createEmptyBorder(0, 10, 10, 10));
+ btnSave = new JButton("Änderungen speichern");
+ buttonPane.add(btnSave);
+ buttonPane.add(Box.createGlue());
+ btnClose = new JButton("Abbrechen");
+ buttonPane.add(btnClose);
+ contentPane.add(buttonPane, BorderLayout.PAGE_END);
+
+
+ setPreferredSize(new Dimension(480, 350));
+ pack();
+ setLocationRelativeTo( modalParent );
+ }
+}
diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/LectureDetailsWindowLayout.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/LectureDetailsWindowLayout.java
index 1d3e1a90..eee3cb91 100644
--- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/LectureDetailsWindowLayout.java
+++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/LectureDetailsWindowLayout.java
@@ -41,7 +41,7 @@ import org.openslx.thrifthelper.Comparators;
@SuppressWarnings("serial")
public abstract class LectureDetailsWindowLayout extends JDialog {
- protected final JLabel txtTitle;
+ protected final JTextArea txtTitle;
protected final JTextArea txtDescription;
protected final JLabel txtImageName;
protected final JButton btnLinkImage;
@@ -60,6 +60,14 @@ public abstract class LectureDetailsWindowLayout extends JDialog {
protected final JTextField txtId;
protected final JLabel lblUseCount;
+
+ protected final JCheckBox chkCustomPermAdmin;
+ protected final JCheckBox chkCustomPermEdit;
+ protected final JCheckBox chkCustomPermDownload;
+ protected final JCheckBox chkCustomPermLink;
+
+ protected final JButton btnCustomPermissions;
+
protected final JButton btnSaveChanges;
protected final JButton btnClose;
protected final JButton btnDownloadImage;
@@ -92,7 +100,7 @@ public abstract class LectureDetailsWindowLayout extends JDialog {
GridManager grid = new GridManager(infoPanel, 3);
// -- name --
- txtTitle = new JLabel();
+ txtTitle = new JTextArea();
txtTitle.setFont(txtTitle.getFont().deriveFont(Font.BOLD, txtTitle.getFont().getSize2D() * 2));
grid.add(txtTitle, 3).expand(true, false).fill(true, false);
grid.nextRow();
@@ -216,9 +224,29 @@ public abstract class LectureDetailsWindowLayout extends JDialog {
grid.add(new JLabel("Aufrufe"));
grid.add(lblUseCount, 2);
grid.nextRow();
+
+ // Panel with the default permissions
+ JPanel defaultPermissionPane = new JPanel();
+ defaultPermissionPane.setBorder(BorderFactory.createTitledBorder( "Default Berechtigungen"));
+ chkCustomPermAdmin = new JCheckBox("Admin");
+ chkCustomPermDownload = new JCheckBox("Download");
+ chkCustomPermEdit = new JCheckBox("Bearbeiten");
+ chkCustomPermLink = new JCheckBox("Link");
+ defaultPermissionPane.add(chkCustomPermLink);
+ defaultPermissionPane.add(chkCustomPermDownload);
+ defaultPermissionPane.add(chkCustomPermEdit);
+ defaultPermissionPane.add(chkCustomPermAdmin);
+ grid.add(defaultPermissionPane, 3);
+ grid.nextRow();
+
+ // button for the custom permissions
+ btnCustomPermissions = new JButton("Standart Berechtigungen");
+ grid.add(btnCustomPermissions);
+ grid.skip(2);
+ grid.nextRow();
grid.finish(true);
-
+
// finally add the infoPanel itself to the main view
add(infoPanel, BorderLayout.CENTER);
// button panel on the bottom