SEBSERV-312 as discussed
This commit is contained in:
parent
97f174d740
commit
22bbee1117
4 changed files with 19 additions and 7 deletions
|
@ -34,6 +34,8 @@ import ch.ethz.seb.sebserver.gui.widget.WidgetFactory;
|
|||
|
||||
public final class SelectionFieldBuilder extends FieldBuilder<String> {
|
||||
|
||||
private static final String TEST_KEY_SUFFIX = ".action";
|
||||
|
||||
final Supplier<List<Tuple<String>>> itemsSupplier;
|
||||
Consumer<Form> selectionListener = null;
|
||||
final Selection.Type type;
|
||||
|
@ -69,14 +71,14 @@ public final class SelectionFieldBuilder extends FieldBuilder<String> {
|
|||
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<String> {
|
|||
}
|
||||
|
||||
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;
|
||||
|
|
|
@ -33,6 +33,7 @@ public final class MultiSelectionCheckbox extends Composite implements Selection
|
|||
|
||||
private Listener listener = null;
|
||||
private final Map<String, Button> 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 {
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue