summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonathan Bauer2016-03-03 18:01:37 +0100
committerJonathan Bauer2016-03-03 18:01:37 +0100
commitf6a0867f2d8235a9c38c06dc0702c6e948928bcf (patch)
treebcd38a61059097cf559d6f4b8898628285871fce
parent[client] add 10px border to wizard's footer (diff)
downloadtutor-module-f6a0867f2d8235a9c38c06dc0702c6e948928bcf.tar.gz
tutor-module-f6a0867f2d8235a9c38c06dc0702c6e948928bcf.tar.xz
tutor-module-f6a0867f2d8235a9c38c06dc0702c6e948928bcf.zip
[client/server] add support for advanced configuration for usb/netrules stuff
-rw-r--r--dozentenmodul/src/main/java/org/openslx/dozmod/gui/MainWindow.java4
-rw-r--r--dozentenmodul/src/main/java/org/openslx/dozmod/gui/control/AdvancedConfigurator.java351
-rw-r--r--dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/LectureAdvancedSettingsWindow.java98
-rw-r--r--dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/LectureDetailsWindow.java33
-rw-r--r--dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/LectureSettingsWindow.java34
-rw-r--r--dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/LectureAdvancedSettingsWindowLayout.java56
-rw-r--r--dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/LectureDetailsWindowLayout.java18
-rw-r--r--dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/LectureSettingsWindowLayout.java122
-rw-r--r--dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/LectureWizard.java10
-rw-r--r--dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/layout/LectureOptionsPageLayout.java44
-rw-r--r--dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/page/LectureOptionsPage.java32
-rw-r--r--dozentenmodul/src/main/java/org/openslx/dozmod/state/LectureWizardState.java6
-rw-r--r--dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/database/mappers/DbLecture.java15
13 files changed, 636 insertions, 187 deletions
diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/MainWindow.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/MainWindow.java
index 0c90d60b..e8827ed7 100644
--- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/MainWindow.java
+++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/MainWindow.java
@@ -52,6 +52,7 @@ import org.openslx.dozmod.gui.window.ConfigWindow;
import org.openslx.dozmod.gui.window.DisclaimerWindow;
import org.openslx.dozmod.gui.window.ImageListWindow;
import org.openslx.dozmod.gui.window.LectureListWindow;
+import org.openslx.dozmod.gui.window.LectureAdvancedSettingsWindow;
import org.openslx.dozmod.gui.window.LoginWindow;
import org.openslx.dozmod.gui.window.MainMenuWindow;
import org.openslx.dozmod.gui.window.VirtualizerNoticeWindow;
@@ -198,6 +199,9 @@ public abstract class MainWindow {
event.consume();
}
}
+ } else if (code == 4 && type == KeyEvent.KEY_RELEASED) { // Ctrl-D = Open Dev Window // TODO REMOVE THIS
+ LectureAdvancedSettingsWindow.open(mainWindow, null);
+ event.consume();
}
return event.isConsumed();
}
diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/control/AdvancedConfigurator.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/control/AdvancedConfigurator.java
new file mode 100644
index 00000000..df036aa3
--- /dev/null
+++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/control/AdvancedConfigurator.java
@@ -0,0 +1,351 @@
+package org.openslx.dozmod.gui.control;
+
+import java.awt.Color;
+import java.awt.Insets;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.swing.BorderFactory;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.JTextArea;
+import javax.swing.JTextPane;
+import javax.swing.text.BadLocationException;
+import javax.swing.text.MutableAttributeSet;
+import javax.swing.text.SimpleAttributeSet;
+import javax.swing.text.StyleConstants;
+import javax.swing.text.StyledDocument;
+
+import org.apache.log4j.Logger;
+import org.openslx.bwlp.thrift.iface.NetDirection;
+import org.openslx.bwlp.thrift.iface.NetRule;
+import org.openslx.dozmod.gui.Gui;
+import org.openslx.dozmod.gui.helper.GridManager;
+import org.openslx.dozmod.gui.helper.MessageType;
+
+/**
+ * Widget for advanced configuration options for lectures. This handles
+ * following options - Network rules - Runscript - USB
+ */
+public class AdvancedConfigurator extends AdvancedConfiguratorLayout {
+
+ private static final long serialVersionUID = -3497629601818983994L;
+ private final static Logger LOGGER = Logger
+ .getLogger(AdvancedConfigurator.class);
+
+ /**
+ * Character defining how the rules are parsed, e.g. for whitespace \\s
+ * Example: "IN 8.8.8.8 80"
+ */
+ private static final String FIELD_DELIMITER = "\\s";
+
+ public AdvancedConfigurator() {
+ super();
+ }
+
+ public AdvancedConfiguration getState() {
+ List<NetRule> rules = parseNetRules(taNetworkRules.getText());
+ if (rules != null) {
+ return new AdvancedConfiguration(rules, taRunScript.getText());
+ }
+ return null;
+ }
+
+ public void setState(final AdvancedConfiguration config) {
+ // setText() blanks the text area if null is given, so no null checks
+ this.taNetworkRules.setText(decodeNetRulesToText(config.netRulesList));
+ this.taRunScript.setText(config.runScriptText);
+ }
+
+ public boolean isValidState() {
+ // TODO test state validity?
+ List<NetRule> tmp = parseNetRules(taNetworkRules.getText());
+ if (tmp != null)
+ LOGGER.debug("Parsed: " + tmp.toString());
+ else {
+ LOGGER.debug("Parsed null.");
+ }
+ return tmp != null && !tmp.isEmpty();
+ }
+
+ /**
+ * @param netRulesList
+ * list of NetRule to decode
+ * @return String representation of the list of rules
+ */
+ public static String decodeNetRulesToText(final List<NetRule> netRulesList) {
+ if (netRulesList == null || netRulesList.isEmpty())
+ return "";
+
+ String decodedRules = "";
+ Iterator<NetRule> it = netRulesList.iterator();
+ while (it.hasNext()) {
+ String currentLine = "";
+ NetRule currentRule = it.next();
+ // simple test for validity (since this comes from the server it
+ // should be correct anyways)
+ if (currentRule.host.isEmpty() || currentRule.port > 65535) {
+ LOGGER.error("Invalid rule! Ignoring: " + currentRule.host
+ + ":" + currentRule.port);
+ continue;
+ }
+ currentLine += currentRule.host + " ";
+ currentLine += currentRule.port + " ";
+ currentLine += currentRule.direction.name();
+ decodedRules += currentLine + System.lineSeparator();
+ }
+ return decodedRules;
+ }
+
+ /**
+ * @param rawNetRules
+ * the raw text to be parsed
+ * @return list of valid net rules parsed from the given rawNetRules,
+ * invalid ones are not included
+ * @throws Exception
+ * when parsing fails
+ */
+ public List<NetRule> parseNetRules(final String rawNetRules) {
+ if (rawNetRules == null)
+ return null;
+ List<NetRule> rulesList = new ArrayList<NetRule>();
+ if (rawNetRules.isEmpty()) {
+ return rulesList;
+ }
+ // rawNetRules is the text as entered in the textarea
+ // split it line by line
+ final String[] netRules = rawNetRules.split(System.lineSeparator());
+ for (String ruleLine : netRules) {
+ LOGGER.debug("Parsing rule: " + ruleLine);
+ // split the fields and check if we have 3 as expected.
+ String[] fields = ruleLine.split(FIELD_DELIMITER);
+ if (fields.length != 3) {
+ markText(ruleLine, Color.RED);
+ LOGGER.debug("Invalid number of fields! Expected 3, got: "
+ + fields.length);
+ Gui.showMessageBox(
+ "Nicht genug Felder! Nutzen Sie: <host> <port> [in|out]",
+ MessageType.ERROR, LOGGER, null);
+ break;
+ }
+
+ // start to check fields one by one from the last to the first ....
+ // check net direction: accept either 'in' or 'out' (case
+ // insensitive)
+ if (!fields[2].matches("(?i)^(IN|OUT)+$")) {
+ markText(ruleLine, Color.RED);
+ LOGGER.debug("Invalid net direction! Expected (case insensitive) 'IN' or OUT'. Got: "
+ + fields[2]);
+ Gui.showMessageBox(
+ "Ungültige Richtung: nur 'IN' oder 'OUT' erlaubt!",
+ MessageType.ERROR, LOGGER, null);
+ break;
+ }
+
+ // check port: accept if > -2 and < 65535
+ int port = -2;
+ try {
+ port = Integer.parseInt(fields[1]);
+ } catch (NumberFormatException e) {
+ LOGGER.error("Could not parse '" + fields[1] + "' to an int.");
+ }
+ // TODO: port = -1 for all ports?
+ if (port <= -2 && port > 65535) {
+ markText(ruleLine, Color.RED);
+ LOGGER.debug("Invalid port number! Got: " + port);
+ Gui.showMessageBox(
+ "Ungültiges Port! Muss zwischen 0 und 65536 sein.",
+ MessageType.ERROR, LOGGER, null);
+ break;
+ }
+ // check hostname: bit more to do here
+ // for IPs and/or resolvable hostnames we make use of java.net's
+ // InetAddress.getByName() method which checks the validity of
+ // an IP-Address represented by a string or if the given hostname
+ // is resolvable. If any of these happen, we have a valid hostname.
+ // Non-resolvable hostnames are handled differently, see after the
+ // try/catch-block
+ InetAddress ruleHost = null;
+ try {
+ ruleHost = InetAddress.getByName(fields[0]);
+ } catch (UnknownHostException e) {
+ LOGGER.debug("Invalid hostname (java.net): ", e);
+ // might be good to see this exception in the log file
+ }
+ if (ruleHost == null) {
+ // either invalid IP-Address or an invalid resolvable hostname
+ // however it might also be a non-resolvable hostname that would
+ // be
+ // valid in the actual pool-rooms, so lets check its syntax
+ // according to: http://tools.ietf.org/html/rfc1034#section-3.1
+ LOGGER.debug("Invalid host/IP! Got: " + fields[0]);
+ if (checkHostnameSimple(fields[0])) {
+ markText(ruleLine, Color.YELLOW);
+ if (!Gui.showMessageBox(
+ "Konnte '"
+ + fields[0]
+ + "' nicht verifizieren. Wollen Sie es trotzdem verwenden?",
+ MessageType.WARNING_RETRY, LOGGER, null)) {
+ break;
+ } else {
+ // keep it
+ }
+ } else {
+ markText(ruleLine, Color.RED);
+ continue;
+ }
+ } else {
+ markText(ruleLine, Color.GREEN);
+ }
+ // valid, put it in the list
+ rulesList.add(new NetRule(rulesList.size(), NetDirection
+ .valueOf(fields[2].toUpperCase()), fields[0], port));
+ }
+ if (netRules.length == rulesList.size()) {
+ return rulesList;
+ }
+ return null;
+ }
+
+ private boolean checkHostnameSimple(final String hostname) {
+ if (hostname.length() > 254) {
+ LOGGER.debug("Hostname is too long!");
+ Gui.showMessageBox("Hostname ist zu lang!", MessageType.ERROR,
+ LOGGER, null);
+ return false;
+ }
+ for (int i = 0; i < hostname.length(); i++) {
+ Character c = Character.valueOf(hostname.charAt(i));
+ if (!(Character.isDigit(c) || Character.isLetter(c)
+ || c.equals('-') || c.equals('.') || c.equals('/'))) {
+ LOGGER.debug("Invalid character in hostname: '" + c + "'");
+ Gui.showMessageBox("Ungültiges Zeichen '" + c
+ + "' in hostname!", MessageType.ERROR, LOGGER, null);
+ return false;
+ }
+ }
+ return true;
+ }
+
+ // TODO still buggy with text colors: the marking works fine
+ // but when trying to input new text, funny things happen
+ private void markText(final String txt, final Color color) {
+ MutableAttributeSet origSet = taNetworkRules.getInputAttributes();
+ SimpleAttributeSet set = new SimpleAttributeSet();
+ StyleConstants.setForeground(set, color);
+ StyleConstants.setBold(set, color == Color.red);
+ StyledDocument doc = taNetworkRules.getStyledDocument();
+ try {
+ boolean found = false;
+ for (int pos = 0; pos < doc.getLength() - txt.length() + 1; ++pos) {
+ String current = doc.getText(pos, txt.length());
+ if (current.endsWith(System.lineSeparator())) {
+ current = current.substring(0, current.length() - 1);
+ }
+ if (current.equals(txt)) {
+ doc.setCharacterAttributes(pos, txt.length(), set, true);
+ found = true;
+ break;
+ }
+ }
+ if (found) {
+ }
+ } catch (BadLocationException e) {
+ LOGGER.error(
+ "Failed to set '" + txt + "' to color " + color.toString(),
+ e);
+ }
+ taNetworkRules.setCharacterAttributes(origSet, true);
+ taNetworkRules.setStyledDocument(doc);
+ }
+
+ /**
+ * Wrapper class for the advanced configuration information needed since we
+ * need to return a single object from the runAndReturn routine
+ */
+ public static class AdvancedConfiguration {
+ public List<NetRule> netRulesList;
+ public String runScriptText;
+
+ public AdvancedConfiguration(List<NetRule> netRulesList,
+ String runScriptText) {
+ this.netRulesList = netRulesList;
+ this.runScriptText = runScriptText;
+ }
+ }
+}
+
+/**
+ * Internal layout class for the advanced configurator (to keep it clean even
+ * for widgets)
+ */
+class AdvancedConfiguratorLayout extends JPanel {
+
+ private static final long serialVersionUID = 648729071828404053L;
+
+ 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 txtNetworkRulesTitle = "Netzwerk-Regeln";
+ private final static String txtRunScriptTitle = "Run-Skript";
+ private final static String txtRunScriptDesc = "Ein hier abgelegtes Skript wird beim Start einer Windows-VM automatisch ausgeführt.";
+
+ private final JPanel pnlNetworkOptions;
+ private final JPanel pnlRunScript;
+ protected final JTextPane taNetworkRules;
+ protected final JTextArea taRunScript;
+
+ public AdvancedConfiguratorLayout() {
+
+ GridManager grid = new GridManager(this, 1, true,
+ new Insets(5, 5, 5, 5));
+
+ // 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));
+ taNetworkRules = new JTextPane();
+
+ 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);
+
+ // second middle panel for the run script textpane
+ 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);
+
+ // build the final grid
+ grid.add(pnlNetworkOptions).fill(true, true).expand(true, true);
+ grid.nextRow();
+ grid.add(pnlRunScript).fill(true, true).expand(true, true);
+ grid.finish(false);
+
+ }
+}
diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/LectureAdvancedSettingsWindow.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/LectureAdvancedSettingsWindow.java
new file mode 100644
index 00000000..844f464b
--- /dev/null
+++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/LectureAdvancedSettingsWindow.java
@@ -0,0 +1,98 @@
+package org.openslx.dozmod.gui.window;
+
+import java.awt.Window;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+
+import org.apache.log4j.Logger;
+import org.openslx.dozmod.gui.Gui;
+import org.openslx.dozmod.gui.Gui.GuiCallable;
+import org.openslx.dozmod.gui.control.AdvancedConfigurator.AdvancedConfiguration;
+import org.openslx.dozmod.gui.helper.MessageType;
+import org.openslx.dozmod.gui.helper.UiFeedback;
+import org.openslx.dozmod.gui.window.layout.LectureAdvancedSettingsWindowLayout;
+
+public class LectureAdvancedSettingsWindow extends LectureAdvancedSettingsWindowLayout
+ implements UiFeedback {
+
+ private static final long serialVersionUID = -1970717955867180231L;
+ private static final Logger LOGGER = Logger
+ .getLogger(LectureAdvancedSettingsWindow.class);
+ private boolean apply = false;
+ private AdvancedConfiguration newConfig = null;
+ public LectureAdvancedSettingsWindow(Window modalParent,
+ AdvancedConfiguration advConfig) {
+ super(modalParent);
+
+ btnSave.addActionListener(new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ newConfig = ctlAdvancedConfigurator.getState();
+ if (newConfig == null) {
+ return;
+ }
+ apply = true;
+ dispose();
+ }
+ });
+ // listeners for the buttons
+ btnClose.addActionListener(new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ safeClose();
+ }
+ });
+ ctlAdvancedConfigurator.setState(advConfig);
+ }
+
+ /**
+ * @return list of ids of the selected locations. Will be either a new list
+ * if the user clicked apply or the list received from the sat.
+ */
+ public AdvancedConfiguration runAndReturn() {
+ setVisible(true);
+ if (!apply)
+ return null;
+ return newConfig;
+ }
+
+ /**
+ * Static method to open this window with
+ *
+ * @param modalParent
+ * parent to this window
+ * @param locations
+ * locations to preselect in the LocationSelector
+ * @return forwards the return value of the window itself: list of ids of
+ * the selected locations
+ */
+ public static AdvancedConfiguration open(final Window modalParent,
+ final AdvancedConfiguration advConfig) {
+ return Gui.syncExec(new GuiCallable<AdvancedConfiguration>() {
+ @Override
+ public AdvancedConfiguration run() {
+ return new LectureAdvancedSettingsWindow(modalParent, advConfig)
+ .runAndReturn();
+ }
+ });
+ }
+
+ @Override
+ public boolean wantConfirmQuit() {
+ return false;
+ }
+
+ @Override
+ public void escapePressed() {
+ safeClose();
+ }
+ private void safeClose() {
+ if (newConfig != null) {
+ if (Gui.showMessageBox("Änderungen werden verworfen. Wollen Sie wirklich abbrechen?", MessageType.ERROR_RETRY, LOGGER, null)) {
+ dispose();
+ }
+ } else {
+ dispose();
+ }
+ }
+}
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 752c6625..df91e811 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
@@ -36,6 +36,7 @@ import org.openslx.bwlp.thrift.iface.LectureWrite;
import org.openslx.bwlp.thrift.iface.UserInfo;
import org.openslx.dozmod.gui.Gui;
import org.openslx.dozmod.gui.MainWindow;
+import org.openslx.dozmod.gui.control.AdvancedConfigurator.AdvancedConfiguration;
import org.openslx.dozmod.gui.helper.DateTimeHelper;
import org.openslx.dozmod.gui.helper.MessageType;
import org.openslx.dozmod.gui.helper.TextChangeListener;
@@ -112,7 +113,9 @@ public class LectureDetailsWindow extends LectureDetailsWindowLayout implements
private LocationInfo locationInfo = null;
- /**
+ private AdvancedConfiguration currentAdvConf = null;
+
+ /**
* Constructor
*
* @param modalParent parent of this popup window
@@ -173,6 +176,16 @@ public class LectureDetailsWindow extends LectureDetailsWindowLayout implements
cboVersions.setEnabled(!chkAutoUpdate.isSelected());
}
});
+ btnAdvancedOptions.addActionListener(new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ AdvancedConfiguration conf = LectureAdvancedSettingsWindow.open(JOptionPane.getFrameForComponent(me), currentAdvConf);
+ if (conf == null)
+ return;
+ currentAdvConf = conf;
+ reactToChange();
+ }
+ });
btnChangeOwner.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
@@ -260,6 +273,7 @@ public class LectureDetailsWindow extends LectureDetailsWindowLayout implements
chkAutoUpdate.addActionListener(actionListener);
chkIsExam.addActionListener(actionListener);
chkHasInternetAccess.addActionListener(actionListener);
+ chkHasUsbAccess.addActionListener(actionListener);
chkIsActive.addActionListener(actionListener);
dtpStartDate.addActionListener(actionListener);
dtpEndDate.addActionListener(actionListener);
@@ -311,11 +325,15 @@ public class LectureDetailsWindow extends LectureDetailsWindowLayout implements
makeEditable(false);
return;
}
+
if (image == null) {
txtImageName.setText("-");
} else {
txtImageName.setText(image.getImageName());
}
+ // remember original advanced config
+ currentAdvConf = new AdvancedConfiguration(lecture.networkExceptions, lecture.runscript);
+
// remember default permissions
if (lecture.defaultPermissions != null) {
originalDefaultPermissions = new LecturePermissions(lecture.defaultPermissions);
@@ -345,6 +363,7 @@ public class LectureDetailsWindow extends LectureDetailsWindowLayout implements
chkIsActive.setSelected(lecture.isEnabled);
chkHasInternetAccess.setSelected(lecture.hasInternetAccess);
+ chkHasUsbAccess.setSelected(lecture.hasUsbAccess);
chkIsExam.setSelected(lecture.isExam);
chkAutoUpdate.setSelected(lecture.autoUpdate);
cboVersions.setEnabled(!lecture.autoUpdate);
@@ -488,9 +507,12 @@ public class LectureDetailsWindow extends LectureDetailsWindowLayout implements
final LectureWrite metadata = new LectureWrite(txtTitle.getText(), txtDescription.getText(),
lecture.getImageVersionId(), chkAutoUpdate.isSelected(), chkIsActive.isSelected(),
DateTimeHelper.getDateFrom(dtpStartDate, spnStartTime).getTime() / 1000L,
- DateTimeHelper.getDateFrom(dtpEndDate, spnEndTime).getTime() / 1000L, null, null,
- chkIsExam.isSelected(), chkHasInternetAccess.isSelected(),
- lecture.getDefaultPermissions(), locationInfo.locationList, locationInfo.limitToLocations, false); // TODO: Location related
+ DateTimeHelper.getDateFrom(dtpEndDate, spnEndTime).getTime() / 1000L, currentAdvConf.runScriptText, null,
+ chkIsExam.isSelected(), chkHasInternetAccess.isSelected(), // TODO USBACCESS
+ lecture.getDefaultPermissions(), locationInfo.locationList, locationInfo.limitToLocations,
+ // TODO: coming "false" is Location related
+ false, chkHasUsbAccess.isSelected());
+ metadata.setNetworkExceptions(currentAdvConf.netRulesList);
// now trigger the actual action
try {
ThriftManager.getSatClient().updateLecture(Session.getSatelliteToken(),
@@ -620,10 +642,13 @@ public class LectureDetailsWindow extends LectureDetailsWindowLayout implements
|| chkAutoUpdate.isSelected() != lecture.autoUpdate
|| chkIsExam.isSelected() != lecture.isExam
|| chkHasInternetAccess.isSelected() != lecture.hasInternetAccess
+ || chkHasUsbAccess.isSelected() != lecture.hasUsbAccess
|| chkIsActive.isSelected() != lecture.isEnabled
|| !lecture.defaultPermissions.equals(originalDefaultPermissions)
|| (locationInfo != null && lecture.locationIds != null && !lecture.locationIds.equals(locationInfo.locationList))
|| (locationInfo != null && lecture.limitToLocations != locationInfo.limitToLocations)
+ || (currentAdvConf != null && lecture.networkExceptions != null && !lecture.networkExceptions.equals(currentAdvConf.netRulesList))
+ || (currentAdvConf != null && lecture.runscript != null && !lecture.runscript.equals(currentAdvConf.runScriptText))
|| imageLinkChanged;
return changed;
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
deleted file mode 100644
index 8cb3a1ad..00000000
--- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/LectureSettingsWindow.java
+++ /dev/null
@@ -1,34 +0,0 @@
-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/LectureAdvancedSettingsWindowLayout.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/LectureAdvancedSettingsWindowLayout.java
new file mode 100644
index 00000000..a81e390e
--- /dev/null
+++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/LectureAdvancedSettingsWindowLayout.java
@@ -0,0 +1,56 @@
+package org.openslx.dozmod.gui.window.layout;
+
+import java.awt.BorderLayout;
+import java.awt.Window;
+
+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.openslx.dozmod.gui.Gui;
+import org.openslx.dozmod.gui.control.AdvancedConfigurator;
+
+public class LectureAdvancedSettingsWindowLayout extends JDialog {
+
+ private static final long serialVersionUID = 5565439063675405598L;
+
+ private final static String txtTitle = "Erweiterte Einstellungen";
+ private final static String txtButtonClose = "Schließen";
+ private final static String txtButtonSave = "Speichern";
+
+ protected final AdvancedConfigurator ctlAdvancedConfigurator;
+
+ private final JPanel pnlBottomButtons;
+ protected final JButton btnSave;
+ protected final JButton btnClose;
+
+ public LectureAdvancedSettingsWindowLayout(Window modalParent) {
+ super(modalParent, txtTitle, modalParent != null ? ModalityType.APPLICATION_MODAL
+ : ModalityType.MODELESS);
+
+ // the main content widget
+ ctlAdvancedConfigurator = new AdvancedConfigurator();
+
+ // init the layout
+ getContentPane().setLayout(new BorderLayout());
+ getContentPane().add(ctlAdvancedConfigurator, BorderLayout.CENTER);
+
+ // 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);
+ getContentPane().add(pnlBottomButtons, BorderLayout.PAGE_END);
+
+ setPreferredSize(Gui.getScaledDimension(500, 400));
+ pack();
+ Gui.centerShellOverShell(modalParent, this);
+ }
+}
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 b0cf0eb8..0d10d919 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
@@ -17,6 +17,7 @@ import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JDialog;
import javax.swing.JFrame;
+import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JSpinner;
@@ -58,7 +59,9 @@ public abstract class LectureDetailsWindowLayout extends JDialog {
protected final ComboBox<ImageVersionDetails> cboVersions;
protected final JCheckBox chkIsExam;
protected final JCheckBox chkHasInternetAccess;
+ protected final JCheckBox chkHasUsbAccess;
protected final JCheckBox chkIsActive;
+ protected final JButton btnAdvancedOptions;
protected final JTextField txtId;
protected final QLabel lblUseCount;
@@ -91,7 +94,7 @@ public abstract class LectureDetailsWindowLayout extends JDialog {
setResizable(true);
setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
setLayout(new BorderLayout());
-
+ ((JPanel)getContentPane()).setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
// use panel to put every info related widget in it
// then we will set the panel in BorderLayout.CENTER
JPanel infoPanel = new JPanel();
@@ -210,9 +213,11 @@ public abstract class LectureDetailsWindowLayout extends JDialog {
grid.nextRow();
// is exam
- chkIsExam = new JCheckBox("Klausur");
- grid.skip();
- grid.add(chkIsExam, 2);
+ chkIsExam = new JCheckBox("Klausurmodus aktiv");
+ grid.add(new JLabel("Beschränkungen"));
+ grid.add(chkIsExam);
+ btnAdvancedOptions = new JButton("Einstellungen");
+ grid.add(btnAdvancedOptions);
grid.nextRow();
chkHasInternetAccess = new JCheckBox("Internetzugriff");
@@ -220,6 +225,11 @@ public abstract class LectureDetailsWindowLayout extends JDialog {
grid.add(chkHasInternetAccess, 2);
grid.nextRow();
+ chkHasUsbAccess = new JCheckBox("USB-Zugriff");
+ grid.skip();
+ grid.add(chkHasUsbAccess, 2);
+ grid.nextRow();
+
chkIsActive = new JCheckBox("Aktiv");
grid.skip();
grid.add(chkIsActive, 2);
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
deleted file mode 100644
index 1a90f157..00000000
--- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/LectureSettingsWindowLayout.java
+++ /dev/null
@@ -1,122 +0,0 @@
-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);
- }
-}
diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/LectureWizard.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/LectureWizard.java
index 6d88cb90..577cd16e 100644
--- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/LectureWizard.java
+++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/LectureWizard.java
@@ -15,8 +15,8 @@ import org.openslx.dozmod.gui.window.LectureListWindow;
import org.openslx.dozmod.gui.wizard.page.LectureCreationPage;
import org.openslx.dozmod.gui.wizard.page.LectureCustomPermissionPage;
import org.openslx.dozmod.gui.wizard.page.LectureImageListPage;
-import org.openslx.dozmod.gui.wizard.page.LectureOptionsPage;
import org.openslx.dozmod.gui.wizard.page.LectureLocationSelectionPage;
+import org.openslx.dozmod.gui.wizard.page.LectureOptionsPage;
import org.openslx.dozmod.state.LectureWizardState;
import org.openslx.dozmod.thrift.Session;
import org.openslx.dozmod.thrift.ThriftActions;
@@ -137,8 +137,10 @@ public class LectureWizard extends Wizard implements UiFeedback {
}
private LectureWrite lectureWriteFromState() {
- return new LectureWrite(state.name, state.description, state.imageVersionId, state.autoUpdate,
- state.isEnabled, state.start.getTime() / 1000L, state.end.getTime() / 1000L, null, null,
- state.isExam, state.internetAccess, state.defaultPermissions, state.locations, state.onlyInSelectedLocations, false);
+ LectureWrite lw = new LectureWrite(state.name, state.description, state.imageVersionId, state.autoUpdate,
+ state.isEnabled, state.start.getTime() / 1000L, state.end.getTime() / 1000L, state.runScriptText, null,
+ state.isExam, state.internetAccess, state.defaultPermissions, state.locations, state.onlyInSelectedLocations, false, state.usbAllowed);
+ lw.networkExceptions = state.netRules;
+ return lw;
}
}
diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/layout/LectureOptionsPageLayout.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/layout/LectureOptionsPageLayout.java
index ac29393c..6dc9e85c 100644
--- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/layout/LectureOptionsPageLayout.java
+++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/layout/LectureOptionsPageLayout.java
@@ -1,6 +1,10 @@
package org.openslx.dozmod.gui.wizard.layout;
+import javax.swing.Box;
+import javax.swing.BoxLayout;
+import javax.swing.JButton;
import javax.swing.JCheckBox;
+import javax.swing.JLabel;
import org.openslx.dozmod.gui.helper.GridManager;
import org.openslx.dozmod.gui.wizard.Wizard;
@@ -11,10 +15,12 @@ public abstract class LectureOptionsPageLayout extends WizardPage {
protected static String title = "Zusätzliche Optionen";
+ protected final JCheckBox chkUsbEnabled;
protected final JCheckBox chkInternetEnabled;
protected final JCheckBox chkIsExam;
protected final JCheckBox chkAutoUpdate;
protected final JCheckBox chkIsActive;
+ protected final JButton btnAdvanced;
/**
* Page for additional options of lecture
@@ -22,26 +28,48 @@ public abstract class LectureOptionsPageLayout extends WizardPage {
public LectureOptionsPageLayout(Wizard wizard) {
super(wizard, title);
setDescription("Bitte wählen Sie aus folgenden Optionen aus:");
- GridManager grid = new GridManager(this, 1);
+ GridManager grid = new GridManager(this, 2);
- // Options related to exams
- chkIsExam = new JCheckBox("Veranstaltung ist eine Prüfung");
+ // first column for labels hopefully clearing up some of the mess...
+ // first category for general options
+ JLabel lblGeneral = new JLabel("Allgemeines");
+ grid.add(lblGeneral);
+ chkAutoUpdate = new JCheckBox("Immer auf aktuellste VM-Version updaten", true);
+ grid.add(chkAutoUpdate);
+ grid.nextRow();
+
+ chkIsActive = new JCheckBox("Veranstaltung ist aktiv", true);
+ grid.skip();
+ grid.add(chkIsActive);
+ grid.nextRow();
+
+ chkIsExam = new JCheckBox("Veranstaltung ist eine Prüfung", false);
+ grid.skip();
grid.add(chkIsExam);
grid.nextRow();
+ grid.add(Box.createVerticalStrut(10), 2);
+ grid.nextRow();
+ // second category for restrictions options
+ JLabel lblRestriction = new JLabel("Beschränkungen");
+ grid.add(lblRestriction);
+
chkInternetEnabled = new JCheckBox("Internet verfügbar", true);
grid.add(chkInternetEnabled);
grid.nextRow();
- chkAutoUpdate = new JCheckBox("Immer auf aktuellste VM-Version updaten", true);
- grid.add(chkAutoUpdate);
+ chkUsbEnabled = new JCheckBox("USB-Geräte zulassen", true);
+ grid.skip();
+ grid.add(chkUsbEnabled);
grid.nextRow();
- chkIsActive = new JCheckBox("Vorlesung ist aktiv", true);
- grid.add(chkIsActive);
+ btnAdvanced = new JButton("Erweiterte Einstellung");
+ grid.add(Box.createVerticalStrut(10), 2);
+ grid.nextRow();
+ grid.skip();
+ grid.add(btnAdvanced);
grid.nextRow();
grid.finish(true);
-
}
}
diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/page/LectureOptionsPage.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/page/LectureOptionsPage.java
index 7a3f1f6e..38522954 100644
--- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/page/LectureOptionsPage.java
+++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/page/LectureOptionsPage.java
@@ -1,6 +1,13 @@
package org.openslx.dozmod.gui.wizard.page;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+
+import javax.swing.SwingUtilities;
+
import org.apache.log4j.Logger;
+import org.openslx.dozmod.gui.control.AdvancedConfigurator.AdvancedConfiguration;
+import org.openslx.dozmod.gui.window.LectureAdvancedSettingsWindow;
import org.openslx.dozmod.gui.wizard.Wizard;
import org.openslx.dozmod.gui.wizard.layout.LectureOptionsPageLayout;
import org.openslx.dozmod.state.LectureWizardState;
@@ -8,19 +15,31 @@ import org.openslx.dozmod.state.LectureWizardState;
@SuppressWarnings("serial")
public class LectureOptionsPage extends LectureOptionsPageLayout {
- private final static Logger LOGGER = Logger.getLogger(LectureOptionsPage.class);
-
+ private LectureOptionsPage me = this;
private LectureWizardState state = null;
+ private AdvancedConfiguration currentConf = new AdvancedConfiguration(null, null);
/**
* Page for lecture options
*/
- public LectureOptionsPage(Wizard wizard, LectureWizardState state) {
+ public LectureOptionsPage(final Wizard wizard, LectureWizardState state) {
super(wizard);
this.state = state;
- setPageComplete(true);
+ this.currentConf = new AdvancedConfiguration(state.netRules, state.runScriptText);
- //TODO Temporarily disabled until implemented
+ setPageComplete(true);
+ btnAdvanced.addActionListener(new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ AdvancedConfiguration newConf = LectureAdvancedSettingsWindow.open(
+ SwingUtilities.getWindowAncestor(me), currentConf);
+ if (newConf != null) {
+ currentConf = newConf;
+ updateState();
+ }
+ }
+ });
+ // TODO Temporarily disabled until implemented
chkIsExam.setEnabled(false);
chkInternetEnabled.setEnabled(false);
}
@@ -38,6 +57,9 @@ public class LectureOptionsPage extends LectureOptionsPageLayout {
state.autoUpdate = chkAutoUpdate.isSelected();
state.internetAccess = chkInternetEnabled.isSelected();
state.isEnabled = chkIsActive.isSelected();
+ state.usbAllowed = chkUsbEnabled.isSelected();
+ state.netRules = currentConf.netRulesList;
+ state.runScriptText = currentConf.runScriptText;
setDescription("Klicken Sie auf 'Weiter' für Berechtigungen oder 'Fertigstellen'.");
return true;
diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/state/LectureWizardState.java b/dozentenmodul/src/main/java/org/openslx/dozmod/state/LectureWizardState.java
index c836a96b..2d2b9081 100644
--- a/dozentenmodul/src/main/java/org/openslx/dozmod/state/LectureWizardState.java
+++ b/dozentenmodul/src/main/java/org/openslx/dozmod/state/LectureWizardState.java
@@ -7,6 +7,7 @@ import java.util.Map;
import org.openslx.bwlp.thrift.iface.ImageSummaryRead;
import org.openslx.bwlp.thrift.iface.LecturePermissions;
import org.openslx.bwlp.thrift.iface.Location;
+import org.openslx.bwlp.thrift.iface.NetRule;
import org.openslx.dozmod.thrift.Session;
public class LectureWizardState {
@@ -28,6 +29,11 @@ public class LectureWizardState {
// list of locations for the lecture
public List<Integer> locations = null;
public boolean onlyInSelectedLocations = false;
+ // enable usb flag
+ public boolean usbAllowed = true;
+ // list of network rules
+ public List<NetRule> netRules = null;
+ public String runScriptText = null;
// -- thrift internal stuff --
public String uuid = null;
}
diff --git a/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/database/mappers/DbLecture.java b/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/database/mappers/DbLecture.java
index 2cc4ff48..c0ce648a 100644
--- a/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/database/mappers/DbLecture.java
+++ b/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/database/mappers/DbLecture.java
@@ -73,6 +73,7 @@ public class DbLecture {
stmt.setString("netrules", netruleJson);
stmt.setBoolean("isexam", lecture.isExam);
stmt.setBoolean("hasinternetaccess", lecture.hasInternetAccess);
+ stmt.setBoolean("hasusbaccess", lecture.hasUsbAccess);
stmt.setBoolean("caneditdefault", lecture.defaultPermissions.edit);
stmt.setBoolean("canadmindefault", lecture.defaultPermissions.admin);
}
@@ -100,13 +101,13 @@ public class DbLecture {
+ " isenabled, starttime, endtime, createtime, updatetime,"
+ " isprivate, islocationprivate,"
+ " ownerid, updaterid, runscript, nics, netrules, isexam,"
- + " hasinternetaccess, caneditdefault, canadmindefault)"
+ + " hasinternetaccess, hasusbaccess, caneditdefault, canadmindefault)"
+ " VALUES "
+ " (:lectureid, :displayname, :description, :imageversionid, :autoupdate,"
+ " :isenabled, :starttime, :endtime, UNIX_TIMESTAMP(), UNIX_TIMESTAMP(),"
+ " :isprivate, :islocationprivate,"
+ " :ownerid, :updaterid, :runscript, :nics, :netrules, :isexam,"
- + " :hasinternetaccess, :caneditdefault, :canadmindefault)");
+ + " :hasinternetaccess, :hasusbaccess, :caneditdefault, :canadmindefault)");
String lectureId = UUID.randomUUID().toString();
setWriteFields(stmt, lectureId, lecture, user);
stmt.setString("ownerid", user.userId);
@@ -128,7 +129,7 @@ public class DbLecture {
+ " endtime = :endtime, updatetime = UNIX_TIMESTAMP(),"
+ " isprivate = :isprivate, islocationprivate = :islocationprivate,"
+ " updaterid = :updaterid, runscript = :runscript, nics = :nics,"
- + " netrules = :netrules, isexam = :isexam, hasinternetaccess = :hasinternetaccess,"
+ + " netrules = :netrules, isexam = :isexam, hasinternetaccess = :hasinternetaccess, hasusbaccess = :hasusbaccess,"
+ " caneditdefault = :caneditdefault, canadmindefault = :canadmindefault"
+ " WHERE lectureid = :lectureid");
setWriteFields(stmt, lectureId, lecture, user);
@@ -177,6 +178,7 @@ public class DbLecture {
lecture.setUpdaterId(rs.getString("updaterid"));
lecture.setIsExam(rs.getBoolean("isexam"));
lecture.setHasInternetAccess(rs.getBoolean("hasinternetaccess"));
+ lecture.setHasUsbAccess(rs.getBoolean("hasusbaccess"));
lecture.setDefaultPermissions(DbLecturePermissions.fromResultSetDefault(rs));
lecture.setUserPermissions(DbLecturePermissions.fromResultSetUser(rs));
lecture.setIsImageVersionUsable(rs.getBoolean("imgvalid"));
@@ -189,7 +191,7 @@ public class DbLecture {
private static final String summaryBaseSql = "SELECT"
+ " l.lectureid, l.displayname AS lecturename, l.imageversionid, i.imagebaseid,"
+ " l.isenabled, l.starttime, l.endtime, l.lastused, l.usecount, l.ownerid, l.updaterid,"
- + " l.isexam, l.hasinternetaccess, l.caneditdefault, l.canadmindefault,"
+ + " l.isexam, l.hasinternetaccess, l.hasusbaccess, l.caneditdefault, l.canadmindefault,"
+ " i.isvalid AS imgvalid, perm.canedit, perm.canadmin"
+ " FROM lecture l "
+ " LEFT JOIN imageversion i USING (imageversionid)"
@@ -264,8 +266,8 @@ public class DbLecture {
+ " l.lectureid, l.displayname AS lecturename, l.description, l.imageversionid, i.imagebaseid,"
+ " l.autoupdate, l.isenabled, l.starttime, l.endtime, l.lastused, l.usecount, l.createtime,"
+ " l.updatetime, l.ownerid, l.updaterid, l.runscript, l.nics, l.netrules, l.isexam,"
- + " l.isprivate, l.islocationprivate,"
- + " l.hasinternetaccess, l.caneditdefault, l.canadmindefault, p.canedit, p.canadmin"
+ + " l.isprivate, l.islocationprivate, l.hasinternetaccess, l.hasusbaccess,"
+ + " l.caneditdefault, l.canadmindefault, p.canedit, p.canadmin"
+ " FROM lecture l "
+ " LEFT JOIN imageversion i USING (imageversionid)"
+ " LEFT JOIN lecturepermission p ON (l.lectureid = p.lectureid AND p.userid = :userid)"
@@ -308,6 +310,7 @@ public class DbLecture {
}
lecture.setIsExam(rs.getBoolean("isexam"));
lecture.setHasInternetAccess(rs.getBoolean("hasinternetaccess"));
+ lecture.setHasUsbAccess(rs.getBoolean("hasusbaccess"));
lecture.setAllowedUsers(getAllowedUsers(connection, lectureId));
lecture.setDefaultPermissions(DbLecturePermissions.fromResultSetDefault(rs));
lecture.setUserPermissions(DbLecturePermissions.fromResultSetUser(rs));