From 1c038f7e910a0a082eae3fa04a123be05673f6e8 Mon Sep 17 00:00:00 2001 From: hkarwa2s <holger.karwanni@smail.inf.h-brs.de> Date: Sat, 15 Apr 2017 19:03:07 +0200 Subject: [PATCH] Anhand von Tutorial mal eine Tabellenfunktion implementiert, ist noch sehr simpel gehalten und ohne Bezug auf eine Datenbank. --- nbactions.xml | 21 +++++ src/main/java/org/s4s/MyUI.java | 63 ++++++++++++++- .../org/s4s/modell/objects/dto/Product.java | 72 ++++++++++++++++++ .../s4s/process/controll/ProductSearch.java | 49 ++++++++++++ target/classes/org/s4s/MyUI$MyUIServlet.class | Bin 613 -> 613 bytes target/classes/org/s4s/MyUI.class | Bin 873 -> 2717 bytes .../compile/default-compile/createdFiles.lst | 5 +- 7 files changed, 207 insertions(+), 3 deletions(-) create mode 100644 src/main/java/org/s4s/modell/objects/dto/Product.java create mode 100644 src/main/java/org/s4s/process/controll/ProductSearch.java diff --git a/nbactions.xml b/nbactions.xml index 8e9c9c7..96f859f 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 0b0a92c..9360b11 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 0000000..686f73e --- /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 0000000..2133119 --- /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 GIT binary patch delta 13 UcmaFL@|0x*4-;eDWL~BS03jv=>Hq)$ delta 13 UcmaFL@|0x*4-=#EWL~BS03ZJYuK)l5 diff --git a/target/classes/org/s4s/MyUI.class b/target/classes/org/s4s/MyUI.class index 7fd5e05e59bc505fb02cd67306c886da9bc764ec..57da999953d803a007acf2367511332fa9dffe1f 100644 GIT binary patch literal 2717 zcma)8TXz#x6#k}7GD$k+652wbK!74?p#&6A+KTo<X(6T9lwuIXX>w=>CNpJbQfL(g z6)!xwmXE&b50Hm+Ewh$Cz#rxEJCig_QmW?RT=xF<eV?8A>+e7Q1aJ;7<LJXR71=0e z;%LKl6|-@KaZN5a;y8wnRLsQ@lb~E29de(K;${pBxD`hyK9<b9gy&<pjZft1jy&B} z@u`Y?arEG`D0I0mswhNJjN<@=T<*(dNyTy;DHu}Q0~HTdm?}yNI%d{xPUnQPY6?$* zHf>qL88>y;6|REFh+!GtB?ay2{sjf0al0rK?93XLxLz(T3TIwlG)YNh?SgJD=#C-p zbz;a{HmGAq)^?UM?m0IjEe%tP)Ty8^oh{g<%&M*z4J+f)1L0&A{M(#(R2Hr`ENyny z0CkdrBmXI-AZ+T3!c@>5#FmXrR+8yK#MIa9GJQDI0$31^XE2hi&nI%%vh5h_w&iWo z6r@^Yrdkk`ih1IRci#|ZQ9-f=K2O%9WJy03%bsUj3VK>VV?LdTP*L}E<|@dSq)gc} z%*>e3t#Rob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{>)%#YN0w2)8hdyQJR7 zC@1$Ao{;+j6L^Ws_z6?^6?s2VcWTL~CyHsoS!(2X!7tQ$j+sy3XX?H{KaS%W-o<-N z=V?ypi?kA^1%sAGnEXdXzmH2$X(xpb@F5dDN}pvZYP>P>+UbX^=LG!#V`{@B`Bz-J dG+jGf#R+ou`}U6EE&7+@UH-n~2jKUS*gww<<vsua delta 304 zcmYL^O-=$q6okK-W~PS*0TB>X<WCd^6E|+SfIGJsw_L#kcm^{YH?D{Wa3hH(9)O#8 z0hh#@mc(@W)$4v$U%FqK-|=L#{rCc|nK>+d%OGLs2pKtI&Mafgx#i+%^^-aCY)X`~ zS96n;n3S24X7lJSTSe(31Np5`C>$W4>Yh$l(m)!eYl1gFuBgWTvO`sUZk2%=`_ck+ z4s?@;7Z@$5eG=Z+&6>h(dihTD&#Cx%cZuUvu$~9@|3W*U;xuRqng6N9p<ZZc3mekm YNZL?$tog|UU15CFlN;@TM5!XhUlk!5qyPW_ 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 43046df..39bed80 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 -- GitLab