From c66a59223e6e1d9b9c2c54ba503e3042ffbd1138 Mon Sep 17 00:00:00 2001 From: anhefti Date: Wed, 2 Feb 2022 13:35:13 +0100 Subject: [PATCH] fixed more test keys --- .../gui/form/CheckboxFieldBuilder.java | 2 + .../sebserver/gui/form/TextFieldBuilder.java | 4 +- .../examconfig/impl/SliderFieldBuilder.java | 7 +++ .../sebserver/gui/widget/ThresholdList.java | 2 + .../sebserver/gui/widget/WidgetFactory.java | 43 ++++++------------- src/main/resources/messages.properties | 1 + 6 files changed, 28 insertions(+), 31 deletions(-) diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/form/CheckboxFieldBuilder.java b/src/main/java/ch/ethz/seb/sebserver/gui/form/CheckboxFieldBuilder.java index 6a13d139..11b4a950 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/form/CheckboxFieldBuilder.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/form/CheckboxFieldBuilder.java @@ -46,6 +46,7 @@ public class CheckboxFieldBuilder extends FieldBuilder { SWT.CHECK, this.label, this.tooltip, + this.label.name, getARIALabel(builder)); } else { titleLabel = createTitleLabel(builder.formParent, builder, this); @@ -55,6 +56,7 @@ public class CheckboxFieldBuilder extends FieldBuilder { SWT.CHECK, null, null, + this.label.name, getARIALabel(builder)); } diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/form/TextFieldBuilder.java b/src/main/java/ch/ethz/seb/sebserver/gui/form/TextFieldBuilder.java index 3a51f6d4..8ebc39b7 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/form/TextFieldBuilder.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/form/TextFieldBuilder.java @@ -121,9 +121,9 @@ public final class TextFieldBuilder extends FieldBuilder { final String testKey = (this.label != null) ? this.label.name : this.name; final LocTextKey label = getARIALabel(builder); final Text textInput = (this.isNumber) - ? builder.widgetFactory.numberInput(fieldGrid, this.numberCheck, readonly, label) + ? builder.widgetFactory.numberInput(fieldGrid, this.numberCheck, readonly, testKey, label) : (this.isArea) - ? builder.widgetFactory.textAreaInput(fieldGrid, readonly, label) + ? builder.widgetFactory.textAreaInput(fieldGrid, readonly, testKey, label) : builder.widgetFactory.textInput(fieldGrid, this.isPassword, readonly, testKey, label); if (builder.pageService.getFormTooltipMode() == PageService.FormTooltipMode.INPUT) { diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/service/examconfig/impl/SliderFieldBuilder.java b/src/main/java/ch/ethz/seb/sebserver/gui/service/examconfig/impl/SliderFieldBuilder.java index 63486312..62096f31 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/service/examconfig/impl/SliderFieldBuilder.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/service/examconfig/impl/SliderFieldBuilder.java @@ -22,8 +22,11 @@ import ch.ethz.seb.sebserver.gbl.model.sebconfig.AttributeType; import ch.ethz.seb.sebserver.gbl.model.sebconfig.ConfigurationAttribute; import ch.ethz.seb.sebserver.gbl.model.sebconfig.Orientation; import ch.ethz.seb.sebserver.gbl.profile.GuiProfile; +import ch.ethz.seb.sebserver.gui.service.examconfig.ExamConfigurationService; import ch.ethz.seb.sebserver.gui.service.examconfig.InputField; import ch.ethz.seb.sebserver.gui.service.examconfig.InputFieldBuilder; +import ch.ethz.seb.sebserver.gui.service.i18n.I18nSupport; +import ch.ethz.seb.sebserver.gui.widget.WidgetFactory; @Lazy @Component @@ -48,6 +51,7 @@ public class SliderFieldBuilder implements InputFieldBuilder { final ConfigurationAttribute attribute, final ViewContext viewContext) { + final I18nSupport i18nSupport = viewContext.getI18nSupport(); final Orientation orientation = viewContext .getOrientation(attribute.id); final Composite innerGrid = InputFieldBuilder @@ -55,6 +59,9 @@ public class SliderFieldBuilder implements InputFieldBuilder { final Slider slider = new Slider(innerGrid, SWT.NONE); slider.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); + final String attributeNameKey = ExamConfigurationService.attributeNameKey(attribute); + WidgetFactory.setTestId(slider, attributeNameKey); + WidgetFactory.setARIALabel(slider, i18nSupport.getText(attributeNameKey)); try { final String[] split = StringUtils.split( diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/widget/ThresholdList.java b/src/main/java/ch/ethz/seb/sebserver/gui/widget/ThresholdList.java index 30dd5ab3..57572f61 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/widget/ThresholdList.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/widget/ThresholdList.java @@ -154,6 +154,8 @@ public final class ThresholdList extends Composite { Double.parseDouble(s); } }, + false, + VALUE_TEXT_KEY.name + "_" + this.thresholds.size(), VALUE_TEXT_KEY); final GridData valueCell = new GridData(SWT.FILL, SWT.CENTER, true, false); valueInput.setLayoutData(valueCell); diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/widget/WidgetFactory.java b/src/main/java/ch/ethz/seb/sebserver/gui/widget/WidgetFactory.java index 5dda27ca..6dc21cc9 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/widget/WidgetFactory.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/widget/WidgetFactory.java @@ -399,27 +399,6 @@ public class WidgetFactory { return button; } - public Button buttonLocalized( - final Composite parent, - final int type, - final LocTextKey locTextKey, - final LocTextKey toolTipKey, - final LocTextKey ariaLabel) { - - final Button button = new Button(parent, type); - setARIARole(button, AriaRole.button); - if (ariaLabel != null) { - setARIALabel(button, this.i18nSupport.getText(ariaLabel)); - } - if (locTextKey != null) { - setTestId(button, locTextKey.name); - } else if (toolTipKey != null) { - setTestId(button, toolTipKey.name); - } - this.polyglotPageService.injectI18n(button, locTextKey, toolTipKey); - return button; - } - public Button buttonLocalized( final Composite parent, final int type, @@ -518,7 +497,6 @@ public class WidgetFactory { return textInput; } -// public Text passwordInput(final Composite content, final String testKey, final LocTextKey ariaLabel) { return textInput(content, true, false, testKey, ariaLabel); } @@ -526,6 +504,7 @@ public class WidgetFactory { public Text textAreaInput( final Composite content, final boolean readonly, + final String testKey, final LocTextKey ariaLabel) { final Text input = readonly @@ -534,6 +513,9 @@ public class WidgetFactory { if (ariaLabel != null) { WidgetFactory.setARIALabel(input, this.i18nSupport.getText(ariaLabel)); } + if (testKey != null) { + setTestId(input, testKey); + } return input; } @@ -559,20 +541,23 @@ public class WidgetFactory { return input; } - public Text numberInput(final Composite content, final Consumer numberCheck, final LocTextKey label) { - return numberInput(content, numberCheck, false, label); - } +// public Text numberInput(final Composite content, final Consumer numberCheck, final LocTextKey label) { +// return numberInput(content, numberCheck, false, label); +// } public Text numberInput( final Composite content, final Consumer numberCheck, final boolean readonly, - final LocTextKey label) { + final String testKey, + final LocTextKey ariaLabel) { final Text numberInput = new Text(content, (readonly) ? SWT.LEFT | SWT.READ_ONLY : SWT.RIGHT | SWT.BORDER); - if (label != null) { - setARIALabel(numberInput, this.i18nSupport.getText(label)); - setTestId(numberInput, label.name); + if (ariaLabel != null) { + setARIALabel(numberInput, this.i18nSupport.getText(ariaLabel)); + } + if (testKey != null) { + setTestId(numberInput, testKey); } if (numberCheck != null) { numberInput.addListener(SWT.Verify, event -> { diff --git a/src/main/resources/messages.properties b/src/main/resources/messages.properties index 4bde55c7..2a72b205 100644 --- a/src/main/resources/messages.properties +++ b/src/main/resources/messages.properties @@ -975,6 +975,7 @@ sebserver.examconfig.props.label.audioControlEnabled=Enable audio controls sebserver.examconfig.props.label.audioControlEnabled.tooltip=Displays an audio control in the SEB taskbar sebserver.examconfig.props.label.audioMute=Mute audio on startup sebserver.examconfig.props.label.audioMute.tooltip=The audio is muted when the SEB/exam starts +sebserver.examconfig.props.label.audioVolumeLevel=Set initial volume level sebserver.examconfig.props.label.audioSetVolumeLevel=Set initial volume level sebserver.examconfig.props.label.audioSetVolumeLevel.tooltip=The volume level after starting SEB/exam