SEBSERV-206 fixed by using a list of inverted checkbox SEB settings
This commit is contained in:
parent
191f8432de
commit
6162027400
3 changed files with 41 additions and 10 deletions
|
@ -114,23 +114,38 @@ public class CheckBoxBuilder implements InputFieldBuilder {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void setValueToControl(final String value) {
|
protected void setValueToControl(final String value) {
|
||||||
|
if (ViewContext.INVERTED_CHECKBOX_SETTINGS.contains(this.attribute.name)) {
|
||||||
|
this.control.setSelection(!Boolean.parseBoolean(this.initValue));
|
||||||
|
} else {
|
||||||
this.control.setSelection(Boolean.parseBoolean(this.initValue));
|
this.control.setSelection(Boolean.parseBoolean(this.initValue));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getValue() {
|
public String getValue() {
|
||||||
|
if (ViewContext.INVERTED_CHECKBOX_SETTINGS.contains(this.attribute.name)) {
|
||||||
|
return this.control.getSelection()
|
||||||
|
? Constants.FALSE_STRING
|
||||||
|
: Constants.TRUE_STRING;
|
||||||
|
} else {
|
||||||
return this.control.getSelection()
|
return this.control.getSelection()
|
||||||
? Constants.TRUE_STRING
|
? Constants.TRUE_STRING
|
||||||
: Constants.FALSE_STRING;
|
: Constants.FALSE_STRING;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getReadableValue() {
|
public String getReadableValue() {
|
||||||
|
if (ViewContext.INVERTED_CHECKBOX_SETTINGS.contains(this.attribute.name)) {
|
||||||
|
return this.control.getSelection()
|
||||||
|
? "Inactive"
|
||||||
|
: "Active";
|
||||||
|
} else {
|
||||||
return this.control.getSelection()
|
return this.control.getSelection()
|
||||||
? "Active"
|
? "Active"
|
||||||
: "Inactive";
|
: "Inactive";
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,10 +8,13 @@
|
||||||
|
|
||||||
package ch.ethz.seb.sebserver.gui.service.examconfig.impl;
|
package ch.ethz.seb.sebserver.gui.service.examconfig.impl;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
@ -30,6 +33,10 @@ public final class ViewContext {
|
||||||
|
|
||||||
private static final Logger log = LoggerFactory.getLogger(ViewContext.class);
|
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 Configuration configuration;
|
||||||
private final View view;
|
private final View view;
|
||||||
private final Function<String, ViewContext> viewContextSupplier;
|
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) {
|
public void setValue(final String name, final String value) {
|
||||||
try {
|
try {
|
||||||
final ConfigurationAttribute attributeByName = getAttributeByName(name);
|
final ConfigurationAttribute attributeByName = getAttributeByName(name);
|
||||||
|
@ -289,7 +306,6 @@ public final class ViewContext {
|
||||||
} catch (final Exception e) {
|
} catch (final Exception e) {
|
||||||
log.error("Failed to set attribute value: {} : {}, cause {}", name, value, e.getMessage());
|
log.error("Failed to set attribute value: {} : {}, cause {}", name, value, e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void setValuesToInputFields(final Collection<ConfigurationValue> values) {
|
void setValuesToInputFields(final Collection<ConfigurationValue> values) {
|
||||||
|
|
|
@ -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=Custom
|
||||||
sebserver.examconfig.props.label.browserUserAgentMac.1.tooltip=Zoom only text on web pages using Ctrl-Mousewheel (Win)
|
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.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
|
sebserver.examconfig.props.label.browserWindowTitleSuffix=Suffix to be added to every browser window
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue