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 4afc37f..bb12b7d 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 @@ -2,8 +2,6 @@ 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; @@ -29,8 +27,8 @@ public class TypeInferenceView extends VerticalLayout private final Div content; private final ControlPanel controlPanel; - public TypeInferenceView() { - typeInferer = ComponentUtil.getData(UI.getCurrent(), TypeInfererInterface.class); + public TypeInferenceView(TypeInfererInterface typeInferer) { + this.typeInferer = typeInferer; setId("type-inference-view"); setSizeFull(); addAttachListener(this); 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 6013d2e..1199386 100644 --- a/src/main/java/edu/kit/typicalc/view/main/MainViewImpl.java +++ b/src/main/java/edu/kit/typicalc/view/main/MainViewImpl.java @@ -1,6 +1,5 @@ package edu.kit.typicalc.view.main; -import com.vaadin.flow.component.ComponentUtil; import com.vaadin.flow.component.UI; import com.vaadin.flow.component.applayout.AppLayout; import com.vaadin.flow.component.button.Button; @@ -13,6 +12,7 @@ import com.vaadin.flow.component.notification.Notification.Position; import com.vaadin.flow.component.notification.NotificationVariant; import com.vaadin.flow.component.orderedlayout.FlexComponent; import com.vaadin.flow.component.orderedlayout.VerticalLayout; +import com.vaadin.flow.router.Location; import edu.kit.typicalc.model.ModelImpl; import edu.kit.typicalc.model.TypeInfererInterface; import edu.kit.typicalc.model.parser.ParseError; @@ -30,7 +30,10 @@ import edu.kit.typicalc.view.content.typeinferencecontent.TypeInferenceView; @JavaScript("./src/tex-svg-full.js") public class MainViewImpl extends AppLayout implements MainView { private static final long serialVersionUID = -2411433187835906976L; + private static final String ROUTE = "infer"; + private static final String SLASH = "/"; + private String termToType = "lambda x.x"; //todo replace with real value /** * Creates a new MainViewImpl. */ @@ -39,12 +42,14 @@ public class MainViewImpl extends AppLayout implements MainView { MainViewListener presenter = new Presenter(new ModelImpl(), this); addToNavbar(true, new UpperBar(presenter)); addToDrawer(new DrawerContent()); + } @Override public void setTypeInferenceView(final TypeInfererInterface typeInferer) { - ComponentUtil.setData(UI.getCurrent(), TypeInfererInterface.class, typeInferer); - this.getUI().ifPresent(ui -> ui.navigate(TypeInferenceView.class)); + TypeInferenceView tiv = new TypeInferenceView(typeInferer); + UI.getCurrent().getPage().getHistory().replaceState(null, new Location(ROUTE + SLASH + termToType)); + setContent(tiv); } @Override