From 836a9b154717ae45affda2532866ec940da1da5f Mon Sep 17 00:00:00 2001 From: Me Date: Tue, 26 Jan 2021 16:19:01 +0100 Subject: [PATCH] rough package structure --- .../TypeInferenceViewView.java | 11 +++---- .../view/info_content/StartPageView.java | 32 +++++++++++++++++++ .../main/MainViewImpl.java} | 19 +++++------ 3 files changed, 44 insertions(+), 18 deletions(-) rename src/main/java/edu/kit/typicalc/{views/typeinferenceview => view/content/type_inference_content}/TypeInferenceViewView.java (71%) create mode 100644 src/main/java/edu/kit/typicalc/view/info_content/StartPageView.java rename src/main/java/edu/kit/typicalc/{views/main/MainView.java => view/main/MainViewImpl.java} (91%) diff --git a/src/main/java/edu/kit/typicalc/views/typeinferenceview/TypeInferenceViewView.java b/src/main/java/edu/kit/typicalc/view/content/type_inference_content/TypeInferenceViewView.java similarity index 71% rename from src/main/java/edu/kit/typicalc/views/typeinferenceview/TypeInferenceViewView.java rename to src/main/java/edu/kit/typicalc/view/content/type_inference_content/TypeInferenceViewView.java index 986b639..ef77391 100644 --- a/src/main/java/edu/kit/typicalc/views/typeinferenceview/TypeInferenceViewView.java +++ b/src/main/java/edu/kit/typicalc/view/content/type_inference_content/TypeInferenceViewView.java @@ -1,20 +1,17 @@ -package edu.kit.typicalc.views.typeinferenceview; +package edu.kit.typicalc.view.content.type_inference_content; import com.vaadin.flow.component.button.Button; import com.vaadin.flow.component.dependency.CssImport; import com.vaadin.flow.component.notification.Notification; import com.vaadin.flow.component.orderedlayout.HorizontalLayout; -import com.vaadin.flow.component.orderedlayout.VerticalLayout; import com.vaadin.flow.component.textfield.TextField; import com.vaadin.flow.router.PageTitle; import com.vaadin.flow.router.Route; -import edu.kit.typicalc.views.main.MainView; -import com.vaadin.flow.router.RouteAlias; +import edu.kit.typicalc.view.main.MainViewImpl; -@Route(value = "visualize", layout = MainView.class) +@Route(value = "visualize", layout = MainViewImpl.class) @PageTitle("TypeInferenceView") @CssImport("./styles/views/typeinferenceview/type-inference-view-view.css") -@RouteAlias(value = "", layout = MainView.class) public class TypeInferenceViewView extends HorizontalLayout { private TextField name; @@ -27,7 +24,7 @@ public class TypeInferenceViewView extends HorizontalLayout { add(name, sayHello); setVerticalComponentAlignment(Alignment.END, name, sayHello); sayHello.addClickListener(e -> { - Notification.show("Hello " + name.getValue()); + Notification.show("Hello, test " + name.getValue()); }); } diff --git a/src/main/java/edu/kit/typicalc/view/info_content/StartPageView.java b/src/main/java/edu/kit/typicalc/view/info_content/StartPageView.java new file mode 100644 index 0000000..df01143 --- /dev/null +++ b/src/main/java/edu/kit/typicalc/view/info_content/StartPageView.java @@ -0,0 +1,32 @@ +package edu.kit.typicalc.view.info_content; + +import com.vaadin.flow.component.button.Button; +import com.vaadin.flow.component.dependency.CssImport; +import com.vaadin.flow.component.notification.Notification; +import com.vaadin.flow.component.orderedlayout.VerticalLayout; +import com.vaadin.flow.component.textfield.TextField; +import com.vaadin.flow.router.PageTitle; +import com.vaadin.flow.router.Route; +import com.vaadin.flow.router.RouteAlias; +import edu.kit.typicalc.view.main.MainViewImpl; + +@Route(value = "home", layout = MainViewImpl.class) +@PageTitle("Typicalc") +@CssImport("./styles/views/typeinferenceview/type-inference-view-view.css") +@RouteAlias(value = "", layout = MainViewImpl.class) +public class StartPageView extends VerticalLayout { + + private TextField name; + private Button sayHello; + + public StartPageView() { + setId("start-page"); + name = new TextField("Your name"); + sayHello = new Button("Say hello"); + add(name, sayHello); + sayHello.addClickListener(e -> { + Notification.show("Hello " + name.getValue()); + }); + } + +} diff --git a/src/main/java/edu/kit/typicalc/views/main/MainView.java b/src/main/java/edu/kit/typicalc/view/main/MainViewImpl.java similarity index 91% rename from src/main/java/edu/kit/typicalc/views/main/MainView.java rename to src/main/java/edu/kit/typicalc/view/main/MainViewImpl.java index 52ee23b..935e873 100644 --- a/src/main/java/edu/kit/typicalc/views/main/MainView.java +++ b/src/main/java/edu/kit/typicalc/view/main/MainViewImpl.java @@ -1,6 +1,4 @@ -package edu.kit.typicalc.views.main; - -import java.util.Optional; +package edu.kit.typicalc.view.main; import com.vaadin.flow.component.Component; import com.vaadin.flow.component.ComponentUtil; @@ -9,8 +7,8 @@ import com.vaadin.flow.component.applayout.DrawerToggle; import com.vaadin.flow.component.avatar.Avatar; import com.vaadin.flow.component.dependency.CssImport; import com.vaadin.flow.component.dependency.JsModule; -import com.vaadin.flow.component.html.Image; import com.vaadin.flow.component.html.H1; +import com.vaadin.flow.component.html.Image; import com.vaadin.flow.component.orderedlayout.FlexComponent; import com.vaadin.flow.component.orderedlayout.HorizontalLayout; import com.vaadin.flow.component.orderedlayout.VerticalLayout; @@ -19,23 +17,22 @@ import com.vaadin.flow.component.tabs.Tabs; import com.vaadin.flow.component.tabs.TabsVariant; import com.vaadin.flow.router.PageTitle; import com.vaadin.flow.router.RouterLink; -import com.vaadin.flow.server.PWA; -import com.vaadin.flow.theme.Theme; -import edu.kit.typicalc.views.main.MainView; -import edu.kit.typicalc.views.typeinferenceview.TypeInferenceViewView; +import edu.kit.typicalc.view.content.type_inference_content.TypeInferenceViewView; + +import java.util.Optional; /** * The main view is a top-level placeholder for other views. */ @CssImport("./styles/views/main/main-view.css") @JsModule("./styles/shared-styles.js") -public class MainView extends AppLayout { +public class MainViewImpl extends AppLayout { private final Tabs menu; private H1 viewTitle; - public MainView() { - setPrimarySection(Section.DRAWER); + public MainViewImpl() { + setDrawerOpened(false); addToNavbar(true, createHeaderContent()); menu = createMenu(); addToDrawer(createDrawerContent(menu));