diff --git a/nbactions.xml b/nbactions.xml index 96f859f0e4a15315b7ebe16ef16b24b757d0e9c6..fcf24843b143c0740c61241c7d6daba30d4206dc 100644 --- a/nbactions.xml +++ b/nbactions.xml @@ -26,7 +26,7 @@ <actionName>CUSTOM-run jetty</actionName> <displayName>run jetty</displayName> <goals> - <goal>jetty:run</goal> + <goal>jetty:run-war</goal> </goals> </action> <action> diff --git a/src/main/java/org/s4s/MyUI.java b/src/main/java/org/s4s/MyUI.java index 9360b11704e334f310d55ff0e9d08dc6d35eb301..fe05effba24d1fdec218d7e2d41f3fdaba07b13a 100644 --- a/src/main/java/org/s4s/MyUI.java +++ b/src/main/java/org/s4s/MyUI.java @@ -6,6 +6,7 @@ import com.vaadin.annotations.Theme; import com.vaadin.annotations.Title; import com.vaadin.annotations.VaadinServletConfiguration; import com.vaadin.data.util.BeanContainer; +import com.vaadin.navigator.Navigator; import com.vaadin.server.FontAwesome; import com.vaadin.server.VaadinRequest; import com.vaadin.server.VaadinServlet; @@ -21,8 +22,11 @@ import com.vaadin.ui.TextField; import com.vaadin.ui.UI; import com.vaadin.ui.VerticalLayout; import java.util.List; +import org.s4s.gui.views.MainView; +import org.s4s.gui.views.WelcomeView; import org.s4s.modell.objects.dto.Product; import org.s4s.process.controll.ProductSearch; +import org.s4s.services.util.Views; /** * This UI is the application entry point. A UI may either represent a browser window @@ -37,56 +41,13 @@ public class MyUI extends UI { @Override protected void init(VaadinRequest vaadinRequest) { - Label label = new Label("Das erste Label unseres Shop in Shop System"); - // setContent(label); - final VerticalLayout layout = new VerticalLayout(); - layout.setMargin(true); - setContent(layout); + Navigator navi = new Navigator ( this , this ); + navi.addView(Views.MAIN, MainView.class ); + navi.addView(Views.WELCOME, WelcomeView.class); - - final HorizontalLayout horizontalLayout = new HorizontalLayout(); - - - TextField textfield = new TextField(); - Button button = new Button("Suche" , FontAwesome.SEARCH); - - horizontalLayout.addComponent(textfield); - horizontalLayout.addComponent(button); - - - layout.addComponent(label); - layout.setComponentAlignment(label, Alignment.TOP_LEFT); - layout.addComponent(horizontalLayout); - layout.setComponentAlignment(horizontalLayout, Alignment.TOP_RIGHT); - - - - - final BeanContainer<Integer, Product> data = new BeanContainer<Integer, Product>(Product.class); - data.setBeanIdProperty("id"); - final Table table = new Table ("Products" , data); - table.setSizeFull(); - table.setSelectable(true); - - - button.addClickListener(new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event){ - String str = textfield.getValue(); - - if(str.equals("")){ - Notification.show(null, "Bitte gesuchtes Produkt eingeben!", Notification.Type.WARNING_MESSAGE); - } else{ - layout.addComponent(table); - - List<Product> liste = ProductSearch.getInstance().getProductByTyp(str); - data.removeAllItems(); - data.addAll(liste); - table.setPageLength(table.size()); - } - } - }); + UI.getCurrent().getNavigator().navigateTo(Views.WELCOME); } + @WebServlet(urlPatterns = "/*", name = "MyUIServlet", asyncSupported = true) diff --git a/src/main/java/org/s4s/gui/views/MainView.java b/src/main/java/org/s4s/gui/views/MainView.java new file mode 100644 index 0000000000000000000000000000000000000000..00e5e50c4ba06bbbb88eed4a1be764e7f5a10831 --- /dev/null +++ b/src/main/java/org/s4s/gui/views/MainView.java @@ -0,0 +1,81 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package org.s4s.gui.views; + +import com.vaadin.data.util.BeanContainer; +import com.vaadin.navigator.View; +import com.vaadin.navigator.ViewChangeListener; +import com.vaadin.server.FontAwesome; +import com.vaadin.ui.Alignment; +import com.vaadin.ui.Button; +import com.vaadin.ui.HorizontalLayout; +import com.vaadin.ui.Label; +import com.vaadin.ui.Notification; +import com.vaadin.ui.Table; +import com.vaadin.ui.TextField; +import com.vaadin.ui.VerticalLayout; +import java.util.List; +import org.s4s.modell.objects.dto.Product; +import org.s4s.process.controll.ProductSearch; + +/** + * + * @author Holger + */ +public class MainView extends VerticalLayout implements View{ + + @Override + public void enter(ViewChangeListener.ViewChangeEvent event) { + this.setUp(); + } + + + public void setUp(){ + // setSizeFull(); + setMargin(true); + + final HorizontalLayout searchLayout = new HorizontalLayout(); + final HorizontalLayout buttonLayout = new HorizontalLayout(); + + TextField textfield = new TextField(); + Button button = new Button("Suche" , FontAwesome.SEARCH); + Label label = new Label("Das erste Label unseres Shop in Shop System"); + + buttonLayout.addComponent(label); + buttonLayout.setComponentAlignment(label, Alignment.TOP_LEFT); + + searchLayout.addComponent(textfield); + searchLayout.addComponent(button); + buttonLayout.addComponent(searchLayout); + buttonLayout.setComponentAlignment(searchLayout, Alignment.TOP_RIGHT); + buttonLayout.setSizeFull(); + addComponent(buttonLayout); + //setComponentAlignment(buttonLayout, Alignment.TOP_CENTER); + + + final BeanContainer<Integer, Product> data = new BeanContainer<>(Product.class); + data.setBeanIdProperty("id"); + final Table table = new Table ("Products" , data); + table.setSizeFull(); + table.setSelectable(true); + + + button.addClickListener((Button.ClickEvent event) -> { + String str = textfield.getValue().trim(); + + if(str.equals("")){ + Notification.show(null, "Bitte gesuchtes Produkt eingeben!", Notification.Type.WARNING_MESSAGE); + } else{ + addComponent(table); + + List<Product> liste = ProductSearch.getInstance().getProductByTyp(str); + data.removeAllItems(); + data.addAll(liste); + table.setPageLength(table.size()); + } + }); + } +} diff --git a/src/main/java/org/s4s/gui/views/WelcomeView.java b/src/main/java/org/s4s/gui/views/WelcomeView.java new file mode 100644 index 0000000000000000000000000000000000000000..bfdc98cf4bd585bf91b40794069b78603508432a --- /dev/null +++ b/src/main/java/org/s4s/gui/views/WelcomeView.java @@ -0,0 +1,59 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package org.s4s.gui.views; + +import com.vaadin.navigator.View; +import com.vaadin.navigator.ViewChangeListener; +import com.vaadin.ui.Alignment; +import com.vaadin.ui.Button; +import com.vaadin.ui.HorizontalLayout; +import com.vaadin.ui.Label; +import com.vaadin.ui.UI; +import com.vaadin.ui.VerticalLayout; +import org.s4s.services.util.Views; + +/** + * + * @author Holger + */ +public class WelcomeView extends VerticalLayout implements View{ + + @Override + public void enter(ViewChangeListener.ViewChangeEvent event) { + this.setUp(); + } + + public void setUp(){ + setSizeFull(); + setMargin(true); + final HorizontalLayout horizontalLayout = new HorizontalLayout(); + final HorizontalLayout buttonLayout = new HorizontalLayout(); + + + Button sucheButton = new Button("Besuche Shop"); + buttonLayout.addComponent(sucheButton); + buttonLayout.setComponentAlignment(sucheButton, Alignment.TOP_LEFT); + + + Button loginButton = new Button("Login"); + buttonLayout.addComponent(loginButton); + buttonLayout.setComponentAlignment(loginButton, Alignment.TOP_RIGHT); + + + addComponent(buttonLayout); + buttonLayout.setSizeFull(); + sucheButton.addClickListener((Button.ClickEvent event) ->{ + UI.getCurrent().getNavigator().navigateTo(Views.MAIN); + }); + + Label label = new Label("Willkommen in unserem Shop in Shop System!"); + horizontalLayout.addComponent(label); + horizontalLayout.setComponentAlignment(label, Alignment.MIDDLE_CENTER); + addComponent(horizontalLayout); + setComponentAlignment(horizontalLayout, Alignment.TOP_CENTER); + } + +} diff --git a/src/main/java/org/s4s/services/util/Views.java b/src/main/java/org/s4s/services/util/Views.java new file mode 100644 index 0000000000000000000000000000000000000000..9cf7f096b171f6c02b6f5abc5e1ee154261562de --- /dev/null +++ b/src/main/java/org/s4s/services/util/Views.java @@ -0,0 +1,15 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package org.s4s.services.util; + +/** + * + * @author Holger + */ +public class Views { + public final static String WELCOME = "welcome"; + public final static String MAIN = "main"; +} diff --git a/target/classes/org/s4s/MyUI$MyUIServlet.class b/target/classes/org/s4s/MyUI$MyUIServlet.class index 6e384c0fbc9b8b32e3ac5ce4142019326d2a0a9e..6f0ae277adc91764a43f3225c09b1cb007100a33 100644 Binary files a/target/classes/org/s4s/MyUI$MyUIServlet.class and b/target/classes/org/s4s/MyUI$MyUIServlet.class differ diff --git a/target/classes/org/s4s/MyUI.class b/target/classes/org/s4s/MyUI.class index 57da999953d803a007acf2367511332fa9dffe1f..2a3154d514c76342ccfae7133f33c5850b7e0e14 100644 Binary files a/target/classes/org/s4s/MyUI.class and b/target/classes/org/s4s/MyUI.class differ diff --git a/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst b/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst index 39bed8086f9b9ef4e1ee69a743a9e5539fab52a5..d38b2aa6978edcce0fee233c323a4de06d944ff7 100644 --- a/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst +++ b/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst @@ -1,5 +1,7 @@ org\s4s\modell\objects\dto\Product.class +org\s4s\gui\views\WelcomeView.class org\s4s\process\controll\ProductSearch.class org\s4s\MyUI.class +org\s4s\services\util\Views.class org\s4s\MyUI$MyUIServlet.class -org\s4s\MyUI$1.class +org\s4s\gui\views\MainView.class diff --git a/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst b/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst index 775437f85ab3f83838724a5f87b37de1997b5907..4baeefa9dde9326f42bc91b4600c1fa66ca1d1ce 100644 --- a/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst +++ b/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst @@ -1 +1,6 @@ +C:\Users\Holger\Documents\NetBeansProjects\s4s\src\main\java\org\s4s\process\controll\ProductSearch.java C:\Users\Holger\Documents\NetBeansProjects\s4s\src\main\java\org\s4s\MyUI.java +C:\Users\Holger\Documents\NetBeansProjects\s4s\src\main\java\org\s4s\modell\objects\dto\Product.java +C:\Users\Holger\Documents\NetBeansProjects\s4s\src\main\java\org\s4s\gui\views\WelcomeView.java +C:\Users\Holger\Documents\NetBeansProjects\s4s\src\main\java\org\s4s\services\util\Views.java +C:\Users\Holger\Documents\NetBeansProjects\s4s\src\main\java\org\s4s\gui\views\MainView.java