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 java
.awt
.event
.MouseAdapter
;
10 import java
.awt
.event
.MouseEvent
;
11 import java
.util
.ArrayList
;
12 import java
.util
.Date
;
13 import javax
.swing
.table
.DefaultTableModel
;
19 public class ManageNoticesDialog
extends javax
.swing
.JDialog
{
22 * Creates new form ManageNoticesDialog
24 public ManageNoticesDialog(java
.awt
.Frame parent
, boolean modal
) {
28 tableNotices
.addMouseListener(new MouseAdapter() {
30 public void mousePressed(MouseEvent arg0
) {
31 if (arg0
.isPopupTrigger()) {
32 popMenu
.show(arg0
.getComponent(), arg0
.getX(), arg0
.getY());
40 * This method is called from within the constructor to initialize the form.
41 * WARNING: Do NOT modify this code. The content of this method is always
42 * regenerated by the Form Editor.
44 @SuppressWarnings("unchecked")
45 // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
46 private void initComponents() {
48 popMenu
= new javax
.swing
.JPopupMenu();
49 menuDescription
= new javax
.swing
.JMenuItem();
50 menuDraftStatus
= new javax
.swing
.JMenuItem();
51 menuDispatchDetails
= new javax
.swing
.JMenuItem();
52 menuBillDetails
= new javax
.swing
.JMenuItem();
53 menuClarificationDetails
= new javax
.swing
.JMenuItem();
54 jScrollPane1
= new javax
.swing
.JScrollPane();
55 tableNotices
= new javax
.swing
.JTable();
57 menuDescription
.setMnemonic('e');
58 menuDescription
.setText("Description...");
59 menuDescription
.addActionListener(new java
.awt
.event
.ActionListener() {
60 public void actionPerformed(java
.awt
.event
.ActionEvent evt
) {
61 menuDescriptionActionPerformed(evt
);
64 popMenu
.add(menuDescription
);
66 menuDraftStatus
.setMnemonic('D');
67 menuDraftStatus
.setText("Draft Status...");
68 menuDraftStatus
.setToolTipText("");
69 menuDraftStatus
.addActionListener(new java
.awt
.event
.ActionListener() {
70 public void actionPerformed(java
.awt
.event
.ActionEvent evt
) {
71 menuDraftStatusActionPerformed(evt
);
74 popMenu
.add(menuDraftStatus
);
76 menuDispatchDetails
.setMnemonic('h');
77 menuDispatchDetails
.setText("Dispatch Details...");
78 menuDispatchDetails
.addActionListener(new java
.awt
.event
.ActionListener() {
79 public void actionPerformed(java
.awt
.event
.ActionEvent evt
) {
80 menuDispatchDetailsActionPerformed(evt
);
83 popMenu
.add(menuDispatchDetails
);
85 menuBillDetails
.setMnemonic('B');
86 menuBillDetails
.setText("Bill Details...");
87 menuBillDetails
.addActionListener(new java
.awt
.event
.ActionListener() {
88 public void actionPerformed(java
.awt
.event
.ActionEvent evt
) {
89 menuBillDetailsActionPerformed(evt
);
92 popMenu
.add(menuBillDetails
);
94 menuClarificationDetails
.setMnemonic('r');
95 menuClarificationDetails
.setText("Clarification Details...");
96 menuClarificationDetails
.addActionListener(new java
.awt
.event
.ActionListener() {
97 public void actionPerformed(java
.awt
.event
.ActionEvent evt
) {
98 menuClarificationDetailsActionPerformed(evt
);
101 popMenu
.add(menuClarificationDetails
);
103 setDefaultCloseOperation(javax
.swing
.WindowConstants
.DISPOSE_ON_CLOSE
);
104 setTitle("Manage Notices");
105 setLocationByPlatform(true);
107 tableNotices
.setModel(new javax
.swing
.table
.DefaultTableModel(
112 "id", "Reference Number", "Description"
115 Class
[] types
= new Class
[] {
116 java
.lang
.Integer
.class, java
.lang
.String
.class, java
.lang
.String
.class
118 boolean[] canEdit
= new boolean [] {
122 public Class
getColumnClass(int columnIndex
) {
123 return types
[columnIndex
];
126 public boolean isCellEditable(int rowIndex
, int columnIndex
) {
127 return canEdit
[columnIndex
];
130 tableNotices
.setSelectionMode(javax
.swing
.ListSelectionModel
.SINGLE_SELECTION
);
131 tableNotices
.setSelectionMode(javax
.swing
.ListSelectionModel
.SINGLE_SELECTION
);
132 jScrollPane1
.setViewportView(tableNotices
);
134 javax
.swing
.GroupLayout layout
= new javax
.swing
.GroupLayout(getContentPane());
135 getContentPane().setLayout(layout
);
136 layout
.setHorizontalGroup(
137 layout
.createParallelGroup(javax
.swing
.GroupLayout
.Alignment
.LEADING
)
138 .addComponent(jScrollPane1
, javax
.swing
.GroupLayout
.DEFAULT_SIZE
, 537, Short
.MAX_VALUE
)
140 layout
.setVerticalGroup(
141 layout
.createParallelGroup(javax
.swing
.GroupLayout
.Alignment
.LEADING
)
142 .addComponent(jScrollPane1
, javax
.swing
.GroupLayout
.DEFAULT_SIZE
, 317, Short
.MAX_VALUE
)
146 }// </editor-fold>//GEN-END:initComponents
148 private void menuDraftStatusActionPerformed(java
.awt
.event
.ActionEvent evt
) {//GEN-FIRST:event_menuDraftStatusActionPerformed
149 // TODO add your handling code here:
150 int selid
= getSelectedNotice ();
151 if (selid
== -1) return;
153 DraftStatusDialog frm
= new DraftStatusDialog((Frame
) this.getParent(), true);
154 ArrayList
<Object
> notice
= Utility
.getNoticeDetails (selid
);
155 if (notice
== null) return;
157 frm
.setFields(selid
, (boolean)notice
.get(4), (boolean)notice
.get(5));
158 frm
.setVisible(true);
160 }//GEN-LAST:event_menuDraftStatusActionPerformed
162 private void menuDescriptionActionPerformed(java
.awt
.event
.ActionEvent evt
) {//GEN-FIRST:event_menuDescriptionActionPerformed
163 // TODO add your handling code here:
164 int selid
= getSelectedNotice();
165 if (selid
== -1) return;
166 ArrayList
<Object
> notice
= Utility
.getNoticeDetails(selid
);
167 if (notice
== null) return;
169 DescriptionDialog frm
= new DescriptionDialog((Frame
)this.getParent(), true);
170 frm
.setFields(selid
, (String
)notice
.get(0), (String
)notice
.get(1), (Date
)notice
.get(2));
171 frm
.setVisible(true);
173 }//GEN-LAST:event_menuDescriptionActionPerformed
175 private void menuDispatchDetailsActionPerformed(java
.awt
.event
.ActionEvent evt
) {//GEN-FIRST:event_menuDispatchDetailsActionPerformed
176 // TODO add your handling code here:
177 int selid
= getSelectedNotice();
178 if (selid
== -1) return;
179 ArrayList
<Object
> notice
= Utility
.getNoticeDetails(selid
);
180 if (notice
== null) return;
182 DispatchDetailsDialog frm
= new DispatchDetailsDialog((Frame
) this.getParent(), true);
183 frm
.setFields (selid
, (boolean)notice
.get(6), (Date
)notice
.get(7),
184 (String
)notice
.get(8), (boolean) notice
.get(9),(Date
) notice
.get(10));
185 frm
.setVisible(true);
186 }//GEN-LAST:event_menuDispatchDetailsActionPerformed
188 private void menuBillDetailsActionPerformed(java
.awt
.event
.ActionEvent evt
) {//GEN-FIRST:event_menuBillDetailsActionPerformed
189 // TODO add your handling code here:
190 int selid
= getSelectedNotice();
191 if (selid
== -1) return;
192 ArrayList
<Object
> notice
= Utility
.getNoticeDetails(selid
);
193 if (notice
== null) return;
195 BillDetailsDialog frm
= new BillDetailsDialog((Frame
) this.getParent(),true);
196 frm
.setFields (selid
, (String
)notice
.get(11), (int)notice
.get(12), (Date
)notice
.get(13));
197 frm
.setVisible(true);
198 }//GEN-LAST:event_menuBillDetailsActionPerformed
200 private void menuClarificationDetailsActionPerformed(java
.awt
.event
.ActionEvent evt
) {//GEN-FIRST:event_menuClarificationDetailsActionPerformed
201 // TODO add your handling code here:
202 int selid
= getSelectedNotice();
203 if (selid
== -1) return;
204 ArrayList
<Object
> notice
= Utility
.getNoticeDetails(selid
);
205 if (notice
== null) return;
206 ClarificationDetailsDialog frm
= new ClarificationDetailsDialog(
207 (Frame
)this.getParent(), true);
209 frm
.setFields (selid
, (boolean)notice
.get(14), (String
)notice
.get(15));
210 frm
.setVisible(true);
211 }//GEN-LAST:event_menuClarificationDetailsActionPerformed
214 * @param args the command line arguments
216 public static void main(String args
[]) {
217 /* Set the Nimbus look and feel */
218 //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
219 /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
220 * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
223 for (javax
.swing
.UIManager
.LookAndFeelInfo info
: javax
.swing
.UIManager
.getInstalledLookAndFeels()) {
224 if ("Nimbus".equals(info
.getName())) {
225 javax
.swing
.UIManager
.setLookAndFeel(info
.getClassName());
229 } catch (ClassNotFoundException ex
) {
230 java
.util
.logging
.Logger
.getLogger(ManageNoticesDialog
.class.getName()).log(java
.util
.logging
.Level
.SEVERE
, null, ex
);
231 } catch (InstantiationException ex
) {
232 java
.util
.logging
.Logger
.getLogger(ManageNoticesDialog
.class.getName()).log(java
.util
.logging
.Level
.SEVERE
, null, ex
);
233 } catch (IllegalAccessException ex
) {
234 java
.util
.logging
.Logger
.getLogger(ManageNoticesDialog
.class.getName()).log(java
.util
.logging
.Level
.SEVERE
, null, ex
);
235 } catch (javax
.swing
.UnsupportedLookAndFeelException ex
) {
236 java
.util
.logging
.Logger
.getLogger(ManageNoticesDialog
.class.getName()).log(java
.util
.logging
.Level
.SEVERE
, null, ex
);
240 /* Create and display the dialog */
241 java
.awt
.EventQueue
.invokeLater(new Runnable() {
243 ManageNoticesDialog dialog
= new ManageNoticesDialog(new javax
.swing
.JFrame(), true);
244 dialog
.addWindowListener(new java
.awt
.event
.WindowAdapter() {
246 public void windowClosing(java
.awt
.event
.WindowEvent e
) {
250 dialog
.setVisible(true);
255 // Variables declaration - do not modify//GEN-BEGIN:variables
256 private javax
.swing
.JScrollPane jScrollPane1
;
257 private javax
.swing
.JMenuItem menuBillDetails
;
258 private javax
.swing
.JMenuItem menuClarificationDetails
;
259 private javax
.swing
.JMenuItem menuDescription
;
260 private javax
.swing
.JMenuItem menuDispatchDetails
;
261 private javax
.swing
.JMenuItem menuDraftStatus
;
262 private javax
.swing
.JPopupMenu popMenu
;
263 private javax
.swing
.JTable tableNotices
;
264 // End of variables declaration//GEN-END:variables
266 private void populateNotices() {
267 DefaultTableModel mdl
= (DefaultTableModel
) tableNotices
.getModel ();
269 ArrayList
<Object
> notices
= Utility
.getNotices ();
270 if (notices
== null) return;
271 for (int i
= 0; i
< notices
.size(); i
+= 3) {
272 mdl
.addRow (new Object
[] { notices
.get(i
), notices
.get(i
+1),
277 private int getSelectedNotice() {
278 int selid
= tableNotices
.getSelectedRow();
281 DefaultTableModel mdl
= (DefaultTableModel
) tableNotices
.getModel();
282 int rkey
= (int) mdl
.getValueAt(selid
, 0);