|
/*
|
|
* This program is a part of the IoTa Project.
|
|
*
|
|
* Copyright © 2008-2012 Université de Caen Basse-Normandie, GREYC
|
|
* Copyright © 2008-2012 Orange Labs
|
|
*
|
|
* This program is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
* <http://www.gnu.org/licenses/>
|
|
*
|
|
* See AUTHORS for a list of contributors.
|
|
*/
|
|
package fr.unicaen.iota.discovery.client.gui;
|
|
|
|
import fr.unicaen.iota.discovery.client.DsClient;
|
|
import fr.unicaen.iota.discovery.client.util.Configuration;
|
|
import fr.unicaen.iota.discovery.client.util.EnhancedProtocolException;
|
|
import java.io.PrintStream;
|
|
import java.rmi.RemoteException;
|
|
import java.util.Calendar;
|
|
import javax.swing.UIManager;
|
|
import org.apache.commons.logging.Log;
|
|
import org.apache.commons.logging.LogFactory;
|
|
|
|
/**
|
|
*
|
|
*/
|
|
public class CaptureClient extends GuiClient {
|
|
|
|
private static final Log log = LogFactory.getLog(CaptureClient.class);
|
|
|
|
public CaptureClient() {
|
|
try {
|
|
UIManager.setLookAndFeel("com.sun.java.swing.plaf.gtk.GTKLookAndFeel");
|
|
} catch (Exception e) {
|
|
log.error(null, e);
|
|
}
|
|
initComponents();
|
|
this.setLocationRelativeTo(null);
|
|
JTextAreaOutputStream oos = new JTextAreaOutputStream(jTextArea1);
|
|
JTextAreaOutputStream eos = new JTextAreaOutputStream(jTextArea2);
|
|
System.setOut(new PrintStream(oos));
|
|
System.setErr(new PrintStream(eos));
|
|
}
|
|
|
|
/**
|
|
* This method is called from within the constructor to initialize the form.
|
|
* WARNING: Do NOT modify this code. The content of this method is always
|
|
* regenerated by the Form Editor.
|
|
*/
|
|
@SuppressWarnings("unchecked")
|
|
// <editor-fold defaultstate="collapsed" desc="Generated Code">
|
|
private void initComponents() {
|
|
|
|
jPanel1 = new javax.swing.JPanel();
|
|
jLabel1 = new javax.swing.JLabel();
|
|
jTextField1 = new javax.swing.JTextField();
|
|
jButton1 = new javax.swing.JButton();
|
|
jPanel2 = new javax.swing.JPanel();
|
|
jTextField2 = new javax.swing.JTextField();
|
|
jTextField3 = new javax.swing.JTextField();
|
|
jTextField4 = new javax.swing.JTextField();
|
|
jTextField5 = new javax.swing.JTextField();
|
|
jTextField6 = new javax.swing.JTextField();
|
|
jTextField7 = new javax.swing.JTextField();
|
|
jLabel3 = new javax.swing.JLabel();
|
|
jLabel4 = new javax.swing.JLabel();
|
|
jLabel5 = new javax.swing.JLabel();
|
|
jLabel6 = new javax.swing.JLabel();
|
|
jLabel7 = new javax.swing.JLabel();
|
|
jLabel8 = new javax.swing.JLabel();
|
|
jButton3 = new javax.swing.JButton();
|
|
jButton5 = new javax.swing.JButton();
|
|
jButton2 = new javax.swing.JButton();
|
|
jLabel2 = new javax.swing.JLabel();
|
|
jPanel3 = new javax.swing.JPanel();
|
|
jTabbedPane1 = new javax.swing.JTabbedPane();
|
|
jScrollPane1 = new javax.swing.JScrollPane();
|
|
jTextArea1 = new javax.swing.JTextArea();
|
|
jScrollPane2 = new javax.swing.JScrollPane();
|
|
jTextArea2 = new javax.swing.JTextArea();
|
|
jButton6 = new javax.swing.JButton();
|
|
jButton4 = new javax.swing.JButton();
|
|
|
|
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
|
|
setTitle("DS capture client ...");
|
|
setForeground(java.awt.Color.white);
|
|
|
|
jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Service address", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("DejaVu Sans", 0, 13), new java.awt.Color(33, 32, 90))); // NOI18N
|
|
|
|
jLabel1.setText("Service address: ");
|
|
|
|
jTextField1.setText("http://ds.iota.greyc.fr:8080/ds-unicaen/services/ESDS_Service");
|
|
|
|
jButton1.setText("Test");
|
|
jButton1.addActionListener(new java.awt.event.ActionListener() {
|
|
|
|
@Override
|
|
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
|
jButton1ActionPerformed(evt);
|
|
}
|
|
});
|
|
|
|
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
|
|
jPanel1.setLayout(jPanel1Layout);
|
|
jPanel1Layout.setHorizontalGroup(
|
|
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(jPanel1Layout.createSequentialGroup().addContainerGap().addComponent(jLabel1).addGap(6, 6, 6).addComponent(jTextField1, javax.swing.GroupLayout.DEFAULT_SIZE, 402, Short.MAX_VALUE).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED).addComponent(jButton1).addContainerGap()));
|
|
jPanel1Layout.setVerticalGroup(
|
|
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(jPanel1Layout.createSequentialGroup().addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE).addComponent(jTextField1, javax.swing.GroupLayout.DEFAULT_SIZE, 27, Short.MAX_VALUE).addComponent(jButton1).addComponent(jLabel1)).addContainerGap()));
|
|
|
|
jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Event properties", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("DejaVu Sans", 0, 13), new java.awt.Color(37, 41, 98))); // NOI18N
|
|
jLabel3.setText("Time to live:");
|
|
jLabel4.setText("Priority:");
|
|
jLabel5.setText("Source Time Stamp:");
|
|
jLabel6.setText("Class:");
|
|
jLabel7.setText("Business Step:");
|
|
jLabel8.setText("EPC:");
|
|
jButton3.setText("Publish");
|
|
jButton3.addActionListener(new java.awt.event.ActionListener() {
|
|
|
|
@Override
|
|
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
|
jButton3ActionPerformed(evt);
|
|
}
|
|
});
|
|
|
|
jButton5.setText("Reset");
|
|
jButton5.addActionListener(new java.awt.event.ActionListener() {
|
|
|
|
@Override
|
|
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
|
jButton5ActionPerformed(evt);
|
|
}
|
|
});
|
|
|
|
jButton2.setText("fill in with exemple");
|
|
jButton2.addActionListener(new java.awt.event.ActionListener() {
|
|
|
|
@Override
|
|
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
|
jButton2ActionPerformed(evt);
|
|
}
|
|
});
|
|
|
|
jLabel2.setForeground(new java.awt.Color(45, 48, 110));
|
|
jLabel2.setText("All text fields have to be filled");
|
|
|
|
javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
|
|
jPanel2.setLayout(jPanel2Layout);
|
|
jPanel2Layout.setHorizontalGroup(
|
|
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(jPanel2Layout.createSequentialGroup().addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING).addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel2Layout.createSequentialGroup().addContainerGap().addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(jLabel5).addComponent(jLabel4).addComponent(jLabel3).addComponent(jLabel6).addComponent(jLabel7).addComponent(jLabel8)).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(jTextField2, javax.swing.GroupLayout.DEFAULT_SIZE, 426, Short.MAX_VALUE).addComponent(jTextField3, javax.swing.GroupLayout.DEFAULT_SIZE, 426, Short.MAX_VALUE).addComponent(jTextField4, javax.swing.GroupLayout.DEFAULT_SIZE, 426, Short.MAX_VALUE).addComponent(jTextField7, javax.swing.GroupLayout.DEFAULT_SIZE, 426, Short.MAX_VALUE).addComponent(jTextField6, javax.swing.GroupLayout.DEFAULT_SIZE, 426, Short.MAX_VALUE).addComponent(jTextField5, javax.swing.GroupLayout.DEFAULT_SIZE, 426, Short.MAX_VALUE))).addGroup(jPanel2Layout.createSequentialGroup().addGap(41, 41, 41).addComponent(jLabel2).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 89, Short.MAX_VALUE).addComponent(jButton2).addGap(18, 18, 18).addComponent(jButton5).addGap(18, 18, 18).addComponent(jButton3))).addContainerGap()));
|
|
jPanel2Layout.setVerticalGroup(
|
|
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(jPanel2Layout.createSequentialGroup().addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE).addComponent(jLabel8).addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE)).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE).addComponent(jLabel7).addComponent(jTextField3, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE)).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE).addComponent(jLabel6).addComponent(jTextField4, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE)).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE).addComponent(jLabel5).addComponent(jTextField5, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE)).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE).addComponent(jLabel4).addComponent(jTextField6, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE)).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE).addComponent(jLabel3).addComponent(jTextField7, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE)).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED).addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE).addComponent(jButton3).addComponent(jButton5).addComponent(jButton2).addComponent(jLabel2)).addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));
|
|
|
|
jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Logs", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("DejaVu Sans", 0, 13), new java.awt.Color(28, 32, 88))); // NOI18N
|
|
|
|
jTextArea1.setColumns(20);
|
|
jTextArea1.setRows(5);
|
|
jScrollPane1.setViewportView(jTextArea1);
|
|
|
|
jTabbedPane1.addTab("Execution stack", jScrollPane1);
|
|
|
|
jTextArea2.setColumns(20);
|
|
jTextArea2.setRows(5);
|
|
jScrollPane2.setViewportView(jTextArea2);
|
|
|
|
jTabbedPane1.addTab("Debug stack", jScrollPane2);
|
|
|
|
jButton6.setText("Clear debug stack");
|
|
jButton6.addActionListener(new java.awt.event.ActionListener() {
|
|
|
|
@Override
|
|
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
|
jButton6ActionPerformed(evt);
|
|
}
|
|
});
|
|
|
|
jButton4.setText("Clear execution stack");
|
|
jButton4.addActionListener(new java.awt.event.ActionListener() {
|
|
|
|
@Override
|
|
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
|
jButton4ActionPerformed(evt);
|
|
}
|
|
});
|
|
|
|
javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
|
|
jPanel3.setLayout(jPanel3Layout);
|
|
jPanel3Layout.setHorizontalGroup(
|
|
jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup().addContainerGap().addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING).addComponent(jTabbedPane1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 573, Short.MAX_VALUE).addGroup(jPanel3Layout.createSequentialGroup().addComponent(jButton4).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(jButton6))).addContainerGap()));
|
|
jPanel3Layout.setVerticalGroup(
|
|
jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup().addComponent(jTabbedPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 168, Short.MAX_VALUE).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED).addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE).addComponent(jButton6).addComponent(jButton4)).addContainerGap()));
|
|
|
|
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
|
|
getContentPane().setLayout(layout);
|
|
layout.setHorizontalGroup(
|
|
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup().addContainerGap().addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING).addComponent(jPanel3, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE).addComponent(jPanel1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE).addComponent(jPanel2, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)).addContainerGap()));
|
|
layout.setVerticalGroup(
|
|
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(layout.createSequentialGroup().addContainerGap().addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED).addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE).addContainerGap()));
|
|
|
|
pack();
|
|
}// </editor-fold>
|
|
|
|
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
|
|
log.info("Processing Hello ...");
|
|
String address = jTextField1.getText();
|
|
DsClient dsClient = new DsClient(address);
|
|
try {
|
|
dsClient.hello(Configuration.DEFAULT_SESSION);
|
|
} catch (EnhancedProtocolException ex) {
|
|
System.out.println(ex.getMessage());
|
|
return;
|
|
} catch (RemoteException ex) {
|
|
System.out.println(ex.getMessage());
|
|
return;
|
|
}
|
|
log.info("Done.");
|
|
}
|
|
|
|
private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {
|
|
jTextArea1.setText("");
|
|
}
|
|
|
|
private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {
|
|
jTextField1.setText("");
|
|
jTextField2.setText("");
|
|
jTextField3.setText("");
|
|
jTextField4.setText("");
|
|
jTextField5.setText("");
|
|
jTextField6.setText("");
|
|
jTextField7.setText("");
|
|
}
|
|
|
|
private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {
|
|
LoginPassModal lpm = new LoginPassModal(this);
|
|
lpm.setModal(true);
|
|
lpm.setVisible(true);
|
|
if (isCanceled()) {
|
|
setCanceled(false);
|
|
return;
|
|
}
|
|
log.info("Processing publish ...");
|
|
for (String epc : jTextField2.getText().split(",")) {
|
|
CaptureOperation captureOperation = new CaptureOperation();
|
|
captureOperation.setBUSINESS_STEP(jTextField3.getText());
|
|
captureOperation.setCLASS(jTextField4.getText());
|
|
captureOperation.setEPC(epc);
|
|
captureOperation.setLOGIN(getLogin());
|
|
captureOperation.setPASS(getPasswd());
|
|
captureOperation.setPRIORITY(Integer.parseInt(jTextField6.getText()));
|
|
captureOperation.setSERVICE_ADDRESS(jTextField1.getText());
|
|
captureOperation.setSOURCE_TS(Calendar.getInstance()); //jtextField5
|
|
captureOperation.setTTL(Integer.parseInt(jTextField7.getText()));
|
|
captureOperation.publishEvent(captureOperation.getSERVICE_ADDRESS());
|
|
}
|
|
}
|
|
|
|
private void jButton6ActionPerformed(java.awt.event.ActionEvent evt) {
|
|
jTextArea2.setText("");
|
|
}
|
|
|
|
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
|
|
jTextField2.setText("urn:epc:id:sgtin:1.2.3");
|
|
jTextField3.setText("urn:orange:demo:bizstep:fmcg:production");
|
|
jTextField4.setText("C1");
|
|
jTextField5.setText("*");
|
|
jTextField6.setText("1");
|
|
jTextField7.setText("30");
|
|
}
|
|
|
|
/**
|
|
* @param args the command line arguments
|
|
*/
|
|
public static void main(String args[]) {
|
|
java.awt.EventQueue.invokeLater(new Runnable() {
|
|
|
|
@Override
|
|
public void run() {
|
|
new CaptureClient().setVisible(true);
|
|
}
|
|
});
|
|
}
|
|
// Variables declaration - do not modify
|
|
private javax.swing.JButton jButton1;
|
|
private javax.swing.JButton jButton2;
|
|
private javax.swing.JButton jButton3;
|
|
private javax.swing.JButton jButton4;
|
|
private javax.swing.JButton jButton5;
|
|
private javax.swing.JButton jButton6;
|
|
private javax.swing.JLabel jLabel1;
|
|
private javax.swing.JLabel jLabel2;
|
|
private javax.swing.JLabel jLabel3;
|
|
private javax.swing.JLabel jLabel4;
|
|
private javax.swing.JLabel jLabel5;
|
|
private javax.swing.JLabel jLabel6;
|
|
private javax.swing.JLabel jLabel7;
|
|
private javax.swing.JLabel jLabel8;
|
|
private javax.swing.JPanel jPanel1;
|
|
private javax.swing.JPanel jPanel2;
|
|
private javax.swing.JPanel jPanel3;
|
|
private javax.swing.JScrollPane jScrollPane1;
|
|
private javax.swing.JScrollPane jScrollPane2;
|
|
private javax.swing.JTabbedPane jTabbedPane1;
|
|
private javax.swing.JTextArea jTextArea1;
|
|
private javax.swing.JTextArea jTextArea2;
|
|
private javax.swing.JTextField jTextField1;
|
|
private javax.swing.JTextField jTextField2;
|
|
private javax.swing.JTextField jTextField3;
|
|
private javax.swing.JTextField jTextField4;
|
|
private javax.swing.JTextField jTextField5;
|
|
private javax.swing.JTextField jTextField6;
|
|
private javax.swing.JTextField jTextField7;
|
|
// End of variables declaration
|
|
}
|