From 8bf00bf413c8a72cb27ef6715b72a091f88c4333 Mon Sep 17 00:00:00 2001 From: anhefti Date: Wed, 27 Jan 2021 17:24:30 +0100 Subject: [PATCH] fixed some GUI issues --- .../gui/content/SEBClientConfigForm.java | 33 +++++++++++++------ .../gui/service/ResourceService.java | 4 ++- 2 files changed, 26 insertions(+), 11 deletions(-) diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/content/SEBClientConfigForm.java b/src/main/java/ch/ethz/seb/sebserver/gui/content/SEBClientConfigForm.java index 036236d2..d14e928c 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/content/SEBClientConfigForm.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/content/SEBClientConfigForm.java @@ -102,6 +102,12 @@ public class SEBClientConfigForm implements TemplateComposer { SEBClientConfig.ATTR_FALLBACK_PASSWORD_CONFIRM, SEBClientConfig.ATTR_QUIT_PASSWORD, SEBClientConfig.ATTR_QUIT_PASSWORD_CONFIRM)); + private static final Set FALLBACK_RESET_ATTRIBUTES = new HashSet<>(Arrays.asList( + SEBClientConfig.ATTR_FALLBACK_START_URL, + SEBClientConfig.ATTR_FALLBACK_PASSWORD, + SEBClientConfig.ATTR_FALLBACK_PASSWORD_CONFIRM, + SEBClientConfig.ATTR_QUIT_PASSWORD, + SEBClientConfig.ATTR_QUIT_PASSWORD_CONFIRM)); private static final String FALLBACK_DEFAULT_TIME = String.valueOf(30 * Constants.SECOND_IN_MILLIS); private static final String FALLBACK_DEFAULT_ATTEMPTS = String.valueOf(5); @@ -306,16 +312,23 @@ public class SEBClientConfigForm implements TemplateComposer { if (!isReadonly) { formHandle.getForm().getFieldInput(SEBClientConfig.ATTR_FALLBACK) - .addListener(SWT.Selection, event -> formHandle.process( - FALLBACK_ATTRIBUTES::contains, - ffa -> { - final boolean selected = ((Button) event.widget).getSelection(); - ffa.setVisible(selected); - if (!selected && ffa.hasError()) { - ffa.resetError(); - ffa.setStringValue(StringUtils.EMPTY); - } - })); + .addListener(SWT.Selection, event -> { + formHandle.process( + FALLBACK_ATTRIBUTES::contains, + ffa -> { + final boolean selected = ((Button) event.widget).getSelection(); + ffa.setVisible(selected); + }); + formHandle.process( + FALLBACK_RESET_ATTRIBUTES::contains, + ffa -> { + final boolean selected = ((Button) event.widget).getSelection(); + if (!selected) { + ffa.resetError(); + ffa.setStringValue(StringUtils.EMPTY); + } + }); + }); } final UrlLauncher urlLauncher = RWT.getClient().getService(UrlLauncher.class); diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/service/ResourceService.java b/src/main/java/ch/ethz/seb/sebserver/gui/service/ResourceService.java index 36d97879..336907e2 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/service/ResourceService.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/service/ResourceService.java @@ -659,7 +659,7 @@ public class ResourceService { public List> getExamConfigTemplateResources() { final UserInfo userInfo = this.currentUser.get(); - return this.restService.getBuilder(GetExamConfigNodes.class) + final List> collect = this.restService.getBuilder(GetExamConfigNodes.class) .withQueryParam(Entity.FILTER_ATTR_INSTITUTION, String.valueOf(userInfo.getInstitutionId())) .withQueryParam(ConfigurationNode.FILTER_ATTR_TYPE, ConfigurationType.TEMPLATE.name()) .call() @@ -668,6 +668,8 @@ public class ResourceService { .map(node -> new Tuple<>(node.getModelId(), node.name)) .sorted(RESOURCE_COMPARATOR) .collect(Collectors.toList()); + collect.add(0, new Tuple<>(null, "")); + return collect; } public List> sebRestrictionWhiteListResources() {