Author: jflesch
Date: 2007-04-19 21:56:12 +0000 (Thu, 19 Apr 2007)
New Revision: 12805
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/Comment.java
trunk/apps/Thaw/src/thaw/plugins/index/DetailPanel.java
trunk/apps/Thaw/src/thaw/plugins/index/Index.java
trunk/apps/Thaw/src/thaw/plugins/index/IndexBrowserPanel.java
trunk/apps/Thaw/src/thaw/plugins/index/IndexManagementHelper.java
trunk/apps/Thaw/src/thaw/plugins/index/IndexTree.java
Log:
Thaw can now display the comments
Modified: trunk/apps/Thaw/src/thaw/i18n/source.thaw_fr.properties
===================================================================
--- trunk/apps/Thaw/src/thaw/i18n/source.thaw_fr.properties 2007-04-19
17:36:28 UTC (rev 12804)
+++ trunk/apps/Thaw/src/thaw/i18n/source.thaw_fr.properties 2007-04-19
21:56:12 UTC (rev 12805)
@@ -328,10 +328,12 @@
thaw.plugin.index.stillRev0=N'oubliez pas d'ins?rer cet index sur Freenet
avant de donner la clef ? quelqu'un
-thaw.plugin.index.comment.comments=Voir les ? commentaires
+thaw.plugin.index.comment.comments=Voir les commentaires (?)
+thaw.plugin.index.comment.readComments=Voir les commentaires
thaw.plugin.index.comment.add=Ajouter un commentaire
thaw.plugin.index.comment.comment=Commentaire
thaw.plugin.index.comment.author=Auteur
+thaw.plugin.index.comment.commentList=Commentaires
Modified: trunk/apps/Thaw/src/thaw/i18n/thaw.properties
===================================================================
--- trunk/apps/Thaw/src/thaw/i18n/thaw.properties 2007-04-19 17:36:28 UTC
(rev 12804)
+++ trunk/apps/Thaw/src/thaw/i18n/thaw.properties 2007-04-19 21:56:12 UTC
(rev 12805)
@@ -323,8 +323,10 @@
thaw.plugin.index.stillRev0=Don't forget to insert this index on Freenet
before giving the key to someone
-thaw.plugin.index.comment.comments=See the ? comment(s)
+thaw.plugin.index.comment.comments=See the comments (?)
+thaw.plugin.index.comment.readComments=See the comments
thaw.plugin.index.comment.comment=Comment
+thaw.plugin.index.comment.commentList=Comments
thaw.plugin.index.comment.author=Author
thaw.plugin.index.comment.add=Add a comment
Modified: trunk/apps/Thaw/src/thaw/i18n/thaw_fr.properties
===================================================================
--- trunk/apps/Thaw/src/thaw/i18n/thaw_fr.properties 2007-04-19 17:36:28 UTC
(rev 12804)
+++ trunk/apps/Thaw/src/thaw/i18n/thaw_fr.properties 2007-04-19 21:56:12 UTC
(rev 12805)
@@ -328,10 +328,12 @@
thaw.plugin.index.stillRev0=N'oubliez pas d'ins\u00e9rer cet index sur Freenet
avant de donner la clef \u00e0 quelqu'un
-thaw.plugin.index.comment.comments=Voir les ? commentaires
+thaw.plugin.index.comment.comments=Voir les commentaires (?)
+thaw.plugin.index.comment.readComments=Voir les commentaires
thaw.plugin.index.comment.add=Ajouter un commentaire
thaw.plugin.index.comment.comment=Commentaire
thaw.plugin.index.comment.author=Auteur
+thaw.plugin.index.comment.commentList=Commentaires
Modified: trunk/apps/Thaw/src/thaw/plugins/index/Comment.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/index/Comment.java 2007-04-19 17:36:28 UTC
(rev 12804)
+++ trunk/apps/Thaw/src/thaw/plugins/index/Comment.java 2007-04-19 21:56:12 UTC
(rev 12805)
@@ -15,7 +15,10 @@
import javax.swing.JLabel;
import javax.swing.JTextArea;
import javax.swing.JButton;
+import javax.swing.BorderFactory;
+import javax.swing.JScrollPane;
+import java.awt.GridLayout;
/* DOM */
@@ -61,6 +64,7 @@
import thaw.core.Config;
import thaw.core.Logger;
+import thaw.core.I18n;
import thaw.fcp.FreenetURIHelper;
import thaw.fcp.FCPTransferQuery;
@@ -107,9 +111,19 @@
}
- public JPanel createPanel() {
- JPanel panel = null;
+ public JPanel getPanel() {
+ JPanel panel = new JPanel(new GridLayout(1, 1));
+ JTextArea text = new JTextArea(comment.trim());
+
panel.setBorder(BorderFactory.createTitledBorder(I18n.getMessage("thaw.plugin.index.comment.author")+"
: "+author));
+
+ text.setEditable(false);
+ text.setBackground(panel.getBackground());
+
+ //panel.setPreferredSize(new java.awt.Dimension(600, 150));
+
+ panel.add(text);
+
return panel;
}
@@ -459,7 +473,7 @@
publicKey += "comment-"+Integer.toString(rev)+"/comment.xml";
FCPClientGet get = new FCPClientGet(publicKey, 2 /* priority
*/, 2 /* persistence */,
- false /* global queue */, 3
/* max retries */,
+ false /* global queue */, 5
/* max retries */,
System.getProperty("java.io.tmpdir"),
MAX_SIZE, true /* no DDA
*/);
Modified: trunk/apps/Thaw/src/thaw/plugins/index/DetailPanel.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/index/DetailPanel.java 2007-04-19
17:36:28 UTC (rev 12804)
+++ trunk/apps/Thaw/src/thaw/plugins/index/DetailPanel.java 2007-04-19
21:56:12 UTC (rev 12805)
@@ -27,6 +27,8 @@
public class DetailPanel {
private JPanel panel;
+ private JButton viewCommentButton;
+
private Vector buttonActions;
@@ -39,10 +41,10 @@
buttonActions = new Vector(2);
JButton button;
- button = new
JButton(I18n.getMessage("thaw.plugin.index.comment.comments").replaceAll("\\?",
"0"),
+ viewCommentButton = new
JButton(I18n.getMessage("thaw.plugin.index.comment.comments").replaceAll("\\?",
"0"),
IconBox.minReadComments);
- buttonActions.add(new
IndexManagementHelper.IndexCommentViewer(button));
- buttonPanel.add(button);
+ buttonActions.add(new
IndexManagementHelper.IndexCommentViewer(indexBrowser, viewCommentButton));
+ buttonPanel.add(viewCommentButton);
button = new
JButton(I18n.getMessage("thaw.plugin.index.comment.add"),
IconBox.minAddComment);
@@ -61,6 +63,9 @@
public void setIndexTarget(Index l) {
+
viewCommentButton.setText(I18n.getMessage("thaw.plugin.index.comment.comments").replaceAll("\\?",
+
l == null ? "0" :
Integer.toString(l.getNmbComments())));
+
for (Iterator it = buttonActions.iterator();
it.hasNext();) {
IndexManagementHelper.IndexAction action =
(IndexManagementHelper.IndexAction)it.next();
Modified: trunk/apps/Thaw/src/thaw/plugins/index/Index.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/index/Index.java 2007-04-19 17:36:28 UTC
(rev 12804)
+++ trunk/apps/Thaw/src/thaw/plugins/index/Index.java 2007-04-19 21:56:12 UTC
(rev 12805)
@@ -1843,4 +1843,69 @@
comment.fetchComment(queueManager);
}
}
+
+
+ public Vector getComments() {
+ return getComments(true);
+ }
+
+ public Vector getComments(boolean asc) {
+
+ try {
+ synchronized(db.dbLock) {
+ Vector comments = new Vector();
+
+ PreparedStatement st;
+
+ st =
db.getConnection().prepareStatement("SELECT author, text, rev FROM
indexComments WHERE indexId = ? ORDER BY rev"
+ + (asc
? "" : " DESC"));
+
+ st.setInt(1, id);
+
+ ResultSet set = st.executeQuery();
+
+ while(set.next())
+ comments.add(new Comment(db, this,
+
set.getInt("rev"),
+
set.getString("author"),
+
set.getString("text")));
+
+ if (comments.size() == 0)
+ Logger.notice(this, "No comment for
this index");
+ else
+ Logger.info(this,
Integer.toString(comments.size())+ " comments for this index");
+
+ return comments;
+ }
+ } catch(SQLException e) {
+ Logger.error(this, "Error while fetching comment list :
"+e.toString());
+ }
+
+ return null;
+ }
+
+
+ public int getNmbComments() {
+
+ try {
+ synchronized(db.dbLock) {
+ PreparedStatement st;
+
+ st =
db.getConnection().prepareStatement("SELECT count(id) FROM indexComments WHERE
indexId = ?");
+
+ st.setInt(1, id);
+
+ ResultSet set = st.executeQuery();
+
+ if (set.next())
+ return set.getInt(1);
+
+ return 0;
+ }
+ } catch(SQLException e) {
+ Logger.error(this, "Error while fetching comment list :
"+e.toString());
+ }
+
+ return 0;
+ }
}
Modified: trunk/apps/Thaw/src/thaw/plugins/index/IndexBrowserPanel.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/index/IndexBrowserPanel.java
2007-04-19 17:36:28 UTC (rev 12804)
+++ trunk/apps/Thaw/src/thaw/plugins/index/IndexBrowserPanel.java
2007-04-19 21:56:12 UTC (rev 12805)
@@ -23,6 +23,7 @@
private IndexProgressBar indexProgressBar;
private BlackList blackList;
+ private CommentTab commentTab;
private JSplitPane split;
@@ -50,6 +51,10 @@
indexTree = new
IndexTree(I18n.getMessage("thaw.plugin.index.indexes"),
false, queueManager, this, config);
+ commentTab = new CommentTab(core.getConfig(),
+ core.getQueueManager(),
+ this);
+
leftSplit = new JSplitPane(JSplitPane.VERTICAL_SPLIT,
indexTree.getPanel(),
unknownList.getPanel());
@@ -118,6 +123,10 @@
return detailPanel;
}
+ public CommentTab getCommentTab() {
+ return commentTab;
+ }
+
public IndexProgressBar getIndexProgressBar() {
return indexProgressBar;
}
@@ -156,10 +165,13 @@
protected void setList(final FileAndLinkList l) {
tables.setList(l);
- if (l instanceof Index)
+ if (l instanceof Index) {
detailPanel.setIndexTarget((Index)l);
- else
+ commentTab.setIndex((Index)l);
+ } else {
detailPanel.setIndexTarget(null);
+ commentTab.setIndex(null);
+ }
}
protected void setFileList(final FileList l) {
Modified: trunk/apps/Thaw/src/thaw/plugins/index/IndexManagementHelper.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/index/IndexManagementHelper.java
2007-04-19 17:36:28 UTC (rev 12804)
+++ trunk/apps/Thaw/src/thaw/plugins/index/IndexManagementHelper.java
2007-04-19 21:56:12 UTC (rev 12805)
@@ -1640,8 +1640,8 @@
public static class IndexCommentViewer extends BasicIndexAction
implements Runnable {
- public IndexCommentViewer(final AbstractButton actionSource) {
- super(null, null, actionSource);
+ public IndexCommentViewer(IndexBrowserPanel indexBrowser, final
AbstractButton actionSource) {
+ super(null, indexBrowser, actionSource);
if (actionSource != null)
actionSource.setEnabled(false);
@@ -1657,7 +1657,7 @@
}
public void apply() {
- /* TODO */
+ getIndexBrowserPanel().getCommentTab().showTab();
}
}
}
Modified: trunk/apps/Thaw/src/thaw/plugins/index/IndexTree.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/index/IndexTree.java 2007-04-19
17:36:28 UTC (rev 12804)
+++ trunk/apps/Thaw/src/thaw/plugins/index/IndexTree.java 2007-04-19
21:56:12 UTC (rev 12805)
@@ -64,6 +64,7 @@
private JPopupMenu indexAndFileMenu; /* hem ... and links ... */
private Vector indexAndFileActions; /* hem ... and links ... */ /*
IndexManagementHelper.MenuAction */
+
private JMenu indexMenu;
// download
// insert
@@ -81,6 +82,10 @@
private JMenu linkMenu;
// addALink
+ private JMenu commentMenu;
+ // readComments
+ // postComments
+
private boolean selectionOnly;
private IndexTreeNode selectedNode = null;
@@ -155,6 +160,8 @@
fileMenu.setIcon(IconBox.minFile);
linkMenu = new
JMenu(I18n.getMessage("thaw.plugin.index.links"));
linkMenu.setIcon(IconBox.minLink);
+ commentMenu = new
JMenu(I18n.getMessage("thaw.plugin.index.comment.commentList"));
+ commentMenu.setIcon(IconBox.minReadComments);
// Folder menu
@@ -275,9 +282,23 @@
linkMenu.add(item);
indexAndFileActions.add(new
IndexManagementHelper.LinkAdder(indexBrowser, item));
+
+ // Comment menu
+ item = new
JMenuItem(I18n.getMessage("thaw.plugin.index.comment.readComments"),
+ IconBox.minReadComments);
+ commentMenu.add(item);
+ indexAndFileActions.add(new
IndexManagementHelper.IndexCommentViewer(indexBrowser, item));
+
+ item = new
JMenuItem(I18n.getMessage("thaw.plugin.index.comment.add"),
+ IconBox.minAddComment);
+ commentMenu.add(item);
+ indexAndFileActions.add(new
IndexManagementHelper.IndexCommentAdder(config, queueManager, indexBrowser,
item));
+
+
indexAndFileMenu.add(indexMenu);
indexAndFileMenu.add(fileMenu);
indexAndFileMenu.add(linkMenu);
+ indexAndFileMenu.add(commentMenu);
updateMenuState(null);
@@ -730,7 +751,7 @@
setFont(new Font("Dialog", style, 12));
if (newComment)
- value = o.toString() + "*";
+ value = o.toString() + " *";
}
}