From c2de56a29a3c80927b4c93b4766c7e5696047560 Mon Sep 17 00:00:00 2001 From: Johanna Stuber Date: Fri, 5 Mar 2021 16:56:23 +0100 Subject: [PATCH 1/4] add amsmath to needed packages --- .../typeinferencecontent/ShareDialog.java | 16 +++++++--------- .../typeinferencecontent/TypeInferenceView.java | 2 +- .../latexcreator/LatexCreator.java | 13 +------------ .../latexcreator/LatexCreatorConstants.java | 2 -- src/main/resources/language/general.properties | 6 +++++- 5 files changed, 14 insertions(+), 25 deletions(-) diff --git a/src/main/java/edu/kit/typicalc/view/content/typeinferencecontent/ShareDialog.java b/src/main/java/edu/kit/typicalc/view/content/typeinferencecontent/ShareDialog.java index dc835c7..5b5df8a 100644 --- a/src/main/java/edu/kit/typicalc/view/content/typeinferencecontent/ShareDialog.java +++ b/src/main/java/edu/kit/typicalc/view/content/typeinferencecontent/ShareDialog.java @@ -25,7 +25,7 @@ public class ShareDialog extends Dialog implements LocaleChangeObserver { private static final String CLOSE_ICON_ID = "closeIcon"; private final TextField urlField; - private final TextField packageField; + private final TextArea packageArea; private final TextArea latexArea; private final H3 heading; @@ -34,11 +34,9 @@ public class ShareDialog extends Dialog implements LocaleChangeObserver { * to the String that is passed as corresponding parameter. * * @param url a permalink to share with other users - * @param latexPackages the needed LaTeX-packages to use the displayed mathematics - * in other LaTeX documents. Should be in the form „\\usepackage<package>“ * @param latexCode LaTeX code for users to copy into their own LaTeX document(s) */ - public ShareDialog(String url, String latexPackages, String latexCode) { + public ShareDialog(String url, String latexCode) { HorizontalLayout headingLayout = new HorizontalLayout(); headingLayout.setId(HEADING_LAYOUT_ID); @@ -55,17 +53,17 @@ public class ShareDialog extends Dialog implements LocaleChangeObserver { setId(SHARE_DIALOG_ID); urlField = new TextField(); - packageField = new TextField(); + packageArea = new TextArea(); latexArea = new TextArea(); urlField.setValue(url); urlField.setClassName(FIELD_CLASS); - packageField.setValue(latexPackages); - packageField.setClassName(FIELD_CLASS); + packageArea.setValue(getTranslation("share.neededPackages")); + packageArea.setClassName(FIELD_CLASS); latexArea.setValue(latexCode); latexArea.setClassName(FIELD_CLASS); - layout.add(urlField, packageField, latexArea); + layout.add(urlField, packageArea, latexArea); add(headingLayout, layout); } @@ -75,7 +73,7 @@ public class ShareDialog extends Dialog implements LocaleChangeObserver { public void localeChange(LocaleChangeEvent localeChangeEvent) { heading.setText(getTranslation("share.heading")); urlField.setLabel(getTranslation("share.url.label")); - packageField.setLabel(getTranslation("share.packages.label")); + packageArea.setLabel(getTranslation("share.packages.label")); latexArea.setLabel(getTranslation("share.latex.label")); } } diff --git a/src/main/java/edu/kit/typicalc/view/content/typeinferencecontent/TypeInferenceView.java b/src/main/java/edu/kit/typicalc/view/content/typeinferencecontent/TypeInferenceView.java index f189547..5136e5a 100644 --- a/src/main/java/edu/kit/typicalc/view/content/typeinferencecontent/TypeInferenceView.java +++ b/src/main/java/edu/kit/typicalc/view/content/typeinferencecontent/TypeInferenceView.java @@ -82,7 +82,7 @@ public class TypeInferenceView extends VerticalLayout @Override public void shareButton() { UI.getCurrent().getPage().executeJs("return decodeURI(window.location.href)").then(url -> - new ShareDialog(url.asString(), lc.getLatexPackages(), lc.getTree()).open() + new ShareDialog(url.asString(), lc.getTree()).open() ); } diff --git a/src/main/java/edu/kit/typicalc/view/content/typeinferencecontent/latexcreator/LatexCreator.java b/src/main/java/edu/kit/typicalc/view/content/typeinferencecontent/latexcreator/LatexCreator.java index 0027bca..e841c98 100644 --- a/src/main/java/edu/kit/typicalc/view/content/typeinferencecontent/latexcreator/LatexCreator.java +++ b/src/main/java/edu/kit/typicalc/view/content/typeinferencecontent/latexcreator/LatexCreator.java @@ -77,16 +77,6 @@ public class LatexCreator implements StepVisitor { return constraintsCreator.getTreeNumbers(); } - /** - * Returns needed LaTeX packages - * - * @return the packages needed for the LaTeX-code from getTree() to work - */ - public String getLatexPackages() { - return BUSSPROOFS; - } - - private String conclusionToLatex(Conclusion conclusion) { String typeAssumptions = typeAssumptionsToLatex(conclusion.getTypeAssumptions()); String term = new LatexCreatorTerm(conclusion.getLambdaTerm()).getLatex(); @@ -155,8 +145,7 @@ public class LatexCreator implements StepVisitor { tree.insert(0, generateConclusion(varL, LABEL_VAR, UIC)); String typeAbstraction = generateTypeAbstraction(varL.getTypeAbsInPremise()); String instantiatedType = new LatexCreatorType(varL.getInstantiatedTypeAbs()).getLatex(); - String premiseRight = DOLLAR_SIGN + typeAbstraction + INSTANTIATE_SIGN + instantiatedType - + DOLLAR_SIGN + NEW_LINE; + String premiseRight = DOLLAR_SIGN + typeAbstraction + INSTANTIATE_SIGN + instantiatedType + DOLLAR_SIGN; String premiseLeft = AXC + CURLY_LEFT + DOLLAR_SIGN + ALIGN_BEGIN + generateVarStepPremise(varL).replace(DOLLAR_SIGN, "") + SPACE + LATEX_NEW_LINE + SPACE // todo less replacement fixups diff --git a/src/main/java/edu/kit/typicalc/view/content/typeinferencecontent/latexcreator/LatexCreatorConstants.java b/src/main/java/edu/kit/typicalc/view/content/typeinferencecontent/latexcreator/LatexCreatorConstants.java index a24e587..0a1e65c 100644 --- a/src/main/java/edu/kit/typicalc/view/content/typeinferencecontent/latexcreator/LatexCreatorConstants.java +++ b/src/main/java/edu/kit/typicalc/view/content/typeinferencecontent/latexcreator/LatexCreatorConstants.java @@ -74,6 +74,4 @@ public final class LatexCreatorConstants { protected static final String ALIGN_END = "\\end{aligned}"; protected static final String SPLIT_BEGIN = "\\begin{split}"; protected static final String SPLIT_END = "\\end{split}"; - - protected static final String BUSSPROOFS = "\\usepackage{bussproofs}"; } diff --git a/src/main/resources/language/general.properties b/src/main/resources/language/general.properties index 10da464..b7df9bd 100644 --- a/src/main/resources/language/general.properties +++ b/src/main/resources/language/general.properties @@ -79,4 +79,8 @@ root.varLetLatex=\ \ \\LeftLabel{\\textrm V{\\small AR}}\ \\BinaryInfC{$\\Gamma \\vdash \\texttt{x} : \\tau$}\ -\\end{prooftree} \ No newline at end of file +\\end{prooftree} + +share.neededPackages=\ +\\usepackage{bussproofs}\n\ +\\usepackage{amsmath} \ No newline at end of file From d3abb4f10c83176f6eae8cc4cb58b70c341b8c43 Mon Sep 17 00:00:00 2001 From: Moritz Dieing <63721811+moritzdieing@users.noreply.github.com> Date: Fri, 5 Mar 2021 17:11:14 +0100 Subject: [PATCH 2/4] Add title attribute to buttons --- .../typicalc/view/content/ControlPanel.java | 13 +++++++++- .../view/main/InferenceRuleField.java | 1 + .../edu/kit/typicalc/view/main/InputBar.java | 8 +++++-- .../edu/kit/typicalc/view/main/UpperBar.java | 24 ++++++++++++++----- .../language/translation_de.properties | 9 +++++++ .../language/translation_en.properties | 9 +++++++ 6 files changed, 55 insertions(+), 9 deletions(-) diff --git a/src/main/java/edu/kit/typicalc/view/content/ControlPanel.java b/src/main/java/edu/kit/typicalc/view/content/ControlPanel.java index 8936004..d9cb1ac 100644 --- a/src/main/java/edu/kit/typicalc/view/content/ControlPanel.java +++ b/src/main/java/edu/kit/typicalc/view/content/ControlPanel.java @@ -4,11 +4,13 @@ import com.vaadin.flow.component.button.Button; import com.vaadin.flow.component.icon.Icon; import com.vaadin.flow.component.icon.VaadinIcon; import com.vaadin.flow.component.orderedlayout.HorizontalLayout; +import com.vaadin.flow.i18n.LocaleChangeEvent; +import com.vaadin.flow.i18n.LocaleChangeObserver; /** * Provides a GUI in form of buttons for the user to navigate through steps. */ -public class ControlPanel extends HorizontalLayout { +public class ControlPanel extends HorizontalLayout implements LocaleChangeObserver { public static final String ID = "control-panel"; private final Button firstStep; @@ -85,4 +87,13 @@ public class ControlPanel extends HorizontalLayout { public void setEnabledShareButton(boolean setEnabled) { share.setEnabled(setEnabled); } + + @Override + public void localeChange(LocaleChangeEvent event) { + share.getElement().setAttribute("title", getTranslation("root.shareButtonTooltip")); + firstStep.getElement().setAttribute("title", getTranslation("root.firstStepTooltip")); + previousStep.getElement().setAttribute("title", getTranslation("root.previousStepTooltip")); + nextStep.getElement().setAttribute("title", getTranslation("root.nextStepTooltip")); + lastStep.getElement().setAttribute("title", getTranslation("root.lastStepTooltip")); + } } diff --git a/src/main/java/edu/kit/typicalc/view/main/InferenceRuleField.java b/src/main/java/edu/kit/typicalc/view/main/InferenceRuleField.java index ee89c7b..93674c7 100644 --- a/src/main/java/edu/kit/typicalc/view/main/InferenceRuleField.java +++ b/src/main/java/edu/kit/typicalc/view/main/InferenceRuleField.java @@ -71,6 +71,7 @@ public class InferenceRuleField extends VerticalLayout implements LocaleChangeOb @Override public void localeChange(LocaleChangeEvent event) { ruleName.setText(getTranslation(nameKey)); + copyButton.getElement().setAttribute("title", getTranslation("root.copyLatexTooltip")); } } 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 dc48e48..53c887a 100644 --- a/src/main/java/edu/kit/typicalc/view/main/InputBar.java +++ b/src/main/java/edu/kit/typicalc/view/main/InputBar.java @@ -39,8 +39,10 @@ public class InputBar extends HorizontalLayout implements LocaleChangeObserver { private static final short MAX_INPUT_LENGTH = 1000; private final transient Consumer>> callback; + private final Button infoIcon; private final TextField inputField; private TypeAssumptionsArea typeAssumptionsArea; + private final Button exampleButton; private final Button inferTypeButton; private final Button typeAssumptions; @@ -53,7 +55,7 @@ public class InputBar extends HorizontalLayout implements LocaleChangeObserver { protected InputBar(Consumer>> callback) { this.callback = callback; - Button infoIcon = new Button(new Icon(VaadinIcon.INFO_CIRCLE)); + infoIcon = new Button(new Icon(VaadinIcon.INFO_CIRCLE)); infoIcon.addClickListener(event -> onInfoIconClick()); inputField = new TextField(); @@ -79,7 +81,7 @@ public class InputBar extends HorizontalLayout implements LocaleChangeObserver { UI.getCurrent().getPage().executeJs("window.lambdaButtonListener($0, $1);", LAMBDA_BUTTON_ID, INPUT_FIELD_ID); typeAssumptions = new Button("", event -> onTypeAssumptionsButton()); typeAssumptionsArea = new TypeAssumptionsArea(); - Button exampleButton = new Button(VaadinIcon.PAPERCLIP.create(), event -> onExampleButtonClick()); + exampleButton = new Button(VaadinIcon.PAPERCLIP.create(), event -> onExampleButtonClick()); exampleButton.setId(EXAMPLE_BUTTON_ID); inferTypeButton = new Button("", event -> onTypeInferButtonClick()); inferTypeButton.addClickShortcut(Key.ENTER).listenOn(this); @@ -134,5 +136,7 @@ public class InputBar extends HorizontalLayout implements LocaleChangeObserver { inputField.setPlaceholder(getTranslation("root.inputFieldPlaceholder")); inferTypeButton.setText(getTranslation("root.typeInfer")); typeAssumptions.setText(getTranslation("root.typeAssumptions")); + infoIcon.getElement().setAttribute("title", getTranslation("root.inputSyntax")); + exampleButton.getElement().setAttribute("title", getTranslation("root.exampleTooltip")); } } diff --git a/src/main/java/edu/kit/typicalc/view/main/UpperBar.java b/src/main/java/edu/kit/typicalc/view/main/UpperBar.java index 1c32ce2..2fba615 100644 --- a/src/main/java/edu/kit/typicalc/view/main/UpperBar.java +++ b/src/main/java/edu/kit/typicalc/view/main/UpperBar.java @@ -9,6 +9,9 @@ import com.vaadin.flow.component.html.H1; import com.vaadin.flow.component.icon.Icon; import com.vaadin.flow.component.icon.VaadinIcon; import com.vaadin.flow.component.orderedlayout.HorizontalLayout; +import com.vaadin.flow.i18n.LocaleChangeEvent; +import com.vaadin.flow.i18n.LocaleChangeObserver; + import edu.kit.typicalc.view.main.MainView.MainViewListener; import org.apache.commons.lang3.tuple.Pair; @@ -20,7 +23,7 @@ import java.util.function.Consumer; * Contains all the components constantly shown in the upper part of the webpage. */ @CssImport("./styles/view/main/upper-bar.css") -public class UpperBar extends HorizontalLayout { +public class UpperBar extends HorizontalLayout implements LocaleChangeObserver { private static final long serialVersionUID = -7344967027514015830L; /* @@ -32,7 +35,9 @@ public class UpperBar extends HorizontalLayout { private static final String UPPER_BAR_ID = "header"; private final InputBar inputBar; - + private final Button toggle; + private final Button helpButton; + private final transient MainViewListener presenter; private final transient Consumer>> setTermInURL; @@ -47,15 +52,16 @@ public class UpperBar extends HorizontalLayout { this.presenter = presenter; this.setTermInURL = setTermInURL; + toggle = new DrawerToggle(); H1 viewTitle = new H1(new Anchor("/", getTranslation("root.typicalc"))); viewTitle.setId(VIEW_TITLE_ID); this.inputBar = new InputBar(this::typeInfer); inputBar.setId(INPUT_BAR_ID); - Button helpIcon = new Button(new Icon(VaadinIcon.QUESTION_CIRCLE)); - helpIcon.addClickListener(event -> onHelpIconClick()); - helpIcon.setId(HELP_ICON_ID); + helpButton = new Button(new Icon(VaadinIcon.QUESTION_CIRCLE)); + helpButton.addClickListener(event -> onHelpIconClick()); + helpButton.setId(HELP_ICON_ID); - add(new DrawerToggle(), viewTitle, inputBar, helpIcon); + add(toggle, viewTitle, inputBar, helpButton); setId(UPPER_BAR_ID); getThemeList().set("dark", true); setSpacing(false); @@ -94,4 +100,10 @@ public class UpperBar extends HorizontalLayout { Dialog helpDialog = new HelpDialog(); helpDialog.open(); } + + @Override + public void localeChange(LocaleChangeEvent event) { + toggle.getElement().setAttribute("title", getTranslation("root.drawerToggleTooltip")); + helpButton.getElement().setAttribute("title", getTranslation("root.helpIconTooltip")); + } } diff --git a/src/main/resources/language/translation_de.properties b/src/main/resources/language/translation_de.properties index 5f45830..b074a6c 100644 --- a/src/main/resources/language/translation_de.properties +++ b/src/main/resources/language/translation_de.properties @@ -101,6 +101,15 @@ root.text7=Der Teilen-Knopfs wird betätigt, um das entsprechende Dialogfenster root.image8=/carousel/UseExportDialog.png root.text8=In dem Dialogfenster sind der Permalink zur aktuellen Seite, der Latex-Code des Baums und die im Code \ verwendeten Pakete aufgelistet. +root.copyLatexTooltip=Kopiere LaTeX-code +root.drawerToggleTooltip=Ableitungsregeln +root.helpIconTooltip=Hilfe und Sprachwechsel +root.exampleTooltip=Beispielterme +root.shareButtonTooltip=LaTeX-Code und Permalink +root.lastStepTooltip=Letzter Schritt +root.firstStepTooltip=Erster Schritt +root.previousStepTooltip=Vorheriger Schritt +root.nextStepTooltip=Nächster Schritt root.absLetLatex=\ \\begin{prooftree}\ diff --git a/src/main/resources/language/translation_en.properties b/src/main/resources/language/translation_en.properties index 63542ce..a006223 100644 --- a/src/main/resources/language/translation_en.properties +++ b/src/main/resources/language/translation_en.properties @@ -94,6 +94,15 @@ root.text7=The share button is clicked to open up the corresponding dialog. root.image8=/carousel/UseExportDialog.png root.text8=The dialog contains a permalink to the current page, the LaTeX-code of the tree and the packages needed \ to compile the code. +root.copyLatexTooltip=Copy LaTeX code +root.drawerToggleTooltip=Type inference rules +root.helpIconTooltip=Help and language switch +root.exampleTooltip=Example terms +root.shareButtonTooltip=LaTeX code and permalink +root.lastStepTooltip=Last step +root.firstStepTooltip=First step +root.previousStepTooltip=Previous step +root.nextStepTooltip=Next step root.absLetLatex=\ \\begin{prooftree}\ From 3fd5de761148a5189a021d0cfff778bad88bf596 Mon Sep 17 00:00:00 2001 From: Moritz Dieing <63721811+moritzdieing@users.noreply.github.com> Date: Fri, 5 Mar 2021 17:44:37 +0100 Subject: [PATCH 3/4] Better hover for buttons --- frontend/styles/global.css | 4 ++++ frontend/styles/view/button-hover.css | 3 +++ frontend/styles/view/main/help-dialog.css | 3 ++- src/main/java/edu/kit/typicalc/view/main/UpperBar.java | 2 ++ 4 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 frontend/styles/view/button-hover.css diff --git a/frontend/styles/global.css b/frontend/styles/global.css index 8327a2f..934d593 100644 --- a/frontend/styles/global.css +++ b/frontend/styles/global.css @@ -5,3 +5,7 @@ vaadin-button { vaadin-button, iron-icon, vaadin-drawer-toggle { cursor: pointer; } + +#closeIcon:hover { + color: rgb(120, 120, 120); +} diff --git a/frontend/styles/view/button-hover.css b/frontend/styles/view/button-hover.css new file mode 100644 index 0000000..008a7a7 --- /dev/null +++ b/frontend/styles/view/button-hover.css @@ -0,0 +1,3 @@ +:host(:hover)::before { + opacity: 0.12; +} \ No newline at end of file diff --git a/frontend/styles/view/main/help-dialog.css b/frontend/styles/view/main/help-dialog.css index b1c21b3..d9e7379 100644 --- a/frontend/styles/view/main/help-dialog.css +++ b/frontend/styles/view/main/help-dialog.css @@ -15,7 +15,8 @@ #languageSelect { position: absolute; - right: 0; + margin: 0; + left: 0; } #accordion { diff --git a/src/main/java/edu/kit/typicalc/view/main/UpperBar.java b/src/main/java/edu/kit/typicalc/view/main/UpperBar.java index 2fba615..10751df 100644 --- a/src/main/java/edu/kit/typicalc/view/main/UpperBar.java +++ b/src/main/java/edu/kit/typicalc/view/main/UpperBar.java @@ -23,6 +23,8 @@ import java.util.function.Consumer; * Contains all the components constantly shown in the upper part of the webpage. */ @CssImport("./styles/view/main/upper-bar.css") +@CssImport(value = "./styles/view/button-hover.css", themeFor = "vaadin-button") +@CssImport(value = "./styles/view/button-hover.css", themeFor = "vaadin-drawer-toggle") public class UpperBar extends HorizontalLayout implements LocaleChangeObserver { private static final long serialVersionUID = -7344967027514015830L; From 4c00af90072a9addda2974feeb52affe2f865513 Mon Sep 17 00:00:00 2001 From: Johanna Stuber Date: Fri, 5 Mar 2021 18:16:23 +0100 Subject: [PATCH 4/4] fix exportLatexWithAssumptions test (failed due to icons that are now buttons) --- src/main/java/edu/kit/typicalc/view/main/InputBar.java | 2 ++ .../java/edu/kit/typicalc/view/pageobjects/InputBarElement.java | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) 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 53c887a..b24dd9c 100644 --- a/src/main/java/edu/kit/typicalc/view/main/InputBar.java +++ b/src/main/java/edu/kit/typicalc/view/main/InputBar.java @@ -35,6 +35,7 @@ public class InputBar extends HorizontalLayout implements LocaleChangeObserver { private static final String INFER_BUTTON_ID = "inferButton"; private static final String EXAMPLE_BUTTON_ID = "exampleButton"; private static final String LAMBDA_BUTTON_ID = "lambdaButton"; + private static final String ASS_BUTTON_ID = "assButton"; private static final short MAX_INPUT_LENGTH = 1000; @@ -80,6 +81,7 @@ public class InputBar extends HorizontalLayout implements LocaleChangeObserver { lambdaButton.setId(LAMBDA_BUTTON_ID); UI.getCurrent().getPage().executeJs("window.lambdaButtonListener($0, $1);", LAMBDA_BUTTON_ID, INPUT_FIELD_ID); typeAssumptions = new Button("", event -> onTypeAssumptionsButton()); + typeAssumptions.setId(ASS_BUTTON_ID); typeAssumptionsArea = new TypeAssumptionsArea(); exampleButton = new Button(VaadinIcon.PAPERCLIP.create(), event -> onExampleButtonClick()); exampleButton.setId(EXAMPLE_BUTTON_ID); diff --git a/src/test/java/edu/kit/typicalc/view/pageobjects/InputBarElement.java b/src/test/java/edu/kit/typicalc/view/pageobjects/InputBarElement.java index 71c17f4..80200ea 100644 --- a/src/test/java/edu/kit/typicalc/view/pageobjects/InputBarElement.java +++ b/src/test/java/edu/kit/typicalc/view/pageobjects/InputBarElement.java @@ -47,7 +47,7 @@ public class InputBarElement extends HorizontalLayoutElement { * Opens the type assumptions area. */ public void openTypeAssumptionsArea() { - $(ButtonElement.class).first().click(); + $(ButtonElement.class).id("assButton").click(); } }