Commits

Rudi Giacomini  committed 475bb0e

Update tree with autoload of fb and pb data

  • Participants
  • Parent commits c412f83

Comments (0)

Files changed (7)

File src/nyagua/Bundle.properties

 Ny.helpMenu1.text_1=Help
 Ny.editMenu1.text_1=Options
 Ny.exitMenuItem1.text_1=Exit
-Ny.jTree1.toolTipText=Select an aquarium
 Ny.title_1=Nyagua
 Ny.jLabel68.text=Enviroment:
 Ny.jLabel69.text=Enviroment:
 FILTERED-DATA=Filtered Data
 PREFERENCES=<html><b>Preferences:</b><br> Here you can set the application \npersistent preferences. Click on a tab to select a category.</html>
 Ny.plantsReportButtontoolTipText=Create report
+Ny.mainTree.toolTipText=Select an aquarium

File src/nyagua/Bundle_de_DE.properties

 Ny.helpMenu1.text_1=Hilfe
 Ny.editMenu1.text_1=Optionen
 Ny.exitMenuItem1.text_1=Ausgang
-Ny.jTree1.toolTipText=W\u00e4hl ein Aquarium
 Ny.title_1=Nyagua
 Ny.jLabel68.text=Umgebung:
 Ny.jLabel69.text=Umgebung:
 Ny.plantsClearButton.text=
 settings.use.gnuplot=
 Ny.plantsReportButtontoolTipText=Report erstellen
+Ny.mainTree.toolTipText=W\u00e4hl ein Aquarium

File src/nyagua/Bundle_en_US.properties

 Ny.helpMenu1.text_1=Help
 Ny.editMenu1.text_1=Options
 Ny.exitMenuItem1.text_1=Exit
-Ny.jTree1.toolTipText=Select an aquarium
 Ny.title_1=Nyagua
 Ny.jLabel68.text=Enviroment:
 Ny.jLabel69.text=Enviroment:
 DAYS=Days
 Ny.plantsReportButtontoolTipText=Create report
 PREFERENCES=<html><b>Preferences:</b><br> Here you can set the application \npersistent preferences. Click on a tab to select a category.</html>
+Ny.mainTree.toolTipText=Select an aquarium

File src/nyagua/Bundle_it_IT.properties

 Ny.helpMenu1.text_1=Help
 Ny.editMenu1.text_1=Opzioni
 Ny.exitMenuItem1.text_1=Esci
-Ny.jTree1.toolTipText=Seleziona un acquario
 Ny.title_1=Nyagua
 Ny.jLabel68.text=Ambiente:
 Ny.jLabel69.text=Ambiente:
 DAYS=Giorni
 Ny.plantsReportButtontoolTipText=Crea report
 PREFERENCES=<html><b>Preferenze:</b><br> Qui \u00e8 possibile personalizzare alcuni aspetti del programma. Cliccare sulle linguette per selezionare la categoria.</html>
+Ny.mainTree.toolTipText=Seleziona un acquario

File src/nyagua/Bundle_pt_BR.properties

 Ny.helpMenu1.text_1=Ajuda
 Ny.editMenu1.text_1=Op\u00e7\u00f5es
 Ny.exitMenuItem1.text_1=Sair
-Ny.jTree1.toolTipText=Selecione um aqu\u00e1rio
 Ny.title_1=Nyagua
 Ny.jLabel68.text=Ambiente:
 Ny.jLabel69.text=Ambiente:
 Ny.plantsClearButton.text=
 settings.use.gnuplot=
 Ny.plantsReportButtontoolTipText=Criar relat\u00f3rio
+Ny.mainTree.toolTipText=Selecione um aqu\u00e1rio

File src/nyagua/Ny.form

 
               <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
               <SubComponents>
-                <Component class="javax.swing.JTree" name="jTree1">
+                <Component class="javax.swing.JTree" name="mainTree">
                   <Properties>
                     <Property name="model" type="javax.swing.tree.TreeModel" editor="org.netbeans.modules.form.editors2.TreeModelEditor">
                       <TreeModel code="Aquariums"/>
                     </Property>
                     <Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
-                      <ResourceString bundle="nyagua/Bundle.properties" key="Ny.jTree1.toolTipText" replaceFormat="java.util.ResourceBundle.getBundle(&quot;{bundleNameSlashes}&quot;).getString(&quot;{key}&quot;)"/>
+                      <ResourceString bundle="nyagua/Bundle.properties" key="Ny.mainTree.toolTipText" replaceFormat="java.util.ResourceBundle.getBundle(&quot;{bundleNameSlashes}&quot;).getString(&quot;{key}&quot;)"/>
                     </Property>
                     <Property name="alignmentX" type="float" value="1.0"/>
                     <Property name="alignmentY" type="float" value="1.0"/>
                     </Property>
                   </Properties>
                   <Events>
-                    <EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="jTree1MouseClicked"/>
+                    <EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="mainTreeMouseClicked"/>
                   </Events>
                   <AuxValues>
                     <AuxValue name="JavaCodeGenerator_InitCodePost" type="java.lang.String" value="PopulateTree();"/>

File src/nyagua/Ny.java

         filterStateLabel = new javax.swing.JLabel();
         filterStateBtn = new javax.swing.JButton();
         jScrollPane1 = new javax.swing.JScrollPane();
-        jTree1 = new javax.swing.JTree();
+        mainTree = new javax.swing.JTree();
         jSeparator17 = new javax.swing.JSeparator();
         menuBar1 = new javax.swing.JMenuBar();
         fileBackupMenu = new javax.swing.JMenu();
             .addGroup(utilityPanelLayout.createSequentialGroup()
                 .addGap(23, 23, 23)
                 .addComponent(phKhCo2RelationPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
-                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 52, Short.MAX_VALUE)
+                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 47, Short.MAX_VALUE)
                 .addComponent(heaterCalculatorPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
-                .addGap(0, 174, Short.MAX_VALUE))
+                .addGap(0, 169, Short.MAX_VALUE))
         );
 
         jTabbedPane1.addTab(bundle.getString("Ny.utilityPanel.TabConstraints.tabTitle"), utilityPanel); // NOI18N
         jScrollPane1.setPreferredSize(new java.awt.Dimension(97, 403));
 
         javax.swing.tree.DefaultMutableTreeNode treeNode1 = new javax.swing.tree.DefaultMutableTreeNode("Aquariums");
-        jTree1.setModel(new javax.swing.tree.DefaultTreeModel(treeNode1));
-        jTree1.setToolTipText(bundle.getString("Ny.jTree1.toolTipText")); // NOI18N
-        jTree1.setAlignmentX(1.0F);
-        jTree1.setAlignmentY(1.0F);
-        jTree1.setAutoscrolls(true);
-        jTree1.setPreferredSize(new java.awt.Dimension(80, 20));
+        mainTree.setModel(new javax.swing.tree.DefaultTreeModel(treeNode1));
+        mainTree.setToolTipText(bundle.getString("Ny.mainTree.toolTipText")); // NOI18N
+        mainTree.setAlignmentX(1.0F);
+        mainTree.setAlignmentY(1.0F);
+        mainTree.setAutoscrolls(true);
+        mainTree.setPreferredSize(new java.awt.Dimension(80, 20));
         PopulateTree();
-        jTree1.addMouseListener(new java.awt.event.MouseAdapter() {
+        mainTree.addMouseListener(new java.awt.event.MouseAdapter() {
             public void mouseClicked(java.awt.event.MouseEvent evt) {
-                jTree1MouseClicked(evt);
+                mainTreeMouseClicked(evt);
             }
         });
-        jScrollPane1.setViewportView(jTree1);
+        jScrollPane1.setViewportView(mainTree);
 
         jPanel0.add(jScrollPane1, java.awt.BorderLayout.CENTER);
         jPanel0.add(jSeparator17, java.awt.BorderLayout.PAGE_START);
 }//GEN-LAST:event_aquariumImageLoadButtonActionPerformed
 
     @SuppressWarnings("static-access")
-private void jTree1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTree1MouseClicked
+private void mainTreeMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_mainTreeMouseClicked
     /**Load selected aquarium data from db */
-    int node=jTree1.getLeadSelectionRow();    
+    int node=mainTree.getLeadSelectionRow();    
     if (node==1) {//fishbase icon selected
         this.jTabbedPane1.setSelectedIndex(5);
+        FishBase.populateTable(fbTable);            
     } else if (node==2){//plantsbase icon selected            
         this.jTabbedPane1.setSelectedIndex(7);
+        PlantBase.populateTable(pbTable);
     } else {
         this.jTabbedPane1.setSelectedIndex(0);
         try {
                 String aquariumName = rs.getString("Name");// NOI18N
                 //compare with selected element
                 if (aquariumName.matches(
-                        jTree1.getLastSelectedPathComponent().toString())) {
+                        mainTree.getLastSelectedPathComponent().toString())) {
                     Global.AqID = rs.getInt("id");// NOI18N
                     Ny.PopulateTable();
                     Aquarium tank=Aquarium.getById(Global.AqID);
             Logger.getLogger(Ny.class.getName()).log(Level.SEVERE, null, ex);
         }
     }    
-    if (jTree1.isRowSelected(0)) {
+    if (mainTree.isRowSelected(0)) {
         Global.AqID = 0;
         Ny.PopulateTable();
         PopulateList(0);
         CleanAllFields(0);
     }
-}//GEN-LAST:event_jTree1MouseClicked
+}//GEN-LAST:event_mainTreeMouseClicked
 
     
 private void aquariumClearButtonMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_aquariumClearButtonMouseClicked
     /** Cleans all textFields on tab1 (aquarium)*/
-    jTree1.setSelectionRow(0);
+    mainTree.setSelectionRow(0);
     Global.AqID = 0;
     PopulateList(0);
     CleanAllFields(0);
     public void PopulateTree() {
         /**Populate tree from db */
         String treename="/";
-        if (Application.DATA_FILENAME!=null){
-            treename=Application.DATA_FILENAME;
+        if (DB.getCurrent()!=null){            
+            treename=DB.getCurrent().substring(DB.getCurrent().lastIndexOf("/")+1);
+            treename=treename + ".db";
         }
-        jTree1.setModel(null);                
+        mainTree.setModel(null);                
         //root node
         IconNode treeNode1=new IconNodeImpl(treename, new javax.swing.ImageIcon(getClass().getResource("/icons/database.png")), "");//NOI18N            
         //jTree1.setModel(new javax.swing.tree.DefaultTreeModel(treeNode1));
-        jTree1.setCellRenderer(new IconNodeRenderer());
-        jTree1.setModel(new DefaultTreeModel(treeNode1));//Apply custom gui-bits model structure
+        mainTree.setCellRenderer(new IconNodeRenderer());
+        mainTree.setModel(new DefaultTreeModel(treeNode1));//Apply custom gui-bits model structure
         IconNode leaf1 = new IconNodeImpl(java.util.ResourceBundle.getBundle("nyagua/Bundle").getString("FISHBASE"), new javax.swing.ImageIcon(getClass().getResource("/icons/fish.png")),"");// NOI18N
         treeNode1.add(leaf1);
         //Fishbase leaf
         } catch (SQLException ex) {
             Logger.getLogger(Ny.class.getName()).log(Level.SEVERE, null, ex);
         }
-        jTree1.expandRow(0);
-        jTree1.expandRow(3);
+        mainTree.expandRow(0);
+        mainTree.expandRow(3);
+        FishBase.populateTable(fbTable);
+        PlantBase.populateTable(pbTable);
     }
 
     /**
     private javax.swing.JToolBar jToolBar7;
     private javax.swing.JToolBar jToolBar8;
     private javax.swing.JToolBar jToolBar9;
-    private javax.swing.JTree jTree1;
     private javax.swing.ButtonGroup khButtonGroup;
+    private javax.swing.JTree mainTree;
     private javax.swing.JButton maintClearButton;
     private javax.swing.JLabel maintDateLabel;
     private com.toedter.calendar.JDateChooser maintDateTextField;