From 6b84aa5402dd5c12a4a8b7cb7f6298dc6de753b9 Mon Sep 17 00:00:00 2001 From: Arne Keller Date: Thu, 11 Mar 2021 15:07:38 +0100 Subject: [PATCH] New example button in help dialog --- .../edu/kit/typicalc/view/TypicalcI18NProvider.java | 3 +++ .../java/edu/kit/typicalc/view/main/HelpDialog.java | 4 ++-- src/main/java/edu/kit/typicalc/view/main/InputBar.java | 10 ++++++++-- src/main/resources/language/translation_de.properties | 1 - src/main/resources/language/translation_en.properties | 1 - 5 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/main/java/edu/kit/typicalc/view/TypicalcI18NProvider.java b/src/main/java/edu/kit/typicalc/view/TypicalcI18NProvider.java index 8a94ec8..98b36ef 100644 --- a/src/main/java/edu/kit/typicalc/view/TypicalcI18NProvider.java +++ b/src/main/java/edu/kit/typicalc/view/TypicalcI18NProvider.java @@ -36,6 +36,9 @@ public class TypicalcI18NProvider implements I18NProvider { @Override public String getTranslation(String key, Locale locale, Object... params) { + if (key.equals("")) { + return ""; + } ResourceBundle bundle = ResourceBundle.getBundle(LANGUAGE_BUNDLE_PREFIX, locale); String result; diff --git a/src/main/java/edu/kit/typicalc/view/main/HelpDialog.java b/src/main/java/edu/kit/typicalc/view/main/HelpDialog.java index 1430f17..0a6c8c3 100644 --- a/src/main/java/edu/kit/typicalc/view/main/HelpDialog.java +++ b/src/main/java/edu/kit/typicalc/view/main/HelpDialog.java @@ -82,8 +82,8 @@ public class HelpDialog extends Dialog implements LocaleChangeObserver { acc.add(new HelpContentField("root.inferenceViewFeatures", "root.helpInferenceViewFeatures")); acc.add(new HelpContentField("root.shortcuts", "root.helpShortcuts")); acc.add(new HelpContentField("root.drawer", "root.helpDrawer")); - acc.add(new HelpContentField("root.example", - new Button(new Icon(VaadinIcon.PAPERCLIP)), "root.helpExample")); + acc.add(new HelpContentField("", + InputBar.createExampleButton(), "root.helpExample")); acc.add(new HelpContentField("root.firstStepButton", new Button(new Icon(VaadinIcon.ANGLE_DOUBLE_LEFT)), "root.helpFirstStepButton")); acc.add(new HelpContentField("root.previousStepButton", diff --git a/src/main/java/edu/kit/typicalc/view/main/InputBar.java b/src/main/java/edu/kit/typicalc/view/main/InputBar.java index 4a93f08..7309096 100644 --- a/src/main/java/edu/kit/typicalc/view/main/InputBar.java +++ b/src/main/java/edu/kit/typicalc/view/main/InputBar.java @@ -77,8 +77,8 @@ public class InputBar extends HorizontalLayout implements LocaleChangeObserver { typeAssumptions = new Button("", event -> onTypeAssumptionsButton()); typeAssumptions.setId(ASS_BUTTON_ID); typeAssumptionsArea = new TypeAssumptionsArea(); - exampleButton = new Button(getTranslation("root.exampleButton"), event -> onExampleButtonClick()); - exampleButton.setId(EXAMPLE_BUTTON_ID); + exampleButton = createExampleButton(); + exampleButton.addClickListener(event -> onExampleButtonClick()); inferTypeButton = new Button("", event -> onTypeInferButtonClick()); inferTypeButton.addClickShortcut(Key.ENTER).listenOn(this); inferTypeButton.addThemeVariants(ButtonVariant.LUMO_PRIMARY); @@ -87,6 +87,12 @@ public class InputBar extends HorizontalLayout implements LocaleChangeObserver { add(infoIcon, typeAssumptions, lambdaButton, inputField, exampleButton, inferTypeButton); } + public static Button createExampleButton() { + Button button = new Button(UI.getCurrent().getTranslation("root.exampleButton")); + button.setId(EXAMPLE_BUTTON_ID); + return button; + } + /** * Sets the provided string as the value of the inputField. * diff --git a/src/main/resources/language/translation_de.properties b/src/main/resources/language/translation_de.properties index b48f6df..ae8913d 100644 --- a/src/main/resources/language/translation_de.properties +++ b/src/main/resources/language/translation_de.properties @@ -27,7 +27,6 @@ root.type=Typ root.title404=404 - Seite nicht gefunden root.message404=Versuche /infer/ oder gib deinen Lieblingsterm in das Eingabefeld ein. root.drawer=Ableitungsregeln-Knopf -root.example=Beispiele root.shortcuts=Tastaturbefehle root.inputField=Eingabefeld root.typeInferButton=Typisieren-Knopf diff --git a/src/main/resources/language/translation_en.properties b/src/main/resources/language/translation_en.properties index 3fdda19..14da4c0 100644 --- a/src/main/resources/language/translation_en.properties +++ b/src/main/resources/language/translation_en.properties @@ -27,7 +27,6 @@ root.type=Type root.title404=404 - Not Found root.message404=Try /infer/ or type your favourite term into the input field. root.drawer=Type Inference Rules Button -root.example=Examples root.shortcuts=Shortcuts root.inputField=Input Field root.typeInferButton=Type Button