diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/service/examconfig/InputField.java b/src/main/java/ch/ethz/seb/sebserver/gui/service/examconfig/InputField.java index cd347e54..3c0c7705 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/service/examconfig/InputField.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/service/examconfig/InputField.java @@ -42,7 +42,7 @@ public interface InputField { void initValue(final String value, final Integer listIndex); /** Get the current field value. - * + * * @return the current field value. */ String getValue(); @@ -53,7 +53,7 @@ public interface InputField { /** Use this to show an error message below the input field. * This is only possible if the concrete input field has an error label, otherwise ignored - * + * * @param errorMessage the error message to display below the input field */ void showError(String errorMessage); 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 6003c362..20e1fabf 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 @@ -223,6 +223,24 @@ public final class ViewContext { inputField); } + public void setValue(final String name, final String value) { + try { + final ConfigurationAttribute attributeByName = getAttributeByName(name); + final InputField inputField = this.inputFieldMapping.get(attributeByName.id); + inputField.initValue(value, 0); + if (this.valueChangeListener != null) { + this.valueChangeListener.valueChanged( + this, + attributeByName, + value, + 0); + } + } catch (final Exception e) { + log.error("Failed to set attribute value: {} : {}, cause {}", name, value, e.getMessage()); + } + + } + void setValuesToInputFields(final Collection values) { this.inputFieldMapping .values() diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/service/examconfig/impl/rules/BrowserViewModeRule.java b/src/main/java/ch/ethz/seb/sebserver/gui/service/examconfig/impl/rules/BrowserViewModeRule.java index ec5a7530..9f8d3e5c 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/service/examconfig/impl/rules/BrowserViewModeRule.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/service/examconfig/impl/rules/BrowserViewModeRule.java @@ -8,12 +8,14 @@ package ch.ethz.seb.sebserver.gui.service.examconfig.impl.rules; +import org.apache.commons.lang3.BooleanUtils; import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Service; +import ch.ethz.seb.sebserver.gbl.Constants; import ch.ethz.seb.sebserver.gbl.model.sebconfig.ConfigurationAttribute; import ch.ethz.seb.sebserver.gbl.model.sebconfig.ConfigurationValue; import ch.ethz.seb.sebserver.gbl.profile.GuiProfile; @@ -30,10 +32,11 @@ public class BrowserViewModeRule implements ValueChangeRule { public static final String KEY_BROWSER_VIEW_MODE = "browserViewMode"; public static final String KEY_TOUCH_EXIT = "enableTouchExit"; public static final String KEY_MAIN_WINDOW_GROUP = "mainBrowserWindowWidth"; + public static final String KEY_TOUCH_OPTIMIZED = "touchOptimized"; @Override public boolean observesAttribute(final ConfigurationAttribute attribute) { - return KEY_BROWSER_VIEW_MODE.equals(attribute.name); + return KEY_BROWSER_VIEW_MODE.equals(attribute.name) || KEY_TOUCH_OPTIMIZED.equals(attribute.name); } @Override @@ -50,19 +53,35 @@ public class BrowserViewModeRule implements ValueChangeRule { context.enable(KEY_TOUCH_EXIT); context.enableGroup(KEY_MAIN_WINDOW_GROUP); - switch (Integer.parseInt(value.value)) { - case 1: { - context.disable(KEY_TOUCH_EXIT); + if (KEY_TOUCH_OPTIMIZED.equals(attribute.name)) { + if (BooleanUtils.toBoolean(value.value)) { context.disableGroup(KEY_MAIN_WINDOW_GROUP); - break; - } - case 2: { - context.disableGroup(KEY_MAIN_WINDOW_GROUP); - break; - } - default: { + context.setValue(KEY_BROWSER_VIEW_MODE, "2"); + } else { + context.setValue(KEY_TOUCH_EXIT, Constants.FALSE_STRING); context.disable(KEY_TOUCH_EXIT); - break; + } + + return; + } + + if (KEY_BROWSER_VIEW_MODE.equals(attribute.name)) { + switch (Integer.parseInt(value.value)) { + case 1: { + context.disable(KEY_TOUCH_EXIT); + context.disableGroup(KEY_MAIN_WINDOW_GROUP); + context.setValue(KEY_TOUCH_OPTIMIZED, Constants.FALSE_STRING); + break; + } + case 2: { + context.disableGroup(KEY_MAIN_WINDOW_GROUP); + break; + } + default: { + context.disable(KEY_TOUCH_EXIT); + context.setValue(KEY_TOUCH_OPTIMIZED, Constants.FALSE_STRING); + break; + } } } } catch (final Exception e) { diff --git a/src/main/resources/config/sql/base/V2__insert_data_v1_0.sql b/src/main/resources/config/sql/base/V2__insert_data_v1_0.sql index ff0c273e..9d68947a 100644 --- a/src/main/resources/config/sql/base/V2__insert_data_v1_0.sql +++ b/src/main/resources/config/sql/base/V2__insert_data_v1_0.sql @@ -20,7 +20,7 @@ INSERT INTO configuration_attribute VALUES (6, 'exitKey2', 'SINGLE_SELECTION', null, '0,1,2,3,4,5,6,7,8,9,10,11', 'ExitKeySequenceValidator', 'resourceLocTextKey=sebserver.examconfig.props.label.exitKey', '10'), (7, 'exitKey3', 'SINGLE_SELECTION', null, '0,1,2,3,4,5,6,7,8,9,10,11', 'ExitKeySequenceValidator', 'resourceLocTextKey=sebserver.examconfig.props.label.exitKey', '5'), - (8, 'browserViewMode', 'RADIO_SELECTION', null, '0,1,2', null, null, '0'), + (8, 'browserViewMode', 'RADIO_SELECTION', null, '0,1', null, null, '0'), (9, 'enableTouchExit', 'CHECKBOX', null, null, null, null, 'false'), (10, 'mainBrowserWindowWidth', 'COMBO_SELECTION', null, '50%,100%,800,1000', 'WindowsSizeValidator', null, '100%'), (11, 'mainBrowserWindowHeight', 'COMBO_SELECTION', null, '80%,100%,600,800', 'WindowsSizeValidator', null, '100%'), @@ -281,7 +281,8 @@ INSERT INTO orientation VALUES (6, 6, 0, 1, 'exitSequence', 2, 2, 1, 1, 'NONE'), (7, 7, 0, 1, 'exitSequence', 2, 3, 1, 1, 'NONE'), - (8, 8, 0, 2, 'browserViewMode', 0, 0, 3, 3, 'NONE'), + (8, 8, 0, 2, 'browserViewMode', 0, 0, 3, 2, 'NONE'), + (804, 804, 0, 2, 'browserViewMode', 0, 2, 3, 1, 'NONE'), (9, 9, 0, 2, 'browserViewMode', 3, 2, 4, 1, 'NONE'), (10, 10, 0, 2, 'winsize', 1, 4, 2, 1, 'LEFT'), (11, 11, 0, 2, 'winsize', 1, 5, 2, 1, 'LEFT'), diff --git a/src/main/resources/messages.properties b/src/main/resources/messages.properties index fb444366..3a437873 100644 --- a/src/main/resources/messages.properties +++ b/src/main/resources/messages.properties @@ -766,8 +766,8 @@ sebserver.examconfig.props.label.browserViewMode.0=Use browser window sebserver.examconfig.props.label.browserViewMode.0.tooltip=Use window for the SEB browser which can be scaled and moved around, also to another screen if available sebserver.examconfig.props.label.browserViewMode.1=Use full screen mode sebserver.examconfig.props.label.browserViewMode.1.tooltip=Display the SEB browser full screen. -sebserver.examconfig.props.label.browserViewMode.2=Touch optimized -sebserver.examconfig.props.label.browserViewMode.2.tooltip=Mainly to be used on Windows tablets. Not working with the Create New Desktop kiosk mode +sebserver.examconfig.props.label.touchOptimized=Touch optimized +sebserver.examconfig.props.label.touchOptimized.tooltip=Mainly to be used on Windows tablets. Not working with the Create New Desktop kiosk mode sebserver.examconfig.props.label.enableTouchExit=Enable touch exit sebserver.examconfig.props.label.enableTouchExit.tooltip=SEB can be quit by a swipe down from the upper display edge