From 0109c82b782e02046aa520811ea5bfe3f6c675a5 Mon Sep 17 00:00:00 2001 From: Harishankar Date: Tue, 31 Mar 2020 14:26:50 +0530 Subject: [PATCH] Manage Legal Notices - Clarification Details Created the screen for updating clarification details. --- src/habeas/ClarificationDetailsDialog.form | 110 +++++++++++++ src/habeas/ClarificationDetailsDialog.java | 180 +++++++++++++++++++++ src/habeas/ManageNoticesDialog.form | 9 ++ src/habeas/ManageNoticesDialog.java | 24 +++ src/habeas/Utility.java | 20 +++ 5 files changed, 343 insertions(+) create mode 100644 src/habeas/ClarificationDetailsDialog.form create mode 100644 src/habeas/ClarificationDetailsDialog.java diff --git a/src/habeas/ClarificationDetailsDialog.form b/src/habeas/ClarificationDetailsDialog.form new file mode 100644 index 0000000..51f448d --- /dev/null +++ b/src/habeas/ClarificationDetailsDialog.form @@ -0,0 +1,110 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/src/habeas/ClarificationDetailsDialog.java b/src/habeas/ClarificationDetailsDialog.java new file mode 100644 index 0000000..cbb64e1 --- /dev/null +++ b/src/habeas/ClarificationDetailsDialog.java @@ -0,0 +1,180 @@ +/* + * 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 javax.swing.JOptionPane; + +/** + * + * @author hari + */ +public class ClarificationDetailsDialog extends javax.swing.JDialog { + + private int selected_id; + + /** + * Creates new form ClarificationDetailsDialog + */ + public ClarificationDetailsDialog(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() { + + checkClarificationPending = new javax.swing.JCheckBox(); + jLabel1 = new javax.swing.JLabel(); + jScrollPane1 = new javax.swing.JScrollPane(); + textClarificationRemarks = new javax.swing.JTextArea(); + buttonApply = new javax.swing.JButton(); + buttonCancel = new javax.swing.JButton(); + + setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); + setTitle("Clarification Details"); + setLocationByPlatform(true); + + checkClarificationPending.setText("Clarification Pending"); + + jLabel1.setText("Clarification Remarks"); + + textClarificationRemarks.setColumns(20); + textClarificationRemarks.setRows(5); + jScrollPane1.setViewportView(textClarificationRemarks); + + 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(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) + .addGroup(layout.createSequentialGroup() + .addComponent(buttonApply, javax.swing.GroupLayout.PREFERRED_SIZE, 106, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(buttonCancel, javax.swing.GroupLayout.PREFERRED_SIZE, 106, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) + .addComponent(checkClarificationPending, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 369, Short.MAX_VALUE))) + .addContainerGap(21, Short.MAX_VALUE)) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addComponent(checkClarificationPending) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(jLabel1) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 96, 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: + boolean rt = Utility.updateNoticeClarificationDetails (selected_id, + checkClarificationPending.isSelected(), + textClarificationRemarks.getText()); + if (rt == false) + JOptionPane.showMessageDialog(this, ERROR_UPDATING); + else + dispose (); + }//GEN-LAST:event_buttonApplyActionPerformed + private static final String ERROR_UPDATING = "Error in updating"; + + /** + * @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(ClarificationDetailsDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + } catch (InstantiationException ex) { + java.util.logging.Logger.getLogger(ClarificationDetailsDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + } catch (IllegalAccessException ex) { + java.util.logging.Logger.getLogger(ClarificationDetailsDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + } catch (javax.swing.UnsupportedLookAndFeelException ex) { + java.util.logging.Logger.getLogger(ClarificationDetailsDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + } + // + + /* Create and display the dialog */ + java.awt.EventQueue.invokeLater(new Runnable() { + public void run() { + ClarificationDetailsDialog dialog = new ClarificationDetailsDialog(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 checkClarificationPending; + private javax.swing.JLabel jLabel1; + private javax.swing.JScrollPane jScrollPane1; + private javax.swing.JTextArea textClarificationRemarks; + // End of variables declaration//GEN-END:variables + + void setFields(int selid, boolean clarification_pending, String + clarification_remarks) { + selected_id = selid; + checkClarificationPending.setSelected(clarification_pending); + textClarificationRemarks.setText(clarification_remarks); + } +} diff --git a/src/habeas/ManageNoticesDialog.form b/src/habeas/ManageNoticesDialog.form index c537409..75f457f 100644 --- a/src/habeas/ManageNoticesDialog.form +++ b/src/habeas/ManageNoticesDialog.form @@ -45,6 +45,15 @@ + + + + + + + + + diff --git a/src/habeas/ManageNoticesDialog.java b/src/habeas/ManageNoticesDialog.java index b1b5c47..50928a4 100644 --- a/src/habeas/ManageNoticesDialog.java +++ b/src/habeas/ManageNoticesDialog.java @@ -50,6 +50,7 @@ public class ManageNoticesDialog extends javax.swing.JDialog { menuDraftStatus = new javax.swing.JMenuItem(); menuDispatchDetails = new javax.swing.JMenuItem(); menuBillDetails = new javax.swing.JMenuItem(); + menuClarificationDetails = new javax.swing.JMenuItem(); jScrollPane1 = new javax.swing.JScrollPane(); tableNotices = new javax.swing.JTable(); @@ -90,6 +91,15 @@ public class ManageNoticesDialog extends javax.swing.JDialog { }); popMenu.add(menuBillDetails); + menuClarificationDetails.setMnemonic('r'); + menuClarificationDetails.setText("Clarification Details..."); + menuClarificationDetails.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + menuClarificationDetailsActionPerformed(evt); + } + }); + popMenu.add(menuClarificationDetails); + setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); setTitle("Manage Notices"); setLocationByPlatform(true); @@ -187,6 +197,19 @@ public class ManageNoticesDialog extends javax.swing.JDialog { frm.setVisible(true); }//GEN-LAST:event_menuBillDetailsActionPerformed + private void menuClarificationDetailsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuClarificationDetailsActionPerformed + // TODO add your handling code here: + int selid = getSelectedNotice(); + if (selid == -1) return; + ArrayList notice = Utility.getNoticeDetails(selid); + if (notice == null) return; + ClarificationDetailsDialog frm = new ClarificationDetailsDialog( + (Frame)this.getParent(), true); + + frm.setFields (selid, (boolean)notice.get(14), (String)notice.get(15)); + frm.setVisible(true); + }//GEN-LAST:event_menuClarificationDetailsActionPerformed + /** * @param args the command line arguments */ @@ -232,6 +255,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 menuBillDetails; + private javax.swing.JMenuItem menuClarificationDetails; private javax.swing.JMenuItem menuDescription; private javax.swing.JMenuItem menuDispatchDetails; private javax.swing.JMenuItem menuDraftStatus; diff --git a/src/habeas/Utility.java b/src/habeas/Utility.java index 6ca96e5..f7fdae7 100644 --- a/src/habeas/Utility.java +++ b/src/habeas/Utility.java @@ -340,6 +340,26 @@ public class Utility { return false; } + } + + static boolean updateNoticeClarificationDetails(int selected_id, boolean + clarification_pending, String clarification_remarks) { + try { + Connection conn = DriverManager.getConnection(JDBC + connectionURL); + PreparedStatement st = conn.prepareStatement ("UPDATE legalnotices" + + " SET ClarificationPending=?, ClarificationRemarks=? " + + "WHERE id=?;"); + st.setBoolean(1, clarification_pending); + st.setString(2, clarification_remarks); + st.setInt (3, selected_id); + st.execute(); + conn.close (); + return true; + } catch (SQLException ex) { + Logger.getLogger(Utility.class.getName()).log(Level.SEVERE, null, ex); + return false; + } + } public Utility () { -- 2.20.1