Author: jflesch
Date: 2007-04-18 20:28:09 +0000 (Wed, 18 Apr 2007)
New Revision: 12797

Modified:
   trunk/apps/Thaw/src/thaw/core/Logger.java
   trunk/apps/Thaw/src/thaw/fcp/FCPClientPut.java
   trunk/apps/Thaw/src/thaw/fcp/FCPQueueLoader.java
   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/Comment.java
   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/IndexManagementHelper.java
   trunk/apps/Thaw/src/thaw/plugins/peerMonitor/PeerHelper.java
Log:
Add comment posting on the indexes (but Thaw still doesn't know how to read 
them)

Modified: trunk/apps/Thaw/src/thaw/core/Logger.java
===================================================================
--- trunk/apps/Thaw/src/thaw/core/Logger.java   2007-04-18 20:15:12 UTC (rev 
12796)
+++ trunk/apps/Thaw/src/thaw/core/Logger.java   2007-04-18 20:28:09 UTC (rev 
12797)
@@ -22,7 +22,7 @@
         * 2 or more is recommanded.
         * 4 or more is unhealthy
         */
-       public final static int LOG_LEVEL = 2;
+       public final static int LOG_LEVEL = 3;

        private static Vector logListeners = null;


Modified: trunk/apps/Thaw/src/thaw/fcp/FCPClientPut.java
===================================================================
--- trunk/apps/Thaw/src/thaw/fcp/FCPClientPut.java      2007-04-18 20:15:12 UTC 
(rev 12796)
+++ trunk/apps/Thaw/src/thaw/fcp/FCPClientPut.java      2007-04-18 20:28:09 UTC 
(rev 12797)
@@ -177,6 +177,8 @@
        public boolean start(final FCPQueueManager queueManager) {
                this.queueManager = queueManager;

+               identifier = null;
+
                if((localFile != null) && (localFile.length() <= 0)) {
                        Logger.warning(this, "Empty or unreachable 
file:"+localFile.getPath());


Modified: trunk/apps/Thaw/src/thaw/fcp/FCPQueueLoader.java
===================================================================
--- trunk/apps/Thaw/src/thaw/fcp/FCPQueueLoader.java    2007-04-18 20:15:12 UTC 
(rev 12796)
+++ trunk/apps/Thaw/src/thaw/fcp/FCPQueueLoader.java    2007-04-18 20:28:09 UTC 
(rev 12797)
@@ -108,11 +108,21 @@
                        if(msg.getValue("Identifier").startsWith(thawId))
                                filePath = msg.getValue("ClientToken");

+                       String fileName = null;
+
+                       if ((fileName = msg.getValue("TargetFilename")) == 
null) {
+                               if 
(msg.getValue("Identifier").startsWith(thawId)) {
+                                       fileName = (new 
java.io.File(filePath)).getName();
+                               } else /* this is not out insertion, and we 
don't have the filename
+                                         so we can't resume it */
+                                  return;
+                       }
+
                        final FCPClientPut clientPut = new 
FCPClientPut(msg.getValue("Identifier"),
                                                                        
msg.getValue("URI"), // key
                                                                        
priority, persistence, global,
                                                                        
filePath,
-                                                                       
msg.getValue("TargetFilename"),
+                                                                       
fileName,
                                                                        
"Inserting", 0, fileSize,
                                                                        
queueManager);


Modified: trunk/apps/Thaw/src/thaw/gui/IconBox.java
===================================================================
--- trunk/apps/Thaw/src/thaw/gui/IconBox.java   2007-04-18 20:15:12 UTC (rev 
12796)
+++ trunk/apps/Thaw/src/thaw/gui/IconBox.java   2007-04-18 20:28:09 UTC (rev 
12797)
@@ -118,6 +118,12 @@
        public static ImageIcon indexSettings;
        public static ImageIcon minIndexSettings;

+       public static ImageIcon addComment;
+       public static ImageIcon minAddComment;
+
+       public static ImageIcon readComments;
+       public static ImageIcon minReadComments;
+
        /**
         * Not really used
         */
@@ -223,6 +229,10 @@
                IconBox.minLink             = 
IconBox.loadIcon("min-indexBrowser.png");
                IconBox.minIndexSettings    = 
IconBox.loadIcon("min-indexSettings.png");
                IconBox.indexSettings       = 
IconBox.loadIcon("indexSettings.png");
+               IconBox.addComment          = 
IconBox.loadIcon("newComment.png");
+               IconBox.minAddComment       = 
IconBox.loadIcon("min-newComment.png");
+               IconBox.readComments        = 
IconBox.loadIcon("readComments.png");
+               IconBox.minReadComments     = 
IconBox.loadIcon("min-readComments.png");
        }

 }

Modified: trunk/apps/Thaw/src/thaw/i18n/source.thaw_fr.properties
===================================================================
--- trunk/apps/Thaw/src/thaw/i18n/source.thaw_fr.properties     2007-04-18 
20:15:12 UTC (rev 12796)
+++ trunk/apps/Thaw/src/thaw/i18n/source.thaw_fr.properties     2007-04-18 
20:28:09 UTC (rev 12797)
@@ -330,6 +330,8 @@

 thaw.plugin.index.comment.comments=Voir les ? commentaires
 thaw.plugin.index.comment.add=Ajouter un commentaire
+thaw.plugin.index.comment.comment=Commentaire
+thaw.plugin.index.comment.author=Auteur




Modified: trunk/apps/Thaw/src/thaw/i18n/thaw.properties
===================================================================
--- trunk/apps/Thaw/src/thaw/i18n/thaw.properties       2007-04-18 20:15:12 UTC 
(rev 12796)
+++ trunk/apps/Thaw/src/thaw/i18n/thaw.properties       2007-04-18 20:28:09 UTC 
(rev 12797)
@@ -324,6 +324,8 @@


 thaw.plugin.index.comment.comments=See the ? comment(s)
+thaw.plugin.index.comment.comment=Comment
+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-18 20:15:12 UTC 
(rev 12796)
+++ trunk/apps/Thaw/src/thaw/i18n/thaw_fr.properties    2007-04-18 20:28:09 UTC 
(rev 12797)
@@ -330,6 +330,8 @@

 thaw.plugin.index.comment.comments=Voir les ? commentaires
 thaw.plugin.index.comment.add=Ajouter un commentaire
+thaw.plugin.index.comment.comment=Commentaire
+thaw.plugin.index.comment.author=Auteur




Modified: trunk/apps/Thaw/src/thaw/plugins/index/Comment.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/index/Comment.java 2007-04-18 20:15:12 UTC 
(rev 12796)
+++ trunk/apps/Thaw/src/thaw/plugins/index/Comment.java 2007-04-18 20:28:09 UTC 
(rev 12797)
@@ -194,10 +194,16 @@
                         return false;

                FCPClientPut put = new FCPClientPut(xmlFile, 2, 0, "comment",
-                                                    
FreenetURIHelper.convertSSKtoUSK(privateKey), 2, false, 0);
+                                                    
FreenetURIHelper.convertSSKtoUSK(privateKey)+"/", /* the convertion fonction 
forget the '/' */
+                                                   2, false, 0);
                 put.addObserver(this);

-               return put.start(queueManager);
+               boolean res = put.start(queueManager);
+
+               if (res)
+                       queueManager.addQueryToTheRunningQueue(put, false);
+
+               return res;
        }


@@ -228,21 +234,34 @@


        public void update(Observable o, Object param) {
-               if (o instanceof FCPClientPut) {
-                       FCPClientPut put = (FCPClientPut)o;
+               if (o instanceof FCPTransferQuery) {

-                       if (put.isFinished() && put.isSuccessful()) {
-                               if (put.stop(queueManager))
-                                       queueManager.remove(put); /* because 
the PersistentPut message sent by the node problably made it added to the 
queueManager */
+                       if (o instanceof FCPClientPut) {
+                               FCPClientPut put = (FCPClientPut)o;
+
+                               if (put.isFinished() && put.isSuccessful()) {
+                                       if (put.stop(queueManager))
+                                               queueManager.remove(put);
+                                       /* because the PersistentPut message 
sent by the node problably made it added to the queueManager  by the 
QueueLoader*/
+                               }
                        }
-               }

-               if (o instanceof FCPClientGet) {
-                       FCPClientGet get = (FCPClientGet)o;
+                       if (o instanceof FCPClientGet) {
+                               FCPClientGet get = (FCPClientGet)o;

-                       if (get.isFinished() && get.isSuccessful()) {
-                               parseComment(new java.io.File(get.getPath()));
+                               if (get.isFinished() && get.isSuccessful()) {
+                                       parseComment(new 
java.io.File(get.getPath()));
+                               }
                        }
+
+                       FCPTransferQuery q = ((FCPTransferQuery)o);
+
+                       if (q.isFinished() && q.isSuccessful()) {
+                               java.io.File file = new 
java.io.File(q.getPath());
+
+                               file.delete();
+                       }
+
                }

                if (o instanceof FCPTransferQuery) {

Modified: trunk/apps/Thaw/src/thaw/plugins/index/DetailPanel.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/index/DetailPanel.java     2007-04-18 
20:15:12 UTC (rev 12796)
+++ trunk/apps/Thaw/src/thaw/plugins/index/DetailPanel.java     2007-04-18 
20:28:09 UTC (rev 12797)
@@ -12,6 +12,7 @@

 import thaw.core.I18n;
 import thaw.core.Logger;
+import thaw.core.Config;

 import thaw.fcp.FCPQueueManager;

@@ -27,7 +28,7 @@
        private Vector buttonActions;


-       public DetailPanel(FCPQueueManager queueManager, IndexBrowserPanel 
indexBrowser) {
+       public DetailPanel(Config config, FCPQueueManager queueManager, 
IndexBrowserPanel indexBrowser) {
                panel = new JPanel(new BorderLayout());

                panel.add(new JLabel(""), BorderLayout.CENTER); /* because we 
need something */
@@ -41,7 +42,7 @@
                buttonPanel.add(button);

                button  = new 
JButton(I18n.getMessage("thaw.plugin.index.comment.add"));
-               buttonActions.add(new 
IndexManagementHelper.IndexCommentAdder(queueManager, indexBrowser, button));
+               buttonActions.add(new 
IndexManagementHelper.IndexCommentAdder(config, queueManager, indexBrowser, 
button));
                buttonPanel.add(button);



Modified: trunk/apps/Thaw/src/thaw/plugins/index/IndexBrowserPanel.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/index/IndexBrowserPanel.java       
2007-04-18 20:15:12 UTC (rev 12796)
+++ trunk/apps/Thaw/src/thaw/plugins/index/IndexBrowserPanel.java       
2007-04-18 20:28:09 UTC (rev 12797)
@@ -58,7 +58,7 @@
                listAndDetails.setLayout(new BorderLayout(10, 10));

                tables = new Tables(false, queueManager, this, config);
-               detailPanel = new DetailPanel(queueManager, this);
+               detailPanel = new DetailPanel(core.getConfig(), queueManager, 
this);

                listAndDetails.add(tables.getPanel(), BorderLayout.CENTER);
                listAndDetails.add(detailPanel.getPanel(), BorderLayout.SOUTH);

Modified: trunk/apps/Thaw/src/thaw/plugins/index/IndexManagementHelper.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/index/IndexManagementHelper.java   
2007-04-18 20:15:12 UTC (rev 12796)
+++ trunk/apps/Thaw/src/thaw/plugins/index/IndexManagementHelper.java   
2007-04-18 20:28:09 UTC (rev 12797)
@@ -34,7 +34,10 @@
 import javax.swing.JTextField;
 import javax.swing.tree.MutableTreeNode;
 import javax.swing.tree.TreeNode;
+import javax.swing.JScrollPane;

+import thaw.gui.IconBox;
+
 import thaw.core.Config;
 import thaw.core.FileChooser;
 import thaw.fcp.FreenetURIHelper;
@@ -1513,13 +1516,25 @@


        public static class IndexCommentAdder extends BasicIndexAction 
implements Runnable, ActionListener {
+               private Config config;

-               public IndexCommentAdder(FCPQueueManager queueManager,
+               private JDialog dialog;
+
+               private JTextField author;
+               private JTextArea textArea;
+               private JButton okButton;
+               private JButton cancelButton;
+
+
+               public IndexCommentAdder(Config config,
+                                        FCPQueueManager queueManager,
                                         IndexBrowserPanel indexBrowser,
                                         final AbstractButton actionSource) {
-
                        super(queueManager, indexBrowser, actionSource);

+                       this.config = config;
+
+
                        if (actionSource != null)
                                actionSource.setEnabled(false);
                }
@@ -1535,14 +1550,84 @@


                private void showDialog() {
-                       
+                       if (dialog != null)
+                               return;
+
+                       String defaultAuthor = config.getValue("userNickname");
+
+                       if (defaultAuthor == null)
+                               defaultAuthor = "User who didn't configure its 
Thaw";
+
+
+                       dialog = new 
JDialog(getIndexBrowserPanel().getMainWindow().getMainFrame(),
+                                            
I18n.getMessage("thaw.plugin.index.comment.add"));
+
+                       JLabel headerLabel = new 
JLabel(I18n.getMessage("thaw.plugin.index.comment.comment"),
+                                                  IconBox.addComment,
+                                                  JLabel.LEFT);
+
+                       JPanel authorPanel = new JPanel(new BorderLayout(5, 5));
+                       authorPanel.add(new 
JLabel(I18n.getMessage("thaw.plugin.index.comment.author")),
+                                       BorderLayout.WEST);
+
+                       author = new JTextField(defaultAuthor);
+                       authorPanel.add(author, BorderLayout.CENTER);
+
+                       JPanel header = new JPanel(new GridLayout(2, 1));
+
+                       header.add(headerLabel);
+                       header.add(authorPanel);
+
+
+                       textArea = new JTextArea("");
+
+                       okButton = new 
JButton(I18n.getMessage("thaw.common.ok"));
+                       cancelButton = new 
JButton(I18n.getMessage("thaw.common.cancel"));
+
+                       okButton.addActionListener(this);
+                       cancelButton.addActionListener(this);
+
+                       JPanel buttonPanel = new JPanel(new GridLayout(1, 2));
+
+                       buttonPanel.add(okButton);
+                       buttonPanel.add(cancelButton);
+
+                       dialog.getContentPane().setLayout(new BorderLayout(5, 
5));
+
+                       dialog.getContentPane().add(header, BorderLayout.NORTH);
+                       dialog.getContentPane().add(new JScrollPane(textArea), 
BorderLayout.CENTER);
+                       dialog.getContentPane().add(buttonPanel, 
BorderLayout.SOUTH);
+
+                       dialog.setSize(700, 300);
+                       dialog.setVisible(true);
                }


                public void actionPerformed(ActionEvent e) {
-                       if (e.getSource() == getActionSource())
+                       boolean closeDialog = false;
+
+                       if (e.getSource() == getActionSource()) {
                                super.actionPerformed(e);
+                       }

+                       if (e.getSource() == okButton) {
+                               if (getTarget() instanceof Index) {
+                                       
((Index)getTarget()).postComment(getQueueManager(),
+                                                                        
author.getText().trim(),
+                                                                        
textArea.getText().trim());
+                               }
+
+                               closeDialog = true;
+                       }
+
+                       if (e.getSource() == cancelButton) {
+                               closeDialog = true;
+                       }
+
+                       if (closeDialog) {
+                               dialog.setVisible(false);
+                               dialog = null;
+                       }
                }



Modified: trunk/apps/Thaw/src/thaw/plugins/peerMonitor/PeerHelper.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/peerMonitor/PeerHelper.java        
2007-04-18 20:15:12 UTC (rev 12796)
+++ trunk/apps/Thaw/src/thaw/plugins/peerMonitor/PeerHelper.java        
2007-04-18 20:28:09 UTC (rev 12797)
@@ -57,7 +57,7 @@
                                dialog = new JDialog(mainWindow.getMainFrame(),
                                                     
I18n.getMessage("thaw.plugin.peerMonitor.addPeer"));

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

                                JPanel centerPanel = new JPanel(new 
BorderLayout());



Reply via email to