diff options
author | Jonathan Bauer | 2017-09-06 13:48:33 +0200 |
---|---|---|
committer | Jonathan Bauer | 2017-09-06 13:48:33 +0200 |
commit | e310fa0738149f20b9de6b173d3d175857b0c748 (patch) | |
tree | 5857811d25cc53c51590cc0158ec84e049a3ed88 /dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/LectureDetailsWindow.java | |
parent | [client] Update apache httpclient, pass custom client to ecp-client-lean (diff) | |
download | tutor-module-e310fa0738149f20b9de6b173d3d175857b0c748.tar.gz tutor-module-e310fa0738149f20b9de6b173d3d175857b0c748.tar.xz tutor-module-e310fa0738149f20b9de6b173d3d175857b0c748.zip |
[client/server] network share feature [WIP]
Diffstat (limited to 'dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/LectureDetailsWindow.java')
-rw-r--r-- | dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/LectureDetailsWindow.java | 53 |
1 files changed, 40 insertions, 13 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 index 2918428f..be65ad04 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 @@ -37,6 +37,7 @@ import org.openslx.bwlp.thrift.iface.LecturePermissions; import org.openslx.bwlp.thrift.iface.LectureRead; import org.openslx.bwlp.thrift.iface.LectureWrite; import org.openslx.bwlp.thrift.iface.NetRule; +import org.openslx.bwlp.thrift.iface.NetShare; import org.openslx.bwlp.thrift.iface.UserInfo; import org.openslx.dozmod.gui.Gui; import org.openslx.dozmod.gui.MainWindow; @@ -44,6 +45,8 @@ import org.openslx.dozmod.gui.control.JCheckBoxTree.CheckChangeEvent; import org.openslx.dozmod.gui.control.JCheckBoxTree.CheckChangeEventListener; import org.openslx.dozmod.gui.control.LectureCustomPermissionManager.UserChangeEvent; import org.openslx.dozmod.gui.control.LectureCustomPermissionManager.UserChangeEventListener; +import org.openslx.dozmod.gui.control.NetshareConfigurator.NetshareConfigurationChangeEvent; +import org.openslx.dozmod.gui.control.NetshareConfigurator.NetshareConfigurationChangeEventListener; import org.openslx.dozmod.gui.control.RunscriptConfigurator.RunscriptConfigurationChangeEvent; import org.openslx.dozmod.gui.control.RunscriptConfigurator.RunscriptConfigurationChangeEventListener; import org.openslx.dozmod.gui.helper.DateTimeHelper; @@ -140,6 +143,8 @@ public class LectureDetailsWindow extends LectureDetailsWindowLayout implements private List<NetRule> originalNetrules = null; private String currentRunscript = null; private String originalRunscript = null; + private List<NetShare> currentNetshares = null; + private List<NetShare> originalNetshares = null; /** * Constructor @@ -287,6 +292,12 @@ public class LectureDetailsWindow extends LectureDetailsWindowLayout implements } }); + ctlNetshareConfigurator.addNetshareConfigurationChangeEventListener(new NetshareConfigurationChangeEventListener() { + @Override + public void stateChanged(NetshareConfigurationChangeEvent event) { + reactToChange(); + } + }); // Comboboxes final ItemListener comboItemListener = new ItemListener() { @Override @@ -381,12 +392,16 @@ public class LectureDetailsWindow extends LectureDetailsWindowLayout implements txtImageName.setText(image.getImageName()); lblImageNameInfo.setText(image.getImageName()); } + // remember original netrules and runscript originalNetrules = lecture.networkExceptions != null ? lecture.networkExceptions : new ArrayList<NetRule>(); originalRunscript = lecture.runscript != null ? lecture.runscript : new String(""); + originalNetshares = lecture.networkShares != null ? new ArrayList<NetShare>(lecture.networkShares) : new ArrayList<NetShare>(); currentNetrules = originalNetrules; currentRunscript = originalRunscript; + currentNetshares = originalNetshares; + // remember default permissions if (lecture.defaultPermissions != null) { @@ -415,7 +430,8 @@ public class LectureDetailsWindow extends LectureDetailsWindowLayout implements // init advanced info ctlRunscriptConfigurator.setState(lecture.runscript); - + ctlNetshareConfigurator.setState(lecture.networkShares); + txtTitle.setText(lecture.getLectureName()); lblTitleInfo.setText(lecture.getLectureName()); txtDescription.setText(lecture.getDescription()); @@ -602,17 +618,29 @@ public class LectureDetailsWindow extends LectureDetailsWindowLayout implements Date start = DateTimeHelper.getDateFrom(dtpStartDate, spnStartTime); Date end = DateTimeHelper.getDateFrom(dtpEndDate, spnEndTime); if (!isPeriodValid(start, end, false) && dateHasChanged()) { + pnlTabs.setSelectedIndex(pnlTabs.indexOfTab("Allgemein")); lblError.setText("Ungültiger Zeitraum!"); return false; } // runscript stuff String newState = ctlRunscriptConfigurator.getState(); if (newState == null) { - // marker for error, switch to tab + // script extension was missing from the user input. + // feedback happens in the configurator, just switch to the tab. + pnlTabs.setSelectedIndex(pnlTabs.indexOfTab("Startskript")); return false; } else { currentRunscript = newState; } + + // netshare stuff + List<NetShare> newNetshareList = ctlNetshareConfigurator.getState(); + if (newNetshareList == null) { + // the network share list was never queried if this returns null + return false; + } else { + currentNetshares = newNetshareList; + } // done with mandatory checks, remove error message lblError.setText(null); @@ -632,8 +660,8 @@ public class LectureDetailsWindow extends LectureDetailsWindowLayout implements || (locationInfo != null && lecture.limitToLocations != locationInfo.limitToLocations) || (currentNetrules != null && !currentNetrules.equals(originalNetrules)) || (currentRunscript != null && !currentRunscript.equals(originalRunscript)) + || (currentNetshares != null && !currentNetshares.equals(originalNetshares)) || imageLinkChanged; - return changed; } @@ -661,16 +689,10 @@ public class LectureDetailsWindow extends LectureDetailsWindowLayout implements lecture.imageVersionId = chkAutoUpdate.isSelected() ? image.latestVersionId : cboVersions.getItemAt(cboVersions.getSelectedIndex()).versionId; } - // goto to advanced tab and check (by getting) the state of the textAreas - currentRunscript = ctlRunscriptConfigurator.getState(); - if (currentRunscript == null) { - // getState() will return null only if it couldn't parse the rules - // which means that the user got informed about what was invalid - // So we just return here until the parsing works. - pnlTabs.setSelectedIndex(pnlTabs.indexOfTab("Startskript")); - return false; - } - metadataChanged |= (currentNetrules != lecture.networkExceptions || currentRunscript != lecture.runscript); + + metadataChanged |= (currentNetrules != lecture.networkExceptions + || currentRunscript != lecture.runscript + || currentNetshares != lecture.networkShares); // now check if we need to push a new LectureWrite if (metadataChanged) { // first build the LectureWrite from the GUI fields @@ -683,6 +705,8 @@ public class LectureDetailsWindow extends LectureDetailsWindowLayout implements // TODO: coming "false" is Location related false, chkHasUsbAccess.isSelected()); metadata.setNetworkExceptions(currentNetrules); + metadata.setNetworkShares(currentNetshares); + // now trigger the actual action try { ThriftManager.getSatClient().updateLecture(Session.getSatelliteToken(), @@ -770,6 +794,9 @@ public class LectureDetailsWindow extends LectureDetailsWindowLayout implements if (pnlTabs.indexOfTab("Startskript") != -1) { pnlTabs.setEnabledAt(pnlTabs.indexOfTab("Startskript"), editable); } + if (pnlTabs.indexOfTab("Netwerk-Shares") != -1) { + pnlTabs.setEnabledAt(pnlTabs.indexOfTab("Netzwerk-Shares"), true); + } btnChangeOwner.setEnabled(LecturePerms.canAdmin(lecture)); btnDownloadImage.setEnabled(ImagePerms.canDownload(image)); } |