summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephan Schwaer2015-08-03 18:11:39 +0200
committerStephan Schwaer2015-08-03 18:11:39 +0200
commitba9eadf7288cbc697c6a82884e2d590e81ed88ed (patch)
tree8cf1c86975e13fe949a87fba11ec69ac55499650
parent[client] Remove debug output from LoginWindow (diff)
downloadtutor-module-ba9eadf7288cbc697c6a82884e2d590e81ed88ed.tar.gz
tutor-module-ba9eadf7288cbc697c6a82884e2d590e81ed88ed.tar.xz
tutor-module-ba9eadf7288cbc697c6a82884e2d590e81ed88ed.zip
[client] Added lecture details layout and window. (not working yet)
-rw-r--r--dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/LectureDetailsWindow.java147
-rw-r--r--dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/LectureListWindow.java13
-rw-r--r--dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/LectureDetailsWindowLayout.java151
3 files changed, 311 insertions, 0 deletions
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
new file mode 100644
index 00000000..ee7f5db8
--- /dev/null
+++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/LectureDetailsWindow.java
@@ -0,0 +1,147 @@
+package org.openslx.dozmod.gui.window;
+
+import java.awt.Frame;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.KeyAdapter;
+import java.awt.event.KeyEvent;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+
+import org.apache.log4j.Logger;
+import org.openslx.bwlp.thrift.iface.ImageDetailsRead;
+import org.openslx.bwlp.thrift.iface.LectureRead;
+import org.openslx.bwlp.thrift.iface.OperatingSystem;
+import org.openslx.bwlp.thrift.iface.Virtualizer;
+import org.openslx.dozmod.gui.Gui;
+import org.openslx.dozmod.gui.MainWindow;
+import org.openslx.dozmod.gui.helper.MessageType;
+import org.openslx.dozmod.gui.window.layout.LectureDetailsWindowLayout;
+import org.openslx.dozmod.permissions.ImagePerms;
+import org.openslx.dozmod.thrift.MetaDataCache;
+import org.openslx.dozmod.thrift.Session;
+import org.openslx.dozmod.thrift.UserCache;
+import org.openslx.dozmod.util.FormatHelper;
+import org.openslx.thrifthelper.ThriftManager;
+import org.openslx.util.QuickTimer;
+import org.openslx.util.QuickTimer.Task;
+
+@SuppressWarnings("serial")
+public class LectureDetailsWindow extends LectureDetailsWindowLayout {
+
+ private static final Logger LOGGER = Logger.getLogger(LectureDetailsWindow.class);
+
+ private final LectureDetailsWindow me = this;
+
+ private LectureRead lecture = null;
+
+ public LectureDetailsWindow(Frame modalParent) {
+ super(modalParent);
+
+ // Close button closes window
+ btnClose.addActionListener(new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ dispose();
+ }
+ });
+ // ESC closes this window
+ addKeyListener(new KeyAdapter() {
+ @Override
+ public void keyPressed(KeyEvent e) {
+ LOGGER.debug("he");
+ if (e.getKeyCode() == KeyEvent.VK_ESCAPE) {
+ dispose();
+ }
+ }
+ });
+ setFocusable(true);
+ }
+
+ /**
+ * @param lectureId the id of the image to be displayed
+ */
+ public void setLecture(final String lectureId) {
+
+ QuickTimer.scheduleOnce(new Task() {
+ @Override
+ public void fire() {
+ Exception error = null;
+ try {
+ synchronized (me) {
+ if (lecture != null)
+ return;
+ lecture = ThriftManager.getSatClient().getLectureDetails(Session.getSatelliteToken(), lectureId);
+ }
+ } catch (Exception e) {
+ error = e;
+ }
+ final Exception e = error;
+ Gui.asyncExec(new Runnable() {
+ @Override
+ public void run() {
+ if (e != null || lecture == null) {
+ Gui.showMessageBox(null, "Konnte Daten der Vorlesung nicht abrufen",
+ MessageType.ERROR, LOGGER, e);
+ dispose();
+ } else {
+ fill();
+ }
+ }
+ });
+ }
+ });
+ }
+
+ /**
+ * callback function when we received the image's details from the server
+ */
+ private void fill() {
+ if (lecture == null)
+ return;
+ txtTitle.setText(lecture.getLectureName());
+ txtDescription.setText(lecture.getDescription());
+ if (lecture.image != null)
+ txtImageName.setText(lecture.image.getImageName());
+ lblOwner.setUser(UserCache.find(lecture.getOwnerId()));
+ lblUpdater.setUser(UserCache.find(lecture.getUpdaterId()));
+ lblCreateTime.setText(FormatHelper.longDate(lecture.getCreateTime()));
+ lblUpdateTime.setText(FormatHelper.longDate(lecture.getUpdateTime()));
+ lblStartTime.setText(FormatHelper.longDate(lecture.getStartTime()));
+ lblEndTime.setText(FormatHelper.longDate(lecture.getEndTime()));
+
+ txtId.setText(lecture.getLectureId());
+
+ btnIsEnabled.setSelected(lecture.isEnabled);
+ btnIsExam.setSelected(lecture.isExam);
+ // TODO grey out non editable components
+ //makeEditable(ImagePerms.canEdit(lecture));
+ pack();
+ MainWindow.centerShell(this);
+ setVisible(true);
+ }
+
+ /**
+ * Enables/disables the editable fields based on 'editable'
+ *
+ * @param editable true to make fields editable, false otherwise.
+ */
+ private void makeEditable(boolean editable) {
+ txtTitle.setEnabled(editable);
+ txtDescription.setEnabled(editable);
+ txtId.setEnabled(editable);
+ }
+
+ /**
+ * Opens a new LectureDetailsWindow showing the details of the
+ * lecture with ID = lectureId
+ *
+ * @param modalParent parent of this window
+ * @param lectureId id of the lecture to set the details of
+ */
+ public static void open(Frame modalParent, String lectureId) {
+ LectureDetailsWindow win = new LectureDetailsWindow(modalParent);
+ win.setLecture(lectureId);
+ }
+}
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 4b24ce5e..eb4dc1ee 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
@@ -6,6 +6,7 @@ import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.List;
+import javax.swing.JFrame;
import javax.swing.JTextField;
import javax.swing.SwingUtilities;
import javax.swing.event.DocumentEvent;
@@ -51,6 +52,18 @@ public class LectureListWindow extends LectureListWindowLayout {
// TODO: Set filter
}
});
+
+ lectureTable.addMouseListener(new MouseAdapter() {
+ @Override
+ public void mouseClicked(MouseEvent e) {
+ if (e.getClickCount() == 2) {
+ LectureSummary lecture = lectureTable.getSelectedItem();
+ if (lecture == null)
+ return;
+ LectureDetailsWindow.open((JFrame)SwingUtilities.getWindowAncestor(me), lecture.getLectureId());
+ }
+ }
+ });
lectureTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
@Override
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
new file mode 100644
index 00000000..18231147
--- /dev/null
+++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/LectureDetailsWindowLayout.java
@@ -0,0 +1,151 @@
+package org.openslx.dozmod.gui.window.layout;
+
+import java.awt.BorderLayout;
+import java.awt.Component;
+import java.awt.Font;
+import java.awt.Frame;
+import java.awt.GridBagLayout;
+
+import javax.swing.BorderFactory;
+import javax.swing.Box;
+import javax.swing.BoxLayout;
+import javax.swing.DefaultListCellRenderer;
+import javax.swing.JButton;
+import javax.swing.JCheckBox;
+import javax.swing.JComboBox;
+import javax.swing.JDialog;
+import javax.swing.JFrame;
+import javax.swing.JLabel;
+import javax.swing.JList;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.JTextArea;
+import javax.swing.JTextField;
+
+import org.openslx.bwlp.thrift.iface.OperatingSystem;
+import org.openslx.bwlp.thrift.iface.ShareMode;
+import org.openslx.dozmod.gui.control.PersonLabel;
+import org.openslx.dozmod.gui.helper.GridPos;
+
+@SuppressWarnings("serial")
+public abstract class LectureDetailsWindowLayout extends JDialog {
+
+ protected final JLabel txtTitle;
+ protected final JTextArea txtDescription;
+
+ protected final JTextField txtImageName;
+
+ protected final PersonLabel lblOwner;
+ protected final JLabel lblCreateTime;
+ protected final PersonLabel lblUpdater;
+ protected final JLabel lblUpdateTime;
+
+ protected final JLabel lblStartTime;
+ protected final JLabel lblEndTime;
+
+ protected final JCheckBox btnIsEnabled;
+ protected final JCheckBox btnAutoUpdate;
+ protected final JCheckBox btnIsExam;
+
+
+ protected final JTextField txtId;
+
+ protected final JLabel lblUseCount;
+
+ protected final JButton btnSaveChanges;
+ protected final JButton btnClose;
+
+ // TODO: Permissions, ...
+
+ public LectureDetailsWindowLayout(Frame modalParent) {
+ super(modalParent, "der mit dem blub", ModalityType.APPLICATION_MODAL);
+ setResizable(true);
+ setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
+ setLayout(new BorderLayout());
+
+ // use panel to put every info related widget in it
+ // then we will set the panel in BorderLayout.CENTER
+ JPanel infoPanel = new JPanel();
+ infoPanel.setLayout(new GridBagLayout());
+ infoPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
+
+ // helper for row index
+ int row = 0;
+
+ // -- name --
+ txtTitle = new JLabel();
+ txtTitle.setFont(txtTitle.getFont().deriveFont(Font.BOLD, txtTitle.getFont().getSize2D() * 2));
+ infoPanel.add(txtTitle, GridPos.get(0, row++, 2, 1, true, false));
+
+ // description
+ txtDescription = new JTextArea();
+ infoPanel.add(new JLabel("Beschreibung"), GridPos.get(0, row++, false, false));
+ infoPanel.add(new JScrollPane(txtDescription), GridPos.get(1, row++, true, false));
+
+ // linked image name
+ txtImageName = new JTextField();
+ infoPanel.add(new JLabel("Imagename"), GridPos.get(0, row++, false, false));
+ infoPanel.add(txtImageName, GridPos.get(1, row++, true, false));
+
+ // start time of the lecture
+ lblStartTime = new JLabel();
+ infoPanel.add(new JLabel("Startzeit"), GridPos.get(0, row++, false, false));
+ infoPanel.add(lblStartTime, GridPos.get(1, row++, true, false));
+
+ // end time of the lecture
+ lblEndTime = new JLabel();
+ infoPanel.add(new JLabel("Endzeit"), GridPos.get(0, row++, false, false));
+ infoPanel.add(lblEndTime, GridPos.get(1, row++, true, false));
+
+ // owner
+ lblOwner = new PersonLabel();
+ infoPanel.add(new JLabel("Besitzer"), GridPos.get(0, row++, false, false));
+ infoPanel.add(lblOwner, GridPos.get(1, row++, true, false));
+ // creation time
+ lblCreateTime = new JLabel();
+ infoPanel.add(new JLabel("Erstellt"), GridPos.get(0, row++, false, false));
+ infoPanel.add(lblCreateTime, GridPos.get(1, row++, true, false));
+ // last updater
+ lblUpdater = new PersonLabel();
+ infoPanel.add(new JLabel("Geändert durch"), GridPos.get(0, row++, false, false));
+ infoPanel.add(lblUpdater, GridPos.get(1, row++, true, false));
+ // last updated
+ lblUpdateTime = new JLabel();
+ infoPanel.add(new JLabel("Änderungszeitpunkt"), GridPos.get(0, row++, false, false));
+ infoPanel.add(lblUpdateTime, GridPos.get(1, row++, true, false));
+ // enabled
+ btnIsEnabled = new JCheckBox();
+ infoPanel.add(new JLabel("Vorlage"), GridPos.get(0, row++, false, false));
+ infoPanel.add(btnIsEnabled, GridPos.get(1, row++, true, false));
+ // is exam
+ btnIsExam = new JCheckBox();
+ infoPanel.add(new JLabel("Vorlage"), GridPos.get(0, row++, false, false));
+ infoPanel.add(btnIsExam, GridPos.get(1, row++, true, false));
+
+ // auto update
+ btnAutoUpdate = new JCheckBox();
+ infoPanel.add(new JLabel("Vorlage"), GridPos.get(0, row++, false, false));
+ infoPanel.add(btnAutoUpdate, GridPos.get(1, row++, true, false));
+ // id
+ txtId = new JTextField();
+ infoPanel.add(new JLabel("ID"), GridPos.get(0, row++, false, false));
+ infoPanel.add(txtId, GridPos.get(1, row++, true, false));
+ // use count
+ lblUseCount = new JLabel();
+ infoPanel.add(new JLabel("ID"), GridPos.get(0, row++, false, false));
+ infoPanel.add(lblUseCount, GridPos.get(1, row++, true, false));
+
+
+ // finally add the infoPanel itself to the main view
+ add(infoPanel, BorderLayout.CENTER);
+ // button panel on the bottom
+ JPanel buttonPanel = new JPanel();
+ buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.X_AXIS));
+ btnSaveChanges = new JButton("Speichern");
+ btnClose = new JButton("Schließen");
+ buttonPanel.add(btnSaveChanges);
+ buttonPanel.add(Box.createGlue());
+ buttonPanel.add(btnClose);
+ add(buttonPanel, BorderLayout.SOUTH);
+ }
+}