From b0d6ebe32dfa60d078b367278544efcac4a89529 Mon Sep 17 00:00:00 2001 From: Jonathan Bauer Date: Thu, 25 Feb 2016 17:41:59 +0100 Subject: [client] added LectureSettingsWindow skeleton (WIP) --- .../dozmod/gui/window/LectureSettingsWindow.java | 34 ++++++ .../window/layout/LectureSettingsWindowLayout.java | 122 +++++++++++++++++++++ 2 files changed, 156 insertions(+) create mode 100644 dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/LectureSettingsWindow.java create mode 100644 dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/LectureSettingsWindowLayout.java (limited to 'dozentenmodul/src/main') diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/LectureSettingsWindow.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/LectureSettingsWindow.java new file mode 100644 index 00000000..8cb3a1ad --- /dev/null +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/LectureSettingsWindow.java @@ -0,0 +1,34 @@ +package org.openslx.dozmod.gui.window; + +import java.awt.Window; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +import org.openslx.bwlp.thrift.iface.LectureRead; +import org.openslx.dozmod.gui.window.layout.LectureSettingsWindowLayout; + +public class LectureSettingsWindow extends LectureSettingsWindowLayout { + + private static final long serialVersionUID = -1970717955867180231L; + + public LectureSettingsWindow(Window modalParent, LectureRead lecture) { + super(modalParent); + + taNetworkRules.setEnabled(false); + chkEnableInternet.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + taNetworkRules.setEnabled(!taNetworkRules.isEnabled()); + } + }); + } + /** + * Opens a new LectureSettingsWindow + * + * @param modalParent + */ + public static void open(Window modalParent, LectureRead lecture) { + LectureSettingsWindow win = new LectureSettingsWindow(modalParent, lecture); + win.setVisible(true); + } +} diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/LectureSettingsWindowLayout.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/LectureSettingsWindowLayout.java new file mode 100644 index 00000000..1a90f157 --- /dev/null +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/LectureSettingsWindowLayout.java @@ -0,0 +1,122 @@ +package org.openslx.dozmod.gui.window.layout; + +import java.awt.Insets; +import java.awt.Window; + +import javax.swing.BorderFactory; +import javax.swing.Box; +import javax.swing.BoxLayout; +import javax.swing.JButton; +import javax.swing.JCheckBox; +import javax.swing.JDialog; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTextArea; + +import org.openslx.dozmod.gui.Gui; +import org.openslx.dozmod.gui.control.WordWrapLabel; +import org.openslx.dozmod.gui.helper.GridManager; + +public class LectureSettingsWindowLayout extends JDialog { + + private static final long serialVersionUID = 5565439063675405598L; + + private final static String txtTitle = "Erweiterte Einstellungen"; + private final static String txtGeneralOptionsTitle = "Allgemeine Optionen"; + private final static String txtGeneralOptionsDesc = "Mit dieser Option schalten Sie USB-Geräte für diese Veranstaltung ab."; + private final static String txtNetworkOptionsTitle = "Netzwerk Einstellungen"; + private final static String txtNetworkOptionsDesc = "Hier können Sie Firewall-Regeln festlegen mit folgendem Format (TODO)"; + private final static String txtEnableUsb = "Zugriff auf das USB-Geräte erlauben"; + private final static String txtEnableInternet = "Zugriff auf das Internet beschränken"; + private final static String txtNetworkRulesTitle = "Netzwerk-Regeln"; + private final static String txtRunScriptTitle = "Run-Skript"; + private final static String txtRunScriptDesc = "Ein hier abgelegtes Skript wird beim Start automatisch ausgeführt."; + private final static String txtButtonClose = "Schließen"; + private final static String txtButtonSave = "Speichern"; + + private final JPanel pnlGeneralOptions; + private final JPanel pnlNetworkOptions; + private final JPanel pnlRunScript; + private final JPanel pnlBottomButtons; + protected final JCheckBox chkEnableInternet; + protected final JCheckBox chkEnableUsb; + protected final JTextArea taNetworkRules; + protected final JTextArea taRunScript; + protected final JButton btnSave; + protected final JButton btnClose; + + public LectureSettingsWindowLayout(Window modalParent) { + super(modalParent, txtTitle, modalParent != null ? ModalityType.APPLICATION_MODAL + : ModalityType.MODELESS); + + GridManager grid = new GridManager(this, 1, true, new Insets(5, 5, 5, 5)); + // top panel for general options + pnlGeneralOptions = new JPanel(); + pnlGeneralOptions.setBorder(BorderFactory.createTitledBorder(txtGeneralOptionsTitle)); + GridManager gridGeneralOptions = new GridManager(pnlGeneralOptions, 1); + chkEnableUsb = new JCheckBox(txtEnableUsb); + // TODO moar + gridGeneralOptions.add(chkEnableUsb).fill(true, false).expand(true, false); + gridGeneralOptions.nextRow(); + gridGeneralOptions.add(new WordWrapLabel(txtGeneralOptionsDesc, false, true)).fill(true, false).expand(true, false); + gridGeneralOptions.finish(false); + + + // middle panel for network rules + pnlNetworkOptions = new JPanel(); + GridManager gridNetworkOptions = new GridManager(pnlNetworkOptions, 1, true, new Insets(2, 2, 2, 2)); + pnlNetworkOptions.setBorder(BorderFactory.createTitledBorder(txtNetworkOptionsTitle)); + chkEnableInternet = new JCheckBox(txtEnableInternet); + gridNetworkOptions.add(chkEnableInternet).fill(true, false).expand(true, false); + gridNetworkOptions.nextRow(); + taNetworkRules = new JTextArea("", 5, 20); + taNetworkRules.setLineWrap(true); + taNetworkRules.setWrapStyleWord(true); + JScrollPane scpNetworkRules = new JScrollPane(taNetworkRules, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, + JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); + pnlNetworkOptions.setBorder(BorderFactory.createTitledBorder(txtNetworkRulesTitle)); + gridNetworkOptions.add(new WordWrapLabel(txtNetworkOptionsDesc, false, true)).fill(true, false).expand(true, false); + gridNetworkOptions.nextRow(); + gridNetworkOptions.add(scpNetworkRules).fill(true, true).expand(true, true); + gridNetworkOptions.finish(false); + + // TODO middle panel for run script + pnlRunScript = new JPanel(); + GridManager gridRunScript = new GridManager(pnlRunScript, 1, true, new Insets(2, 2, 2, 2)); + taRunScript = new JTextArea("", 5, 20); + taRunScript.setLineWrap(true); + taRunScript.setWrapStyleWord(true); + JScrollPane scpRunScript = new JScrollPane(taRunScript, + JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, + JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); + pnlRunScript.setBorder(BorderFactory.createTitledBorder(txtRunScriptTitle)); + gridRunScript.add(new WordWrapLabel(txtRunScriptDesc, false, true)).fill(true, false).expand(true, false); + gridRunScript.nextRow(); + gridRunScript.add(scpRunScript).fill(true, true).expand(true, true); + gridRunScript.finish(false); + + // bottom panel for controls + pnlBottomButtons = new JPanel(); + pnlBottomButtons.setLayout(new BoxLayout(pnlBottomButtons, BoxLayout.LINE_AXIS)); + pnlBottomButtons.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); + btnClose = new JButton(txtButtonClose); + btnSave = new JButton(txtButtonSave); + pnlBottomButtons.add(Box.createHorizontalGlue()); + pnlBottomButtons.add(btnClose); + pnlBottomButtons.add(btnSave); + + // build the final grid + grid.add(pnlGeneralOptions).fill(true, false).expand(true, false); + grid.nextRow(); + grid.add(pnlNetworkOptions).fill(true, true).expand(true, true); + grid.nextRow(); + grid.add(pnlRunScript).fill(true, true).expand(true, true); + grid.nextRow(); + grid.add(pnlBottomButtons).fill(true, false).expand(true, false); + grid.finish(false); + + setPreferredSize(Gui.getScaledDimension(700, 600)); + pack(); + Gui.centerShellOverShell(modalParent, this); + } +} -- cgit v1.2.3-55-g7522