SEBSERV-206 fixed by using a list of inverted checkbox SEB settings

This commit is contained in:
anhefti 2022-04-13 16:07:57 +02:00
parent 191f8432de
commit 6162027400
3 changed files with 41 additions and 10 deletions

View file

@ -114,23 +114,38 @@ public class CheckBoxBuilder implements InputFieldBuilder {
@Override
protected void setValueToControl(final String value) {
this.control.setSelection(Boolean.parseBoolean(this.initValue));
if (ViewContext.INVERTED_CHECKBOX_SETTINGS.contains(this.attribute.name)) {
this.control.setSelection(!Boolean.parseBoolean(this.initValue));
} else {
this.control.setSelection(Boolean.parseBoolean(this.initValue));
}
}
@Override
public String getValue() {
return this.control.getSelection()
? Constants.TRUE_STRING
: Constants.FALSE_STRING;
if (ViewContext.INVERTED_CHECKBOX_SETTINGS.contains(this.attribute.name)) {
return this.control.getSelection()
? Constants.FALSE_STRING
: Constants.TRUE_STRING;
} else {
return this.control.getSelection()
? Constants.TRUE_STRING
: Constants.FALSE_STRING;
}
}
@Override
public String getReadableValue() {
return this.control.getSelection()
? "Active"
: "Inactive";
if (ViewContext.INVERTED_CHECKBOX_SETTINGS.contains(this.attribute.name)) {
return this.control.getSelection()
? "Inactive"
: "Active";
} else {
return this.control.getSelection()
? "Active"
: "Inactive";
}
}
}
}

View file

@ -8,10 +8,13 @@
package ch.ethz.seb.sebserver.gui.service.examconfig.impl;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.function.Function;
import org.slf4j.Logger;
@ -30,6 +33,10 @@ public final class ViewContext {
private static final Logger log = LoggerFactory.getLogger(ViewContext.class);
/** Defines a list of checkbox fields that are inverted on the display of SEB settings */
public static final Set<String> INVERTED_CHECKBOX_SETTINGS = new HashSet<>(Arrays.asList(
"enableSebBrowser"));
private final Configuration configuration;
private final View view;
private final Function<String, ViewContext> viewContextSupplier;
@ -274,6 +281,16 @@ public final class ViewContext {
}
}
public void putValue(final String name, final String value) {
try {
final ConfigurationAttribute attributeByName = getAttributeByName(name);
final InputField inputField = this.inputFieldMapping.get(attributeByName.id);
inputField.initValue(value, 0);
} catch (final Exception e) {
log.error("Failed to put attribute value: {} : {}, cause {}", name, value, e.getMessage());
}
}
public void setValue(final String name, final String value) {
try {
final ConfigurationAttribute attributeByName = getAttributeByName(name);
@ -289,7 +306,6 @@ public final class ViewContext {
} catch (final Exception e) {
log.error("Failed to set attribute value: {} : {}, cause {}", name, value, e.getMessage());
}
}
void setValuesToInputFields(final Collection<ConfigurationValue> values) {

View file

@ -1102,7 +1102,7 @@ sebserver.examconfig.props.label.browserUserAgentMac.0=Default (depends on insta
sebserver.examconfig.props.label.browserUserAgentMac.1=Custom
sebserver.examconfig.props.label.browserUserAgentMac.1.tooltip=Zoom only text on web pages using Ctrl-Mousewheel (Win)
sebserver.examconfig.props.label.enableSebBrowser=Enable SEB with browser window
sebserver.examconfig.props.label.enableSebBrowser=Use SEB without browser window
sebserver.examconfig.props.label.enableSebBrowser.tooltip=Disable this to start another application in kiosk mode<br/>(for example a virtual desktop infrastructure client)
sebserver.examconfig.props.label.browserWindowTitleSuffix=Suffix to be added to every browser window