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 javax
.swing
.table
.DefaultTableModel
;
18 public class ManageNoticesDialog
extends javax
.swing
.JDialog
{
21 * Creates new form ManageNoticesDialog
23 public ManageNoticesDialog(java
.awt
.Frame parent
, boolean modal
) {
27 tableNotices
.add(popMenu
);
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 menuDraftStatus
= new javax
.swing
.JMenuItem();
50 jScrollPane1
= new javax
.swing
.JScrollPane();
51 tableNotices
= new javax
.swing
.JTable();
53 menuDraftStatus
.setMnemonic('D');
54 menuDraftStatus
.setText("Draft Status...");
55 menuDraftStatus
.setToolTipText("");
56 menuDraftStatus
.addActionListener(new java
.awt
.event
.ActionListener() {
57 public void actionPerformed(java
.awt
.event
.ActionEvent evt
) {
58 menuDraftStatusActionPerformed(evt
);
61 popMenu
.add(menuDraftStatus
);
63 setDefaultCloseOperation(javax
.swing
.WindowConstants
.DISPOSE_ON_CLOSE
);
64 setTitle("Manage Notices");
65 setLocationByPlatform(true);
67 tableNotices
.setModel(new javax
.swing
.table
.DefaultTableModel(
72 "id", "Reference Number", "Description"
75 Class
[] types
= new Class
[] {
76 java
.lang
.Integer
.class, java
.lang
.String
.class, java
.lang
.String
.class
78 boolean[] canEdit
= new boolean [] {
82 public Class
getColumnClass(int columnIndex
) {
83 return types
[columnIndex
];
86 public boolean isCellEditable(int rowIndex
, int columnIndex
) {
87 return canEdit
[columnIndex
];
90 tableNotices
.setSelectionMode(javax
.swing
.ListSelectionModel
.SINGLE_SELECTION
);
91 tableNotices
.setSelectionMode(javax
.swing
.ListSelectionModel
.SINGLE_SELECTION
);
92 jScrollPane1
.setViewportView(tableNotices
);
94 javax
.swing
.GroupLayout layout
= new javax
.swing
.GroupLayout(getContentPane());
95 getContentPane().setLayout(layout
);
96 layout
.setHorizontalGroup(
97 layout
.createParallelGroup(javax
.swing
.GroupLayout
.Alignment
.LEADING
)
98 .addComponent(jScrollPane1
, javax
.swing
.GroupLayout
.DEFAULT_SIZE
, 537, Short
.MAX_VALUE
)
100 layout
.setVerticalGroup(
101 layout
.createParallelGroup(javax
.swing
.GroupLayout
.Alignment
.LEADING
)
102 .addComponent(jScrollPane1
, javax
.swing
.GroupLayout
.DEFAULT_SIZE
, 317, Short
.MAX_VALUE
)
106 }// </editor-fold>//GEN-END:initComponents
108 private void menuDraftStatusActionPerformed(java
.awt
.event
.ActionEvent evt
) {//GEN-FIRST:event_menuDraftStatusActionPerformed
109 // TODO add your handling code here:
110 int selid
= getSelectedNotice ();
111 if (selid
== -1) return;
113 DraftStatusDialog frm
= new DraftStatusDialog((Frame
) this.getParent(), true);
114 ArrayList
<Object
> notice
= Utility
.getNoticeDetails (selid
);
115 if (notice
== null) return;
117 frm
.setDraftStatus((boolean)notice
.get(4), (boolean)notice
.get(5));
118 frm
.setSelectedNotice (selid
);
119 frm
.setVisible(true);
121 }//GEN-LAST:event_menuDraftStatusActionPerformed
124 * @param args the command line arguments
126 public static void main(String args
[]) {
127 /* Set the Nimbus look and feel */
128 //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
129 /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
130 * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
133 for (javax
.swing
.UIManager
.LookAndFeelInfo info
: javax
.swing
.UIManager
.getInstalledLookAndFeels()) {
134 if ("Nimbus".equals(info
.getName())) {
135 javax
.swing
.UIManager
.setLookAndFeel(info
.getClassName());
139 } catch (ClassNotFoundException ex
) {
140 java
.util
.logging
.Logger
.getLogger(ManageNoticesDialog
.class.getName()).log(java
.util
.logging
.Level
.SEVERE
, null, ex
);
141 } catch (InstantiationException ex
) {
142 java
.util
.logging
.Logger
.getLogger(ManageNoticesDialog
.class.getName()).log(java
.util
.logging
.Level
.SEVERE
, null, ex
);
143 } catch (IllegalAccessException ex
) {
144 java
.util
.logging
.Logger
.getLogger(ManageNoticesDialog
.class.getName()).log(java
.util
.logging
.Level
.SEVERE
, null, ex
);
145 } catch (javax
.swing
.UnsupportedLookAndFeelException ex
) {
146 java
.util
.logging
.Logger
.getLogger(ManageNoticesDialog
.class.getName()).log(java
.util
.logging
.Level
.SEVERE
, null, ex
);
150 /* Create and display the dialog */
151 java
.awt
.EventQueue
.invokeLater(new Runnable() {
153 ManageNoticesDialog dialog
= new ManageNoticesDialog(new javax
.swing
.JFrame(), true);
154 dialog
.addWindowListener(new java
.awt
.event
.WindowAdapter() {
156 public void windowClosing(java
.awt
.event
.WindowEvent e
) {
160 dialog
.setVisible(true);
165 // Variables declaration - do not modify//GEN-BEGIN:variables
166 private javax
.swing
.JScrollPane jScrollPane1
;
167 private javax
.swing
.JMenuItem menuDraftStatus
;
168 private javax
.swing
.JPopupMenu popMenu
;
169 private javax
.swing
.JTable tableNotices
;
170 // End of variables declaration//GEN-END:variables
172 private void populateNotices() {
173 DefaultTableModel mdl
= (DefaultTableModel
) tableNotices
.getModel ();
175 ArrayList
<Object
> notices
= Utility
.getNotices ();
176 if (notices
== null) return;
177 for (int i
= 0; i
< notices
.size(); i
+= 3) {
178 mdl
.addRow (new Object
[] { notices
.get(i
), notices
.get(i
+1),
183 private int getSelectedNotice() {
184 int selid
= tableNotices
.getSelectedRow();
187 DefaultTableModel mdl
= (DefaultTableModel
) tableNotices
.getModel();
188 int rkey
= (int) mdl
.getValueAt(selid
, 0);