From fe2d89ca49bf0d23bcd67a3756c9e9c862e9cae2 Mon Sep 17 00:00:00 2001 From: anhefti Date: Tue, 1 Feb 2022 15:42:22 +0100 Subject: [PATCH] fixed test attributes and typos --- .../seb/sebserver/gui/content/LoginPage.java | 2 +- .../sebserver/gui/form/TextFieldBuilder.java | 3 +- .../sebserver/gui/widget/WidgetFactory.java | 54 +++++++------------ src/main/resources/messages.properties | 2 +- 4 files changed, 23 insertions(+), 38 deletions(-) diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/content/LoginPage.java b/src/main/java/ch/ethz/seb/sebserver/gui/content/LoginPage.java index 44e9c466..30963de3 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/content/LoginPage.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/content/LoginPage.java @@ -91,7 +91,7 @@ public class LoginPage implements TemplateComposer { gridData.verticalIndent = 10; final Label pwd = this.widgetFactory.labelLocalized(loginGroup, TEXT_PWD); pwd.setLayoutData(gridData); - final Text loginPassword = this.widgetFactory.passwordInput(loginGroup, TEXT_PWD); + final Text loginPassword = this.widgetFactory.passwordInput(loginGroup, TEXT_PWD.name, TEXT_PWD); loginPassword.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false)); final Composite buttons = new Composite(loginGroup, SWT.NONE); 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 2e0fe733..3a51f6d4 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 @@ -118,12 +118,13 @@ public final class TextFieldBuilder extends FieldBuilder { return; } + 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) : (this.isArea) ? builder.widgetFactory.textAreaInput(fieldGrid, readonly, label) - : builder.widgetFactory.textInput(fieldGrid, this.isPassword, readonly, label); + : builder.widgetFactory.textInput(fieldGrid, this.isPassword, readonly, testKey, label); if (builder.pageService.getFormTooltipMode() == PageService.FormTooltipMode.INPUT) { builder.pageService.getPolyglotPageService().injectI18nTooltip( 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 02fe1584..5dda27ca 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 @@ -502,63 +502,47 @@ public class WidgetFactory { return labelLocalized; } - public Text textInput(final Composite content, final LocTextKey label) { - return textInput(content, false, false, label.name, this.i18nSupport.getText(label)); + public Text textInput(final Composite content, final LocTextKey ariaLabel) { + return textInput(content, false, false, ariaLabel.name, ariaLabel); } - public Text textInput(final Composite content, final String testKey, final LocTextKey label) { - return textInput(content, false, false, testKey, this.i18nSupport.getText(label)); + public Text textInput(final Composite content, final String testKey, final LocTextKey ariaLabel) { + return textInput(content, false, false, testKey, ariaLabel); } - public Text textInput(final Composite content, final String testKey, final String label) { - return textInput(content, false, false, testKey, label); + public Text textInput(final Composite content, final String testKey, final String ariaLabel) { + final Text textInput = textInput(content, false, false, testKey, null); + if (ariaLabel != null) { + WidgetFactory.setARIALabel(textInput, this.i18nSupport.getText(ariaLabel)); + } + return textInput; } - public Text passwordInput(final Composite content, final LocTextKey label) { - return textInput(content, true, false, label.name, this.i18nSupport.getText(label)); - } - - public Text passwordInput(final Composite content, final String testKey, final String label) { - return textInput(content, true, false, testKey, label); +// + public Text passwordInput(final Composite content, final String testKey, final LocTextKey ariaLabel) { + return textInput(content, true, false, testKey, ariaLabel); } public Text textAreaInput( final Composite content, final boolean readonly, - final LocTextKey label) { - - return textAreaInput(content, readonly, this.i18nSupport.getText(label)); - } - - public Text textAreaInput( - final Composite content, - final boolean readonly, - final String label) { + final LocTextKey ariaLabel) { final Text input = readonly ? new Text(content, SWT.LEFT | SWT.MULTI) : new Text(content, SWT.LEFT | SWT.BORDER | SWT.MULTI); - if (label != null) { - WidgetFactory.setARIALabel(input, label); + if (ariaLabel != null) { + WidgetFactory.setARIALabel(input, this.i18nSupport.getText(ariaLabel)); } return input; } - public Text textInput( - final Composite content, - final boolean password, - final boolean readonly, - final LocTextKey label) { - - return textInput(content, password, readonly, label.name, this.i18nSupport.getText(label)); - } - public Text textInput( final Composite content, final boolean password, final boolean readonly, final String testKey, - final String label) { + final LocTextKey ariaLabel) { final Text input = readonly ? new Text(content, SWT.LEFT) @@ -566,8 +550,8 @@ public class WidgetFactory { ? SWT.LEFT | SWT.BORDER | SWT.PASSWORD : SWT.LEFT | SWT.BORDER); - if (label != null) { - WidgetFactory.setARIALabel(input, label); + if (ariaLabel != null) { + WidgetFactory.setARIALabel(input, this.i18nSupport.getText(ariaLabel)); } if (testKey != null) { setTestId(input, testKey); diff --git a/src/main/resources/messages.properties b/src/main/resources/messages.properties index 1ec82344..efa1d735 100644 --- a/src/main/resources/messages.properties +++ b/src/main/resources/messages.properties @@ -1371,7 +1371,7 @@ sebserver.examconfig.props.label.enablePrintScreen=Allow screen capture sebserver.examconfig.props.label.enablePrintScreen.tooltip=Controls Print Screen and OS X screen capture, corresponds with Enable screen capture in Security settings sebserver.examconfig.props.label.enableCtrlEsc=Enable Ctrl-Esc sebserver.examconfig.props.label.enableAltEsc=Enable Alt-Esc -sebserver.examconfig.props.label.enableAltTab=Enable Alt-Tap +sebserver.examconfig.props.label.enableAltTab=Enable Alt-Tab sebserver.examconfig.props.label.enableAltF4=Enable Alt-F4 sebserver.examconfig.props.label.enableStartMenu=Enable Start Menu sebserver.examconfig.props.label.enableRightMouse=Enable Right Mouse