X-Git-Url: https://harishankar.org/repos/?p=habeas.git;a=blobdiff_plain;f=src%2Fhabeas%2FDispatchDetailsDialog.java;fp=src%2Fhabeas%2FDispatchDetailsDialog.java;h=4cfa913c5036a02b2999ce75a9e401c4dce56469;hp=0000000000000000000000000000000000000000;hb=466a2393accd0d6d2df5f68d53488c667d5369de;hpb=fdaede7966b1cfd8a38dcc51fa8ec60420b842b4 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); + } +}