diff --git a/frontend/src/mathjax-unification.ts b/frontend/src/mathjax-unification.ts
index cec8a08..9e2f98d 100644
--- a/frontend/src/mathjax-unification.ts
+++ b/frontend/src/mathjax-unification.ts
@@ -1,10 +1,7 @@
import {MathjaxAdapter} from "./mathjax-adapter";
import {TemplateResult} from "lit-html";
-import {html} from "lit-element";
class MathjaxUnification extends MathjaxAdapter {
- private content: String = "Loading...";
- private latex: String[] = [];
static get properties() {
return {
@@ -13,21 +10,12 @@ class MathjaxUnification extends MathjaxAdapter {
}
render(): TemplateResult {
- return html`
- ${this.content}
- `;
+ return super.render();
}
- protected showStep(n: number): void {
- this.content = this.latex[n];
+ protected showStep(_n: number): void {
this.requestTypeset();
}
-
- public setTex(tex: String): void {
- console.log(tex);
- this.latex.push(tex);
- console.log(this.latex)
- }
}
customElements.define('tc-unification', MathjaxUnification);
\ No newline at end of file
diff --git a/frontend/styles/view/main/info-dialog.css b/frontend/styles/view/main/info-dialog.css
new file mode 100644
index 0000000..f1c4799
--- /dev/null
+++ b/frontend/styles/view/main/info-dialog.css
@@ -0,0 +1,9 @@
+#infoHeader {
+ width: 30vw;
+ align-items: center;
+ justify-content: center;
+}
+
+#infoContent {
+ height: 50vh;
+}
\ No newline at end of file
diff --git a/package.json b/package.json
index 7df1c08..87fa61b 100644
--- a/package.json
+++ b/package.json
@@ -101,12 +101,12 @@
"@vaadin/vaadin-time-picker": "2.4.0",
"@vaadin/vaadin-context-menu": "4.5.0",
"@vaadin/vaadin-avatar": "1.0.3",
- "@vaadin-component-factory/vcf-tooltip": "1.3.13",
"@vaadin/vaadin-radio-button": "1.5.1",
"@vaadin/vaadin-tabs": "3.2.0",
"@vaadin/vaadin-lumo-styles": "1.6.0",
"@vaadin/vaadin-material-styles": "1.3.2",
- "open": "^7.2.1"
+ "open": "^7.2.1",
+ "@vaadin-component-factory/vcf-tooltip": "1.3.13"
},
"devDependencies": {
"compression-webpack-plugin": "4.0.1",
diff --git a/pom.xml b/pom.xml
index 0375864..be2923f 100644
--- a/pom.xml
+++ b/pom.xml
@@ -147,11 +147,6 @@
5.7.0
test
-
- com.vaadin.componentfactory
- tooltip
- 1.3.4
-
diff --git a/src/main/java/edu/kit/typicalc/model/TypeInferenceResult.java b/src/main/java/edu/kit/typicalc/model/TypeInferenceResult.java
index 0dd73bc..b8e878b 100644
--- a/src/main/java/edu/kit/typicalc/model/TypeInferenceResult.java
+++ b/src/main/java/edu/kit/typicalc/model/TypeInferenceResult.java
@@ -14,7 +14,7 @@ import java.util.List;
*/
public class TypeInferenceResult {
- private final List MGU;
+ private final List mgu;
private final Type finalType;
/**
@@ -27,7 +27,7 @@ public class TypeInferenceResult {
* @param typeVar the type variable belonging to the original lambda term
*/
protected TypeInferenceResult(List substitutions, TypeVariable typeVar) {
- MGU = new ArrayList<>(substitutions);
+ mgu = new ArrayList<>(substitutions);
findMGU();
MGU.sort(Comparator.comparingInt((Substitution o) ->
o.getVariable().getIndex()).thenComparing(o -> o.getVariable().getKind()));
@@ -35,10 +35,10 @@ public class TypeInferenceResult {
}
private void findMGU() {
- for (int i = 0; i < MGU.size(); i++) {
- Substitution applySub = MGU.get(i);
- for (int j = 0; j < MGU.size(); j++) {
- Substitution toSub = MGU.get(j);
+ for (int i = 0; i < mgu.size(); i++) {
+ Substitution applySub = mgu.get(i);
+ for (int j = 0; j < mgu.size(); j++) {
+ Substitution toSub = mgu.get(j);
if (i == j) {
continue;
} else if (applySub.getVariable().equals(toSub.getVariable())) {
@@ -49,13 +49,13 @@ public class TypeInferenceResult {
}
Substitution resultSub = new Substitution(toSub.getVariable(), toSub.getType().substitute(applySub));
- MGU.set(j, resultSub);
+ mgu.set(j, resultSub);
}
}
}
private Type findFinalType(TypeVariable typeVar) {
- for (Substitution substitution : MGU) {
+ for (Substitution substitution : mgu) {
if (substitution.getVariable().equals(typeVar)) {
return substitution.getType();
}
@@ -71,7 +71,7 @@ public class TypeInferenceResult {
* @return the most general unifier, null if there is no valid mgu
*/
protected List getMGU() {
- return MGU;
+ return mgu;
}
/**
diff --git a/src/main/java/edu/kit/typicalc/view/content/typeinferencecontent/MathjaxUnification.java b/src/main/java/edu/kit/typicalc/view/content/typeinferencecontent/MathjaxUnification.java
index 3cd49c0..490170f 100644
--- a/src/main/java/edu/kit/typicalc/view/content/typeinferencecontent/MathjaxUnification.java
+++ b/src/main/java/edu/kit/typicalc/view/content/typeinferencecontent/MathjaxUnification.java
@@ -2,7 +2,9 @@ package edu.kit.typicalc.view.content.typeinferencecontent;
import com.vaadin.flow.component.Tag;
import com.vaadin.flow.component.dependency.JsModule;
+import com.vaadin.flow.component.html.Div;
import com.vaadin.flow.component.littemplate.LitTemplate;
+import com.vaadin.flow.component.template.Id;
import edu.kit.typicalc.view.MathjaxAdapter;
/**
@@ -16,6 +18,9 @@ public class MathjaxUnification extends LitTemplate implements MathjaxAdapter {
private final String[] latex;
+ @Id("tc-content")
+ private Div content;
+
/**
* Creates a new HTML element that renders the constraints and unification and
* calculates the steps.
@@ -23,9 +28,6 @@ public class MathjaxUnification extends LitTemplate implements MathjaxAdapter {
*/
public MathjaxUnification(String[] latex) {
this.latex = latex;
- for (String s : latex) {
- getElement().callJsFunction("setTex", s);
- }
showStep(0);
}
@@ -36,6 +38,10 @@ public class MathjaxUnification extends LitTemplate implements MathjaxAdapter {
@Override
public void showStep(int n) {
+ if (n < latex.length) {
+ content.removeAll();
+ content.add(latex[n]);
+ }
getElement().callJsFunction("showStep", n);
}
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 9e9d282..4afc37f 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
@@ -1,11 +1,14 @@
package edu.kit.typicalc.view.content.typeinferencecontent;
+import com.vaadin.flow.component.AttachEvent;
+import com.vaadin.flow.component.ComponentEventListener;
import com.vaadin.flow.component.ComponentUtil;
import com.vaadin.flow.component.UI;
import com.vaadin.flow.component.html.Div;
import com.vaadin.flow.component.orderedlayout.Scroller;
import com.vaadin.flow.component.orderedlayout.VerticalLayout;
import com.vaadin.flow.router.PageTitle;
+import com.vaadin.flow.router.PreserveOnRefresh;
import com.vaadin.flow.router.Route;
import edu.kit.typicalc.model.TypeInfererInterface;
import edu.kit.typicalc.view.content.ControlPanel;
@@ -14,8 +17,9 @@ import edu.kit.typicalc.view.main.MainViewImpl;
@Route(value = "visualize", layout = MainViewImpl.class)
@PageTitle("TypeInferenceView")
+@PreserveOnRefresh
public class TypeInferenceView extends VerticalLayout
- implements ControlPanelView {
+ implements ControlPanelView, ComponentEventListener {
private int currentStep = 0;
@@ -29,6 +33,7 @@ public class TypeInferenceView extends VerticalLayout
typeInferer = ComponentUtil.getData(UI.getCurrent(), TypeInfererInterface.class);
setId("type-inference-view");
setSizeFull();
+ addAttachListener(this);
content = new Div();
controlPanel = new ControlPanel(this);
Scroller scroller = new Scroller(content);
@@ -80,4 +85,10 @@ public class TypeInferenceView extends VerticalLayout
currentStep = currentStep > 0 ? currentStep - 1 : currentStep;
refreshElements(currentStep);
}
+
+ @Override
+ public void onComponentEvent(AttachEvent attachEvent) {
+ currentStep = 0;
+ refreshElements(currentStep);
+ }
}
diff --git a/src/main/java/edu/kit/typicalc/view/main/DrawerContent.java b/src/main/java/edu/kit/typicalc/view/main/DrawerContent.java
index 2fe7933..516d9cd 100644
--- a/src/main/java/edu/kit/typicalc/view/main/DrawerContent.java
+++ b/src/main/java/edu/kit/typicalc/view/main/DrawerContent.java
@@ -15,7 +15,7 @@ public class DrawerContent extends VerticalLayout implements LocaleChangeObserve
private static final long serialVersionUID = -5751275682270653335L;
/*
- * IDs for the imported CSS file
+ * IDs for the imported .css-file
*/
private static final String RULE_CONTAINER_ID = "ruleContainer";
private static final String DRAWER_CONTENT_ID = "drawerContent";
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 4ca2e3c..b02346e 100644
--- a/src/main/java/edu/kit/typicalc/view/main/HelpDialog.java
+++ b/src/main/java/edu/kit/typicalc/view/main/HelpDialog.java
@@ -17,7 +17,7 @@ public class HelpDialog extends Dialog implements LocaleChangeObserver {
private static final long serialVersionUID = 4470277770276296164L;
/*
- * IDs for the imported CSS file
+ * IDs for the imported .css-file
*/
private static final String HEADING_LAYOUT_ID = "headingLayout";
private static final String CONTENT_LAYOUT_ID = "contentLayout";
@@ -35,6 +35,7 @@ public class HelpDialog extends Dialog implements LocaleChangeObserver {
headingLayout.add(heading);
final VerticalLayout contentLayout = new VerticalLayout();
+ //TODO inputSyntax wird im inputDialog behandelt --> hier anderer Content
inputSyntax = new H5(getTranslation("root.inputSyntax"));
contentLayout.setId(CONTENT_LAYOUT_ID);
contentLayout.add(inputSyntax);
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 ac0ba61..a984312 100644
--- a/src/main/java/edu/kit/typicalc/view/main/InferenceRuleField.java
+++ b/src/main/java/edu/kit/typicalc/view/main/InferenceRuleField.java
@@ -24,7 +24,7 @@ public class InferenceRuleField extends VerticalLayout implements LocaleChangeOb
private static final long serialVersionUID = -8551851183297707985L;
/*
- * Id's for the imported css-file
+ * IDs for the imported .css-file
*/
private static final String INFERENCE_RULE_FIELD_ID = "inferenceRuleField";
private static final String HEADER_ID = "headerField";
diff --git a/src/main/java/edu/kit/typicalc/view/main/InfoDialog.java b/src/main/java/edu/kit/typicalc/view/main/InfoDialog.java
new file mode 100644
index 0000000..54814eb
--- /dev/null
+++ b/src/main/java/edu/kit/typicalc/view/main/InfoDialog.java
@@ -0,0 +1,45 @@
+package edu.kit.typicalc.view.main;
+
+import com.vaadin.flow.component.dependency.CssImport;
+import com.vaadin.flow.component.dialog.Dialog;
+import com.vaadin.flow.component.html.H4;
+import com.vaadin.flow.component.orderedlayout.HorizontalLayout;
+import com.vaadin.flow.component.orderedlayout.VerticalLayout;
+import com.vaadin.flow.i18n.LocaleChangeEvent;
+import com.vaadin.flow.i18n.LocaleChangeObserver;
+
+/**
+ * Dialog which contains information on the correct syntax for the users input.
+ */
+@CssImport("./styles/view/main/info-dialog.css")
+public class InfoDialog extends Dialog implements LocaleChangeObserver {
+
+ private static final long serialVersionUID = 2914411566361539614L;
+
+ /*
+ * IDs for the imported .css-file
+ */
+ private static final String INFO_HEADER_ID = "infoHeader";
+ private static final String INFO_CONTENT_ID = "infoContent";
+
+ private final H4 heading;
+
+ /**
+ * Creates new InfoDialog.
+ */
+ protected InfoDialog() {
+ heading = new H4(getTranslation("root.inputSyntax"));
+ HorizontalLayout infoHeader = new HorizontalLayout(heading);
+ infoHeader.setId(INFO_HEADER_ID);
+
+ //TODO fill with content
+ VerticalLayout infoContent = new VerticalLayout();
+ infoContent.setId(INFO_CONTENT_ID);
+ add(infoHeader, infoContent);
+ }
+
+ @Override
+ public void localeChange(LocaleChangeEvent event) {
+ heading.setText(getTranslation("root.inputSyntax"));
+ }
+}
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 a1e2296..d88eddd 100644
--- a/src/main/java/edu/kit/typicalc/view/main/InputBar.java
+++ b/src/main/java/edu/kit/typicalc/view/main/InputBar.java
@@ -6,13 +6,10 @@ import java.util.function.Consumer;
import com.vaadin.flow.component.textfield.TextField;
import org.apache.commons.lang3.StringUtils;
-import com.vaadin.componentfactory.Tooltip;
-import com.vaadin.componentfactory.TooltipAlignment;
-import com.vaadin.componentfactory.TooltipPosition;
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.html.H5;
+import com.vaadin.flow.component.dialog.Dialog;
import com.vaadin.flow.component.icon.Icon;
import com.vaadin.flow.component.icon.VaadinIcon;
import com.vaadin.flow.component.orderedlayout.HorizontalLayout;
@@ -27,12 +24,11 @@ public class InputBar extends HorizontalLayout implements LocaleChangeObserver {
private static final long serialVersionUID = -6099700300418752958L;
/*
- * Id's for the imported css-file
+ * IDs for the imported .css-file
*/
private static final String INPUT_FIELD_ID = "inputField";
private static final String INPUT_BAR_ID = "inputBar";
- private final Tooltip infoTooltip;
private final Icon infoIcon;
private final Button exampleButton;
private final Button lambdaButton;
@@ -47,11 +43,8 @@ public class InputBar extends HorizontalLayout implements LocaleChangeObserver {
*/
protected InputBar(final Consumer callback) {
infoIcon = new Icon(VaadinIcon.INFO_CIRCLE);
- // TODO: where is this tooltip supposed to show up? next to icon, currently not working
- infoTooltip = new Tooltip(infoIcon, TooltipPosition.LEFT, TooltipAlignment.LEFT);
- infoTooltip.add(new H5("Hallo"));
- initInfoTooltip();
-
+ infoIcon.addClickListener(event -> onInfoIconClick());
+
inputField = new TextField();
inputField.setId(INPUT_FIELD_ID);
inputField.setClearButtonVisible(true);
@@ -68,7 +61,7 @@ public class InputBar extends HorizontalLayout implements LocaleChangeObserver {
inferTypeButton = new Button(getTranslation("root.typeInfer"), event -> onTypeInferButtonClick(callback));
inferTypeButton.addThemeVariants(ButtonVariant.LUMO_PRIMARY);
- add(infoTooltip, infoIcon, exampleButton, lambdaButton, inputField, inferTypeButton);
+ add(infoIcon, exampleButton, lambdaButton, inputField, inferTypeButton);
setId(INPUT_BAR_ID);
}
@@ -87,12 +80,13 @@ public class InputBar extends HorizontalLayout implements LocaleChangeObserver {
}
private void onExampleButtonClick() {
- ExampleDialog exampleDialog = new ExampleDialog(inputField::setValue);
+ final Dialog exampleDialog = new ExampleDialog(inputField::setValue);
exampleDialog.open();
}
- private void initInfoTooltip() {
- infoTooltip.add(new H5("Hallo"));
+ private void onInfoIconClick() {
+ final Dialog infoDialog = new InfoDialog();
+ infoDialog.open();
}
@Override
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 0347049..49ca41d 100644
--- a/src/main/java/edu/kit/typicalc/view/main/UpperBar.java
+++ b/src/main/java/edu/kit/typicalc/view/main/UpperBar.java
@@ -21,7 +21,7 @@ public class UpperBar extends HorizontalLayout {
private static final long serialVersionUID = -7344967027514015830L;
/*
- * Id's for the imported css-file
+ * IDs for the imported .css-file
*/
private static final String VIEW_TITLE_ID = "viewTitle";
private static final String INPUT_BAR_ID = "inputBar";