summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonathan Bauer2019-04-04 15:39:49 +0200
committerJonathan Bauer2019-04-04 15:39:49 +0200
commit89bfd10b84af304926df839c370ae07abba37edd (patch)
treeb4ed3d5391bd2f725fba425e4efffe766febc95f
parent[client] ldapfilter: disable fields when predef filter is selected (diff)
downloadtutor-module-89bfd10b84af304926df839c370ae07abba37edd.tar.gz
tutor-module-89bfd10b84af304926df839c370ae07abba37edd.tar.xz
tutor-module-89bfd10b84af304926df839c370ae07abba37edd.zip
[client] netshare: fix username/password not disabled when predef share
is selected
-rw-r--r--dozentenmodul/src/main/java/org/openslx/dozmod/gui/configurator/NetshareConfigurator.java29
1 files changed, 18 insertions, 11 deletions
diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/configurator/NetshareConfigurator.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/configurator/NetshareConfigurator.java
index 27d9b5ab..77f2e381 100644
--- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/configurator/NetshareConfigurator.java
+++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/configurator/NetshareConfigurator.java
@@ -53,7 +53,7 @@ public class NetshareConfigurator extends NetshareConfiguratorLayout {
public static final Character EMPTY_MARKER = '-';
public static final String PRINTER_MARKER = "PRINTER";
- // mount points / win drive letters - ideally, we would check whether the image is linux or windows based
+ // mount points / win drive letters - ideally, we would check whether the image is linux- or windows-based
// and either show a drive selection list like this one, or a textfield for a user-defined mount point...
private Character[] mountPoints = { EMPTY_MARKER, 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N',
'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z' };
@@ -64,9 +64,10 @@ public class NetshareConfigurator extends NetshareConfiguratorLayout {
@Override
public void valueChanged(ListSelectionEvent e) {
NetShare item = tblNetshare.getSelectedItem2();
- // only activate form fields if netshare is not predefined
+ // activate form fields when nothing is selected (to add a new one)
+ // or when not predefined by the satellite
boolean editable = (item == null || item.shareId == 0);
- // now disable as needed
+
btnDel.setEnabled(editable);
btnAdd.setEnabled(editable);
tfSharePath.setEnabled(editable);
@@ -77,20 +78,25 @@ public class NetshareConfigurator extends NetshareConfiguratorLayout {
cboNetshareMountPoint.setEnabled(editable);
chkIsPrinter.setEnabled(editable);
chkShowPass.setEnabled(editable);
+ if (editable)
+ btnAdd.setText("Ändern");
+ // clear the contents of the fields and return, if no share was selected.
if (item == null) {
clearInputFields();
return;
}
- // first set the fields to let any listener trigger
+ // some share was selected, fill in the details
tfSharePath.setText(item.path);
+ cboNetshareAuth.setSelectedItem(item.auth);
+ tfUsername.setText(item.username);
+ tfPassword.setText(item.password);
+
if (item.displayname != null)
tfShareName.setText(
String.valueOf(EMPTY_MARKER).equals(item.displayname) ? "" : item.displayname);
- tfUsername.setText(item.username);
- tfPassword.setText(item.password);
- cboNetshareAuth.setSelectedItem(item.auth);
+
if (item.mountpoint != null) {
boolean isPrinter = item.mountpoint.equals(PRINTER_MARKER);
chkIsPrinter.setSelected(isPrinter);
@@ -99,8 +105,6 @@ public class NetshareConfigurator extends NetshareConfiguratorLayout {
: Character.valueOf(item.mountpoint.charAt(0)));
cboNetshareMountPoint.setEnabled(editable && !isPrinter);
}
- if (editable)
- btnAdd.setText("Ändern");
}
});
@@ -120,8 +124,11 @@ public class NetshareConfigurator extends NetshareConfiguratorLayout {
@Override
public void actionPerformed(ActionEvent e) {
NetShareAuth selectedAuth = cboNetshareAuth.getItemAt(cboNetshareAuth.getSelectedIndex());
- boolean activate = selectedAuth != null && selectedAuth == NetShareAuth.OTHER_USER;
- // username field is needed to either special or guest user
+ // check what kind of share is selected
+ NetShare item = tblNetshare.getSelectedItem2();
+ boolean editable = (item == null || item.shareId == 0);
+ // only active if it is editable and a username and a password is required to access the share
+ boolean activate = editable && selectedAuth != null && selectedAuth == NetShareAuth.OTHER_USER;
tfUsername.setEnabled(activate);
tfPassword.setEnabled(activate);
chkShowPass.setEnabled(activate);