test layout for start page

This commit is contained in:
ucrhh 2021-01-29 00:19:49 +01:00
parent c392cc0c0f
commit 0d09d20aa2
3 changed files with 113 additions and 28 deletions

View File

@ -1,16 +1,16 @@
package edu.kit.typicalc.view.content; package edu.kit.typicalc.view.content;
import com.vaadin.flow.component.Component;
import com.vaadin.flow.component.Key; import com.vaadin.flow.component.Key;
import com.vaadin.flow.component.KeyModifier; import com.vaadin.flow.component.KeyModifier;
import com.vaadin.flow.component.button.Button; import com.vaadin.flow.component.button.Button;
import com.vaadin.flow.component.icon.Icon; import com.vaadin.flow.component.icon.Icon;
import com.vaadin.flow.component.icon.VaadinIcon; import com.vaadin.flow.component.icon.VaadinIcon;
import com.vaadin.flow.component.orderedlayout.HorizontalLayout;
/** /**
* Provides a GUI in form of buttons for the user to navigate through steps. * Provides a GUI in form of buttons for the user to navigate through steps.
*/ */
public class ControlPanel extends Component { public class ControlPanel extends HorizontalLayout {
private final Button firstStep; private final Button firstStep;
private final Button lastStep; private final Button lastStep;
@ -26,15 +26,17 @@ public class ControlPanel extends Component {
public ControlPanel(ControlPanelView view) { public ControlPanel(ControlPanelView view) {
firstStep = new Button(new Icon(VaadinIcon.ANGLE_DOUBLE_LEFT), evt -> view.firstStepButton()); firstStep = new Button(new Icon(VaadinIcon.ANGLE_DOUBLE_LEFT), evt -> view.firstStepButton());
lastStep = new Button(new Icon(VaadinIcon.ANGLE_DOUBLE_RIGHT), evt -> view.lastStepButton()); lastStep = new Button(new Icon(VaadinIcon.ANGLE_DOUBLE_RIGHT), evt -> view.lastStepButton());
nextStep = new Button(new Icon(VaadinIcon.ANGLE_DOUBLE_RIGHT), evt -> view.nextStepButton()); nextStep = new Button(new Icon(VaadinIcon.ANGLE_RIGHT), evt -> view.nextStepButton());
previousStep = new Button(new Icon(VaadinIcon.ANGLE_DOUBLE_LEFT), evt -> view.previousStepButton()); previousStep = new Button(new Icon(VaadinIcon.ANGLE_LEFT), evt -> view.previousStepButton());
share = new Button(new Icon(VaadinIcon.CONNECT), evt -> view.shareButton()); share = new Button(new Icon(VaadinIcon.CONNECT), evt -> view.shareButton());
// todo change shortcut scope // todo change shortcut scope
firstStep.addClickShortcut(Key.ARROW_LEFT, KeyModifier.CONTROL); firstStep.addClickShortcut(Key.ARROW_LEFT, KeyModifier.CONTROL);
lastStep.addClickShortcut(Key.ARROW_RIGHT, KeyModifier.CONTROL); lastStep.addClickShortcut(Key.ARROW_RIGHT, KeyModifier.CONTROL);
nextStep.addClickShortcut(Key.ARROW_LEFT); nextStep.addClickShortcut(Key.ARROW_RIGHT);
previousStep.addClickShortcut(Key.ARROW_LEFT); previousStep.addClickShortcut(Key.ARROW_LEFT);
add(share, firstStep, previousStep, nextStep, lastStep);
} }
/** /**

View File

@ -1,11 +1,14 @@
package edu.kit.typicalc.view.content.infocontent; package edu.kit.typicalc.view.content.infocontent;
import com.vaadin.flow.component.button.Button;
import com.vaadin.flow.component.dependency.JsModule; import com.vaadin.flow.component.dependency.JsModule;
import com.vaadin.flow.component.html.Div;
import com.vaadin.flow.component.orderedlayout.Scroller;
import com.vaadin.flow.component.orderedlayout.VerticalLayout; import com.vaadin.flow.component.orderedlayout.VerticalLayout;
import com.vaadin.flow.router.PageTitle; import com.vaadin.flow.router.PageTitle;
import com.vaadin.flow.router.Route; import com.vaadin.flow.router.Route;
import com.vaadin.flow.router.RouteAlias; import com.vaadin.flow.router.RouteAlias;
import edu.kit.typicalc.view.content.ControlPanel;
import edu.kit.typicalc.view.content.ControlPanelView;
import edu.kit.typicalc.view.content.typeinferencecontent.MathjaxProofTree; import edu.kit.typicalc.view.content.typeinferencecontent.MathjaxProofTree;
import edu.kit.typicalc.view.content.typeinferencecontent.MathjaxUnification; import edu.kit.typicalc.view.content.typeinferencecontent.MathjaxUnification;
import edu.kit.typicalc.view.main.MainViewImpl; import edu.kit.typicalc.view.main.MainViewImpl;
@ -15,18 +18,54 @@ import edu.kit.typicalc.view.main.MathjaxDisplay;
@PageTitle("Typicalc") @PageTitle("Typicalc")
@RouteAlias(value = "", layout = MainViewImpl.class) @RouteAlias(value = "", layout = MainViewImpl.class)
@JsModule("./src/mathjax-setup.js") @JsModule("./src/mathjax-setup.js")
public class StartPageView extends VerticalLayout { public class StartPageView extends VerticalLayout implements ControlPanelView {
private Button sayHello; private final Div content;
private final ControlPanel controlPanel;
public StartPageView() { public StartPageView() {
// todo implement correctly // todo implement correctly
setId("start-page"); setId("start-page");
add(new MathjaxDisplay(getTranslation("abs-rule"))); setSizeFull();
add(new MathjaxUnification("\\(constraint test \\vdash \\)")); content = new Div();
add(new MathjaxProofTree(getTranslation("demo-tree"))); controlPanel = new ControlPanel(this);
sayHello = new Button("Say hello"); Scroller scroller = new Scroller(content);
add(sayHello); scroller.setSizeFull();
scroller.setScrollDirection(Scroller.ScrollDirection.BOTH);
content.add(new MathjaxDisplay(getTranslation("abs-rule")));
content.add(new MathjaxUnification("\\(conswwwwwwWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWtraint test \\vdash \\)"));
MathjaxProofTree mjxPT = new MathjaxProofTree(getTranslation("demo-tree"));
mjxPT.showStep(10);
content.add(new MathjaxProofTree(getTranslation("demo-tree")));
content.add(new MathjaxProofTree(getTranslation("demo-tree")));
content.add(new MathjaxProofTree(getTranslation("demo-tree")));
content.add(new MathjaxProofTree(getTranslation("demo-tree")));
setAlignItems(Alignment.CENTER);
add(scroller, controlPanel);
} }
@Override
public void shareButton() {
}
@Override
public void firstStepButton() {
}
@Override
public void lastStepButton() {
}
@Override
public void nextStepButton() {
}
@Override
public void previousStepButton() {
}
} }

View File

@ -1,37 +1,81 @@
package edu.kit.typicalc.view.content.typeinferencecontent; package edu.kit.typicalc.view.content.typeinferencecontent;
import com.vaadin.flow.component.button.Button;
import com.vaadin.flow.component.notification.Notification;
import com.vaadin.flow.component.orderedlayout.HorizontalLayout; import com.vaadin.flow.component.orderedlayout.HorizontalLayout;
import com.vaadin.flow.component.textfield.TextField; import com.vaadin.flow.component.orderedlayout.Scroller;
import com.vaadin.flow.router.BeforeEvent; import com.vaadin.flow.router.BeforeEvent;
import com.vaadin.flow.router.HasUrlParameter; import com.vaadin.flow.router.HasUrlParameter;
import com.vaadin.flow.router.PageTitle; import com.vaadin.flow.router.PageTitle;
import com.vaadin.flow.router.Route; import com.vaadin.flow.router.Route;
import edu.kit.typicalc.model.TypeInfererInterface; import edu.kit.typicalc.model.TypeInfererInterface;
import edu.kit.typicalc.view.content.ControlPanel;
import edu.kit.typicalc.view.content.ControlPanelView;
import edu.kit.typicalc.view.main.MainViewImpl; import edu.kit.typicalc.view.main.MainViewImpl;
@Route(value = "visualize", layout = MainViewImpl.class) @Route(value = "visualize", layout = MainViewImpl.class)
@PageTitle("TypeInferenceView") @PageTitle("TypeInferenceView")
public class TypeInferenceView extends HorizontalLayout implements HasUrlParameter<TypeInfererInterface> { public class TypeInferenceView extends HorizontalLayout
implements ControlPanelView, HasUrlParameter<TypeInfererInterface> {
private TextField name; private int currentStep;
private Button sayHello;
private MathjaxUnification unification;
private MathjaxProofTree tree;
public TypeInferenceView() { public TypeInferenceView() {
setId("type-inference-view"); setId("type-inference-view");
name = new TextField("Your name"); add(new ControlPanel(this));
sayHello = new Button("Say hello");
add(name, sayHello);
setVerticalComponentAlignment(Alignment.END, name, sayHello);
sayHello.addClickListener(e -> {
Notification.show("Hello, test " + name.getValue());
});
} }
@Override @Override
public void setParameter(BeforeEvent event, TypeInfererInterface parameter) { public void setParameter(BeforeEvent event, TypeInfererInterface typeInferer) {
// TODO Auto-generated method stub buildView(typeInferer);
} }
private void buildView(TypeInfererInterface typeInferer) {
if (typeInferer == null) {
// todo throw exception
unification = new MathjaxUnification("\\vdash test");
tree = new MathjaxProofTree(getTranslation("demo-tree"));
} else {
LatexCreator lc = new LatexCreator(typeInferer);
unification = new MathjaxUnification(lc.getUnification());
tree = new MathjaxProofTree(lc.getTree());
}
add(unification);
add(new Scroller(tree));
}
@Override
public void shareButton() {
// todo implement
}
//todo implement correctly
@Override
public void firstStepButton() {
currentStep = 0;
unification.showStep(currentStep);
tree.showStep(currentStep);
}
@Override
public void lastStepButton() {
currentStep = unification.getStepCount() - 1;
unification.showStep(currentStep);
tree.showStep(tree.getStepCount() - 1);
}
@Override
public void nextStepButton() {
currentStep++;
unification.showStep(currentStep);
tree.showStep(currentStep);
}
@Override
public void previousStepButton() {
currentStep--;
unification.showStep(currentStep);
tree.showStep(currentStep);
}
} }