From 9ec7870cd70d09a7d67efb17dae44baa51f77957 Mon Sep 17 00:00:00 2001 From: Harishankar Date: Tue, 31 Mar 2020 20:56:12 +0530 Subject: [PATCH] Stationery Settings and Template for Bill Created the stationery settings dialog and functionality and also started work on the template for generating bill in flat ODT format --- src/habeas/Habeas.java | 1 + src/habeas/MainFrame.form | 9 + src/habeas/MainFrame.java | 23 ++ src/habeas/StationerySettingsDialog.form | 155 +++++++++ src/habeas/StationerySettingsDialog.java | 198 +++++++++++ src/habeas/Utility.java | 26 +- src/resources/noticebill.template.fodt | 404 +++++++++++++++++++++++ src/resources/tablerow.template.xml | 14 + 8 files changed, 824 insertions(+), 6 deletions(-) create mode 100644 src/habeas/StationerySettingsDialog.form create mode 100644 src/habeas/StationerySettingsDialog.java create mode 100644 src/resources/noticebill.template.fodt create mode 100644 src/resources/tablerow.template.xml diff --git a/src/habeas/Habeas.java b/src/habeas/Habeas.java index ae8052b..6c24189 100644 --- a/src/habeas/Habeas.java +++ b/src/habeas/Habeas.java @@ -22,6 +22,7 @@ public class Habeas { public static void main(String[] args) { // TODO code application logic here Utility.retrieveConnectionURL(); + Utility.retrieveStationerySettings(); try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); diff --git a/src/habeas/MainFrame.form b/src/habeas/MainFrame.form index 5113978..0847aae 100644 --- a/src/habeas/MainFrame.form +++ b/src/habeas/MainFrame.form @@ -62,6 +62,15 @@ + + + + + + + + + diff --git a/src/habeas/MainFrame.java b/src/habeas/MainFrame.java index 30458d6..865a403 100644 --- a/src/habeas/MainFrame.java +++ b/src/habeas/MainFrame.java @@ -5,6 +5,12 @@ */ package habeas; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.InputStream; +import java.util.logging.Level; +import java.util.logging.Logger; + /** * * @author hari @@ -35,6 +41,7 @@ public class MainFrame extends javax.swing.JFrame { menuManageNotices = new javax.swing.JMenuItem(); menuSettings = new javax.swing.JMenu(); menuDatabaseSettings = new javax.swing.JMenuItem(); + menuStationery = new javax.swing.JMenuItem(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); setTitle("Habeas - Law Office Manager"); @@ -89,6 +96,15 @@ public class MainFrame extends javax.swing.JFrame { }); menuSettings.add(menuDatabaseSettings); + menuStationery.setMnemonic('S'); + menuStationery.setText("Stationery Settings..."); + menuStationery.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + menuStationeryActionPerformed(evt); + } + }); + menuSettings.add(menuStationery); + jMenuBar1.add(menuSettings); setJMenuBar(jMenuBar1); @@ -131,6 +147,12 @@ public class MainFrame extends javax.swing.JFrame { frm.setVisible(true); }//GEN-LAST:event_menuManageNoticesActionPerformed + private void menuStationeryActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuStationeryActionPerformed + // TODO add your handling code here: + StationerySettingsDialog frm = new StationerySettingsDialog(this, true); + frm.setVisible(true); + }//GEN-LAST:event_menuStationeryActionPerformed + /** * @param args the command line arguments */ @@ -175,5 +197,6 @@ public class MainFrame extends javax.swing.JFrame { private javax.swing.JMenuItem menuManageNotices; private javax.swing.JMenu menuMaster; private javax.swing.JMenu menuSettings; + private javax.swing.JMenuItem menuStationery; // End of variables declaration//GEN-END:variables } diff --git a/src/habeas/StationerySettingsDialog.form b/src/habeas/StationerySettingsDialog.form new file mode 100644 index 0000000..b4e3f37 --- /dev/null +++ b/src/habeas/StationerySettingsDialog.form @@ -0,0 +1,155 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/src/habeas/StationerySettingsDialog.java b/src/habeas/StationerySettingsDialog.java new file mode 100644 index 0000000..f7142c6 --- /dev/null +++ b/src/habeas/StationerySettingsDialog.java @@ -0,0 +1,198 @@ +/* + * 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; + +/** + * + * @author hari + */ +public class StationerySettingsDialog extends javax.swing.JDialog { + + /** + * Creates new form StationerySettingsDialog + */ + public StationerySettingsDialog(java.awt.Frame parent, boolean modal) { + super(parent, modal); + initComponents(); + textLeftHeader.setText(Utility.leftLetterHeader); + textRightHeader.setText(Utility.rightLetterHeader); + textSignatory.setText(Utility.signatoryName); + } + + /** + * 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") + // //GEN-BEGIN:initComponents + private void initComponents() { + + jLabel1 = new javax.swing.JLabel(); + jScrollPane2 = new javax.swing.JScrollPane(); + textLeftHeader = new javax.swing.JTextArea(); + jLabel2 = new javax.swing.JLabel(); + jScrollPane1 = new javax.swing.JScrollPane(); + textRightHeader = new javax.swing.JTextArea(); + jLabel3 = new javax.swing.JLabel(); + textSignatory = new javax.swing.JTextField(); + buttonApply = new javax.swing.JButton(); + buttonClose = new javax.swing.JButton(); + + setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); + setTitle("Stationery Settings"); + setLocationByPlatform(true); + + jLabel1.setText("Letter Left Header"); + + textLeftHeader.setColumns(20); + textLeftHeader.setRows(5); + jScrollPane2.setViewportView(textLeftHeader); + + jLabel2.setText("Letter Right Header"); + + textRightHeader.setColumns(20); + textRightHeader.setRows(5); + jScrollPane1.setViewportView(textRightHeader); + + jLabel3.setText("Signatory Name"); + + buttonApply.setMnemonic('A'); + buttonApply.setText("Apply"); + buttonApply.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + buttonApplyActionPerformed(evt); + } + }); + + buttonClose.setMnemonic('c'); + buttonClose.setText("Close"); + buttonClose.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + buttonCloseActionPerformed(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() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) + .addComponent(jLabel2, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 209, Short.MAX_VALUE) + .addComponent(jLabel1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + .addGap(220, 220, 220)) + .addGroup(layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) + .addComponent(jScrollPane2, javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jScrollPane1)) + .addContainerGap()) + .addGroup(layout.createSequentialGroup() + .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 140, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(textSignatory) + .addContainerGap()))) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(buttonApply, javax.swing.GroupLayout.PREFERRED_SIZE, 106, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(buttonClose, javax.swing.GroupLayout.PREFERRED_SIZE, 101, javax.swing.GroupLayout.PREFERRED_SIZE) + .addContainerGap()) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addComponent(jLabel1) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 77, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jLabel2) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 77, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel3) + .addComponent(textSignatory, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 16, Short.MAX_VALUE) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(buttonApply) + .addComponent(buttonClose)) + .addContainerGap()) + ); + + pack(); + }// //GEN-END:initComponents + + private void buttonCloseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonCloseActionPerformed + // TODO add your handling code here: + dispose (); + }//GEN-LAST:event_buttonCloseActionPerformed + + private void buttonApplyActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonApplyActionPerformed + // TODO add your handling code here: + Utility.saveStationerySettings(textLeftHeader.getText(), + textRightHeader.getText(), textSignatory.getText()); + }//GEN-LAST:event_buttonApplyActionPerformed + + /** + * @param args the command line arguments + */ + public static void main(String args[]) { + /* Set the Nimbus look and feel */ + // + /* 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(StationerySettingsDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + } catch (InstantiationException ex) { + java.util.logging.Logger.getLogger(StationerySettingsDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + } catch (IllegalAccessException ex) { + java.util.logging.Logger.getLogger(StationerySettingsDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + } catch (javax.swing.UnsupportedLookAndFeelException ex) { + java.util.logging.Logger.getLogger(StationerySettingsDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + } + // + + /* Create and display the dialog */ + java.awt.EventQueue.invokeLater(new Runnable() { + public void run() { + StationerySettingsDialog dialog = new StationerySettingsDialog(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 buttonApply; + private javax.swing.JButton buttonClose; + private javax.swing.JLabel jLabel1; + private javax.swing.JLabel jLabel2; + private javax.swing.JLabel jLabel3; + private javax.swing.JScrollPane jScrollPane1; + private javax.swing.JScrollPane jScrollPane2; + private javax.swing.JTextArea textLeftHeader; + private javax.swing.JTextArea textRightHeader; + private javax.swing.JTextField textSignatory; + // End of variables declaration//GEN-END:variables +} diff --git a/src/habeas/Utility.java b/src/habeas/Utility.java index 0e6d9eb..0dc4235 100644 --- a/src/habeas/Utility.java +++ b/src/habeas/Utility.java @@ -16,6 +16,22 @@ import java.util.logging.Logger; * @author hari */ public class Utility { + + static void saveStationerySettings (String left_header, + String right_header, String signatory) { + leftLetterHeader = left_header; + rightLetterHeader = right_header; + signatoryName = signatory; + Preferences.userRoot().put ("LeftHeader", left_header); + Preferences.userRoot().put ("RightHeader", right_header); + Preferences.userRoot().put ("Signatory", signatory); + } + + static void retrieveStationerySettings () { + leftLetterHeader = Preferences.userRoot().get("LeftHeader", "Left Header"); + rightLetterHeader = Preferences.userRoot().get ("RightHeader", "Right Header"); + signatoryName = Preferences.userRoot().get ("Signatory", "Signatory Name"); + } static void saveConnectionURL(String text) { connectionURL = text; @@ -325,15 +341,10 @@ public class Utility { " \"ClarificationPending\" INTEGER DEFAULT 0,\n" + " \"ClarificationRemarks\" TEXT\n" + ");"; - String tblSettings = "CREATE TABLE IF NOT EXISTS \"settings\" (\n" + -" \"key\" TEXT UNIQUE,\n" + -" \"value\" TEXT,\n" + -" PRIMARY KEY(\"key\")\n" + - ");"; + try { Connection conn = DriverManager.getConnection(JDBC + connectionURL); Statement st1 = conn.createStatement(); - st1.execute(tblSettings); st1.execute(tblClients); st1.execute(tblNotices); conn.close(); @@ -384,6 +395,9 @@ public class Utility { } public static String connectionURL ; + public static String leftLetterHeader; + public static String rightLetterHeader; + public static String signatoryName; /** * diff --git a/src/resources/noticebill.template.fodt b/src/resources/noticebill.template.fodt new file mode 100644 index 0000000..7ee76ac --- /dev/null +++ b/src/resources/noticebill.template.fodt @@ -0,0 +1,404 @@ + + + + Harishankar2020-03-31T18:10:42.145558520LibreOffice/6.4.2.2$Linux_X86_64 LibreOffice_project/40$Build-22020-03-31T20:20:34.290574090HarishankarPT26M56S4 + + + 2727 + 0 + 24211 + 8922 + true + false + + + view2 + 3655 + 10012 + 0 + 2727 + 24209 + 11647 + 0 + 1 + false + 140 + false + false + + + + + false + false + false + true + true + true + true + true + false + 0 + false + true + false + false + true + false + false + false + true + true + true + false + false + false + false + false + true + false + false + true + false + false + false + true + 0 + 1 + true + + high-resolution + true + + + false + false + true + false + true + true + + true + 1334322 + + true + false + true + 0 + + false + false + false + false + true + false + false + false + false + true + false + + false + false + true + false + false + false + false + false + false + false + false + false + 1229947 + false + false + false + false + true + false + true + true + false + true + false + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {Left Header} + + + {Right Header} + + + + + + + + + + + + + + + + + + {Date} + To: + {Client Name}{Client Address} + Sir/Madam, + SUB: PENDING BILLS FOR LEGAL NOTICES + With reference to the above, please find below the details of the pending bills: + + + + + + + + Reference Number + + + Description + + + Bill Date + + + Amount + + + {Bill Table Row} + + + Attaching the copies of the notices along with postal acknowledgement. I request you to kindly clear the same at your earliest convenience. + Thanking you, + Yours Truly, + + {Signatory Name} + + + \ No newline at end of file diff --git a/src/resources/tablerow.template.xml b/src/resources/tablerow.template.xml new file mode 100644 index 0000000..62f9ec8 --- /dev/null +++ b/src/resources/tablerow.template.xml @@ -0,0 +1,14 @@ + + + {Reference Number} + + + {Description} + + + {Bill Date} + + + {Bill Amount} + + -- 2.20.1