0154d472173d316a59051e2d03e5c58fb540d504
[habeas.git] / src / habeas / DraftStatusDialog.java
1 /*
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.
5 */
6 package habeas;
7
8 import javax.swing.JOptionPane;
9
10 /**
11 *
12 * @author hari
13 */
14 public class DraftStatusDialog extends javax.swing.JDialog {
15
16 private int selectednotice_id;
17
18 /**
19 * Creates new form DraftStatusDialog
20 */
21
22 public DraftStatusDialog(java.awt.Frame parent, boolean modal) {
23 super(parent, modal);
24 initComponents();
25 }
26
27 public void setDraftStatus (boolean created, boolean approved) {
28 checkDraftCreated.setSelected(created);
29 checkDraftApproved.setSelected(approved);
30 }
31
32 /**
33 * This method is called from within the constructor to initialize the form.
34 * WARNING: Do NOT modify this code. The content of this method is always
35 * regenerated by the Form Editor.
36 */
37 @SuppressWarnings("unchecked")
38 // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
39 private void initComponents() {
40
41 checkDraftCreated = new javax.swing.JCheckBox();
42 checkDraftApproved = new javax.swing.JCheckBox();
43 buttonUpdate = new javax.swing.JButton();
44 buttonCancel = new javax.swing.JButton();
45
46 setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
47 setTitle("Draft Status");
48 setLocationByPlatform(true);
49
50 checkDraftCreated.setText("Draft Created");
51
52 checkDraftApproved.setText("Draft Approved");
53
54 buttonUpdate.setMnemonic('U');
55 buttonUpdate.setText("Update");
56 buttonUpdate.addActionListener(new java.awt.event.ActionListener() {
57 public void actionPerformed(java.awt.event.ActionEvent evt) {
58 buttonUpdateActionPerformed(evt);
59 }
60 });
61
62 buttonCancel.setMnemonic('c');
63 buttonCancel.setText("Cancel");
64 buttonCancel.addActionListener(new java.awt.event.ActionListener() {
65 public void actionPerformed(java.awt.event.ActionEvent evt) {
66 buttonCancelActionPerformed(evt);
67 }
68 });
69
70 javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
71 getContentPane().setLayout(layout);
72 layout.setHorizontalGroup(
73 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
74 .addGroup(layout.createSequentialGroup()
75 .addContainerGap()
76 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
77 .addComponent(checkDraftCreated, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
78 .addComponent(checkDraftApproved, javax.swing.GroupLayout.DEFAULT_SIZE, 224, Short.MAX_VALUE))
79 .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
80 .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
81 .addContainerGap(195, Short.MAX_VALUE)
82 .addComponent(buttonUpdate, javax.swing.GroupLayout.PREFERRED_SIZE, 92, javax.swing.GroupLayout.PREFERRED_SIZE)
83 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
84 .addComponent(buttonCancel, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
85 .addContainerGap())
86 );
87 layout.setVerticalGroup(
88 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
89 .addGroup(layout.createSequentialGroup()
90 .addContainerGap()
91 .addComponent(checkDraftCreated)
92 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
93 .addComponent(checkDraftApproved)
94 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 22, Short.MAX_VALUE)
95 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
96 .addComponent(buttonUpdate)
97 .addComponent(buttonCancel))
98 .addContainerGap())
99 );
100
101 pack();
102 }// </editor-fold>//GEN-END:initComponents
103
104 private void buttonCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonCancelActionPerformed
105 // TODO add your handling code here:
106 dispose ();
107 }//GEN-LAST:event_buttonCancelActionPerformed
108
109 private void buttonUpdateActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonUpdateActionPerformed
110 // TODO add your handling code here:
111 boolean rt = Utility.updateLegalNoticeDraftStatus (selectednotice_id,
112 checkDraftCreated.isSelected(), checkDraftApproved.isSelected());
113
114 if (rt == false)
115 JOptionPane.showMessageDialog(this, ERROR_UPDATING);
116 else
117 dispose ();
118 }//GEN-LAST:event_buttonUpdateActionPerformed
119 private static final String ERROR_UPDATING = "Error updating";
120
121 /**
122 * @param args the command line arguments
123 */
124 public static void main(String args[]) {
125 /* Set the Nimbus look and feel */
126 //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
127 /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
128 * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
129 */
130 try {
131 for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
132 if ("Nimbus".equals(info.getName())) {
133 javax.swing.UIManager.setLookAndFeel(info.getClassName());
134 break;
135 }
136 }
137 } catch (ClassNotFoundException ex) {
138 java.util.logging.Logger.getLogger(DraftStatusDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
139 } catch (InstantiationException ex) {
140 java.util.logging.Logger.getLogger(DraftStatusDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
141 } catch (IllegalAccessException ex) {
142 java.util.logging.Logger.getLogger(DraftStatusDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
143 } catch (javax.swing.UnsupportedLookAndFeelException ex) {
144 java.util.logging.Logger.getLogger(DraftStatusDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
145 }
146 //</editor-fold>
147
148 /* Create and display the dialog */
149 java.awt.EventQueue.invokeLater(new Runnable() {
150 public void run() {
151 DraftStatusDialog dialog = new DraftStatusDialog(new javax.swing.JFrame(), true);
152 dialog.addWindowListener(new java.awt.event.WindowAdapter() {
153 @Override
154 public void windowClosing(java.awt.event.WindowEvent e) {
155 System.exit(0);
156 }
157 });
158 dialog.setVisible(true);
159 }
160 });
161 }
162
163 // Variables declaration - do not modify//GEN-BEGIN:variables
164 private javax.swing.JButton buttonCancel;
165 private javax.swing.JButton buttonUpdate;
166 private javax.swing.JCheckBox checkDraftApproved;
167 private javax.swing.JCheckBox checkDraftCreated;
168 // End of variables declaration//GEN-END:variables
169
170 void setSelectedNotice(int selid) {
171 selectednotice_id = selid;
172 }
173 }