Author: jflesch
Date: 2007-08-08 19:02:52 +0000 (Wed, 08 Aug 2007)
New Revision: 14534

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/IndexManagementHelper.java
Log:
In the details of an index or an index folder, display also the total size of 
the files

Modified: trunk/apps/Thaw/src/thaw/i18n/source.thaw_fr.properties
===================================================================
--- trunk/apps/Thaw/src/thaw/i18n/source.thaw_fr.properties     2007-08-08 
19:00:55 UTC (rev 14533)
+++ trunk/apps/Thaw/src/thaw/i18n/source.thaw_fr.properties     2007-08-08 
19:02:52 UTC (rev 14534)
@@ -393,6 +393,7 @@
 thaw.plugin.index.numberOfFiles=Nombre de fichiers :
 thaw.plugin.index.numberOfLinks=Nombre de liens :
 thaw.plugin.index.insertionDate=Inser? le :
+thaw.plugin.index.totalSize=Taille totale des fichiers :

 thaw.plugin.index.newRev=Index 'X' mis ? jour ? la r?vision 'Y'


Modified: trunk/apps/Thaw/src/thaw/i18n/thaw.properties
===================================================================
--- trunk/apps/Thaw/src/thaw/i18n/thaw.properties       2007-08-08 19:00:55 UTC 
(rev 14533)
+++ trunk/apps/Thaw/src/thaw/i18n/thaw.properties       2007-08-08 19:02:52 UTC 
(rev 14534)
@@ -403,6 +403,7 @@
 thaw.plugin.index.numberOfFiles=Number of files :
 thaw.plugin.index.numberOfLinks=Number of links :
 thaw.plugin.index.insertionDate=Inserted :
+thaw.plugin.index.totalSize=Total size of the files :

 thaw.plugin.index.newRev=Index 'X' updated to the revision 'Y'


Modified: trunk/apps/Thaw/src/thaw/i18n/thaw_fr.properties
===================================================================
--- trunk/apps/Thaw/src/thaw/i18n/thaw_fr.properties    2007-08-08 19:00:55 UTC 
(rev 14533)
+++ trunk/apps/Thaw/src/thaw/i18n/thaw_fr.properties    2007-08-08 19:02:52 UTC 
(rev 14534)
@@ -393,6 +393,7 @@
 thaw.plugin.index.numberOfFiles=Nombre de fichiers :
 thaw.plugin.index.numberOfLinks=Nombre de liens :
 thaw.plugin.index.insertionDate=Inser\u00e9 le :
+thaw.plugin.index.totalSize=Taille totale des fichiers :

 thaw.plugin.index.newRev=Index 'X' mis \u00e0 jour \u00e0 la r\u00e9vision 'Y'


Modified: trunk/apps/Thaw/src/thaw/plugins/index/IndexManagementHelper.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/index/IndexManagementHelper.java   
2007-08-08 19:00:55 UTC (rev 14533)
+++ trunk/apps/Thaw/src/thaw/plugins/index/IndexManagementHelper.java   
2007-08-08 19:02:52 UTC (rev 14534)
@@ -1518,7 +1518,8 @@
                private void displayDialog(MainWindow mainWindow,
                                           int nmbFiles,
                                           int nmbLinks,
-                                          java.sql.Date dateSql) {
+                                          java.sql.Date dateSql,
+                                          long totalSize) {

                        String dateStr = null;

@@ -1537,7 +1538,7 @@

                        dialog.getContentPane().setLayout(new BorderLayout(5, 
5));

-                       JPanel statPanel = new JPanel(new GridLayout(3, 2));
+                       JPanel statPanel = new JPanel(new GridLayout(4, 2));

                        statPanel.add(new 
JLabel(I18n.getMessage("thaw.plugin.index.numberOfFiles")));
                        statPanel.add(new JLabel(Integer.toString(nmbFiles), 
JLabel.RIGHT));
@@ -1548,6 +1549,9 @@
                        statPanel.add(new 
JLabel(I18n.getMessage("thaw.plugin.index.insertionDate")));
                        statPanel.add(new JLabel(dateStr, JLabel.RIGHT));

+                       statPanel.add(new 
JLabel(I18n.getMessage("thaw.plugin.index.totalSize")));
+                       statPanel.add(new 
JLabel(thaw.gui.GUIHelper.getPrintableSize(totalSize), JLabel.RIGHT));
+
                        dialog.getContentPane().add(statPanel, 
BorderLayout.CENTER);

                        closeButton = new 
JButton(I18n.getMessage("thaw.common.ok"));
@@ -1581,6 +1585,7 @@

                        int nmbFilesInt = 0;
                        int nmbLinksInt = 0;
+                       long totalSize = 0;
                        java.sql.Date insertionDate = null;

                        synchronized(db.dbLock) {
@@ -1596,6 +1601,11 @@
                                                        rs = st.executeQuery();
                                                        rs.next();
                                                        nmbLinksInt = 
rs.getInt(1);
+
+                                                       st = 
db.getConnection().prepareStatement("SELECT sum(size) from files");
+                                                       rs = st.executeQuery();
+                                                       rs.next();
+                                                       totalSize = 
rs.getLong(1);
                                                } else {
                                                        st = 
db.getConnection().prepareStatement("SELECT count(id) "+
                                                                                
                 "FROM files WHERE files.indexParent IN "+
@@ -1619,16 +1629,36 @@
                                                        rs.next();
                                                        nmbLinksInt = 
rs.getInt(1);

+
+                                                       st = 
db.getConnection().prepareStatement("SELECT sum(files.size) "+
+                                                                               
                 "FROM files WHERE files.indexParent IN "+
+                                                                               
                 "(SELECT indexParents.indexId "+
+                                                                               
                 " FROM indexParents "+
+                                                                               
                 " WHERE indexParents.folderId = ?)");
+
+                                                       st.setInt(1, 
node.getId());
+                                                       rs = st.executeQuery();
+                                                       rs.next();
+                                                       totalSize = 
rs.getLong(1);
+
                                                }

                                                insertionDate = null;


                                        } else if (node instanceof Index) {
-                                               nmbFilesInt = 
((Index)node).getFileList(null, true).size();
+                                               Vector files = 
((Index)node).getFileList(null, true);
+
+                                               nmbFilesInt = files.size();
                                                nmbLinksInt = 
((Index)node).getLinkList(null, true).size();
                                                insertionDate = 
((Index)node).getDate();

+                                               totalSize = 0;
+
+                                               for (Iterator it = 
files.iterator();
+                                                    it.hasNext();) {
+                                                       totalSize += 
((thaw.plugins.index.File)it.next()).getSize();
+                                               }
                                        }

                                } catch(SQLException e) {
@@ -1638,7 +1668,7 @@
                        }

                        displayDialog(getIndexBrowserPanel().getMainWindow(),
-                                     nmbFilesInt, nmbLinksInt, insertionDate);
+                                     nmbFilesInt, nmbLinksInt, insertionDate, 
totalSize);
                }
        }



Reply via email to