pass typeInferer to TypeInferenceView

This commit is contained in:
Me 2021-01-30 14:23:02 +01:00
parent ba23c64f74
commit e52c0e1d2f
2 changed files with 10 additions and 11 deletions

View File

@ -1,9 +1,9 @@
package edu.kit.typicalc.view.content.typeinferencecontent;
import com.vaadin.flow.component.ComponentUtil;
import com.vaadin.flow.component.UI;
import com.vaadin.flow.component.orderedlayout.HorizontalLayout;
import com.vaadin.flow.component.orderedlayout.Scroller;
import com.vaadin.flow.router.BeforeEvent;
import com.vaadin.flow.router.HasUrlParameter;
import com.vaadin.flow.router.PageTitle;
import com.vaadin.flow.router.Route;
import edu.kit.typicalc.model.TypeInfererInterface;
@ -14,24 +14,21 @@ import edu.kit.typicalc.view.main.MainViewImpl;
@Route(value = "visualize", layout = MainViewImpl.class)
@PageTitle("TypeInferenceView")
public class TypeInferenceView extends HorizontalLayout
implements ControlPanelView, HasUrlParameter<TypeInfererInterface> {
implements ControlPanelView {
private int currentStep;
private MathjaxUnification unification;
private MathjaxProofTree tree;
private TypeInfererInterface typeInferer;
public TypeInferenceView() {
setId("type-inference-view");
add(new ControlPanel(this));
typeInferer = ComponentUtil.getData(UI.getCurrent(), TypeInfererInterface.class);
}
@Override
public void setParameter(BeforeEvent event, TypeInfererInterface typeInferer) {
buildView(typeInferer);
}
private void buildView(TypeInfererInterface typeInferer) {
private void buildView() {
// todo implement correctly
LatexCreator lc = new LatexCreator(typeInferer);
unification = new MathjaxUnification(lc.getUnification());

View File

@ -1,5 +1,7 @@
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;
import com.vaadin.flow.component.dependency.CssImport;
@ -11,7 +13,6 @@ 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 edu.kit.typicalc.model.ModelImpl;
import edu.kit.typicalc.model.TypeInfererInterface;
import edu.kit.typicalc.model.parser.ParseError;
@ -42,7 +43,8 @@ public class MainViewImpl extends AppLayout implements MainView {
@Override
public void setTypeInferenceView(final TypeInfererInterface typeInferer) {
this.getUI().ifPresent(ui -> ui.navigate(TypeInferenceView.class, typeInferer));
ComponentUtil.setData(UI.getCurrent(), TypeInfererInterface.class, typeInferer);
this.getUI().ifPresent(ui -> ui.navigate(TypeInferenceView.class));
}
@Override