From 82aa689084f00404b0950e99954e32ac23082067 Mon Sep 17 00:00:00 2001
From: Moritz Dieing <63721811+moritzdieing@users.noreply.github.com>
Date: Thu, 28 Jan 2021 13:20:44 +0100
Subject: [PATCH] InputBar und UpperBar erweitert
---
package.json | 8 +--
pnpm-lock.yaml | 18 +++++++
pom.xml | 5 ++
.../edu/kit/typicalc/presenter/Presenter.java | 18 +++++++
.../edu/kit/typicalc/view/main/InputBar.java | 51 +++++++++++++++++--
.../edu/kit/typicalc/view/main/MainView.java | 6 +++
.../kit/typicalc/view/main/MainViewImpl.java | 5 +-
.../edu/kit/typicalc/view/main/UpperBar.java | 30 +++++++----
.../language/translation_de.properties | 4 +-
9 files changed, 126 insertions(+), 19 deletions(-)
create mode 100644 src/main/java/edu/kit/typicalc/presenter/Presenter.java
diff --git a/package.json b/package.json
index 0771879..63c7436 100644
--- a/package.json
+++ b/package.json
@@ -41,7 +41,8 @@
"@vaadin/vaadin-radio-button": "1.5.1",
"lit-element": "2.3.1",
"@vaadin/vaadin-core-shrinkwrap": "18.0.5",
- "@vaadin/vaadin-date-picker": "4.4.1"
+ "@vaadin/vaadin-date-picker": "4.4.1",
+ "@vaadin-component-factory/vcf-tooltip": "1.3.13"
},
"devDependencies": {
"@types/validator": "13.1.0",
@@ -115,7 +116,8 @@
"@vaadin/vaadin-time-picker": "2.4.0",
"@vaadin/vaadin-tabs": "3.2.0",
"@vaadin/vaadin-radio-button": "1.5.1",
- "@vaadin/vaadin-rich-text-editor": "1.3.0"
+ "@vaadin/vaadin-rich-text-editor": "1.3.0",
+ "@vaadin-component-factory/vcf-tooltip": "1.3.13"
},
"devDependencies": {
"webpack-babel-multi-target-plugin": "2.3.3",
@@ -141,6 +143,6 @@
"lit-css-loader": "0.0.4",
"extract-loader": "5.1.0"
},
- "hash": "62511e127eb6b94b147718eaf87963a72562a63efa45b11debd35ee61e3cd13a"
+ "hash": "9a8381007196d77745c03255bc222102472ce461f37b2742f39962e71d14929a"
}
}
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index ebbcc78..9ac2c01 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -2,6 +2,7 @@ dependencies:
'@polymer/iron-icon': 3.0.1
'@polymer/iron-list': 3.1.0
'@polymer/polymer': 3.2.0
+ '@vaadin-component-factory/vcf-tooltip': 1.3.13
'@vaadin/flow-frontend': 'link:target/flow-frontend'
'@vaadin/form': 'link:target/flow-frontend/form'
'@vaadin/router': 1.7.2
@@ -1041,6 +1042,16 @@ packages:
dev: true
resolution:
integrity: sha512-gHUHI6pJaANIO2r6WcbT7+WMgbL9GZooR4tWpuBOETpDIqFNxwaJluE+6rj6VGYe8k6OkfhbHz2Fkm8kl06Igw==
+ /@vaadin-component-factory/vcf-tooltip/1.3.13:
+ dependencies:
+ '@polymer/polymer': 3.2.0
+ '@vaadin/vaadin-element-mixin': 2.4.2
+ '@vaadin/vaadin-license-checker': 2.1.2
+ '@vaadin/vaadin-lumo-styles': 1.6.1
+ '@vaadin/vaadin-themable-mixin': 1.6.2
+ dev: false
+ resolution:
+ integrity: sha512-UezXIbkSRapmdLw0KldI3l2VjU81kYIdpyZdC7Dpa+4XOv0e7sPaWhfbyHumQxAIN337DQrkkx0im8M6Y1f1jQ==
/@vaadin/router/1.7.2:
dependencies:
'@vaadin/vaadin-usage-statistics': 2.1.0
@@ -1323,6 +1334,12 @@ packages:
dev: false
resolution:
integrity: sha512-hG1MQ8cLaFlsoqSZFm8bqXrHxMry6vtkJrpiXArxpaZXMwPkJnfrUT3D6Qm/NG/rZHvOzZa5U/1k5+dyledlHA==
+ /@vaadin/vaadin-license-checker/2.1.2:
+ dependencies:
+ '@vaadin/vaadin-development-mode-detector': 2.0.4
+ dev: false
+ resolution:
+ integrity: sha512-oD6/MoavXyIZp6NWhkbJD5RKrpiWohhaQpgqjM0bFIthRr+1NoiG5R1w0uY3NIdMDuaXlsUFSQJ/Viz1v7F/jQ==
/@vaadin/vaadin-list-box/1.4.0:
dependencies:
'@polymer/polymer': 3.2.0
@@ -7336,6 +7353,7 @@ specifiers:
'@polymer/iron-list': 3.1.0
'@polymer/polymer': 3.2.0
'@types/validator': 13.1.0
+ '@vaadin-component-factory/vcf-tooltip': 1.3.13
'@vaadin/flow-frontend': ./target/flow-frontend
'@vaadin/form': ./target/flow-frontend/form
'@vaadin/router': 1.7.2
diff --git a/pom.xml b/pom.xml
index fc13d67..ba903ae 100644
--- a/pom.xml
+++ b/pom.xml
@@ -116,6 +116,11 @@
5.7.0
test
+
+ com.vaadin.componentfactory
+ tooltip
+ 1.3.4
+
diff --git a/src/main/java/edu/kit/typicalc/presenter/Presenter.java b/src/main/java/edu/kit/typicalc/presenter/Presenter.java
new file mode 100644
index 0000000..bfbe837
--- /dev/null
+++ b/src/main/java/edu/kit/typicalc/presenter/Presenter.java
@@ -0,0 +1,18 @@
+package edu.kit.typicalc.presenter;
+
+import java.util.Map;
+import edu.kit.typicalc.model.Model;
+import edu.kit.typicalc.view.main.MainView;
+import edu.kit.typicalc.view.main.MainView.MainViewListener;
+
+public class Presenter implements MainViewListener {
+
+ public Presenter(final Model model, final MainView view) {
+
+ }
+
+ @Override
+ public void typeInferLambdaString(String lambdaTerm, Map typeAssumptions) {
+ // TODO Auto-generated method stub
+ }
+}
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 fadf132..402a9ca 100644
--- a/src/main/java/edu/kit/typicalc/view/main/InputBar.java
+++ b/src/main/java/edu/kit/typicalc/view/main/InputBar.java
@@ -1,19 +1,62 @@
package edu.kit.typicalc.view.main;
+import java.util.Optional;
+import java.util.function.Consumer;
+import org.apache.commons.lang3.StringUtils;
+import com.vaadin.componentfactory.Tooltip;
+import com.vaadin.flow.component.button.Button;
+import com.vaadin.flow.component.combobox.ComboBox;
+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;
public class InputBar extends HorizontalLayout implements LocaleChangeObserver {
+ private final Tooltip infoTooltip;
+ private final Icon infoIcon;
+ private final Button lambdaButton;
+ private final ComboBox inputField;
+ private final Button inferTypeButton;
- public InputBar() {
- //TODO implement
+ protected InputBar(final Consumer callback) {
+ infoIcon = new Icon(VaadinIcon.INFO_CIRCLE);
+ infoTooltip = new Tooltip();
+ initInfoTooltip();
+ infoTooltip.attachToComponent(infoIcon);
+
+ lambdaButton = new Button(getTranslation("root.lambda"), event -> onlambdaButtonClick());
+ inputField = new ComboBox<>();
+ initComboBox();
+ inferTypeButton = new Button(getTranslation("root.typeInfer"), event -> onTypeInferButtonClick(callback));
+
+ //TODO add components to layout
+ }
+
+ private void onTypeInferButtonClick(final Consumer callback) {
+ final Optional currentInput = inputField.getOptionalValue();
+ currentInput.ifPresentOrElse(callback::accept, () -> callback.accept(StringUtils.EMPTY));
+ }
+
+ private void onlambdaButtonClick() {
+ final StringBuilder inputBuilder = new StringBuilder();
+ final Optional currentInput = inputField.getOptionalValue();
+ currentInput.ifPresent(inputBuilder::append);
+ inputBuilder.append(getTranslation("root.lambda"));
+ inputField.setValue(inputBuilder.toString());
+ }
+
+ private void initComboBox() {
+ // TODO add examples to the combo box here
+ }
+
+ private void initInfoTooltip() {
+ //TODO add text too info tooltip here
}
@Override
public void localeChange(LocaleChangeEvent event) {
- // TODO Auto-generated method stub
-
+ inferTypeButton.setText(getTranslation("root.typeInfer"));
}
}
diff --git a/src/main/java/edu/kit/typicalc/view/main/MainView.java b/src/main/java/edu/kit/typicalc/view/main/MainView.java
index b55a795..f55c992 100644
--- a/src/main/java/edu/kit/typicalc/view/main/MainView.java
+++ b/src/main/java/edu/kit/typicalc/view/main/MainView.java
@@ -1,5 +1,6 @@
package edu.kit.typicalc.view.main;
+import java.util.Map;
import edu.kit.typicalc.model.TypeInfererInterface;
import edu.kit.typicalc.model.parser.ParseError;
@@ -23,4 +24,9 @@ public interface MainView {
* @param error the error which is displayed to indicate invalid input
*/
void displayError(ParseError error);
+
+ public interface MainViewListener {
+
+ public void typeInferLambdaString(String lambdaTerm, Map typeAssumptions);
+ }
}
diff --git a/src/main/java/edu/kit/typicalc/view/main/MainViewImpl.java b/src/main/java/edu/kit/typicalc/view/main/MainViewImpl.java
index 00f9ce4..3ae86e3 100644
--- a/src/main/java/edu/kit/typicalc/view/main/MainViewImpl.java
+++ b/src/main/java/edu/kit/typicalc/view/main/MainViewImpl.java
@@ -17,9 +17,11 @@ import com.vaadin.flow.component.orderedlayout.FlexComponent;
import com.vaadin.flow.component.orderedlayout.HorizontalLayout;
import com.vaadin.flow.component.orderedlayout.VerticalLayout;
import com.vaadin.flow.component.tabs.Tabs;
+import edu.kit.typicalc.model.ModelImpl;
import edu.kit.typicalc.model.TypeInfererInterface;
import edu.kit.typicalc.model.parser.ParseError;
import edu.kit.typicalc.view.content.typeinferencecontent.TypeInferenceView;
+import edu.kit.typicalc.presenter.Presenter;
/**
* The main view is a top-level placeholder for other views.
@@ -32,7 +34,8 @@ public class MainViewImpl extends AppLayout implements MainView {
public MainViewImpl() {
setDrawerOpened(false);
- addToNavbar(true, new UpperBar());
+ MainViewListener presenter = new Presenter(new ModelImpl(), this);
+ addToNavbar(true, new UpperBar(presenter));
addToDrawer(new DrawerContent());
}
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 eff66f4..9940ad2 100644
--- a/src/main/java/edu/kit/typicalc/view/main/UpperBar.java
+++ b/src/main/java/edu/kit/typicalc/view/main/UpperBar.java
@@ -11,6 +11,7 @@ import com.vaadin.flow.component.orderedlayout.HorizontalLayout;
import com.vaadin.flow.i18n.LocaleChangeEvent;
import com.vaadin.flow.i18n.LocaleChangeObserver;
import edu.kit.typicalc.view.content.infocontent.StartPageView;
+import edu.kit.typicalc.view.main.MainView.MainViewListener;
@CssImport("./styles/view/main/upper-bar.css")
public class UpperBar extends HorizontalLayout implements LocaleChangeObserver {
@@ -19,21 +20,30 @@ public class UpperBar extends HorizontalLayout implements LocaleChangeObserver {
private final InputBar inputBar;
private final Icon helpDialogIcon;
- public UpperBar() {
+ private final MainViewListener presenter;
+
+ protected UpperBar(final MainViewListener presenter) {
+ this.presenter = presenter;
+
+ add(new DrawerToggle());
+ this.viewTitle = new H1(getTranslation("root.typicalc"));
+ viewTitle.setId("viewTitle");
+ this.inputBar = new InputBar(null); //TODO init correctly
+ this.helpDialogIcon = new Icon(VaadinIcon.QUESTION_CIRCLE);
+ helpDialogIcon.setId("icon");
+
+ viewTitle.addClickListener(event -> this.getUI().get().navigate(StartPageView.class));
+
+ add(viewTitle, inputBar, helpDialogIcon);
setId("header");
getThemeList().set("dark", true);
setWidthFull();
setSpacing(false);
setAlignItems(FlexComponent.Alignment.CENTER);
- add(new DrawerToggle());
- this.viewTitle = new H1(getTranslation("root.typicalc"));
- viewTitle.setId("viewTitle");
- this.inputBar = new InputBar();
- this.helpDialogIcon = new Icon(VaadinIcon.QUESTION_CIRCLE);
- helpDialogIcon.setId("icon");
-
- viewTitle.addClickListener(event -> this.getUI().get().navigate(StartPageView.class));
- add(viewTitle, inputBar, helpDialogIcon);
+ }
+
+ protected void typeInfer() {
+ //TODO implement
}
private void createHelpDialog() {
diff --git a/src/main/resources/language/translation_de.properties b/src/main/resources/language/translation_de.properties
index abd5c11..77cc255 100644
--- a/src/main/resources/language/translation_de.properties
+++ b/src/main/resources/language/translation_de.properties
@@ -11,4 +11,6 @@ abs-rule=\\begin{prooftree}\
\\end{prooftree}
test=hello world
-root.typicalc=Typicalc
\ No newline at end of file
+root.typicalc=Typicalc
+root.lambda=\u03BB
+root.typeInfer=Typisieren
\ No newline at end of file