Add typeInfer button to helpDialog

This commit is contained in:
Moritz Dieing 2021-02-16 16:17:02 +01:00
parent 8c77bd62e5
commit 49c767bd0f
5 changed files with 29 additions and 7 deletions

View File

@ -2,7 +2,7 @@
width: 1000px !important;
padding-left: 0;
padding-right: 0;
height: 500px;
height: 525px;
}
#headingLayout {
@ -22,6 +22,10 @@
width: 100%;
}
#typeButtonCopy {
min-width: 110px;
}
.help-field {
justify-content: center;
align-items: center;

View File

@ -47,7 +47,7 @@ public class ErrorNotification extends Notification {
additionalInformation.setId(ADDITIONAL_INFO_ID);
Paragraph summary = new Paragraph(getTranslation("root." + error.toString()));
summary.setId(ERROR_SUMMARY_ID);
Details generalInformation = new Details(summary, additionalInformation);
Details errorMessage = new Details(summary, additionalInformation);
if (error == ParseError.TOO_FEW_TOKENS) {
additionalInformation.add(new Span(getTranslation("root.tooFewTokensHelp")));
@ -56,6 +56,6 @@ public class ErrorNotification extends Notification {
additionalInformation.add(new Span(getTranslation("root.position") + error.getCause().getPos()));
}
return generalInformation;
return errorMessage;
}
}

View File

@ -5,6 +5,7 @@ import com.vaadin.flow.component.UI;
import com.vaadin.flow.component.accordion.Accordion;
import com.vaadin.flow.component.applayout.DrawerToggle;
import com.vaadin.flow.component.button.Button;
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;
@ -32,10 +33,12 @@ public class HelpDialog extends Dialog implements LocaleChangeObserver {
private static final String CONTENT_LAYOUT_ID = "contentLayout";
private static final String LANGUAGE_SELECT_ID = "languageSelect";
private static final String ACCORDION_ID = "accordion";
private static final String TYPE_BUTTON_COPY_ID = "typeButtonCopy";
private final H3 heading;
private final Select<Locale> languageSelect;
private final ItemLabelGenerator<Locale> renderer;
private final Button typeButtonCopy;
/**
* Create a new HelpDialog.
@ -53,6 +56,9 @@ public class HelpDialog extends Dialog implements LocaleChangeObserver {
headingLayout.add(heading, languageSelect);
VerticalLayout contentLayout = new VerticalLayout();
typeButtonCopy = new Button(getTranslation("root.typeInfer"));
typeButtonCopy.addThemeVariants(ButtonVariant.LUMO_PRIMARY);
typeButtonCopy.setId(TYPE_BUTTON_COPY_ID);
Accordion content = createHelpContent();
content.setId(ACCORDION_ID);
contentLayout.add(content);
@ -67,6 +73,7 @@ public class HelpDialog extends Dialog implements LocaleChangeObserver {
new Button(getTranslation("root.examplebutton")), "root.helpExample"));
acc.add(new HelpContentField("root.inputField", "root.helpInputField"));
acc.add(new HelpContentField("root.typeAssumptions", "root.helpTypeAssumptions"));
acc.add(new HelpContentField("root.typeInferButton", typeButtonCopy, "root.helpTypeInferButton"));
acc.add(new HelpContentField("root.firstStepButton",
new Button(new Icon(VaadinIcon.ANGLE_DOUBLE_LEFT)), "root.helpFirstStepButton"));
acc.add(new HelpContentField("root.previousStepButton",
@ -84,6 +91,7 @@ public class HelpDialog extends Dialog implements LocaleChangeObserver {
public void localeChange(LocaleChangeEvent event) {
heading.setText(getTranslation("root.operatingHelp"));
languageSelect.setLabel(getTranslation("root.selectLanguage"));
typeButtonCopy.setText(getTranslation("root.typeInfer"));
languageSelect.setTextRenderer(renderer);
}
}

View File

@ -26,6 +26,7 @@ root.type=Typ
root.drawer=Drawer
root.example=Beispiele
root.inputField=Eingabefeld
root.typeInferButton=Typisieren Knopf
root.firstStepButton=Erster-Schritt Knopf
root.previousStepButton=Vorheriger-Schritt Knopf
root.nextStepButton=Nächster-Schritt Knopf
@ -44,7 +45,11 @@ angezeigt.
root.helpTypeAssumptions=Durch Klicken des Typannahmen-Knopfs öffnet sich ein Dialog zur Eingabe von Typannahmen. \
Durch Klicken des Info-Symbols wird die korrekte Syntax des Typs einer Typannahme angezeigt. Sofern eine Variable in \
mehreren Typannahmen vorkommt, wird ausschließlich die oberste Typannahme, die diese Variable enthält, \
berücksichtigt.
berücksichtigt. Falls der Typ einer Typannahme mit einem 't' beginnt und anschließend nur Ziffern folgen, wird der Typ \
automatisch zu einer Typvariable.
root.helpTypeInferButton=Durch Klicken des Typisieren-Knopfs wird die Berechnung des Typinferenzalgorithmus mit \
der aktuellen Eingabe gestartet. Je größer der Term desto länger dauert das Anzeigen des Typherleitungsbaums. Bei sehr \
großer Eingabe oder einem langsamen Rechner wird also etwas Geduld benötigt.
root.helpFirstStepButton=Je nach Stand der Algorithmusausführung ändert sich die FunKtion des Knopfs. \
Wenn aktuell der Baum aufgebaut wird, springt die Anzeige nach Klicken des Knopfs zurück zum ersten Schritt des \
Typherleitungsbaums. Wenn bereits die Unifikation druchgeführt wird, sprigt die Anzeige nach Klicken des Knopfs \

View File

@ -28,6 +28,7 @@ root.message404="Try /infer/<term> or type your favourite term into the input fi
root.drawer=Drawer
root.example=Examples
root.inputField=Input Field
root.typeInferButton=Type Button
root.firstStepButton=First Step Button
root.previousStepButton=Previous Step Button
root.nextStepButton=Next Step Button
@ -40,11 +41,15 @@ term is inserted into the input field. Now either the type inference algorithm c
modified.
root.helpInputField=The input field allows the user to enter lambda terms with a maximum length of 1000 characters. \
The \u03BB-sign can be inserted at the current cursor position by either clicking the \u03BB-button or entering a \
backslash. By clicking on the info-symbol the grammar defining the valid input synatx is shown.
backslash. By clicking on the info-symbol the grammar defining the valid input syntax is shown.
root.helpTypeAssumptions=Clicking on the type-assumptions-button opens up a dialog to enter type assumptions. \
By clicking the info-symbol the grammar defining a valid type of a type assmuption is shown. If the same variable \
By clicking the info-symbol the grammar defining a valid type of a type assumption is shown. If the same variable \
is contained in multiple type assumptions, only the uppermost type assumption containing the variable is used for \
the algorithm.
the algorithm. If the type of a type assumptions starts with a 't' followed by only digits, the type is automatically \
converted to a type variable.
root.helpTypeInferButton=Clicking on the type button starts the type inference algorithm for the current input. \
The longer the entered term the longer the time to display the type inference tree. With a slow computer or a \
very long term a lot of patience will be required.
root.helpFirstStepButton=The function of the button depends on the current state of the algorithm execution. \
If the tree is currently being built up, clicking on the button shows the first step of the inference tree. \
If the unification algorithm is already in progress, clicking on the button shows the last step of the inference \