Commits

Anonymous committed 7224b41 Draft

Added limited sorting features to all tables (doesn't sort well id's, reset sorters on new item adding)

Comments (0)

Files changed (8)

src/nyagua/Ny.form

-<?xml version="1.0" encoding="UTF-8" ?>
+<?xml version="1.1" encoding="UTF-8" ?>
 
 <Form version="1.7" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JFrameFormInfo">
   <NonVisualComponents>

src/nyagua/data/Device.java

      * @param dev Device to save
      */
     public void save(Device dev){
-        int currID=dev.id;
-        /*
-        String qry = "";
-        qry = "INSERT OR REPLACE INTO " + TABLE + " VALUES (";// NOI18N
-        if (currID == 0) {
-            qry = qry + "NULL,";    // NOI18N
-            } else {                //the record is in update
-            qry = qry + currID + ",";
-        }
-        qry = qry + "'" + dev.name + "','" + dev.brand + "','";// NOI18N
-        qry = qry + dev.wattage + "','" + dev.notes + "','";// NOI18N
-        qry = qry + dev.onPeriod + "'," + Global.AqID;// NOI18N
-        qry = qry + ");";// NOI18N*/
+        int currID=dev.id;       
         DB.openConn();
         try {
             //Changes due to single quote problem
     public static void populateTable (JTable diplayData){
         try {            
             DefaultTableModel dm = new DefaultTableModel();
+            diplayData.setAutoCreateRowSorter(true);
             DB.openConn();
             String qry = "SELECT COUNT(*) AS cont FROM " + TABLE + "  WHERE AqID ='" + Global.AqID + "';"; // NOI18N
             ResultSet rs = DB.getQuery(qry);

src/nyagua/data/Expense.java

      */
     public void save(Expense exp){
         int currID=exp.id;
-        /*
-        String qry = "";
-        qry = "INSERT OR REPLACE INTO " + TABLE + " VALUES (";// NOI18N
-        if (currID == 0) {
-            qry = qry + "NULL,";    // NOI18N
-            } else {                //the record is in update
-            qry = qry + currID + ",";
-        }
-        qry = qry + "'" + exp.date + "','" + exp.item + "','";// NOI18N
-        qry = qry + exp.price + "','" + exp.notes + "','";// NOI18N
-        qry = qry + exp.shop + "'," + Global.AqID;// NOI18N
-        qry = qry + ");";// NOI18N*/
         DB.openConn();
         try {
             //Changes due to single quote problem
     public static void populateTable (JTable diplayData){
         try {            
             DefaultTableModel dm = new DefaultTableModel();
+            diplayData.setAutoCreateRowSorter(true);
             DB.openConn();
             String qry = "SELECT COUNT(*) AS cont FROM " + TABLE + "  WHERE AqID ='" + Global.AqID + "' " + Util.getPeriod()+ ";"; // NOI18N
             ResultSet rs = DB.getQuery(qry);

src/nyagua/data/Fish.java

      */
     public void save(Fish specimen){
         int currID=specimen.id;
-        /*
-        String qry = "";
-        qry = "INSERT OR REPLACE INTO " + TABLE + " VALUES (";// NOI18N
-        if (currID == 0) {
-            qry = qry + "NULL,";    // NOI18N
-            } else {                //the record is in update
-            qry = qry + currID + ",";
-        }
-        qry = qry + "'" + specimen.date + "','" + specimen.name + "','";// NOI18N
-        qry = qry + specimen.males + "','" + specimen.females + "','";// NOI18N
-        qry = qry + specimen.notes + "'," + Global.AqID;// NOI18N
-        qry = qry + ");";// NOI18N*/
         DB.openConn();
         try {
             //Changes due to single quote problem
     public static void populateTable (JTable diplayData){
         try {
             DefaultTableModel dm = new DefaultTableModel();
+            diplayData.setAutoCreateRowSorter(true);
             DB.openConn();
             String qry = "SELECT COUNT(*) AS cont FROM " + TABLE + "  WHERE AqID ='" + Global.AqID + "' " + Util.getPeriod()+ ";"; // NOI18N
             ResultSet rs = DB.getQuery(qry);

src/nyagua/data/FishBase.java

       *
       * @param diplayData the table to populate
       */
-    public static void populateTable (JTable diplayData){
+    public static void populateTable (JTable displayData){
         try {
             DefaultTableModel dm = new DefaultTableModel();
+            displayData.setAutoCreateRowSorter(true);
             DB.openConn();
             String qry = "SELECT COUNT(*) AS cont FROM " + TABLE +";"; // NOI18N
             ResultSet rs = DB.getQuery(qry);
             DB.closeConn();
             //tb1=LocUtil.localizeTableFieldDate(tb1, 1);
             dm.setDataVector(tableData,CAPTIONS);
-            diplayData.setModel(dm);
+            displayData.setModel(dm);
             // Set the first visible column to 40 pixels wide
-            TableColumn col = diplayData.getColumnModel().getColumn(0);
+            TableColumn col = displayData.getColumnModel().getColumn(0);
             int width = 40;
             col.setPreferredWidth(width);
-            col = diplayData.getColumnModel().getColumn(1);
+            col = displayData.getColumnModel().getColumn(1);
             width = 150;
             col.setPreferredWidth(width);
         } catch (SQLException ex) {

src/nyagua/data/Maintenance.java

 import java.util.logging.Level;
 import java.util.logging.Logger;
 import javax.swing.DefaultComboBoxModel;
-import javax.swing.DefaultListModel;
 import javax.swing.JComboBox;
 import javax.swing.JList;
 import javax.swing.JTable;
         java.util.ResourceBundle.getBundle("nyagua/Bundle").getString("WARNINGS"),
         //java.util.ResourceBundle.getBundle("nyagua/Bundle").getString("AQID")
     };
-
+    
     // <editor-fold defaultstate="collapsed" desc="fields">
     //private Date date;
     private int id;
     /**
      * @return the date
      */
-    /*public String getDate() {
-        return date;
-    }*/
-    
+      
     public Date getDate(){
         return newDate;
     }
             diplayData.setModel(dm);
             // Set the first visible column to 40 pixels wide
             TableColumn col = diplayData.getColumnModel().getColumn(0);
-            int width = 40;
+            int width = 40;         
             col.setPreferredWidth(width);
         } catch (SQLException ex) {
             Logger.getLogger(Reading.class.getName()).log(Level.SEVERE, null, ex);
         }
     }
-
+    
     /**
      * @deprecated 
      * 

src/nyagua/data/PlantBase.java

     public static void populateTable (JTable diplayData){
         try {
             DefaultTableModel dm = new DefaultTableModel();
+            diplayData.setAutoCreateRowSorter(true);
             DB.openConn();
             String qry = "SELECT COUNT(*) AS cont FROM " + TABLE +";"; // NOI18N
             ResultSet rs = DB.getQuery(qry);

src/nyagua/data/Reading.java

     public static void populateTable (JTable diplayData){
         try {            
             DefaultTableModel dm = new DefaultTableModel();
-            //String[] nameHeader = set1.getHeader("Measures"); // NOI18N
-            //String[] fields = set1.getFields("Measures"); //NOI18N
+            diplayData.setAutoCreateRowSorter(true);
             DB.openConn();
             String qry = "SELECT COUNT(*) AS cont FROM " + TABLE + "  WHERE AqID ='" + Global.AqID + "' " + Util.getPeriod()+ ";"; // NOI18N
             ResultSet rs = DB.getQuery(qry);