From b0d44160530eb721a173d56c6cd375857952aabd Mon Sep 17 00:00:00 2001 From: DieGurke <55625494+DieGurke@users.noreply.github.com> Date: Sun, 29 Sep 2019 18:53:47 +0200 Subject: [PATCH] Add files via upload --- src/main/java/envoy/client/EnvoyClient.java | 89 +++++++++++++++ src/main/java/envoy/client/ui/ChatWindow.java | 108 ++++++++++++++++++ target/classes/META-INF/MANIFEST.MF | 5 + .../envoy-client/pom.properties | 7 ++ .../informatik-ag-ngl/envoy-client/pom.xml | 41 +++++++ .../classes/envoy/client/EnvoyClient$1.class | Bin 0 -> 784 bytes target/classes/envoy/client/EnvoyClient.class | Bin 0 -> 3564 bytes .../envoy/client/ui/ChatWindow$1.class | Bin 0 -> 1329 bytes .../classes/envoy/client/ui/ChatWindow.class | Bin 0 -> 2409 bytes 9 files changed, 250 insertions(+) create mode 100644 src/main/java/envoy/client/EnvoyClient.java create mode 100644 src/main/java/envoy/client/ui/ChatWindow.java create mode 100644 target/classes/META-INF/MANIFEST.MF create mode 100644 target/classes/META-INF/maven/informatik-ag-ngl/envoy-client/pom.properties create mode 100644 target/classes/META-INF/maven/informatik-ag-ngl/envoy-client/pom.xml create mode 100644 target/classes/envoy/client/EnvoyClient$1.class create mode 100644 target/classes/envoy/client/EnvoyClient.class create mode 100644 target/classes/envoy/client/ui/ChatWindow$1.class create mode 100644 target/classes/envoy/client/ui/ChatWindow.class diff --git a/src/main/java/envoy/client/EnvoyClient.java b/src/main/java/envoy/client/EnvoyClient.java new file mode 100644 index 0000000..ecb58b2 --- /dev/null +++ b/src/main/java/envoy/client/EnvoyClient.java @@ -0,0 +1,89 @@ +package envoy.client; + +import java.awt.EventQueue; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.time.Instant; + +import javax.ws.rs.client.Client; +import javax.ws.rs.client.ClientBuilder; +import javax.ws.rs.client.Entity; +import javax.ws.rs.client.WebTarget; +import javax.ws.rs.core.Response; +import javax.xml.bind.JAXBException; +import javax.xml.datatype.DatatypeConfigurationException; +import javax.xml.datatype.DatatypeFactory; + +import envoy.client.ui.ChatWindow; +import envoy.schema.Message; +import envoy.schema.ObjectFactory; + +/** + * Project: envoy-client
+ * File: EnvoyClient.java
+ * Created: 28 Sep 2019
+ * Author: Kai S. K. Engelbart and Maximilian Käfer + */ + +public class EnvoyClient { + + public static String content1 = ""; + + + /** + * Calls Class ChatWidow + */ + public static void main(String[] args) throws DatatypeConfigurationException, JAXBException { + EventQueue.invokeLater(new Runnable() { + public void run() { + try { + ChatWindow frame = new ChatWindow(); + frame.setVisible(true); + } catch (Exception e) { + e.printStackTrace(); + } + } + }); + } + + /** + * specifies data
+ * sends xml to server
+ * gets response from server (currently 204) + */ + public static void sendMessage() throws DatatypeConfigurationException, JAXBException { + + ObjectFactory factory = new ObjectFactory(); + + Message.MetaData metaData = factory.createMessageMetaData(); + metaData.setSender("Kai"); + metaData.setRecipient("Maxi"); + metaData.setState(false); + metaData.setDate(DatatypeFactory.newInstance().newXMLGregorianCalendar(Instant.now().toString())); + + Message.Content content = factory.createMessageContent(); + content.setType("text"); + content.setText(content1); + + Message message = factory.createMessage(); + message.setMetaData(metaData); + message.getContent().add(content); + + Client client = ClientBuilder.newClient(); + WebTarget target = client.target("http://localhost:8080/envoy-server/rest/message/send"); + Response response = target.request().post(Entity.entity(message, "application/xml")); + System.out.println("Response code: " + response.getStatus()); + response.close(); + + + + } + + /** + * sets content of xml to content from ChatWindow + */ + public void setContent (String content2) { + content1 = content2; + } + +} diff --git a/src/main/java/envoy/client/ui/ChatWindow.java b/src/main/java/envoy/client/ui/ChatWindow.java new file mode 100644 index 0000000..dad7788 --- /dev/null +++ b/src/main/java/envoy/client/ui/ChatWindow.java @@ -0,0 +1,108 @@ +package envoy.client.ui; + +import java.awt.BorderLayout; +import java.awt.EventQueue; + +import javax.swing.JFrame; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTextArea; +import javax.swing.JTextPane; +import javax.swing.border.EmptyBorder; +import javax.xml.bind.JAXBException; +import javax.xml.datatype.DatatypeConfigurationException; + +import envoy.client.EnvoyClient; + +import java.awt.GridBagLayout; +import java.awt.Insets; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +import javax.swing.JButton; +import java.awt.GridBagConstraints; +import java.awt.Color; + +/** + * Project: envoy-client
+ * File: ChatWindow.java
+ * Created: 28 Sep 2019
+ * Author: Maximilian Käfer + */ + +public class ChatWindow extends JFrame { + + private JPanel contentPane; + EnvoyClient envoyClient = new EnvoyClient(); + + public ChatWindow() { + setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + setBounds(100, 100, 600, 800); + contentPane = new JPanel(); + contentPane.setBackground(new Color(220, 220, 220)); + contentPane.setForeground(new Color(0, 0, 0)); + contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); + setContentPane(contentPane); + GridBagLayout gbl_contentPane = new GridBagLayout(); + gbl_contentPane.columnWidths = new int[]{1, 1, 1}; + gbl_contentPane.rowHeights = new int[]{1, 1, 1}; + gbl_contentPane.columnWeights = new double[]{0.3, 1.0, 0.1}; + gbl_contentPane.rowWeights = new double[]{0.05, 1, 0.07}; + contentPane.setLayout(gbl_contentPane); + + + // Message enter field ---------------------------------------------------------------------------- + JTextArea messageEnterTextfield = new JTextArea(); + messageEnterTextfield.setLineWrap(true); + + GridBagConstraints gbc_moveSelectionMessageEnterTextfield = new GridBagConstraints(); + gbc_moveSelectionMessageEnterTextfield.fill = GridBagConstraints.BOTH; + gbc_moveSelectionMessageEnterTextfield.gridx = 1; + gbc_moveSelectionMessageEnterTextfield.gridy = 2; + + //gbc_moveSelectionMessageEnterTextfield.gridwidth = 10; + + gbc_moveSelectionMessageEnterTextfield.insets = new Insets(10, 10, 10, 10); + + contentPane.add(messageEnterTextfield, gbc_moveSelectionMessageEnterTextfield); + + + // Post Button ----------------------------------------------------------------------------------- + JButton postButton = new JButton("Post"); + postButton.setForeground(new Color(255, 255, 255)); + postButton.setBackground(new Color(0, 100, 0)); + + GridBagConstraints gbc_moveSelectionPostButton = new GridBagConstraints(); + + gbc_moveSelectionPostButton.fill = GridBagConstraints.BOTH; + gbc_moveSelectionPostButton.gridx = 2; + gbc_moveSelectionPostButton.gridy = 2; + + gbc_moveSelectionPostButton.insets = new Insets(10, 10, 10, 10); + + contentPane.add(postButton, gbc_moveSelectionPostButton); + + + postButton.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + try { + if(messageEnterTextfield.getText().isEmpty() == false) { + envoyClient.setContent(messageEnterTextfield.getText()); + envoyClient.sendMessage(); + } + + } catch (DatatypeConfigurationException | JAXBException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + + } + }); + + + + + + } + +} diff --git a/target/classes/META-INF/MANIFEST.MF b/target/classes/META-INF/MANIFEST.MF new file mode 100644 index 0000000..aaa130c --- /dev/null +++ b/target/classes/META-INF/MANIFEST.MF @@ -0,0 +1,5 @@ +Manifest-Version: 1.0 +Built-By: Maxi +Build-Jdk: 12.0.1 +Created-By: Maven Integration for Eclipse + diff --git a/target/classes/META-INF/maven/informatik-ag-ngl/envoy-client/pom.properties b/target/classes/META-INF/maven/informatik-ag-ngl/envoy-client/pom.properties new file mode 100644 index 0000000..d1fda1a --- /dev/null +++ b/target/classes/META-INF/maven/informatik-ag-ngl/envoy-client/pom.properties @@ -0,0 +1,7 @@ +#Generated by Maven Integration for Eclipse +#Sun Sep 29 16:49:31 CEST 2019 +m2e.projectLocation=C\:\\Users\\Maxi\\git\\envoy-client +m2e.projectName=envoy-client +groupId=informatik-ag-ngl +artifactId=envoy-client +version=0.0.1-SNAPSHOT diff --git a/target/classes/META-INF/maven/informatik-ag-ngl/envoy-client/pom.xml b/target/classes/META-INF/maven/informatik-ag-ngl/envoy-client/pom.xml new file mode 100644 index 0000000..d688c37 --- /dev/null +++ b/target/classes/META-INF/maven/informatik-ag-ngl/envoy-client/pom.xml @@ -0,0 +1,41 @@ + + 4.0.0 + + informatik-ag-ngl + envoy-client + 0.0.1-SNAPSHOT + + Envoy Client + https://github.com/informatik-ag-ngl/envoy-client + + + UTF-8 + UTF-8 + 1.8 + 1.8 + + + + + org.jboss.resteasy + resteasy-client + 4.1.1.Final + + + org.jboss.resteasy + resteasy-jaxb-provider + 4.3.1.Final + + + informatik-ag-ngl + envoy-common + 0.0.1-SNAPSHOT + + + + + envoy-client + + \ No newline at end of file diff --git a/target/classes/envoy/client/EnvoyClient$1.class b/target/classes/envoy/client/EnvoyClient$1.class new file mode 100644 index 0000000000000000000000000000000000000000..e179dc4c53c39ceda3a0b8111b08a067de72070a GIT binary patch literal 784 zcmZ`%QE$^Q5dPeyP03QWcC@TxumKySs~|$+ZHSkuNJtqVIu!v=ZfaVO)Tt78uwTUU zUN#9NegHoTadsy*CKky#pZ(o;_ucu|@9#eWJVo0@fniOk!}KVO6DgDqyT<9*{nir~ z4#V;RKjdM;)hK*DI1sURQDUf_pT3gNm#L95T;bkd>luz*D$F3Jo` zkyPT)#E#k`bgH{fC(DDwc1LPtRm~y>ynv;)OJ=T)r@f$0nY-*Hv+n=2DIJ zgdV3u7Y`U#uj-MH04@`_8+=4$hOY4g)%T}ZiQ3KyZhS*I zYM)^B*v3@|-=yS*wP6bgD85C^J2byG>Ud`sAH zc4>Pg@N8!?!~K1<<=DYZ0&CJ8V*>U4?u2YYivXG-u+~5W8U-%T+KxP0DvV2S)EduA zWzNl6`7z70)pxwuxGyxOV+~RU)}e_8gDKk=xHh|*>-3_&VA+nqRq4A{`ly`J2WE4! z7}&1kYiJeNsUn#*XA60A!V0Wlt|-l0S?%6plwNQ+;%3+p#vum zR!Lk>FIRJN%T66_Na@&!%^EfdtPjDoW|)O(;(JF)mZX7CVT(YE&AgnGSu2p9z}4xh zn2whmN5Pc|p|-q9BC|drXd3aQGchcE-2?b5pWl#rZvC?ssst+4DirX1O;6~vKTv-tgt1|{g#dL>(;}{`L=}{T$bXihPzm+GP7UA5V1ZPqtN$T{c2X`76!wCV6n34#@qARkwtb`H`DCpBTW#BaK zVjMNhVy&s>BCv5aV#N~V)#p_!kh4tkJ+L%EYft@$AwjX3#P{NFcX@Sc^hAr+Gn8h6FWlc;htD>l#XF5*n_!7RN;md?P;_{4d zdVb|Xi0*=eB|FbTH1Jj2$I2wJqIH&X?98m0pvD|MAh3HX2#S5CnOEI?%JqZ3-W|O= z%n++?UwYHhGd<}CW+CcLrs`8I_&Ofa@Ss5Js$Lm*7>@`v2JCv0l0;FtInIZXzs%b~<-*^cd7Ik0;@ixh`=&S z)d`{{oh^H@{Z;1A9Ahs)G=xZaM-!xg2^ zIX2cY`BYjB+b-gYz;m(X_VBHHJ1 z!;(3jo4}3GVOE)J;mX#~~Iyu~x`dk@zcU^!{Mvg0Ij&^sJakjgRV%GwKI-Hot7yIg4 z>r?kH;A?g0YiMm)z@q})sVC?0?FD?FYmFE1qf0n{D)sY=c&W9qj91F|br~1Rctd^7 zF9kS+6dmnl7=2jFL2y0xp%wel&e?A}Zow`NMtgCPZ=B=!JA^~H6Nfp13~~e*!W@p^ zX=L#%j)edn4%7M+F5wTfyO#a`k9dpt?!pt<8 literal 0 HcmV?d00001 diff --git a/target/classes/envoy/client/ui/ChatWindow$1.class b/target/classes/envoy/client/ui/ChatWindow$1.class new file mode 100644 index 0000000000000000000000000000000000000000..9c7d5d4553243fde0abf0b0939b2592023cd0cce GIT binary patch literal 1329 zcmaJ>>rN9v7(LTg7Ro{^7eVBzMcaZbRRj^dlu}gEstE)Y6XUQQU~#+K><$GUMPI<* zB!I>rK7bEp{ASw}Fv2FgbNepmJKvf8{paT|08@COA;i!xoT__Zn6@PxY3y1?Zkx-u zmQ!-~5*ZBM4%mhpOHN0?GW6T?8T%lD)qs>(BKO3QT$mM?`PJccH@ZTX2w zN>I2s!yLo)Dz_75;ro0`Cn)uW>H4HFx z|CbOQLl|bzwuDq1F?1zUwTMC2R-{M#%|&q&2@SW-b+mS-V-&Y3faT}Q6?qU8zTSc) z(i&0>eHV97#~8*LS_6w*AR@9qPeEQOtae5qCNQbNVCX#;^o)&;4DK;ReIau$DZ-(G zy6X&`tw-@PfhipiRI6Hj;gpIs9YryNSq%>vI#0Em-#0}?X;jA}4N5V%h?fMP8{ZExO|FdZt*ilon&B7j{Cypq;#9+OAJMFABNslECzr z4qeKe&3#|^7$&WU>AiwbJg&qK#59-J~w-q{_w$W^s)?pfB>9J$9r^k;GPk%?p zVPM!z-zG8y)^Lr!%85+TgI*fxW}~kj=1Vxr32vNVc zi{mGlJ`8}2Ab~lGrN+kuL}l!woWOg6w~j%4ptFx8-cLxu3{VUQfYWspKpIc+jBt!1 nf-Dv&ZjSuv*H_Xo6CvY8T85Cv5{(g(d?%jMEJ`k_9D4o&H|a}{ literal 0 HcmV?d00001 diff --git a/target/classes/envoy/client/ui/ChatWindow.class b/target/classes/envoy/client/ui/ChatWindow.class new file mode 100644 index 0000000000000000000000000000000000000000..c87f19692479e0c967a3e01a0aa9ac74b280dc22 GIT binary patch literal 2409 zcmaJ@%~umw6#qRkNn{)Z1k{L9wUmYkMvGMoR)io54WOW4lxio*5C$hRbY?=JEwx|v zOZ)wCPJ2#w-E`?WCTW|V{sHaMrCoICIc+!Hbl3L2nFJECorKBEefQqqy}x_kef;$I z_dfzSjL-e3Vc4nYOU6n#p{a^)hcjw8GB4XRs-85meh3U(7vv>*Ic#NBJry1uHs!R! zusLDqHtC<0b$V-#R_Sn|)<;T?=ZNE&aH3T}r#Py+MykH!s;=567(BtwX$B!;Boz@J z)Jdp?=tn)nj{hG{TkG%|AI0s=lYlkC- zW|$)O;87lZJ7ve+akN%+NO&AUhB}TWC$6PT4$06IbU0kM?{oD-684w%hYeG4_5J8( zXsaYWZkS2M44+Cb+AD+3vxqK)c>p^(?jZ?Jpr@QA*ChuoX1TT{7p}Df&+w##BRERQ zQMi%Hl5ekySGQ$VS4=YU<0*!1YgC*z)#RX@ipncS#ujmmvvv%}B|Hr(wv;fmOj@5& zllDBZUUPYbubz}Jz*j}n$evNu)Vyu^`tSBQm#_c3FZlH(S3E7@3`U5{k{ef-`x)}} zf8*-;`fvYsqwU*szjK2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