From 53243f7f437e5430b1a653613229363cc68f8101 Mon Sep 17 00:00:00 2001 From: uogau Date: Thu, 11 Mar 2021 13:34:41 +0100 Subject: [PATCH] Added hint to type assumptions --- .../view/main/TypeAssumptionsArea.java | 34 +++++++++++++------ .../language/translation_de.properties | 1 + .../language/translation_en.properties | 1 + 3 files changed, 25 insertions(+), 11 deletions(-) diff --git a/src/main/java/edu/kit/typicalc/view/main/TypeAssumptionsArea.java b/src/main/java/edu/kit/typicalc/view/main/TypeAssumptionsArea.java index 1910136..77c0d07 100644 --- a/src/main/java/edu/kit/typicalc/view/main/TypeAssumptionsArea.java +++ b/src/main/java/edu/kit/typicalc/view/main/TypeAssumptionsArea.java @@ -6,6 +6,7 @@ import com.vaadin.flow.component.button.ButtonVariant; import com.vaadin.flow.component.dependency.CssImport; import com.vaadin.flow.component.dialog.Dialog; import com.vaadin.flow.component.html.H3; +import com.vaadin.flow.component.html.Label; import com.vaadin.flow.component.icon.Icon; import com.vaadin.flow.component.icon.VaadinIcon; import com.vaadin.flow.component.notification.Notification; @@ -48,6 +49,7 @@ public class TypeAssumptionsArea extends Dialog implements LocaleChangeObserver private final Button deleteAll; private final Button saveAssumptions; private final Notification invalidInputNotification; + private final Label hintLabel; private final List fields = new ArrayList<>(); @@ -62,25 +64,20 @@ public class TypeAssumptionsArea extends Dialog implements LocaleChangeObserver VerticalLayout layout = new VerticalLayout(); layout.setId(ASS_LAYOUT_ID); - HorizontalLayout buttons = new HorizontalLayout(); - buttons.setId(ASS_BUTTONS_ID); + addAssumption = new Button("", new Icon(VaadinIcon.PLUS_CIRCLE)); - addAssumption.setIconAfterText(true); - addAssumption.addClickListener(event -> onAddAssumptionClicked()); deleteAll = new Button("", new Icon(VaadinIcon.TRASH)); - deleteAll.addClickListener(event -> onDeleteAllClick()); - deleteAll.setIconAfterText(true); - deleteAll.addThemeVariants(ButtonVariant.LUMO_ERROR); saveAssumptions = new Button(getTranslation("root.save"), event -> closeAction()); - saveAssumptions.addThemeVariants(ButtonVariant.LUMO_SUCCESS); - saveAssumptions.addClickShortcut(Key.ENTER); - buttons.add(addAssumption, deleteAll, saveAssumptions); + HorizontalLayout buttons = makeButtons(); + buttons.setId(ASS_BUTTONS_ID); assumptionContainer = new VerticalLayout(); assumptionContainer.setId(ASS_CONTAINER_ID); + hintLabel = new Label(""); + initializeWithAssumptions(types); - layout.add(buttons, assumptionContainer); + layout.add(hintLabel, buttons, assumptionContainer); HorizontalLayout headingLayout = makeHeader(); add(headingLayout, layout); addDialogCloseActionListener(event -> closeAction()); @@ -125,6 +122,20 @@ public class TypeAssumptionsArea extends Dialog implements LocaleChangeObserver headingLayout.add(closeIcon); return headingLayout; } + + private HorizontalLayout makeButtons() { + HorizontalLayout buttons = new HorizontalLayout(); + buttons.setId(ASS_BUTTONS_ID); + addAssumption.setIconAfterText(true); + addAssumption.addClickListener(event -> onAddAssumptionClicked()); + deleteAll.addClickListener(event -> onDeleteAllClick()); + deleteAll.setIconAfterText(true); + deleteAll.addThemeVariants(ButtonVariant.LUMO_ERROR); + saveAssumptions.addThemeVariants(ButtonVariant.LUMO_SUCCESS); + saveAssumptions.addClickShortcut(Key.ENTER); + buttons.add(addAssumption, deleteAll, saveAssumptions); + return buttons; + } /** * Creates a new empty TypeAssumptionsArea. */ @@ -180,5 +191,6 @@ public class TypeAssumptionsArea extends Dialog implements LocaleChangeObserver deleteAll.setText(getTranslation("root.deleteAll")); saveAssumptions.setText(getTranslation("root.save")); invalidInputNotification.setText(getTranslation("root.correctAssumptions")); + hintLabel.setText(getTranslation("root.typeAssumptionsHint")); } } diff --git a/src/main/resources/language/translation_de.properties b/src/main/resources/language/translation_de.properties index 4daf257..5381527 100644 --- a/src/main/resources/language/translation_de.properties +++ b/src/main/resources/language/translation_de.properties @@ -18,6 +18,7 @@ root.selectLanguage=Sprache root.termExplanation=Die folgende Grammatik beschreibt den Aufbau eines gültigen Terms: root.assExplanation=Die folgende Grammatik beschreibt die Syntax eines gültigen Typs: root.typeAssumptions=Typannahmen +root.typeAssumptionsHint=Um die Typannahmen auf den Term anzuwenden, muss neu typisiert werden. root.addAssumption=Typannahme hinzufügen root.deleteAll=Alle löschen root.variable=Variable diff --git a/src/main/resources/language/translation_en.properties b/src/main/resources/language/translation_en.properties index 6d72c5c..302275a 100644 --- a/src/main/resources/language/translation_en.properties +++ b/src/main/resources/language/translation_en.properties @@ -18,6 +18,7 @@ root.selectLanguage=Language root.termExplanation=The following grammar specifies the structure of a valid term: root.assExplanation=The following grammar specifies the syntax of a valid type: root.typeAssumptions=Type Assumptions +root.typeAssumptionsHint=To apply the type assumptions to the current term, you need to press "Type". root.addAssumption=Add Type Assumption root.deleteAll=Delete All root.variable=Variable