/*
* 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 semesterprojectv5;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import java.text.SimpleDateFormat;
import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.EntityTransaction;
import javax.persistence.Persistence;
import javax.persistence.Query;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;
import okhttp3.OkHttpClient;
import okhttp3.Request;
/**
*
* @author alexa
*/
public class Showdata
extends javax.
swing.
JFrame {
EntityManagerFactory emf = Persistence.createEntityManagerFactory("Semesterprojectv5PU");
EntityManager em = emf.createEntityManager();
EntityTransaction tx = em.getTransaction();
CountryJpaController cjc = new CountryJpaController(emf);
CoviddataJpaController covjc = new CoviddataJpaController(emf);
public Showdata() {
initComponents();
PopulateTable1();
PopulateTable2();
PopulateTable3();
List<Country> countries = cjc.findCountryEntities();
for (Country c : countries) {
model.addElement(c.getName());
}
jComboBox1.setModel(model);
List<Coviddata> dates = covjc.findCoviddataEntities();
for (Coviddata cov : dates) {
modeldate.addElement(cov.getTrndate());
}
jComboBox2.setModel(modeldate);
jComboBox3.setModel(modeldate);
//end
}
public void PopulateTable1(){
tmodel.addColumn("Trndate");
tmodel.addColumn("Qty");
tmodel.addColumn("Proodqty");
List<Coviddata> trndates = covjc.findCoviddataEntities();
for (Coviddata cov : trndates) {
rowdata[0] = cov.getTrndate().toString();
rowdata[1] = cov.getQty();
rowdata[2] = cov.getProodqty();
tmodel.addRow(rowdata);
}
}
public void PopulateTable2(){
tmodel.addColumn("Trndate");
tmodel.addColumn("Qty");
tmodel.addColumn("Proodqty");
List<Coviddata> trndates = covjc.findCoviddataEntities();
for (Coviddata cov : trndates) {
rowdata[0] = cov.getTrndate().toString();
rowdata[1] = cov.getQty();
rowdata[2] = cov.getProodqty();
tmodel.addRow(rowdata);
}
}
public void PopulateTable3(){
tmodel.addColumn("Trndate");
tmodel.addColumn("Qty");
tmodel.addColumn("Proodqty");
List<Coviddata> trndates = covjc.findCoviddataEntities();
for (Coviddata cov : trndates) {
rowdata[0] = cov.getTrndate().toString();
rowdata[1] = cov.getQty();
rowdata[2] = cov.getProodqty();
tmodel.addRow(rowdata);
}
}
/**
* 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() {
jLabel1
= new javax.
swing.
JLabel();
jComboBox1 = new javax.swing.JComboBox<>();
jLabel2
= new javax.
swing.
JLabel();
jComboBox2 = new javax.swing.JComboBox<>();
jLabel3
= new javax.
swing.
JLabel();
jComboBox3 = new javax.swing.JComboBox<>();
jComboBox4 = new javax.swing.JComboBox<>();
jButton1
= new javax.
swing.
JButton();
jButton2
= new javax.
swing.
JButton();
jButton3
= new javax.
swing.
JButton();
jTable1
= new javax.
swing.
JTable();
jTable2
= new javax.
swing.
JTable();
jTable3
= new javax.
swing.
JTable();
jLabel1.
setFont(new java.
awt.
Font("Tahoma",
0,
16)); // NOI18N
jLabel1.setText("Select Country");
jComboBox1.
setFont(new java.
awt.
Font("Tahoma",
0,
16)); // NOI18N
jComboBox1.setMaximumRowCount(300);
jComboBox1.setModel(jComboBox1.getModel());
public void actionPerformed
(java.
awt.
event.
ActionEvent evt
) {
jComboBox1ActionPerformed(evt);
}
});
jLabel2.
setFont(new java.
awt.
Font("Tahoma",
0,
16)); // NOI18N
jLabel2.setText("from Date");
jComboBox2.
setFont(new java.
awt.
Font("Tahoma",
0,
16)); // NOI18N
public void actionPerformed
(java.
awt.
event.
ActionEvent evt
) {
jComboBox2ActionPerformed(evt);
}
});
jLabel3.
setFont(new java.
awt.
Font("Tahoma",
0,
16)); // NOI18N
jLabel3.setText("to Date");
jComboBox3.
setFont(new java.
awt.
Font("Tahoma",
0,
16)); // NOI18N
public void actionPerformed
(java.
awt.
event.
ActionEvent evt
) {
jComboBox3ActionPerformed(evt);
}
});
jComboBox4.
setFont(new java.
awt.
Font("Tahoma",
0,
16)); // NOI18N
jComboBox4.
setModel(new javax.
swing.
DefaultComboBoxModel<>(new String[] { "Complite Chart",
"Deaths",
"Confirmed Cases",
"Recovered" }));
jButton1.
setFont(new java.
awt.
Font("Tahoma",
0,
16)); // NOI18N
jButton1.setText("Chart View");
jButton2.
setFont(new java.
awt.
Font("Tahoma",
0,
16)); // NOI18N
jButton2.setText("View on Google maps");
jButton3.
setFont(new java.
awt.
Font("Tahoma",
0,
16)); // NOI18N
jButton3.setText("Delete Data");
{},
{},
{},
{}
},
}
));
jScrollPane1.setViewportView(jTable1);
jTable1.getAccessibleContext().setAccessibleName("");
{},
{},
{},
{}
},
}
));
jScrollPane2.setViewportView(jTable2);
{},
{},
{},
{}
},
}
));
jScrollPane3.setViewportView(jTable3);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jButton2)
.addComponent(jLabel1)
.addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, 180, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel2)
.addComponent(jComboBox2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel3)
.addComponent(jComboBox3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jComboBox4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jButton1))
.addGap(65, 65, 65)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jButton3)
.addGroup(layout.createSequentialGroup()
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 265, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 266, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 261, javax.swing.GroupLayout.PREFERRED_SIZE)))
.
addContainerGap(55,
Short.
MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(31, 31, 31)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel1)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(45, 45, 45)
.addComponent(jLabel2)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jComboBox2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(45, 45, 45)
.addComponent(jLabel3)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jComboBox3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(100, 100, 100)
.addComponent(jButton1)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jComboBox4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.
addPreferredGap(javax.
swing.
LayoutStyle.
ComponentPlacement.
RELATED,
59,
Short.
MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jButton2)
.addComponent(jButton3))
.addGap(72, 72, 72))
);
pack();
}// </editor-fold>
private void jComboBox1ActionPerformed
(java.
awt.
event.
ActionEvent evt
) {
}
private void jComboBox2ActionPerformed
(java.
awt.
event.
ActionEvent evt
) {
// TODO add your handling code here:
}
private void jComboBox3ActionPerformed
(java.
awt.
event.
ActionEvent evt
) {
// TODO add your handling code here:
}
/**
* @param args the command line arguments
*/
public static void main
(String args
[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
if ("Nimbus".equals(info.getName())) {
javax.
swing.
UIManager.
setLookAndFeel(info.
getClassName());
break;
}
}
java.util.logging.Logger.getLogger(Showdata.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
java.util.logging.Logger.getLogger(Showdata.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
java.util.logging.Logger.getLogger(Showdata.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
java.util.logging.Logger.getLogger(Showdata.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
/* Create and display the form */
public void run() {
new Showdata().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.JComboBox<String> jComboBox1;
private javax.swing.JComboBox<String> jComboBox2;
private javax.swing.JComboBox<String> jComboBox3;
private javax.swing.JComboBox<String> jComboBox4;
private javax.
swing.
JLabel jLabel1
;
private javax.
swing.
JLabel jLabel2
;
private javax.
swing.
JLabel jLabel3
;
private javax.
swing.
JTable jTable1
;
private javax.
swing.
JTable jTable2
;
private javax.
swing.
JTable jTable3
;
// End of variables declaration
}