mirror of
https://gitlab.kit.edu/uskyk/typicalc.git
synced 2024-11-08 18:30:42 +00:00
better passing of TypeInferer to TypeInferenceView, allows for custom URL
This commit is contained in:
parent
64312cd172
commit
fbb3d6fd63
@ -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);
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user