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