diff --git a/nbactions.xml b/nbactions.xml index 8e9c9c7b3b2637b9952b3b041de51256cfc9dc98..96f859f0e4a15315b7ebe16ef16b24b757d0e9c6 100644 --- a/nbactions.xml +++ b/nbactions.xml @@ -22,4 +22,25 @@ <goal>jetty:run</goal> </goals> </action> + <action> + <actionName>CUSTOM-run jetty</actionName> + <displayName>run jetty</displayName> + <goals> + <goal>jetty:run</goal> + </goals> + </action> + <action> + <actionName>debug</actionName> + <packagings> + <packaging>war</packaging> + <packaging>ear</packaging> + <packaging>ejb</packaging> + </packagings> + <goals> + <goal>package</goal> + </goals> + <properties> + <netbeans.deploy.debugmode>true</netbeans.deploy.debugmode> + </properties> + </action> </actions> diff --git a/src/main/java/org/s4s/MyUI.java b/src/main/java/org/s4s/MyUI.java index 0b0a92cdc23b40f1900968804ff7e59b720cbc71..9360b11704e334f310d55ff0e9d08dc6d35eb301 100644 --- a/src/main/java/org/s4s/MyUI.java +++ b/src/main/java/org/s4s/MyUI.java @@ -5,13 +5,24 @@ import javax.servlet.annotation.WebServlet; import com.vaadin.annotations.Theme; import com.vaadin.annotations.Title; import com.vaadin.annotations.VaadinServletConfiguration; +import com.vaadin.data.util.BeanContainer; +import com.vaadin.server.FontAwesome; import com.vaadin.server.VaadinRequest; import com.vaadin.server.VaadinServlet; +import com.vaadin.shared.ui.label.ContentMode; +import com.vaadin.ui.Alignment; import com.vaadin.ui.Button; +import com.vaadin.ui.Button.ClickEvent; +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.UI; import com.vaadin.ui.VerticalLayout; +import java.util.List; +import org.s4s.modell.objects.dto.Product; +import org.s4s.process.controll.ProductSearch; /** * This UI is the application entry point. A UI may either represent a browser window @@ -27,11 +38,59 @@ 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); + // setContent(label); + final VerticalLayout layout = new VerticalLayout(); + layout.setMargin(true); + setContent(layout); + + + 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()); + } + } + }); } + @WebServlet(urlPatterns = "/*", name = "MyUIServlet", asyncSupported = true) @VaadinServletConfiguration(ui = MyUI.class, productionMode = false) public static class MyUIServlet extends VaadinServlet { } -} +} \ No newline at end of file diff --git a/src/main/java/org/s4s/modell/objects/dto/Product.java b/src/main/java/org/s4s/modell/objects/dto/Product.java new file mode 100644 index 0000000000000000000000000000000000000000..686f73e3e25175f4827a8afb456a50aacc6032cf --- /dev/null +++ b/src/main/java/org/s4s/modell/objects/dto/Product.java @@ -0,0 +1,72 @@ +/* + * 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.modell.objects.dto; + +/** + * + * @author Holger Karwanni + */ +public class Product { + + private String name; + private Integer id; + private String typ; + private double price; + private String description; + + public Product(String name, Integer id, String typ, double price, String description){ + this.name = name; + this.id = id; + this.typ = typ; + this.price = price; + this.description = description; + } + + public Product(){ + + } + + public String getName(){ + return name; + } + + public void setName(String name){ + this.name = name; + } + + public Integer getId(){ + return id; + } + + public void setId(Integer id){ + this.id = id; + } + + public String getTyp(){ + return typ; + } + + public void setTyp(String typ){ + this.typ = typ; + } + + public double getPrice(){ + return price; + } + + public void setPrice(double price){ + this.price = price; + } + + public String getDescription(){ + return description; + } + + public void setDescription (String description){ + this.description = description; + } + +} diff --git a/src/main/java/org/s4s/process/controll/ProductSearch.java b/src/main/java/org/s4s/process/controll/ProductSearch.java new file mode 100644 index 0000000000000000000000000000000000000000..2133119d6084452336e4fa9628eae6fc12c04eeb --- /dev/null +++ b/src/main/java/org/s4s/process/controll/ProductSearch.java @@ -0,0 +1,49 @@ +/* + * 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.process.controll; + +import java.util.ArrayList; +import java.util.List; +import org.s4s.modell.objects.dto.Product; + +/** + * + * @author Holger + */ +public class ProductSearch { + + Product p1 = new Product("Nachhilfe Algebra", 1, "Nachhilfe", 2.00, "Biete Nachhilfe in Algebra an!"); + Product p2 = new Product("F&I", 2, "Mitschriften", 5.00, "Mitschriften aus dem WS16/17 in F&I!"); + Product p3 = new Product("Übungen Eidip", 3,"Lösungen" , 10.50, "Lösungen zu alten Eidip Aufgaben!"); + + private ProductSearch(){ + + } + + public static ProductSearch search = null; + + public static ProductSearch getInstance(){ + if(search== null){ + search = new ProductSearch(); + } + return search; + } + + public List<Product> getProductByTyp(String typ){ + ArrayList<Product> liste = new ArrayList<Product> (); + if(typ.equals("Nachhilfe")){ + liste.add(p1); + } + if(typ.equals("Mitschriften")){ + liste.add(p2); + } + if(typ.equals("Lösungen")){ + liste.add(p3); + } + + return liste; + } +} diff --git a/target/classes/org/s4s/MyUI$MyUIServlet.class b/target/classes/org/s4s/MyUI$MyUIServlet.class index 2ee6f97f5dd8ede813ee17667fe276ea918ffcaf..6e384c0fbc9b8b32e3ac5ce4142019326d2a0a9e 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 7fd5e05e59bc505fb02cd67306c886da9bc764ec..57da999953d803a007acf2367511332fa9dffe1f 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 43046df845f418ea34302c9696ae1d0e2580f749..39bed8086f9b9ef4e1ee69a743a9e5539fab52a5 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,2 +1,5 @@ -org\s4s\MyUI$MyUIServlet.class +org\s4s\modell\objects\dto\Product.class +org\s4s\process\controll\ProductSearch.class org\s4s\MyUI.class +org\s4s\MyUI$MyUIServlet.class +org\s4s\MyUI$1.class