From 22bbee1117fc83def0744954927e5570b82a333e Mon Sep 17 00:00:00 2001 From: anhefti Date: Tue, 31 May 2022 15:48:00 +0200 Subject: [PATCH] SEBSERV-312 as discussed --- .../sebserver/gui/form/SelectionFieldBuilder.java | 13 ++++++++++--- .../gui/widget/MultiSelectionCheckbox.java | 6 +++--- .../sebserver/gui/widget/MultiSelectionCombo.java | 5 +++++ .../seb/sebserver/gui/widget/RadioSelection.java | 2 +- 4 files changed, 19 insertions(+), 7 deletions(-) diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/form/SelectionFieldBuilder.java b/src/main/java/ch/ethz/seb/sebserver/gui/form/SelectionFieldBuilder.java index 5a417d9e..f2120b0c 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/form/SelectionFieldBuilder.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/form/SelectionFieldBuilder.java @@ -34,6 +34,8 @@ import ch.ethz.seb.sebserver.gui.widget.WidgetFactory; public final class SelectionFieldBuilder extends FieldBuilder { + private static final String TEST_KEY_SUFFIX = ".action"; + final Supplier>> itemsSupplier; Consumer
selectionListener = null; final Selection.Type type; @@ -69,14 +71,14 @@ public final class SelectionFieldBuilder extends FieldBuilder { private void buildInput(final FormBuilder builder, final Control titleLabel) { final Composite fieldGrid = createFieldGrid(builder.formParent, this.spanInput); - final String actionKey = (this.label != null) ? this.label.name + ".action" : null; + final String testKey = (this.label != null) ? this.label.name + TEST_KEY_SUFFIX : null; final Selection selection = builder.widgetFactory.selectionLocalized( this.type, fieldGrid, this.itemsSupplier, (builder.pageService.getFormTooltipMode() == PageService.FormTooltipMode.INPUT) ? this.tooltip : null, null, - actionKey, + testKey, builder.i18nSupport.getText(getARIALabel(builder))); final GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, false); @@ -161,7 +163,12 @@ public final class SelectionFieldBuilder extends FieldBuilder { } if (this.label != null) { - WidgetFactory.setTestId(label, this.label.name + "_" + valueKey); + final String testKey = this.label.name + TEST_KEY_SUFFIX; + if (this.type == Type.MULTI || this.type == Type.MULTI_COMBO || this.type == Type.MULTI_CHECKBOX) { + WidgetFactory.setTestId(label, testKey + "_" + valueKey); + } else { + WidgetFactory.setTestId(label, testKey); + } } return label; diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/widget/MultiSelectionCheckbox.java b/src/main/java/ch/ethz/seb/sebserver/gui/widget/MultiSelectionCheckbox.java index 36d91d24..2033c806 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/widget/MultiSelectionCheckbox.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/widget/MultiSelectionCheckbox.java @@ -33,6 +33,7 @@ public final class MultiSelectionCheckbox extends Composite implements Selection private Listener listener = null; private final Map checkboxes; + private final String testKey; MultiSelectionCheckbox(final Composite parent, final String testKey) { super(parent, SWT.NONE); @@ -42,6 +43,7 @@ public final class MultiSelectionCheckbox extends Composite implements Selection gridLayout.marginHeight = 0; gridLayout.marginWidth = 0; setLayout(gridLayout); + this.testKey = testKey; if (testKey != null) { WidgetFactory.setTestId(this, testKey); } @@ -69,7 +71,7 @@ public final class MultiSelectionCheckbox extends Composite implements Selection final Button button = new Button(this, SWT.CHECK); button.setText(tuple._2); WidgetFactory.setARIALabel(button, tuple._2); - WidgetFactory.setTestId(button, tuple._1); + WidgetFactory.setTestId(button, (this.testKey != null) ? this.testKey + "_" + tuple._1 : tuple._1); final GridData gridData = new GridData(SWT.FILL, SWT.CENTER, true, true); button.setLayoutData(gridData); button.setData(OPTION_VALUE, tuple._1); @@ -78,8 +80,6 @@ public final class MultiSelectionCheckbox extends Composite implements Selection this.listener.handleEvent(event); } }); - WidgetFactory.setTestId(button, tuple._1); - WidgetFactory.setARIALabel(button, tuple._2); this.checkboxes.put(tuple._1, button); try { diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/widget/MultiSelectionCombo.java b/src/main/java/ch/ethz/seb/sebserver/gui/widget/MultiSelectionCombo.java index 94988016..8f7dd457 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/widget/MultiSelectionCombo.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/widget/MultiSelectionCombo.java @@ -48,6 +48,7 @@ public final class MultiSelectionCombo extends Composite implements Selection { private final Text textInput; private final GridData textCell; private final Composite updateAnchor; + private final String testKey; private Listener listener = null; @@ -59,6 +60,7 @@ public final class MultiSelectionCombo extends Composite implements Selection { super(parent, SWT.NONE); this.widgetFactory = widgetFactory; + this.testKey = locTextPrefix; final GridLayout gridLayout = new GridLayout(); gridLayout.verticalSpacing = 1; @@ -175,6 +177,9 @@ public final class MultiSelectionCombo extends Composite implements Selection { label.addListener(SWT.MouseDoubleClick, this::removeComboSelection); this.selectionControls.add(label); + WidgetFactory.setARIALabel(label, item._2); + WidgetFactory.setTestId(label, (this.testKey != null) ? this.testKey + "_" + item._1 : item._1); + this.availableValues.remove(item); PageService.updateScrolledComposite(this); this.updateAnchor.layout(true, true); diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/widget/RadioSelection.java b/src/main/java/ch/ethz/seb/sebserver/gui/widget/RadioSelection.java index 4ccf29bd..10518c8c 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/widget/RadioSelection.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/widget/RadioSelection.java @@ -75,7 +75,7 @@ public final class RadioSelection extends Composite implements Selection { this.listener.handleEvent(event); } }); - WidgetFactory.setTestId(button, (this.testKey != null) ? this.testKey + tuple._1 : tuple._1); + WidgetFactory.setTestId(button, (this.testKey != null) ? this.testKey + "_" + tuple._1 : tuple._1); WidgetFactory.setARIALabel(button, tuple._2); this.radioButtons.put(tuple._1, button); }