X-Git-Url: https://harishankar.org/repos/?p=habeas.git;a=blobdiff_plain;f=src%2Fhabeas%2FManageNoticesDialog.java;h=5ccdb15c67df55366c86af68a710fd0687d30f50;hp=73d73fe46d97525b1f8fa872f13fb974fd9ea12d;hb=67bb9fdd9ae3818a92a528d14d82baae0d483508;hpb=fdaede7966b1cfd8a38dcc51fa8ec60420b842b4 diff --git a/src/habeas/ManageNoticesDialog.java b/src/habeas/ManageNoticesDialog.java index 73d73fe..5ccdb15 100644 --- a/src/habeas/ManageNoticesDialog.java +++ b/src/habeas/ManageNoticesDialog.java @@ -10,6 +10,7 @@ import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.util.ArrayList; import java.util.Date; +import javax.swing.JOptionPane; import javax.swing.table.DefaultTableModel; /** @@ -25,7 +26,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) { @@ -48,10 +48,17 @@ public class ManageNoticesDialog extends javax.swing.JDialog { popMenu = new javax.swing.JPopupMenu(); menuDescription = new javax.swing.JMenuItem(); + menuClarificationDetails = new javax.swing.JMenuItem(); menuDraftStatus = new javax.swing.JMenuItem(); + menuDispatchDetails = new javax.swing.JMenuItem(); + menuBillDetails = new javax.swing.JMenuItem(); + jSeparator1 = new javax.swing.JPopupMenu.Separator(); + menuView = new javax.swing.JMenuItem(); + menuDelete = new javax.swing.JMenuItem(); jScrollPane1 = new javax.swing.JScrollPane(); tableNotices = new javax.swing.JTable(); + menuDescription.setMnemonic('e'); menuDescription.setText("Description..."); menuDescription.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { @@ -60,6 +67,15 @@ public class ManageNoticesDialog extends javax.swing.JDialog { }); popMenu.add(menuDescription); + 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); + menuDraftStatus.setMnemonic('D'); menuDraftStatus.setText("Draft Status..."); menuDraftStatus.setToolTipText(""); @@ -70,6 +86,42 @@ 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); + + menuBillDetails.setMnemonic('B'); + menuBillDetails.setText("Bill Details..."); + menuBillDetails.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + menuBillDetailsActionPerformed(evt); + } + }); + popMenu.add(menuBillDetails); + popMenu.add(jSeparator1); + + menuView.setMnemonic('V'); + menuView.setText("View..."); + menuView.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + menuViewActionPerformed(evt); + } + }); + popMenu.add(menuView); + + menuDelete.setText("Delete"); + menuDelete.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + menuDeleteActionPerformed(evt); + } + }); + popMenu.add(menuDelete); + setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); setTitle("Manage Notices"); setLocationByPlatform(true); @@ -133,14 +185,91 @@ 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 + + private void menuBillDetailsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuBillDetailsActionPerformed + // TODO add your handling code here: + int selid = getSelectedNotice(); + if (selid == -1) return; + ArrayList notice = Utility.getNoticeDetails(selid); + if (notice == null) return; + + BillDetailsDialog frm = new BillDetailsDialog((Frame) this.getParent(),true); + frm.setFields (selid, (String)notice.get(11), (int)notice.get(12), (Date)notice.get(13)); + 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 + + private void menuDeleteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuDeleteActionPerformed + int selid = getSelectedNotice(); + if (selid == -1) return; + int conf = JOptionPane.showConfirmDialog((Frame)this.getParent(), CONFIRM_DELETE); + if (conf == JOptionPane.YES_OPTION) { + boolean rt = Utility.deleteNotice (selid); + if (rt == false) + JOptionPane.showMessageDialog(this, ERROR_DELETING); + else + populateNotices(); + } + }//GEN-LAST:event_menuDeleteActionPerformed + + private void menuViewActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuViewActionPerformed + // TODO add your handling code here: + int selid = getSelectedNotice(); + if (selid == -1) return; + ArrayList notice = Utility.getNoticeDetails(selid); + if (notice == null) return; + + ViewNoticeDialog frm = new ViewNoticeDialog( + (Frame)this.getParent(), true); + frm.setFields (selid, (String)notice.get(0), + (String)notice.get(1), (Date)notice.get(2), + (String)notice.get(16), (boolean)notice.get(4), + (boolean)notice.get(5), (boolean)notice.get(6), + (Date)notice.get(7), (String)notice.get(8), + (boolean)notice.get(9), (Date)notice.get(10), + (String)notice.get(11), (int)notice.get(12), + (Date)notice.get(13), (boolean)notice.get(14), + (String)notice.get(15)); + frm.setVisible(true); + + + }//GEN-LAST:event_menuViewActionPerformed + private static final String ERROR_DELETING = "Error in deleting"; + private static final String CONFIRM_DELETE = "Are you sure you wish to delete?"; + /** * @param args the command line arguments */ @@ -185,8 +314,14 @@ public class ManageNoticesDialog extends javax.swing.JDialog { // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JScrollPane jScrollPane1; + private javax.swing.JSeparator jSeparator1; + private javax.swing.JMenuItem menuBillDetails; + private javax.swing.JMenuItem menuClarificationDetails; + private javax.swing.JMenuItem menuDelete; private javax.swing.JMenuItem menuDescription; + private javax.swing.JMenuItem menuDispatchDetails; private javax.swing.JMenuItem menuDraftStatus; + private javax.swing.JMenuItem menuView; private javax.swing.JPopupMenu popMenu; private javax.swing.JTable tableNotices; // End of variables declaration//GEN-END:variables