From d4a6acbc075a3c7f267f4876f3534e1b37d7a7f9 Mon Sep 17 00:00:00 2001 From: ucrhh Date: Fri, 5 Mar 2021 12:36:47 +0100 Subject: [PATCH] navigate to startpage when empty term is entered --- src/main/java/edu/kit/typicalc/view/main/MainViewImpl.java | 5 +++++ src/main/java/edu/kit/typicalc/view/main/UpperBar.java | 4 +++- 2 files changed, 8 insertions(+), 1 deletion(-) 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 c86500f..920dd5f 100644 --- a/src/main/java/edu/kit/typicalc/view/main/MainViewImpl.java +++ b/src/main/java/edu/kit/typicalc/view/main/MainViewImpl.java @@ -94,6 +94,11 @@ public class MainViewImpl extends AppLayout private void setTermInURL(Pair> lambdaTermAndAssumptions) { String lambdaTerm = lambdaTermAndAssumptions.getLeft(); + if ("".equals(lambdaTerm)) { + UI.getCurrent().getPage().getHistory().pushState(null, new Location("")); + setContent(new StartPageView()); + return; + } StringBuilder types = new StringBuilder(); for (Map.Entry type : lambdaTermAndAssumptions.getRight().entrySet()) { if (types.length() > 0) { 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 71a1bf6..1c32ce2 100644 --- a/src/main/java/edu/kit/typicalc/view/main/UpperBar.java +++ b/src/main/java/edu/kit/typicalc/view/main/UpperBar.java @@ -69,7 +69,9 @@ public class UpperBar extends HorizontalLayout { */ protected void typeInfer(Pair> termAndAssumptions) { setTermInURL.accept(termAndAssumptions); - startInfer(termAndAssumptions.getLeft(), termAndAssumptions.getRight()); + if (!"".equals(termAndAssumptions.getLeft())) { + startInfer(termAndAssumptions.getLeft(), termAndAssumptions.getRight()); + } } private void startInfer(String term, Map typeAssumptions) {