InputBar und UpperBar erweitert

This commit is contained in:
Moritz Dieing 2021-01-28 13:20:44 +01:00
parent 5ea11e66a0
commit 82aa689084
9 changed files with 126 additions and 19 deletions

View File

@ -41,7 +41,8 @@
"@vaadin/vaadin-radio-button": "1.5.1", "@vaadin/vaadin-radio-button": "1.5.1",
"lit-element": "2.3.1", "lit-element": "2.3.1",
"@vaadin/vaadin-core-shrinkwrap": "18.0.5", "@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": { "devDependencies": {
"@types/validator": "13.1.0", "@types/validator": "13.1.0",
@ -115,7 +116,8 @@
"@vaadin/vaadin-time-picker": "2.4.0", "@vaadin/vaadin-time-picker": "2.4.0",
"@vaadin/vaadin-tabs": "3.2.0", "@vaadin/vaadin-tabs": "3.2.0",
"@vaadin/vaadin-radio-button": "1.5.1", "@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": { "devDependencies": {
"webpack-babel-multi-target-plugin": "2.3.3", "webpack-babel-multi-target-plugin": "2.3.3",
@ -141,6 +143,6 @@
"lit-css-loader": "0.0.4", "lit-css-loader": "0.0.4",
"extract-loader": "5.1.0" "extract-loader": "5.1.0"
}, },
"hash": "62511e127eb6b94b147718eaf87963a72562a63efa45b11debd35ee61e3cd13a" "hash": "9a8381007196d77745c03255bc222102472ce461f37b2742f39962e71d14929a"
} }
} }

View File

@ -2,6 +2,7 @@ dependencies:
'@polymer/iron-icon': 3.0.1 '@polymer/iron-icon': 3.0.1
'@polymer/iron-list': 3.1.0 '@polymer/iron-list': 3.1.0
'@polymer/polymer': 3.2.0 '@polymer/polymer': 3.2.0
'@vaadin-component-factory/vcf-tooltip': 1.3.13
'@vaadin/flow-frontend': 'link:target/flow-frontend' '@vaadin/flow-frontend': 'link:target/flow-frontend'
'@vaadin/form': 'link:target/flow-frontend/form' '@vaadin/form': 'link:target/flow-frontend/form'
'@vaadin/router': 1.7.2 '@vaadin/router': 1.7.2
@ -1041,6 +1042,16 @@ packages:
dev: true dev: true
resolution: resolution:
integrity: sha512-gHUHI6pJaANIO2r6WcbT7+WMgbL9GZooR4tWpuBOETpDIqFNxwaJluE+6rj6VGYe8k6OkfhbHz2Fkm8kl06Igw== 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: /@vaadin/router/1.7.2:
dependencies: dependencies:
'@vaadin/vaadin-usage-statistics': 2.1.0 '@vaadin/vaadin-usage-statistics': 2.1.0
@ -1323,6 +1334,12 @@ packages:
dev: false dev: false
resolution: resolution:
integrity: sha512-hG1MQ8cLaFlsoqSZFm8bqXrHxMry6vtkJrpiXArxpaZXMwPkJnfrUT3D6Qm/NG/rZHvOzZa5U/1k5+dyledlHA== 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: /@vaadin/vaadin-list-box/1.4.0:
dependencies: dependencies:
'@polymer/polymer': 3.2.0 '@polymer/polymer': 3.2.0
@ -7336,6 +7353,7 @@ specifiers:
'@polymer/iron-list': 3.1.0 '@polymer/iron-list': 3.1.0
'@polymer/polymer': 3.2.0 '@polymer/polymer': 3.2.0
'@types/validator': 13.1.0 '@types/validator': 13.1.0
'@vaadin-component-factory/vcf-tooltip': 1.3.13
'@vaadin/flow-frontend': ./target/flow-frontend '@vaadin/flow-frontend': ./target/flow-frontend
'@vaadin/form': ./target/flow-frontend/form '@vaadin/form': ./target/flow-frontend/form
'@vaadin/router': 1.7.2 '@vaadin/router': 1.7.2

View File

@ -116,6 +116,11 @@
<version>5.7.0</version> <version>5.7.0</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency>
<groupId>com.vaadin.componentfactory</groupId>
<artifactId>tooltip</artifactId>
<version>1.3.4</version>
</dependency>
</dependencies> </dependencies>
<build> <build>

View File

@ -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<String, String> typeAssumptions) {
// TODO Auto-generated method stub
}
}

View File

@ -1,19 +1,62 @@
package edu.kit.typicalc.view.main; 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.component.orderedlayout.HorizontalLayout;
import com.vaadin.flow.i18n.LocaleChangeEvent; import com.vaadin.flow.i18n.LocaleChangeEvent;
import com.vaadin.flow.i18n.LocaleChangeObserver; import com.vaadin.flow.i18n.LocaleChangeObserver;
public class InputBar extends HorizontalLayout implements LocaleChangeObserver { public class InputBar extends HorizontalLayout implements LocaleChangeObserver {
private final Tooltip infoTooltip;
private final Icon infoIcon;
private final Button lambdaButton;
private final ComboBox<String> inputField;
private final Button inferTypeButton;
public InputBar() { protected InputBar(final Consumer<String> callback) {
//TODO implement 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<String> callback) {
final Optional<String> currentInput = inputField.getOptionalValue();
currentInput.ifPresentOrElse(callback::accept, () -> callback.accept(StringUtils.EMPTY));
}
private void onlambdaButtonClick() {
final StringBuilder inputBuilder = new StringBuilder();
final Optional<String> 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 @Override
public void localeChange(LocaleChangeEvent event) { public void localeChange(LocaleChangeEvent event) {
// TODO Auto-generated method stub inferTypeButton.setText(getTranslation("root.typeInfer"));
} }
} }

View File

@ -1,5 +1,6 @@
package edu.kit.typicalc.view.main; package edu.kit.typicalc.view.main;
import java.util.Map;
import edu.kit.typicalc.model.TypeInfererInterface; import edu.kit.typicalc.model.TypeInfererInterface;
import edu.kit.typicalc.model.parser.ParseError; 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 * @param error the error which is displayed to indicate invalid input
*/ */
void displayError(ParseError error); void displayError(ParseError error);
public interface MainViewListener {
public void typeInferLambdaString(String lambdaTerm, Map<String, String> typeAssumptions);
}
} }

View File

@ -17,9 +17,11 @@ import com.vaadin.flow.component.orderedlayout.FlexComponent;
import com.vaadin.flow.component.orderedlayout.HorizontalLayout; import com.vaadin.flow.component.orderedlayout.HorizontalLayout;
import com.vaadin.flow.component.orderedlayout.VerticalLayout; import com.vaadin.flow.component.orderedlayout.VerticalLayout;
import com.vaadin.flow.component.tabs.Tabs; import com.vaadin.flow.component.tabs.Tabs;
import edu.kit.typicalc.model.ModelImpl;
import edu.kit.typicalc.model.TypeInfererInterface; import edu.kit.typicalc.model.TypeInfererInterface;
import edu.kit.typicalc.model.parser.ParseError; import edu.kit.typicalc.model.parser.ParseError;
import edu.kit.typicalc.view.content.typeinferencecontent.TypeInferenceView; 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. * The main view is a top-level placeholder for other views.
@ -32,7 +34,8 @@ public class MainViewImpl extends AppLayout implements MainView {
public MainViewImpl() { public MainViewImpl() {
setDrawerOpened(false); setDrawerOpened(false);
addToNavbar(true, new UpperBar()); MainViewListener presenter = new Presenter(new ModelImpl(), this);
addToNavbar(true, new UpperBar(presenter));
addToDrawer(new DrawerContent()); addToDrawer(new DrawerContent());
} }

View File

@ -11,6 +11,7 @@ import com.vaadin.flow.component.orderedlayout.HorizontalLayout;
import com.vaadin.flow.i18n.LocaleChangeEvent; import com.vaadin.flow.i18n.LocaleChangeEvent;
import com.vaadin.flow.i18n.LocaleChangeObserver; import com.vaadin.flow.i18n.LocaleChangeObserver;
import edu.kit.typicalc.view.content.infocontent.StartPageView; import edu.kit.typicalc.view.content.infocontent.StartPageView;
import edu.kit.typicalc.view.main.MainView.MainViewListener;
@CssImport("./styles/view/main/upper-bar.css") @CssImport("./styles/view/main/upper-bar.css")
public class UpperBar extends HorizontalLayout implements LocaleChangeObserver { public class UpperBar extends HorizontalLayout implements LocaleChangeObserver {
@ -19,21 +20,30 @@ public class UpperBar extends HorizontalLayout implements LocaleChangeObserver {
private final InputBar inputBar; private final InputBar inputBar;
private final Icon helpDialogIcon; 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"); setId("header");
getThemeList().set("dark", true); getThemeList().set("dark", true);
setWidthFull(); setWidthFull();
setSpacing(false); setSpacing(false);
setAlignItems(FlexComponent.Alignment.CENTER); setAlignItems(FlexComponent.Alignment.CENTER);
add(new DrawerToggle()); }
this.viewTitle = new H1(getTranslation("root.typicalc"));
viewTitle.setId("viewTitle"); protected void typeInfer() {
this.inputBar = new InputBar(); //TODO implement
this.helpDialogIcon = new Icon(VaadinIcon.QUESTION_CIRCLE);
helpDialogIcon.setId("icon");
viewTitle.addClickListener(event -> this.getUI().get().navigate(StartPageView.class));
add(viewTitle, inputBar, helpDialogIcon);
} }
private void createHelpDialog() { private void createHelpDialog() {

View File

@ -11,4 +11,6 @@ abs-rule=\\begin{prooftree}\
\\end{prooftree} \\end{prooftree}
test=hello world test=hello world
root.typicalc=Typicalc root.typicalc=Typicalc
root.lambda=\u03BB
root.typeInfer=Typisieren