Author: jflesch
Date: 2007-07-03 15:11:30 +0000 (Tue, 03 Jul 2007)
New Revision: 13900
Added:
trunk/apps/Thaw/images/min-details.png
Modified:
trunk/apps/Thaw/src/thaw/gui/IconBox.java
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/IndexManagementHelper.java
Log:
Replace the stats under the file list by a button showing a dialog with these
stats
Added: trunk/apps/Thaw/images/min-details.png
===================================================================
(Binary files differ)
Property changes on: trunk/apps/Thaw/images/min-details.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: trunk/apps/Thaw/src/thaw/gui/IconBox.java
===================================================================
--- trunk/apps/Thaw/src/thaw/gui/IconBox.java 2007-07-03 14:55:25 UTC (rev
13899)
+++ trunk/apps/Thaw/src/thaw/gui/IconBox.java 2007-07-03 15:11:30 UTC (rev
13900)
@@ -132,6 +132,7 @@
public static ImageIcon minOrange;
public static ImageIcon minGreen;
+ public static ImageIcon minDetails;
/**
* Not really used
@@ -247,6 +248,7 @@
IconBox.minRed = IconBox.loadIcon("min-red.png");
IconBox.minOrange =
IconBox.loadIcon("min-orange.png");
IconBox.minGreen = IconBox.loadIcon("min-green.png");
+ IconBox.minDetails =
IconBox.loadIcon("min-details.png");
}
}
Modified: trunk/apps/Thaw/src/thaw/i18n/source.thaw_fr.properties
===================================================================
--- trunk/apps/Thaw/src/thaw/i18n/source.thaw_fr.properties 2007-07-03
14:55:25 UTC (rev 13899)
+++ trunk/apps/Thaw/src/thaw/i18n/source.thaw_fr.properties 2007-07-03
15:11:30 UTC (rev 13900)
@@ -370,10 +370,11 @@
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 : ?
+thaw.plugin.index.details=D?tails
-thaw.plugin.index.insertionDate=Inser? le : ?
+thaw.plugin.index.numberOfFiles=Nombre de fichiers :
+thaw.plugin.index.numberOfLinks=Nombre de liens :
+thaw.plugin.index.insertionDate=Inser? le :
# Peer monitor
Modified: trunk/apps/Thaw/src/thaw/i18n/thaw.properties
===================================================================
--- trunk/apps/Thaw/src/thaw/i18n/thaw.properties 2007-07-03 14:55:25 UTC
(rev 13899)
+++ trunk/apps/Thaw/src/thaw/i18n/thaw.properties 2007-07-03 15:11:30 UTC
(rev 13900)
@@ -380,11 +380,13 @@
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 : ?
-thaw.plugin.index.insertionDate=Inserted : ?
+thaw.plugin.index.details=Details
+thaw.plugin.index.numberOfFiles=Number of files :
+thaw.plugin.index.numberOfLinks=Number of links :
+thaw.plugin.index.insertionDate=Inserted :
+
# 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-03 14:55:25 UTC
(rev 13899)
+++ trunk/apps/Thaw/src/thaw/i18n/thaw_fr.properties 2007-07-03 15:11:30 UTC
(rev 13900)
@@ -370,10 +370,11 @@
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 : ?
+thaw.plugin.index.details=D\u00e9tails
-thaw.plugin.index.insertionDate=Inser\u00e9 le : ?
+thaw.plugin.index.numberOfFiles=Nombre de fichiers :
+thaw.plugin.index.numberOfLinks=Nombre de liens :
+thaw.plugin.index.insertionDate=Inser\u00e9 le :
# Peer monitor
Modified: trunk/apps/Thaw/src/thaw/plugins/index/DetailPanel.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/index/DetailPanel.java 2007-07-03
14:55:25 UTC (rev 13899)
+++ trunk/apps/Thaw/src/thaw/plugins/index/DetailPanel.java 2007-07-03
15:11:30 UTC (rev 13900)
@@ -37,6 +37,7 @@
private JPanel panel;
private JButton viewCommentButton;
+ private JButton detailsButton;
private Vector buttonActions;
@@ -51,34 +52,24 @@
this.dateFormat = DateFormat.getDateInstance();
this.indexBrowser = indexBrowser;
- nmbFilesLabel = new
JLabel(I18n.getMessage("thaw.plugin.index.numberOfFiles").replaceAll("\\?",
""));
- nmbLinksLabel = new
JLabel(I18n.getMessage("thaw.plugin.index.numberOfLinks").replaceAll("\\?",
""));
- insertionDateLabel = new
JLabel(I18n.getMessage("thaw.plugin.index.insertionDate").replaceAll("\\?",
""));
-
panel = new JPanel(new BorderLayout());
- JPanel stats = new JPanel(new GridLayout(1, 3));
- stats.add(nmbFilesLabel);
- stats.add(nmbLinksLabel);
- stats.add(insertionDateLabel);
+ panel.add(new JLabel(""), BorderLayout.CENTER);
- panel.add(stats, BorderLayout.CENTER);
-
JPanel buttonPanel = new JPanel(new GridLayout(1, 1));
buttonActions = new Vector(2);
JButton button;
+ detailsButton = new
JButton(I18n.getMessage("thaw.plugin.index.details"),
+ IconBox.minDetails);
+ buttonActions.add(new
IndexManagementHelper.IndexDetailsViewer(indexBrowser, detailsButton));
+ buttonPanel.add(detailsButton);
+
viewCommentButton = new
JButton(I18n.getMessage("thaw.plugin.index.comment.comments").replaceAll("\\?",
"0"),
- IconBox.minReadComments);
+ IconBox.minReadComments);
buttonActions.add(new
IndexManagementHelper.IndexCommentViewer(indexBrowser, viewCommentButton));
buttonPanel.add(viewCommentButton);
- //button = new
JButton(I18n.getMessage("thaw.plugin.index.comment.add"),
- // IconBox.minAddComment);
- //buttonActions.add(new
IndexManagementHelper.IndexCommentAdder(queueManager, indexBrowser, button));
- //buttonPanel.add(button);
-
-
panel.add(buttonPanel, BorderLayout.EAST);
}
@@ -89,148 +80,31 @@
- private void setIndexTarget(Index l) {
+ public void setTarget(IndexTreeNode l) {
-
viewCommentButton.setText(I18n.getMessage("thaw.plugin.index.comment.comments").replaceAll("\\?",
-
l == null ? "0" :
Integer.toString(l.getNmbComments())));
+ if (l != null && l instanceof Index)
+
viewCommentButton.setText(I18n.getMessage("thaw.plugin.index.comment.comments").replaceAll("\\?",
+
Integer.toString(((Index)l).getNmbComments())));
+ else
+
viewCommentButton.setText(I18n.getMessage("thaw.plugin.index.comment.comments").replaceAll("\\?",
+
"0"));
for (Iterator it = buttonActions.iterator();
it.hasNext();) {
IndexManagementHelper.IndexAction action =
(IndexManagementHelper.IndexAction)it.next();
- action.setTarget((Index)l);
+ action.setTarget(l);
}
}
- 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)));
- }
-
-
- private void setInsertionDate(Index index) {
- if (index == null) {
-
insertionDateLabel.setText(I18n.getMessage("thaw.plugin.index.insertionDate").replaceAll("\\?",
""));
- return;
- }
-
- String dateStr = null;
-
- java.sql.Date dateSql = index.getDate();
-
- if (dateSql != null)
- dateStr = dateFormat.format(dateSql);
-
- if (dateStr != null)
-
insertionDateLabel.setText(I18n.getMessage("thaw.plugin.index.insertionDate").replaceAll("\\?",
dateStr));
- else if (dateSql != null) {
- Logger.warning(this, "There is a date in the db, but
I'm unable to print it");
- }
- }
-
-
/* called by IndexBrowserPanel.setList() */
public void setTarget(FileAndLinkList node) {
if (node instanceof Index) {
- setIndexTarget((Index)node);
- setInsertionDate((Index)node);
+ setTarget((IndexTreeNode)node);
} else {
- setIndexTarget(null);
- setInsertionDate(null);
+ setTarget((IndexTreeNode)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);
-
- }
-
- setInsertionDate(null);
-
-
- } 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);
-
- setInsertionDate((Index)node);
-
- }
-
- } catch(SQLException e) {
- Logger.error(this, "Exception while counting
files/links : "+e.toString());
- }
- }
-
- setStats(nmbFilesInt, nmbLinksInt);
- }
-
}
Modified: trunk/apps/Thaw/src/thaw/plugins/index/IndexManagementHelper.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/index/IndexManagementHelper.java
2007-07-03 14:55:25 UTC (rev 13899)
+++ trunk/apps/Thaw/src/thaw/plugins/index/IndexManagementHelper.java
2007-07-03 15:11:30 UTC (rev 13900)
@@ -39,6 +39,8 @@
import javax.swing.tree.TreeNode;
import javax.swing.JScrollPane;
+import java.text.DateFormat;
+
import thaw.gui.IconBox;
import thaw.core.Config;
@@ -1658,7 +1660,8 @@
super.setTarget(node);
if (getActionSource() != null)
- getActionSource().setEnabled(node instanceof
Index
+ getActionSource().setEnabled(node != null
+ && node instanceof
Index
&&
((Index)node).canHaveComments());
}
@@ -1666,4 +1669,155 @@
getIndexBrowserPanel().getCommentTab().showTab();
}
}
+
+
+ public static class IndexDetailsViewer extends BasicIndexAction
implements Runnable, ActionListener {
+ private DateFormat dateFormat;
+
+ public IndexDetailsViewer(IndexBrowserPanel indexBrowser, final
AbstractButton actionSource) {
+ super(null, indexBrowser, actionSource);
+
+ dateFormat = DateFormat.getDateInstance();
+
+ if (actionSource != null)
+ actionSource.setEnabled(false);
+ }
+
+
+ public void setTarget(final IndexTreeNode node) {
+ super.setTarget(node);
+
+ getActionSource().setEnabled(node != null);
+ }
+
+
+ private JDialog dialog;
+ private JButton closeButton;
+
+ private void displayDialog(MainWindow mainWindow,
+ int nmbFiles,
+ int nmbLinks,
+ java.sql.Date dateSql) {
+
+ String dateStr = null;
+
+ if (dateSql != null)
+ dateStr = dateFormat.format(dateSql);
+
+ if (dateStr == null && dateSql != null)
+ Logger.warning(this, "There is a date in the
db, but I'm unable to print it");
+
+ if (dateStr == null)
+ dateStr = "";
+
+
+ dialog = new JDialog(mainWindow.getMainFrame(),
+
I18n.getMessage("thaw.plugin.index.details"));
+
+ dialog.getContentPane().setLayout(new BorderLayout(5,
5));
+
+ JPanel statPanel = new JPanel(new GridLayout(3, 2));
+
+ statPanel.add(new
JLabel(I18n.getMessage("thaw.plugin.index.numberOfFiles")));
+ statPanel.add(new JLabel(Integer.toString(nmbFiles),
JLabel.RIGHT));
+
+ statPanel.add(new
JLabel(I18n.getMessage("thaw.plugin.index.numberOfLinks")));
+ statPanel.add(new JLabel(Integer.toString(nmbLinks),
JLabel.RIGHT));
+
+ statPanel.add(new
JLabel(I18n.getMessage("thaw.plugin.index.insertionDate")));
+ statPanel.add(new JLabel(dateStr, JLabel.RIGHT));
+
+ dialog.getContentPane().add(statPanel,
BorderLayout.CENTER);
+
+ closeButton = new
JButton(I18n.getMessage("thaw.common.ok"));
+ closeButton.addActionListener(this);
+ dialog.getContentPane().add(closeButton,
BorderLayout.SOUTH);
+
+ dialog.pack();
+
+ dialog.setVisible(true);
+
+ }
+
+ public void actionPerformed(ActionEvent e) {
+ if (e.getSource() == closeButton) {
+ if (dialog != null) {
+ dialog.setVisible(false);
+ dialog = null;
+ }
+ } else {
+ super.actionPerformed(e);
+ }
+ }
+
+
+ public void apply() {
+ IndexTreeNode node = getTarget();
+
+ Hsqldb db = getIndexBrowserPanel().getDb();
+ PreparedStatement st;
+ ResultSet rs;
+
+ int nmbFilesInt = 0;
+ int nmbLinksInt = 0;
+ java.sql.Date insertionDate = null;
+
+ 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);
+
+ }
+
+ insertionDate = null;
+
+
+ } else if (node instanceof Index) {
+ nmbFilesInt =
((Index)node).getFileList(null, true).size();
+ nmbLinksInt =
((Index)node).getLinkList(null, true).size();
+ insertionDate =
((Index)node).getDate();
+
+ }
+
+ } catch(SQLException e) {
+ Logger.error(this, "Exception while
counting files/links : "+e.toString());
+ return;
+ }
+ }
+
+ displayDialog(getIndexBrowserPanel().getMainWindow(),
+ nmbFilesInt, nmbLinksInt, insertionDate);
+ }
+ }
}