Author: jflesch
Date: 2007-07-01 22:50:16 +0000 (Sun, 01 Jul 2007)
New Revision: 13869

Modified:
   trunk/apps/Thaw/src/thaw/i18n/source.thaw_fr.properties
   trunk/apps/Thaw/src/thaw/i18n/thaw.properties
   trunk/apps/Thaw/src/thaw/i18n/thaw_fr.properties
   trunk/apps/Thaw/src/thaw/plugins/index/DetailPanel.java
   trunk/apps/Thaw/src/thaw/plugins/index/IndexBrowserPanel.java
   trunk/apps/Thaw/src/thaw/plugins/index/IndexTree.java
Log:
In the index browser : add stats about the indexes (number of files, number of 
links)

Modified: trunk/apps/Thaw/src/thaw/i18n/source.thaw_fr.properties
===================================================================
--- trunk/apps/Thaw/src/thaw/i18n/source.thaw_fr.properties     2007-07-01 
21:42:36 UTC (rev 13868)
+++ trunk/apps/Thaw/src/thaw/i18n/source.thaw_fr.properties     2007-07-01 
22:50:16 UTC (rev 13869)
@@ -362,6 +362,9 @@

 thaw.plugin.index.warningNonNegative=Attention ! T?l?charger les commentaires 
sans avoir la derni?re version de l'index peut vous faire t?l?charger des spams 
!

+thaw.plugin.index.numberOfFiles=Nombre de fichiers : ?
+thaw.plugin.index.numberOfLinks=Nombre de liens : ?
+
 # Peer monitor

 thaw.plugin.peerMonitor.peerMonitor=Connexion

Modified: trunk/apps/Thaw/src/thaw/i18n/thaw.properties
===================================================================
--- trunk/apps/Thaw/src/thaw/i18n/thaw.properties       2007-07-01 21:42:36 UTC 
(rev 13868)
+++ trunk/apps/Thaw/src/thaw/i18n/thaw.properties       2007-07-01 22:50:16 UTC 
(rev 13869)
@@ -371,6 +371,9 @@

 thaw.plugin.index.warningNonNegative=Warning ! Downloading comments without 
having the latest versions of the indexes may result in receiving spams !

+thaw.plugin.index.numberOfFiles=Number of files : ?
+thaw.plugin.index.numberOfLinks=Number of links : ?
+
 # Peer monitor

 thaw.plugin.peerMonitor.peerMonitor=Connection

Modified: trunk/apps/Thaw/src/thaw/i18n/thaw_fr.properties
===================================================================
--- trunk/apps/Thaw/src/thaw/i18n/thaw_fr.properties    2007-07-01 21:42:36 UTC 
(rev 13868)
+++ trunk/apps/Thaw/src/thaw/i18n/thaw_fr.properties    2007-07-01 22:50:16 UTC 
(rev 13869)
@@ -362,6 +362,9 @@

 thaw.plugin.index.warningNonNegative=Attention ! T\u00e9l\u00e9charger les 
commentaires sans avoir la derni\u00e8re version de l'index peut vous faire 
t\u00e9l\u00e9charger des spams !

+thaw.plugin.index.numberOfFiles=Nombre de fichiers : ?
+thaw.plugin.index.numberOfLinks=Nombre de liens : ?
+
 # Peer monitor

 thaw.plugin.peerMonitor.peerMonitor=Connexion

Modified: trunk/apps/Thaw/src/thaw/plugins/index/DetailPanel.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/index/DetailPanel.java     2007-07-01 
21:42:36 UTC (rev 13868)
+++ trunk/apps/Thaw/src/thaw/plugins/index/DetailPanel.java     2007-07-01 
22:50:16 UTC (rev 13869)
@@ -10,6 +10,8 @@
 import java.util.Vector;
 import java.util.Iterator;

+import java.sql.*;
+
 import thaw.core.I18n;
 import thaw.core.Logger;
 import thaw.core.Config;
@@ -27,19 +29,33 @@
  * be used for the comments
  */
 public class DetailPanel {
+       private IndexBrowserPanel indexBrowser;
+
        private JPanel panel;

        private JButton viewCommentButton;

        private Vector buttonActions;

+       private JLabel nmbFilesLabel;
+       private JLabel nmbLinksLabel;

+
        public DetailPanel(FCPQueueManager queueManager, IndexBrowserPanel 
indexBrowser) {
+               this.indexBrowser = indexBrowser;
+
+               nmbFilesLabel = new 
JLabel(I18n.getMessage("thaw.plugin.index.numberOfFiles").replaceAll("\\?", 
""));
+               nmbLinksLabel = new 
JLabel(I18n.getMessage("thaw.plugin.index.numberOfLinks").replaceAll("\\?", 
""));
+
                panel = new JPanel(new BorderLayout());

-               panel.add(new JLabel(""), BorderLayout.CENTER); /* because we 
need something */
+               JPanel stats = new JPanel(new GridLayout(1, 2));
+               stats.add(nmbFilesLabel);
+               stats.add(nmbLinksLabel);

-               JPanel buttonPanel = new JPanel(new GridLayout(1, 2));
+               panel.add(stats, BorderLayout.CENTER);
+
+               JPanel buttonPanel = new JPanel(new GridLayout(1, 1));
                buttonActions = new Vector(2);
                JButton button;

@@ -64,7 +80,8 @@



-       public void setIndexTarget(Index l) {
+       private void setIndexTarget(Index l) {
+
                
viewCommentButton.setText(I18n.getMessage("thaw.plugin.index.comment.comments").replaceAll("\\?",
                                                                                
                           l == null ? "0" : 
Integer.toString(l.getNmbComments())));

@@ -75,5 +92,106 @@
                }
        }

+
+       private void setStats(int nmbFiles, int nmbLinks) {
+               
nmbFilesLabel.setText(I18n.getMessage("thaw.plugin.index.numberOfFiles").replaceAll("\\?",
+                                                                               
                    Integer.toString(nmbFiles)));
+               
nmbLinksLabel.setText(I18n.getMessage("thaw.plugin.index.numberOfLinks").replaceAll("\\?",
+                                                                               
                    Integer.toString(nmbLinks)));
+       }
+
+
+       /* called by IndexBrowserPanel.setList() */
+       public void setTarget(FileAndLinkList node) {
+               if (node instanceof Index)
+                       setIndexTarget((Index)node);
+               else
+                       setIndexTarget(null);
+
+               int nmbFilesInt = 0;
+               int nmbLinksInt = 0;
+
+               if (node != null) {
+                       nmbFilesInt = node.getFileList(null, true).size();
+                       nmbLinksInt = node.getLinkList(null, true).size();
+               }
+
+               setStats(nmbFilesInt, nmbLinksInt);
+       }
+
+
+       /* called by IndexTree.valueChanged() */
+       public void setTarget(IndexTreeNode node) {
+               Hsqldb db = indexBrowser.getDb();
+               PreparedStatement st;
+               ResultSet rs;
+
+               int nmbFilesInt = 0;
+               int nmbLinksInt = 0;
+
+               synchronized(db.dbLock) {
+                       try {
+                               if (node instanceof IndexFolder) {
+                                       if (node instanceof IndexRoot) {
+                                               st = 
db.getConnection().prepareStatement("SELECT count(id) from files");
+                                               rs = st.executeQuery();
+                                               rs.next();
+                                               nmbFilesInt = rs.getInt(1);
+
+                                               st = 
db.getConnection().prepareStatement("SELECT count(id) from links");
+                                               rs = st.executeQuery();
+                                               rs.next();
+                                               nmbLinksInt = rs.getInt(1);
+                                       } else {
+                                               st = 
db.getConnection().prepareStatement("SELECT count(id) "+
+                                                                               
         "FROM files WHERE files.indexParent IN "+
+                                                                               
         "(SELECT indexParents.indexId "+
+                                                                               
         " FROM indexParents "+
+                                                                               
         " WHERE indexParents.folderId = ?)");
+
+
+                                               st.setInt(1, node.getId());
+                                               rs = st.executeQuery();
+                                               rs.next();
+                                               nmbFilesInt = rs.getInt(1);
+
+
+                                               st = 
db.getConnection().prepareStatement("SELECT count(id) "+
+                                                                               
         "FROM links WHERE links.indexParent IN "+
+                                                                               
         "(SELECT indexParents.indexId "+
+                                                                               
         " FROM indexParents "+
+                                                                               
         " WHERE indexParents.folderId = ?)");
+                                               st.setInt(1, node.getId());
+                                               rs = st.executeQuery();
+                                               rs.next();
+                                               nmbLinksInt = rs.getInt(1);
+                                       }
+
+
+                               } else if (node instanceof Index) {
+                                       st = 
db.getConnection().prepareStatement("SELECT count(id) "+
+                                                                               
 "FROM files WHERE files.indexParent = ?");
+                                       st.setInt(1, node.getId());
+                                       rs = st.executeQuery();
+                                       rs.next();
+                                       nmbFilesInt = rs.getInt(1);
+
+
+                                       st = 
db.getConnection().prepareStatement("SELECT count(id) "+
+                                                                               
 "FROM links WHERE links.indexParent = ?");
+                                       st.setInt(1, node.getId());
+                                       rs = st.executeQuery();
+                                       rs.next();
+                                       nmbLinksInt = rs.getInt(1);
+                               }
+
+                       } catch(SQLException e) {
+                               Logger.error(this, "Exception while counting 
files/links : "+e.toString());
+                       }
+               }
+
+               setStats(nmbFilesInt, nmbLinksInt);
+       }
+
 }


Modified: trunk/apps/Thaw/src/thaw/plugins/index/IndexBrowserPanel.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/index/IndexBrowserPanel.java       
2007-07-01 21:42:36 UTC (rev 13868)
+++ trunk/apps/Thaw/src/thaw/plugins/index/IndexBrowserPanel.java       
2007-07-01 22:50:16 UTC (rev 13869)
@@ -169,11 +169,11 @@
        protected void setList(final FileAndLinkList l) {
                tables.setList(l);

+               detailPanel.setTarget(l);
+
                if (l instanceof Index) {
-                       detailPanel.setIndexTarget((Index)l);
                        commentTab.setIndex((Index)l);
                } else {
-                       detailPanel.setIndexTarget(null);
                        commentTab.setIndex(null);
                }
        }

Modified: trunk/apps/Thaw/src/thaw/plugins/index/IndexTree.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/index/IndexTree.java       2007-07-01 
21:42:36 UTC (rev 13868)
+++ trunk/apps/Thaw/src/thaw/plugins/index/IndexTree.java       2007-07-01 
22:50:16 UTC (rev 13869)
@@ -400,6 +400,7 @@

                selectedNode = (IndexTreeNode)(path.getLastPathComponent());

+               indexBrowser.getDetailPanel().setTarget(selectedNode);

                // Update toolbar
                for (final Iterator it = toolbarActions.iterator();


Reply via email to