--- /dev/null
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<Form version="1.3" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JDialogFormInfo">
+ <Properties>
+ <Property name="defaultCloseOperation" type="int" value="2"/>
+ <Property name="title" type="java.lang.String" value="Description"/>
+ <Property name="locationByPlatform" type="boolean" value="true"/>
+ </Properties>
+ <SyntheticProperties>
+ <SyntheticProperty name="formSizePolicy" type="int" value="1"/>
+ <SyntheticProperty name="generateCenter" type="boolean" value="false"/>
+ </SyntheticProperties>
+ <AuxValues>
+ <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
+ <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
+ <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
+ <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
+ <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
+ <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
+ <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
+ <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
+ <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
+ </AuxValues>
+
+ <Layout>
+ <DimensionLayout dim="0">
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Group type="102" attributes="0">
+ <EmptySpace max="-2" attributes="0"/>
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Group type="102" alignment="0" attributes="0">
+ <Component id="jLabel1" min="-2" pref="167" max="-2" attributes="0"/>
+ <EmptySpace max="-2" attributes="0"/>
+ <Component id="textReferenceNumber" max="32767" attributes="0"/>
+ </Group>
+ <Group type="102" alignment="0" attributes="0">
+ <Group type="103" groupAlignment="1" max="-2" attributes="0">
+ <Component id="jLabel3" alignment="0" max="32767" attributes="0"/>
+ <Component id="jLabel2" alignment="0" pref="167" max="32767" attributes="0"/>
+ </Group>
+ <EmptySpace max="-2" attributes="0"/>
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Component id="textEntrustmentDate" max="32767" attributes="0"/>
+ <Component id="jScrollPane1" pref="315" max="32767" attributes="0"/>
+ </Group>
+ </Group>
+ <Group type="102" alignment="1" attributes="0">
+ <EmptySpace min="0" pref="0" max="32767" attributes="0"/>
+ <Component id="buttonUpdate" min="-2" pref="100" max="-2" attributes="0"/>
+ <EmptySpace max="-2" attributes="0"/>
+ <Component id="buttonCancel" min="-2" pref="97" max="-2" attributes="0"/>
+ </Group>
+ </Group>
+ <EmptySpace max="-2" attributes="0"/>
+ </Group>
+ </Group>
+ </DimensionLayout>
+ <DimensionLayout dim="1">
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Group type="102" alignment="0" attributes="0">
+ <EmptySpace max="-2" attributes="0"/>
+ <Group type="103" groupAlignment="3" attributes="0">
+ <Component id="jLabel1" alignment="3" min="-2" max="-2" attributes="0"/>
+ <Component id="textReferenceNumber" alignment="3" min="-2" max="-2" attributes="0"/>
+ </Group>
+ <EmptySpace max="-2" attributes="0"/>
+ <Group type="103" groupAlignment="3" attributes="0">
+ <Component id="textEntrustmentDate" alignment="3" min="-2" max="-2" attributes="0"/>
+ <Component id="jLabel2" alignment="3" min="-2" max="-2" attributes="0"/>
+ </Group>
+ <EmptySpace type="unrelated" max="-2" attributes="0"/>
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Group type="102" attributes="0">
+ <Component id="jLabel3" min="-2" max="-2" attributes="0"/>
+ <EmptySpace min="0" pref="52" max="32767" attributes="0"/>
+ </Group>
+ <Component id="jScrollPane1" pref="0" max="32767" attributes="0"/>
+ </Group>
+ <EmptySpace type="separate" max="-2" attributes="0"/>
+ <Group type="103" groupAlignment="3" attributes="0">
+ <Component id="buttonUpdate" alignment="3" min="-2" max="-2" attributes="0"/>
+ <Component id="buttonCancel" alignment="3" min="-2" max="-2" attributes="0"/>
+ </Group>
+ <EmptySpace max="-2" attributes="0"/>
+ </Group>
+ </Group>
+ </DimensionLayout>
+ </Layout>
+ <SubComponents>
+ <Component class="javax.swing.JLabel" name="jLabel1">
+ <Properties>
+ <Property name="text" type="java.lang.String" value="Reference Number"/>
+ </Properties>
+ </Component>
+ <Component class="javax.swing.JTextField" name="textReferenceNumber">
+ <Properties>
+ <Property name="editable" type="boolean" value="false"/>
+ </Properties>
+ </Component>
+ <Component class="javax.swing.JLabel" name="jLabel2">
+ <Properties>
+ <Property name="text" type="java.lang.String" value="Entrustment Date"/>
+ </Properties>
+ </Component>
+ <Component class="javax.swing.JTextField" name="textEntrustmentDate">
+ <Properties>
+ <Property name="editable" type="boolean" value="false"/>
+ </Properties>
+ </Component>
+ <Component class="javax.swing.JLabel" name="jLabel3">
+ <Properties>
+ <Property name="text" type="java.lang.String" value="Description"/>
+ </Properties>
+ </Component>
+ <Container class="javax.swing.JScrollPane" name="jScrollPane1">
+ <AuxValues>
+ <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
+ </AuxValues>
+
+ <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
+ <SubComponents>
+ <Component class="javax.swing.JTextArea" name="textDescription">
+ <Properties>
+ <Property name="columns" type="int" value="20"/>
+ <Property name="rows" type="int" value="5"/>
+ </Properties>
+ </Component>
+ </SubComponents>
+ </Container>
+ <Component class="javax.swing.JButton" name="buttonUpdate">
+ <Properties>
+ <Property name="mnemonic" type="int" value="85"/>
+ <Property name="text" type="java.lang.String" value="Update"/>
+ </Properties>
+ <Events>
+ <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonUpdateActionPerformed"/>
+ </Events>
+ </Component>
+ <Component class="javax.swing.JButton" name="buttonCancel">
+ <Properties>
+ <Property name="mnemonic" type="int" value="67"/>
+ <Property name="text" type="java.lang.String" value="Cancel"/>
+ </Properties>
+ <Events>
+ <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonCancelActionPerformed"/>
+ </Events>
+ </Component>
+ </SubComponents>
+</Form>
--- /dev/null
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package habeas;
+
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import javax.swing.JOptionPane;
+
+/**
+ *
+ * @author hari
+ */
+public class DescriptionDialog extends javax.swing.JDialog {
+
+ private int selectednotice_id;
+
+ /**
+ * Creates new form DescriptionDialog
+ */
+ public DescriptionDialog(java.awt.Frame parent, boolean modal) {
+ super(parent, modal);
+ initComponents();
+ }
+
+ public void setFields (int selid, String reference,
+ String description, Date entrustmentdate) {
+ selectednotice_id = selid;
+ textDescription.setText(description);
+ DateFormat datfmt = new SimpleDateFormat ("dd/MM/yyyy");
+ textEntrustmentDate.setText (datfmt.format(entrustmentdate));
+ textReferenceNumber.setText(reference);
+ }
+
+ /**
+ * This method is called from within the constructor to initialize the form.
+ * WARNING: Do NOT modify this code. The content of this method is always
+ * regenerated by the Form Editor.
+ */
+ @SuppressWarnings("unchecked")
+ // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
+ private void initComponents() {
+
+ jLabel1 = new javax.swing.JLabel();
+ textReferenceNumber = new javax.swing.JTextField();
+ jLabel2 = new javax.swing.JLabel();
+ textEntrustmentDate = new javax.swing.JTextField();
+ jLabel3 = new javax.swing.JLabel();
+ jScrollPane1 = new javax.swing.JScrollPane();
+ textDescription = new javax.swing.JTextArea();
+ buttonUpdate = new javax.swing.JButton();
+ buttonCancel = new javax.swing.JButton();
+
+ setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
+ setTitle("Description");
+ setLocationByPlatform(true);
+
+ jLabel1.setText("Reference Number");
+
+ textReferenceNumber.setEditable(false);
+
+ jLabel2.setText("Entrustment Date");
+
+ textEntrustmentDate.setEditable(false);
+
+ jLabel3.setText("Description");
+
+ textDescription.setColumns(20);
+ textDescription.setRows(5);
+ jScrollPane1.setViewportView(textDescription);
+
+ buttonUpdate.setMnemonic('U');
+ buttonUpdate.setText("Update");
+ buttonUpdate.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ buttonUpdateActionPerformed(evt);
+ }
+ });
+
+ buttonCancel.setMnemonic('C');
+ buttonCancel.setText("Cancel");
+ buttonCancel.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ buttonCancelActionPerformed(evt);
+ }
+ });
+
+ javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
+ getContentPane().setLayout(layout);
+ layout.setHorizontalGroup(
+ layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(layout.createSequentialGroup()
+ .addContainerGap()
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(layout.createSequentialGroup()
+ .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 167, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addComponent(textReferenceNumber))
+ .addGroup(layout.createSequentialGroup()
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
+ .addComponent(jLabel3, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+ .addComponent(jLabel2, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 167, Short.MAX_VALUE))
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addComponent(textEntrustmentDate)
+ .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 315, Short.MAX_VALUE)))
+ .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
+ .addGap(0, 0, Short.MAX_VALUE)
+ .addComponent(buttonUpdate, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addComponent(buttonCancel, javax.swing.GroupLayout.PREFERRED_SIZE, 97, javax.swing.GroupLayout.PREFERRED_SIZE)))
+ .addContainerGap())
+ );
+ layout.setVerticalGroup(
+ layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(layout.createSequentialGroup()
+ .addContainerGap()
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+ .addComponent(jLabel1)
+ .addComponent(textReferenceNumber, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+ .addComponent(textEntrustmentDate, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addComponent(jLabel2))
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(layout.createSequentialGroup()
+ .addComponent(jLabel3)
+ .addGap(0, 52, Short.MAX_VALUE))
+ .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE))
+ .addGap(18, 18, 18)
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+ .addComponent(buttonUpdate)
+ .addComponent(buttonCancel))
+ .addContainerGap())
+ );
+
+ pack();
+ }// </editor-fold>//GEN-END:initComponents
+
+ private void buttonCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonCancelActionPerformed
+ // TODO add your handling code here:
+ dispose ();
+ }//GEN-LAST:event_buttonCancelActionPerformed
+
+ private void buttonUpdateActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonUpdateActionPerformed
+ // TODO add your handling code here:
+ boolean rt = Utility.updateNoticeDescription (selectednotice_id,
+ textDescription.getText());
+ if (rt == false)
+ JOptionPane.showMessageDialog(this, ERROR_UPDATING);
+ else
+ dispose ();
+ }//GEN-LAST:event_buttonUpdateActionPerformed
+ private static final String ERROR_UPDATING = "Error in updating";
+
+ /**
+ * @param args the command line arguments
+ */
+ public static void main(String args[]) {
+ /* Set the Nimbus look and feel */
+ //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
+ /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
+ * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
+ */
+ try {
+ for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
+ if ("Nimbus".equals(info.getName())) {
+ javax.swing.UIManager.setLookAndFeel(info.getClassName());
+ break;
+ }
+ }
+ } catch (ClassNotFoundException ex) {
+ java.util.logging.Logger.getLogger(DescriptionDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
+ } catch (InstantiationException ex) {
+ java.util.logging.Logger.getLogger(DescriptionDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
+ } catch (IllegalAccessException ex) {
+ java.util.logging.Logger.getLogger(DescriptionDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
+ } catch (javax.swing.UnsupportedLookAndFeelException ex) {
+ java.util.logging.Logger.getLogger(DescriptionDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
+ }
+ //</editor-fold>
+
+ /* Create and display the dialog */
+ java.awt.EventQueue.invokeLater(new Runnable() {
+ public void run() {
+ DescriptionDialog dialog = new DescriptionDialog(new javax.swing.JFrame(), true);
+ dialog.addWindowListener(new java.awt.event.WindowAdapter() {
+ @Override
+ public void windowClosing(java.awt.event.WindowEvent e) {
+ System.exit(0);
+ }
+ });
+ dialog.setVisible(true);
+ }
+ });
+ }
+
+ // Variables declaration - do not modify//GEN-BEGIN:variables
+ private javax.swing.JButton buttonCancel;
+ private javax.swing.JButton buttonUpdate;
+ private javax.swing.JLabel jLabel1;
+ private javax.swing.JLabel jLabel2;
+ private javax.swing.JLabel jLabel3;
+ private javax.swing.JScrollPane jScrollPane1;
+ private javax.swing.JTextArea textDescription;
+ private javax.swing.JTextField textEntrustmentDate;
+ private javax.swing.JTextField textReferenceNumber;
+ // End of variables declaration//GEN-END:variables
+}
initComponents();
}
- public void setDraftStatus (boolean created, boolean approved) {
+ public void setFields (int selid, boolean created, boolean approved) {
+ selectednotice_id = selid;
checkDraftCreated.setSelected(created);
checkDraftApproved.setSelected(approved);
}
private void buttonUpdateActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonUpdateActionPerformed
// TODO add your handling code here:
- boolean rt = Utility.updateLegalNoticeDraftStatus (selectednotice_id,
+ boolean rt = Utility.updateNoticeDraftStatus (selectednotice_id,
checkDraftCreated.isSelected(), checkDraftApproved.isSelected());
if (rt == false)
private javax.swing.JCheckBox checkDraftCreated;
// End of variables declaration//GEN-END:variables
- void setSelectedNotice(int selid) {
- selectednotice_id = selid;
- }
}
<Property name="useNullLayout" type="boolean" value="true"/>
</Layout>
<SubComponents>
+ <MenuItem class="javax.swing.JMenuItem" name="menuDescription">
+ <Properties>
+ <Property name="text" type="java.lang.String" value="Description..."/>
+ </Properties>
+ <Events>
+ <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="menuDescriptionActionPerformed"/>
+ </Events>
+ </MenuItem>
<MenuItem class="javax.swing.JMenuItem" name="menuDraftStatus">
<Properties>
<Property name="mnemonic" type="int" value="68"/>
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.ArrayList;
+import java.util.Date;
import javax.swing.table.DefaultTableModel;
/**
private void initComponents() {
popMenu = new javax.swing.JPopupMenu();
+ menuDescription = new javax.swing.JMenuItem();
menuDraftStatus = new javax.swing.JMenuItem();
jScrollPane1 = new javax.swing.JScrollPane();
tableNotices = new javax.swing.JTable();
+ menuDescription.setText("Description...");
+ menuDescription.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ menuDescriptionActionPerformed(evt);
+ }
+ });
+ popMenu.add(menuDescription);
+
menuDraftStatus.setMnemonic('D');
menuDraftStatus.setText("Draft Status...");
menuDraftStatus.setToolTipText("");
ArrayList<Object> notice = Utility.getNoticeDetails (selid);
if (notice == null) return;
- frm.setDraftStatus((boolean)notice.get(4), (boolean)notice.get(5));
- frm.setSelectedNotice (selid);
+ frm.setFields(selid, (boolean)notice.get(4), (boolean)notice.get(5));
frm.setVisible(true);
}//GEN-LAST:event_menuDraftStatusActionPerformed
+ private void menuDescriptionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuDescriptionActionPerformed
+ // TODO add your handling code here:
+ int selid = getSelectedNotice();
+ if (selid == -1) return;
+ DescriptionDialog frm = new DescriptionDialog((Frame)this.getParent(), true);
+ ArrayList<Object> notice = Utility.getNoticeDetails(selid);
+ if (notice == null) return;
+ frm.setFields(selid, (String)notice.get(0), (String)notice.get(1), (Date)notice.get(2));
+ frm.setVisible(true);
+ populateNotices();
+ }//GEN-LAST:event_menuDescriptionActionPerformed
+
/**
* @param args the command line arguments
*/
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JScrollPane jScrollPane1;
+ private javax.swing.JMenuItem menuDescription;
private javax.swing.JMenuItem menuDraftStatus;
private javax.swing.JPopupMenu popMenu;
private javax.swing.JTable tableNotices;
}
private static final String JDBC = "jdbc:sqlite:";
- static boolean updateLegalNoticeDraftStatus(int selectednotice_id, boolean created, boolean approved) {
+ static boolean updateNoticeDraftStatus(int selectednotice_id, boolean created, boolean approved) {
try {
Connection conn = DriverManager.getConnection(JDBC + connectionURL);
PreparedStatement st = conn.prepareStatement("UPDATE legalnotices "
return false;
}
+ }
+
+ static boolean updateNoticeDescription(int selectednotice_id, String text) {
+ try {
+ Connection conn = DriverManager.getConnection(JDBC + connectionURL);
+ PreparedStatement st = conn.prepareStatement("UPDATE legalnotices "
+ + "SET Description=? WHERE id=?;");
+ st.setString(1, text);
+ st.setInt(2, selectednotice_id);
+ st.execute();
+ conn.close();
+ return true;
+ } catch (SQLException ex) {
+ Logger.getLogger(Utility.class.getName()).log(Level.SEVERE, null, ex);
+ return false;
+ }
+
}
public Utility () {