2 * To change this license header, choose License Headers in Project Properties.
3 * To change this template file, choose Tools | Templates
4 * and open the template in the editor.
9 import javax
.swing
.JOptionPane
;
15 public class DispatchDetailsDialog
extends javax
.swing
.JDialog
{
17 private int selected_id
;
20 * Creates new form DispatchDetailsDialog
22 public DispatchDetailsDialog(java
.awt
.Frame parent
, boolean modal
) {
28 * This method is called from within the constructor to initialize the form.
29 * WARNING: Do NOT modify this code. The content of this method is always
30 * regenerated by the Form Editor.
32 @SuppressWarnings("unchecked")
33 // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
34 private void initComponents() {
36 checkNoticeSent
= new javax
.swing
.JCheckBox();
37 dateSending
= new org
.jdesktop
.swingx
.JXDatePicker();
38 jLabel1
= new javax
.swing
.JLabel();
39 jLabel2
= new javax
.swing
.JLabel();
40 textRPADReference
= new javax
.swing
.JTextField();
41 checkNoticeDelivered
= new javax
.swing
.JCheckBox();
42 jLabel3
= new javax
.swing
.JLabel();
43 dateDelivery
= new org
.jdesktop
.swingx
.JXDatePicker();
44 buttonApply
= new javax
.swing
.JButton();
45 buttonCancel
= new javax
.swing
.JButton();
47 setDefaultCloseOperation(javax
.swing
.WindowConstants
.DISPOSE_ON_CLOSE
);
48 setTitle("Dispatch Details");
49 setLocationByPlatform(true);
51 checkNoticeSent
.setText("Notice Sent");
53 jLabel1
.setText("Date of sending");
55 jLabel2
.setText("RPAD reference");
57 checkNoticeDelivered
.setText("Notice delivered");
59 jLabel3
.setText("Date of delivery");
61 buttonApply
.setMnemonic('A');
62 buttonApply
.setText("Apply");
63 buttonApply
.addActionListener(new java
.awt
.event
.ActionListener() {
64 public void actionPerformed(java
.awt
.event
.ActionEvent evt
) {
65 buttonApplyActionPerformed(evt
);
69 buttonCancel
.setMnemonic('c');
70 buttonCancel
.setText("Cancel");
71 buttonCancel
.addActionListener(new java
.awt
.event
.ActionListener() {
72 public void actionPerformed(java
.awt
.event
.ActionEvent evt
) {
73 buttonCancelActionPerformed(evt
);
77 javax
.swing
.GroupLayout layout
= new javax
.swing
.GroupLayout(getContentPane());
78 getContentPane().setLayout(layout
);
79 layout
.setHorizontalGroup(
80 layout
.createParallelGroup(javax
.swing
.GroupLayout
.Alignment
.LEADING
)
81 .addGroup(layout
.createSequentialGroup()
83 .addGroup(layout
.createParallelGroup(javax
.swing
.GroupLayout
.Alignment
.LEADING
)
84 .addComponent(checkNoticeSent
, javax
.swing
.GroupLayout
.DEFAULT_SIZE
, javax
.swing
.GroupLayout
.DEFAULT_SIZE
, Short
.MAX_VALUE
)
85 .addComponent(checkNoticeDelivered
, javax
.swing
.GroupLayout
.DEFAULT_SIZE
, javax
.swing
.GroupLayout
.DEFAULT_SIZE
, Short
.MAX_VALUE
)
86 .addGroup(layout
.createSequentialGroup()
87 .addGroup(layout
.createParallelGroup(javax
.swing
.GroupLayout
.Alignment
.TRAILING
)
88 .addComponent(jLabel3
, javax
.swing
.GroupLayout
.DEFAULT_SIZE
, javax
.swing
.GroupLayout
.DEFAULT_SIZE
, Short
.MAX_VALUE
)
89 .addComponent(jLabel2
, javax
.swing
.GroupLayout
.DEFAULT_SIZE
, javax
.swing
.GroupLayout
.DEFAULT_SIZE
, Short
.MAX_VALUE
)
90 .addComponent(jLabel1
, javax
.swing
.GroupLayout
.DEFAULT_SIZE
, 137, Short
.MAX_VALUE
))
91 .addPreferredGap(javax
.swing
.LayoutStyle
.ComponentPlacement
.RELATED
)
92 .addGroup(layout
.createParallelGroup(javax
.swing
.GroupLayout
.Alignment
.LEADING
)
93 .addComponent(dateSending
, javax
.swing
.GroupLayout
.DEFAULT_SIZE
, 330, Short
.MAX_VALUE
)
94 .addComponent(textRPADReference
)
95 .addComponent(dateDelivery
, javax
.swing
.GroupLayout
.DEFAULT_SIZE
, javax
.swing
.GroupLayout
.DEFAULT_SIZE
, Short
.MAX_VALUE
)))
96 .addGroup(javax
.swing
.GroupLayout
.Alignment
.TRAILING
, layout
.createSequentialGroup()
97 .addGap(0, 0, Short
.MAX_VALUE
)
98 .addComponent(buttonApply
, javax
.swing
.GroupLayout
.PREFERRED_SIZE
, 102, javax
.swing
.GroupLayout
.PREFERRED_SIZE
)
99 .addPreferredGap(javax
.swing
.LayoutStyle
.ComponentPlacement
.RELATED
)
100 .addComponent(buttonCancel
, javax
.swing
.GroupLayout
.PREFERRED_SIZE
, 102, javax
.swing
.GroupLayout
.PREFERRED_SIZE
)))
103 layout
.setVerticalGroup(
104 layout
.createParallelGroup(javax
.swing
.GroupLayout
.Alignment
.LEADING
)
105 .addGroup(layout
.createSequentialGroup()
107 .addComponent(checkNoticeSent
)
108 .addPreferredGap(javax
.swing
.LayoutStyle
.ComponentPlacement
.RELATED
)
109 .addGroup(layout
.createParallelGroup(javax
.swing
.GroupLayout
.Alignment
.BASELINE
)
110 .addComponent(dateSending
, javax
.swing
.GroupLayout
.PREFERRED_SIZE
, javax
.swing
.GroupLayout
.DEFAULT_SIZE
, javax
.swing
.GroupLayout
.PREFERRED_SIZE
)
111 .addComponent(jLabel1
))
112 .addPreferredGap(javax
.swing
.LayoutStyle
.ComponentPlacement
.UNRELATED
)
113 .addGroup(layout
.createParallelGroup(javax
.swing
.GroupLayout
.Alignment
.BASELINE
)
114 .addComponent(jLabel2
)
115 .addComponent(textRPADReference
, javax
.swing
.GroupLayout
.PREFERRED_SIZE
, javax
.swing
.GroupLayout
.DEFAULT_SIZE
, javax
.swing
.GroupLayout
.PREFERRED_SIZE
))
116 .addPreferredGap(javax
.swing
.LayoutStyle
.ComponentPlacement
.UNRELATED
)
117 .addComponent(checkNoticeDelivered
)
118 .addPreferredGap(javax
.swing
.LayoutStyle
.ComponentPlacement
.UNRELATED
)
119 .addGroup(layout
.createParallelGroup(javax
.swing
.GroupLayout
.Alignment
.BASELINE
)
120 .addComponent(jLabel3
)
121 .addComponent(dateDelivery
, javax
.swing
.GroupLayout
.PREFERRED_SIZE
, javax
.swing
.GroupLayout
.DEFAULT_SIZE
, javax
.swing
.GroupLayout
.PREFERRED_SIZE
))
122 .addPreferredGap(javax
.swing
.LayoutStyle
.ComponentPlacement
.RELATED
, 17, Short
.MAX_VALUE
)
123 .addGroup(layout
.createParallelGroup(javax
.swing
.GroupLayout
.Alignment
.BASELINE
)
124 .addComponent(buttonApply
)
125 .addComponent(buttonCancel
))
130 }// </editor-fold>//GEN-END:initComponents
132 private void buttonCancelActionPerformed(java
.awt
.event
.ActionEvent evt
) {//GEN-FIRST:event_buttonCancelActionPerformed
133 // TODO add your handling code here:
135 }//GEN-LAST:event_buttonCancelActionPerformed
137 private void buttonApplyActionPerformed(java
.awt
.event
.ActionEvent evt
) {//GEN-FIRST:event_buttonApplyActionPerformed
138 // TODO add your handling code here:
139 if (checkNoticeSent
.isSelected() &&
140 ("".equals(textRPADReference
.getText()) || dateSending
.getDate() == null)) {
141 JOptionPane
.showMessageDialog(this, MANDATORY_FIELDS_MISSING
);
144 if (checkNoticeDelivered
.isSelected() && dateDelivery
.getDate() == null) {
145 JOptionPane
.showMessageDialog(this, MANDATORY_FIELDS_MISSING
);
148 boolean rt
= Utility
.updateNoticeDispatchDetails
149 (selected_id
,checkNoticeSent
.isSelected(), dateSending
.getDate(),
150 textRPADReference
.getText(),
151 checkNoticeDelivered
.isSelected(), dateDelivery
.getDate());
153 JOptionPane
.showMessageDialog(this, ERROR_UPDATING
);
156 }//GEN-LAST:event_buttonApplyActionPerformed
157 private static final String ERROR_UPDATING
= "Error in updating";
158 private static final String MANDATORY_FIELDS_MISSING
= "Mandatory fields missing!";
161 * @param args the command line arguments
163 public static void main(String args
[]) {
164 /* Set the Nimbus look and feel */
165 //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
166 /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
167 * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
170 for (javax
.swing
.UIManager
.LookAndFeelInfo info
: javax
.swing
.UIManager
.getInstalledLookAndFeels()) {
171 if ("Nimbus".equals(info
.getName())) {
172 javax
.swing
.UIManager
.setLookAndFeel(info
.getClassName());
176 } catch (ClassNotFoundException ex
) {
177 java
.util
.logging
.Logger
.getLogger(DispatchDetailsDialog
.class.getName()).log(java
.util
.logging
.Level
.SEVERE
, null, ex
);
178 } catch (InstantiationException ex
) {
179 java
.util
.logging
.Logger
.getLogger(DispatchDetailsDialog
.class.getName()).log(java
.util
.logging
.Level
.SEVERE
, null, ex
);
180 } catch (IllegalAccessException ex
) {
181 java
.util
.logging
.Logger
.getLogger(DispatchDetailsDialog
.class.getName()).log(java
.util
.logging
.Level
.SEVERE
, null, ex
);
182 } catch (javax
.swing
.UnsupportedLookAndFeelException ex
) {
183 java
.util
.logging
.Logger
.getLogger(DispatchDetailsDialog
.class.getName()).log(java
.util
.logging
.Level
.SEVERE
, null, ex
);
187 /* Create and display the dialog */
188 java
.awt
.EventQueue
.invokeLater(new Runnable() {
190 DispatchDetailsDialog dialog
= new DispatchDetailsDialog(new javax
.swing
.JFrame(), true);
191 dialog
.addWindowListener(new java
.awt
.event
.WindowAdapter() {
193 public void windowClosing(java
.awt
.event
.WindowEvent e
) {
197 dialog
.setVisible(true);
202 // Variables declaration - do not modify//GEN-BEGIN:variables
203 private javax
.swing
.JButton buttonApply
;
204 private javax
.swing
.JButton buttonCancel
;
205 private javax
.swing
.JCheckBox checkNoticeDelivered
;
206 private javax
.swing
.JCheckBox checkNoticeSent
;
207 private org
.jdesktop
.swingx
.JXDatePicker dateDelivery
;
208 private org
.jdesktop
.swingx
.JXDatePicker dateSending
;
209 private javax
.swing
.JLabel jLabel1
;
210 private javax
.swing
.JLabel jLabel2
;
211 private javax
.swing
.JLabel jLabel3
;
212 private javax
.swing
.JTextField textRPADReference
;
213 // End of variables declaration//GEN-END:variables
215 void setFields(int selid
, boolean notice_sent
, Date sent_date
,
216 String rpad_reference
, boolean notice_delivered
,
217 Date delivery_date
) {
219 checkNoticeSent
.setSelected(notice_sent
);
220 dateSending
.setDate(sent_date
);
221 checkNoticeDelivered
.setSelected(notice_delivered
);
222 textRPADReference
.setText(rpad_reference
);
223 dateDelivery
.setDate(delivery_date
);