Manage Legal Notices - Description
[habeas.git] / src / habeas / DescriptionDialog.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 java.text.DateFormat;
9 import java.text.SimpleDateFormat;
10 import java.util.Date;
11 import javax.swing.JOptionPane;
12
13 /**
14 *
15 * @author hari
16 */
17 public class DescriptionDialog extends javax.swing.JDialog {
18
19 private int selectednotice_id;
20
21 /**
22 * Creates new form DescriptionDialog
23 */
24 public DescriptionDialog(java.awt.Frame parent, boolean modal) {
25 super(parent, modal);
26 initComponents();
27 }
28
29 public void setFields (int selid, String reference,
30 String description, Date entrustmentdate) {
31 selectednotice_id = selid;
32 textDescription.setText(description);
33 DateFormat datfmt = new SimpleDateFormat ("dd/MM/yyyy");
34 textEntrustmentDate.setText (datfmt.format(entrustmentdate));
35 textReferenceNumber.setText(reference);
36 }
37
38 /**
39 * This method is called from within the constructor to initialize the form.
40 * WARNING: Do NOT modify this code. The content of this method is always
41 * regenerated by the Form Editor.
42 */
43 @SuppressWarnings("unchecked")
44 // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
45 private void initComponents() {
46
47 jLabel1 = new javax.swing.JLabel();
48 textReferenceNumber = new javax.swing.JTextField();
49 jLabel2 = new javax.swing.JLabel();
50 textEntrustmentDate = new javax.swing.JTextField();
51 jLabel3 = new javax.swing.JLabel();
52 jScrollPane1 = new javax.swing.JScrollPane();
53 textDescription = new javax.swing.JTextArea();
54 buttonUpdate = new javax.swing.JButton();
55 buttonCancel = new javax.swing.JButton();
56
57 setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
58 setTitle("Description");
59 setLocationByPlatform(true);
60
61 jLabel1.setText("Reference Number");
62
63 textReferenceNumber.setEditable(false);
64
65 jLabel2.setText("Entrustment Date");
66
67 textEntrustmentDate.setEditable(false);
68
69 jLabel3.setText("Description");
70
71 textDescription.setColumns(20);
72 textDescription.setRows(5);
73 jScrollPane1.setViewportView(textDescription);
74
75 buttonUpdate.setMnemonic('U');
76 buttonUpdate.setText("Update");
77 buttonUpdate.addActionListener(new java.awt.event.ActionListener() {
78 public void actionPerformed(java.awt.event.ActionEvent evt) {
79 buttonUpdateActionPerformed(evt);
80 }
81 });
82
83 buttonCancel.setMnemonic('C');
84 buttonCancel.setText("Cancel");
85 buttonCancel.addActionListener(new java.awt.event.ActionListener() {
86 public void actionPerformed(java.awt.event.ActionEvent evt) {
87 buttonCancelActionPerformed(evt);
88 }
89 });
90
91 javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
92 getContentPane().setLayout(layout);
93 layout.setHorizontalGroup(
94 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
95 .addGroup(layout.createSequentialGroup()
96 .addContainerGap()
97 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
98 .addGroup(layout.createSequentialGroup()
99 .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 167, javax.swing.GroupLayout.PREFERRED_SIZE)
100 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
101 .addComponent(textReferenceNumber))
102 .addGroup(layout.createSequentialGroup()
103 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
104 .addComponent(jLabel3, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
105 .addComponent(jLabel2, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 167, Short.MAX_VALUE))
106 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
107 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
108 .addComponent(textEntrustmentDate)
109 .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 315, Short.MAX_VALUE)))
110 .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
111 .addGap(0, 0, Short.MAX_VALUE)
112 .addComponent(buttonUpdate, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
113 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
114 .addComponent(buttonCancel, javax.swing.GroupLayout.PREFERRED_SIZE, 97, javax.swing.GroupLayout.PREFERRED_SIZE)))
115 .addContainerGap())
116 );
117 layout.setVerticalGroup(
118 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
119 .addGroup(layout.createSequentialGroup()
120 .addContainerGap()
121 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
122 .addComponent(jLabel1)
123 .addComponent(textReferenceNumber, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
124 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
125 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
126 .addComponent(textEntrustmentDate, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
127 .addComponent(jLabel2))
128 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
129 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
130 .addGroup(layout.createSequentialGroup()
131 .addComponent(jLabel3)
132 .addGap(0, 52, Short.MAX_VALUE))
133 .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE))
134 .addGap(18, 18, 18)
135 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
136 .addComponent(buttonUpdate)
137 .addComponent(buttonCancel))
138 .addContainerGap())
139 );
140
141 pack();
142 }// </editor-fold>//GEN-END:initComponents
143
144 private void buttonCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonCancelActionPerformed
145 // TODO add your handling code here:
146 dispose ();
147 }//GEN-LAST:event_buttonCancelActionPerformed
148
149 private void buttonUpdateActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonUpdateActionPerformed
150 // TODO add your handling code here:
151 boolean rt = Utility.updateNoticeDescription (selectednotice_id,
152 textDescription.getText());
153 if (rt == false)
154 JOptionPane.showMessageDialog(this, ERROR_UPDATING);
155 else
156 dispose ();
157 }//GEN-LAST:event_buttonUpdateActionPerformed
158 private static final String ERROR_UPDATING = "Error in updating";
159
160 /**
161 * @param args the command line arguments
162 */
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
168 */
169 try {
170 for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
171 if ("Nimbus".equals(info.getName())) {
172 javax.swing.UIManager.setLookAndFeel(info.getClassName());
173 break;
174 }
175 }
176 } catch (ClassNotFoundException ex) {
177 java.util.logging.Logger.getLogger(DescriptionDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
178 } catch (InstantiationException ex) {
179 java.util.logging.Logger.getLogger(DescriptionDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
180 } catch (IllegalAccessException ex) {
181 java.util.logging.Logger.getLogger(DescriptionDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
182 } catch (javax.swing.UnsupportedLookAndFeelException ex) {
183 java.util.logging.Logger.getLogger(DescriptionDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
184 }
185 //</editor-fold>
186
187 /* Create and display the dialog */
188 java.awt.EventQueue.invokeLater(new Runnable() {
189 public void run() {
190 DescriptionDialog dialog = new DescriptionDialog(new javax.swing.JFrame(), true);
191 dialog.addWindowListener(new java.awt.event.WindowAdapter() {
192 @Override
193 public void windowClosing(java.awt.event.WindowEvent e) {
194 System.exit(0);
195 }
196 });
197 dialog.setVisible(true);
198 }
199 });
200 }
201
202 // Variables declaration - do not modify//GEN-BEGIN:variables
203 private javax.swing.JButton buttonCancel;
204 private javax.swing.JButton buttonUpdate;
205 private javax.swing.JLabel jLabel1;
206 private javax.swing.JLabel jLabel2;
207 private javax.swing.JLabel jLabel3;
208 private javax.swing.JScrollPane jScrollPane1;
209 private javax.swing.JTextArea textDescription;
210 private javax.swing.JTextField textEntrustmentDate;
211 private javax.swing.JTextField textReferenceNumber;
212 // End of variables declaration//GEN-END:variables
213 }