From 466a2393accd0d6d2df5f68d53488c667d5369de Mon Sep 17 00:00:00 2001 From: Harishankar Date: Mon, 30 Mar 2020 22:27:24 +0530 Subject: [PATCH] Manage Legal Notices - Dispatch Details Created the screen for updating dispatch details --- src/habeas/DatabaseSettingsDialog.form | 1 - src/habeas/DatabaseSettingsDialog.java | 1 - src/habeas/DispatchDetailsDialog.form | 140 +++++++++++++++ src/habeas/DispatchDetailsDialog.java | 225 +++++++++++++++++++++++++ src/habeas/DraftStatusDialog.form | 6 +- src/habeas/DraftStatusDialog.java | 6 +- src/habeas/Habeas.java | 2 +- src/habeas/ManageNoticesDialog.form | 9 + src/habeas/ManageNoticesDialog.java | 28 ++- src/habeas/Utility.java | 32 ++++ 10 files changed, 439 insertions(+), 11 deletions(-) create mode 100644 src/habeas/DispatchDetailsDialog.form create mode 100644 src/habeas/DispatchDetailsDialog.java diff --git a/src/habeas/DatabaseSettingsDialog.form b/src/habeas/DatabaseSettingsDialog.form index a9ebf5e..cf74391 100644 --- a/src/habeas/DatabaseSettingsDialog.form +++ b/src/habeas/DatabaseSettingsDialog.form @@ -5,7 +5,6 @@ - diff --git a/src/habeas/DatabaseSettingsDialog.java b/src/habeas/DatabaseSettingsDialog.java index 0b7475f..c28c82d 100644 --- a/src/habeas/DatabaseSettingsDialog.java +++ b/src/habeas/DatabaseSettingsDialog.java @@ -40,7 +40,6 @@ public class DatabaseSettingsDialog extends javax.swing.JDialog { setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); setTitle("Connection"); setLocationByPlatform(true); - setResizable(false); jLabel1.setText("Path to Database"); diff --git a/src/habeas/DispatchDetailsDialog.form b/src/habeas/DispatchDetailsDialog.form new file mode 100644 index 0000000..3f219c3 --- /dev/null +++ b/src/habeas/DispatchDetailsDialog.form @@ -0,0 +1,140 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/src/habeas/DispatchDetailsDialog.java b/src/habeas/DispatchDetailsDialog.java new file mode 100644 index 0000000..4cfa913 --- /dev/null +++ b/src/habeas/DispatchDetailsDialog.java @@ -0,0 +1,225 @@ +/* + * 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 habeas; + +import java.util.Date; +import javax.swing.JOptionPane; + +/** + * + * @author hari + */ +public class DispatchDetailsDialog extends javax.swing.JDialog { + + private int selected_id; + + /** + * Creates new form DispatchDetailsDialog + */ + public DispatchDetailsDialog(java.awt.Frame parent, boolean modal) { + super(parent, modal); + initComponents(); + } + + /** + * 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") + // //GEN-BEGIN:initComponents + private void initComponents() { + + checkNoticeSent = new javax.swing.JCheckBox(); + dateSending = new org.jdesktop.swingx.JXDatePicker(); + jLabel1 = new javax.swing.JLabel(); + jLabel2 = new javax.swing.JLabel(); + textRPADReference = new javax.swing.JTextField(); + checkNoticeDelivered = new javax.swing.JCheckBox(); + jLabel3 = new javax.swing.JLabel(); + dateDelivery = new org.jdesktop.swingx.JXDatePicker(); + buttonApply = new javax.swing.JButton(); + buttonCancel = new javax.swing.JButton(); + + setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); + setTitle("Dispatch Details"); + setLocationByPlatform(true); + + checkNoticeSent.setText("Notice Sent"); + + jLabel1.setText("Date of sending"); + + jLabel2.setText("RPAD reference"); + + checkNoticeDelivered.setText("Notice delivered"); + + jLabel3.setText("Date of delivery"); + + buttonApply.setMnemonic('A'); + buttonApply.setText("Apply"); + buttonApply.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + buttonApplyActionPerformed(evt); + } + }); + + buttonCancel.setMnemonic('c'); + buttonCancel.setText("Cancel"); + buttonCancel.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + buttonCancelActionPerformed(evt); + } + }); + + 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(checkNoticeSent, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(checkNoticeDelivered, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addGroup(layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) + .addComponent(jLabel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, 137, Short.MAX_VALUE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(dateSending, javax.swing.GroupLayout.DEFAULT_SIZE, 330, Short.MAX_VALUE) + .addComponent(textRPADReference) + .addComponent(dateDelivery, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() + .addGap(0, 0, Short.MAX_VALUE) + .addComponent(buttonApply, javax.swing.GroupLayout.PREFERRED_SIZE, 102, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(buttonCancel, javax.swing.GroupLayout.PREFERRED_SIZE, 102, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addContainerGap()) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addComponent(checkNoticeSent) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(dateSending, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel1)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel2) + .addComponent(textRPADReference, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(checkNoticeDelivered) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel3) + .addComponent(dateDelivery, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 17, Short.MAX_VALUE) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(buttonApply) + .addComponent(buttonCancel)) + .addContainerGap()) + ); + + pack(); + }// //GEN-END:initComponents + + private void buttonCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonCancelActionPerformed + // TODO add your handling code here: + dispose (); + }//GEN-LAST:event_buttonCancelActionPerformed + + private void buttonApplyActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonApplyActionPerformed + // TODO add your handling code here: + if (checkNoticeSent.isSelected() && + ("".equals(textRPADReference.getText()) || dateSending.getDate() == null)) { + JOptionPane.showMessageDialog(this, MANDATORY_FIELDS_MISSING); + return; + } + if (checkNoticeDelivered.isSelected() && dateDelivery.getDate() == null) { + JOptionPane.showMessageDialog(this, MANDATORY_FIELDS_MISSING); + return; + } + boolean rt = Utility.updateNoticeDispatchDetails + (selected_id,checkNoticeSent.isSelected(), dateSending.getDate(), + textRPADReference.getText(), + checkNoticeDelivered.isSelected(), dateDelivery.getDate()); + if (rt == false) + JOptionPane.showMessageDialog(this, ERROR_UPDATING); + else + dispose (); + }//GEN-LAST:event_buttonApplyActionPerformed + private static final String ERROR_UPDATING = "Error in updating"; + private static final String MANDATORY_FIELDS_MISSING = "Mandatory fields missing!"; + + /** + * @param args the command line arguments + */ + public static void main(String args[]) { + /* Set the Nimbus look and feel */ + // + /* 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 { + for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { + if ("Nimbus".equals(info.getName())) { + javax.swing.UIManager.setLookAndFeel(info.getClassName()); + break; + } + } + } catch (ClassNotFoundException ex) { + java.util.logging.Logger.getLogger(DispatchDetailsDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + } catch (InstantiationException ex) { + java.util.logging.Logger.getLogger(DispatchDetailsDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + } catch (IllegalAccessException ex) { + java.util.logging.Logger.getLogger(DispatchDetailsDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + } catch (javax.swing.UnsupportedLookAndFeelException ex) { + java.util.logging.Logger.getLogger(DispatchDetailsDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + } + // + + /* Create and display the dialog */ + java.awt.EventQueue.invokeLater(new Runnable() { + public void run() { + DispatchDetailsDialog dialog = new DispatchDetailsDialog(new javax.swing.JFrame(), true); + dialog.addWindowListener(new java.awt.event.WindowAdapter() { + @Override + public void windowClosing(java.awt.event.WindowEvent e) { + System.exit(0); + } + }); + dialog.setVisible(true); + } + }); + } + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JButton buttonApply; + private javax.swing.JButton buttonCancel; + private javax.swing.JCheckBox checkNoticeDelivered; + private javax.swing.JCheckBox checkNoticeSent; + private org.jdesktop.swingx.JXDatePicker dateDelivery; + private org.jdesktop.swingx.JXDatePicker dateSending; + private javax.swing.JLabel jLabel1; + private javax.swing.JLabel jLabel2; + private javax.swing.JLabel jLabel3; + private javax.swing.JTextField textRPADReference; + // End of variables declaration//GEN-END:variables + + void setFields(int selid, boolean notice_sent, Date sent_date, + String rpad_reference, boolean notice_delivered, + Date delivery_date) { + selected_id = selid; + checkNoticeSent.setSelected(notice_sent); + dateSending.setDate(sent_date); + checkNoticeDelivered.setSelected(notice_delivered); + textRPADReference.setText(rpad_reference); + dateDelivery.setDate(delivery_date); + } +} diff --git a/src/habeas/DraftStatusDialog.form b/src/habeas/DraftStatusDialog.form index cd6f65f..2c8baa8 100644 --- a/src/habeas/DraftStatusDialog.form +++ b/src/habeas/DraftStatusDialog.form @@ -33,11 +33,11 @@ - - + + - + diff --git a/src/habeas/DraftStatusDialog.java b/src/habeas/DraftStatusDialog.java index 0322a50..4bf55d9 100644 --- a/src/habeas/DraftStatusDialog.java +++ b/src/habeas/DraftStatusDialog.java @@ -78,11 +78,11 @@ public class DraftStatusDialog extends javax.swing.JDialog { .addComponent(checkDraftCreated, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(checkDraftApproved, javax.swing.GroupLayout.DEFAULT_SIZE, 224, Short.MAX_VALUE)) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) - .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() - .addContainerGap(195, Short.MAX_VALUE) + .addGroup(layout.createSequentialGroup() + .addContainerGap(183, Short.MAX_VALUE) .addComponent(buttonUpdate, javax.swing.GroupLayout.PREFERRED_SIZE, 92, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(buttonCancel, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(buttonCancel, javax.swing.GroupLayout.PREFERRED_SIZE, 92, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap()) ); layout.setVerticalGroup( diff --git a/src/habeas/Habeas.java b/src/habeas/Habeas.java index e6fa843..73efc94 100644 --- a/src/habeas/Habeas.java +++ b/src/habeas/Habeas.java @@ -24,7 +24,7 @@ public class Habeas { Utility.getConnectionURL(); try { - UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); + UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName()); } catch (ClassNotFoundException ex) { Logger.getLogger(Habeas.class.getName()).log(Level.SEVERE, null, ex); } catch (InstantiationException ex) { diff --git a/src/habeas/ManageNoticesDialog.form b/src/habeas/ManageNoticesDialog.form index 3a5c2f1..db94879 100644 --- a/src/habeas/ManageNoticesDialog.form +++ b/src/habeas/ManageNoticesDialog.form @@ -26,6 +26,15 @@ + + + + + + + + + diff --git a/src/habeas/ManageNoticesDialog.java b/src/habeas/ManageNoticesDialog.java index 73d73fe..60a9125 100644 --- a/src/habeas/ManageNoticesDialog.java +++ b/src/habeas/ManageNoticesDialog.java @@ -25,7 +25,6 @@ public class ManageNoticesDialog extends javax.swing.JDialog { super(parent, modal); initComponents(); populateNotices (); - tableNotices.add(popMenu); tableNotices.addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent arg0) { @@ -49,6 +48,7 @@ public class ManageNoticesDialog extends javax.swing.JDialog { popMenu = new javax.swing.JPopupMenu(); menuDescription = new javax.swing.JMenuItem(); menuDraftStatus = new javax.swing.JMenuItem(); + menuDispatchDetails = new javax.swing.JMenuItem(); jScrollPane1 = new javax.swing.JScrollPane(); tableNotices = new javax.swing.JTable(); @@ -70,6 +70,15 @@ public class ManageNoticesDialog extends javax.swing.JDialog { }); popMenu.add(menuDraftStatus); + menuDispatchDetails.setMnemonic('h'); + menuDispatchDetails.setText("Dispatch Details..."); + menuDispatchDetails.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + menuDispatchDetailsActionPerformed(evt); + } + }); + popMenu.add(menuDispatchDetails); + setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); setTitle("Manage Notices"); setLocationByPlatform(true); @@ -133,14 +142,28 @@ public class ManageNoticesDialog extends javax.swing.JDialog { // TODO add your handling code here: int selid = getSelectedNotice(); if (selid == -1) return; - DescriptionDialog frm = new DescriptionDialog((Frame)this.getParent(), true); ArrayList notice = Utility.getNoticeDetails(selid); if (notice == null) return; + + DescriptionDialog frm = new DescriptionDialog((Frame)this.getParent(), true); frm.setFields(selid, (String)notice.get(0), (String)notice.get(1), (Date)notice.get(2)); frm.setVisible(true); populateNotices(); }//GEN-LAST:event_menuDescriptionActionPerformed + private void menuDispatchDetailsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuDispatchDetailsActionPerformed + // TODO add your handling code here: + int selid = getSelectedNotice(); + if (selid == -1) return; + ArrayList notice = Utility.getNoticeDetails(selid); + if (notice == null) return; + + DispatchDetailsDialog frm = new DispatchDetailsDialog((Frame) this.getParent(), true); + frm.setFields (selid, (boolean)notice.get(6), (Date)notice.get(7), + (String)notice.get(8), (boolean) notice.get(9),(Date) notice.get(10)); + frm.setVisible(true); + }//GEN-LAST:event_menuDispatchDetailsActionPerformed + /** * @param args the command line arguments */ @@ -186,6 +209,7 @@ public class ManageNoticesDialog extends javax.swing.JDialog { // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JScrollPane jScrollPane1; private javax.swing.JMenuItem menuDescription; + private javax.swing.JMenuItem menuDispatchDetails; private javax.swing.JMenuItem menuDraftStatus; private javax.swing.JPopupMenu popMenu; private javax.swing.JTable tableNotices; diff --git a/src/habeas/Utility.java b/src/habeas/Utility.java index f36623b..4a4042c 100644 --- a/src/habeas/Utility.java +++ b/src/habeas/Utility.java @@ -240,6 +240,38 @@ public class Utility { } } + + static boolean updateNoticeDispatchDetails(int selid, boolean notice_sent, + java.util.Date sent_date, String rpad_reference, + boolean notice_delivered, java.util.Date delivery_date) { + try { + Connection conn = DriverManager.getConnection(JDBC + connectionURL); + PreparedStatement st = conn.prepareStatement("UPDATE legalnotices" + + " SET NoticeSent=?, SentDate=?, RPADReference=?," + + " NoticeDelivered=?, DeliveryDate=? WHERE id=?;"); + + st.setBoolean(1, notice_sent); + st.setDate(2, toSqlDate(sent_date)); + st.setString(3, rpad_reference); + st.setBoolean(4, notice_delivered); + st.setDate(5, toSqlDate(delivery_date)); + st.setInt (6, selid); + st.execute(); + conn.close(); + return true; + } catch (SQLException ex) { + Logger.getLogger(Utility.class.getName()).log(Level.SEVERE, null, ex); + return false; + } + + } + + private static Date toSqlDate(java.util.Date date) { + if (date == null) + return null; + Date sqldate = new Date (date.getTime()/1000); + return sqldate; + } public Utility () { } -- 2.20.1