From 6162027400a41e021cc81641fd380acbdefcaf83 Mon Sep 17 00:00:00 2001 From: anhefti Date: Wed, 13 Apr 2022 16:07:57 +0200 Subject: [PATCH] SEBSERV-206 fixed by using a list of inverted checkbox SEB settings --- .../examconfig/impl/CheckBoxBuilder.java | 31 ++++++++++++++----- .../service/examconfig/impl/ViewContext.java | 18 ++++++++++- src/main/resources/messages.properties | 2 +- 3 files changed, 41 insertions(+), 10 deletions(-) diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/service/examconfig/impl/CheckBoxBuilder.java b/src/main/java/ch/ethz/seb/sebserver/gui/service/examconfig/impl/CheckBoxBuilder.java index ea99ea8f..eec1bed8 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/service/examconfig/impl/CheckBoxBuilder.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/service/examconfig/impl/CheckBoxBuilder.java @@ -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"; + } } - } } diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/service/examconfig/impl/ViewContext.java b/src/main/java/ch/ethz/seb/sebserver/gui/service/examconfig/impl/ViewContext.java index dd34d845..29681987 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/service/examconfig/impl/ViewContext.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/service/examconfig/impl/ViewContext.java @@ -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 INVERTED_CHECKBOX_SETTINGS = new HashSet<>(Arrays.asList( + "enableSebBrowser")); + private final Configuration configuration; private final View view; private final Function 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 values) { diff --git a/src/main/resources/messages.properties b/src/main/resources/messages.properties index de96347f..f0a449a6 100644 --- a/src/main/resources/messages.properties +++ b/src/main/resources/messages.properties @@ -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
(for example a virtual desktop infrastructure client) sebserver.examconfig.props.label.browserWindowTitleSuffix=Suffix to be added to every browser window