Author: jflesch
Date: 2006-12-28 22:23:00 +0000 (Thu, 28 Dec 2006)
New Revision: 11523

Added:
   trunk/apps/Thaw/images/min-v_green.png
   trunk/apps/Thaw/images/min-x_red.png
   trunk/apps/Thaw/images/v_green.png
   trunk/apps/Thaw/images/x_red.png
Modified:
   trunk/apps/Thaw/images/folder-new.png
   trunk/apps/Thaw/readme.txt
   trunk/apps/Thaw/src/thaw/core/Core.java
   trunk/apps/Thaw/src/thaw/core/IconBox.java
   trunk/apps/Thaw/src/thaw/core/MainWindow.java
   trunk/apps/Thaw/src/thaw/fcp/FCPClientGet.java
   trunk/apps/Thaw/src/thaw/i18n/thaw.properties
   trunk/apps/Thaw/src/thaw/i18n/thaw_fr.properties
   trunk/apps/Thaw/src/thaw/plugins/IndexBrowser.java
   trunk/apps/Thaw/src/thaw/plugins/ToolbarModifier.java
   trunk/apps/Thaw/src/thaw/plugins/index/File.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
   trunk/apps/Thaw/src/thaw/plugins/queueWatcher/QueuePanel.java
Log:
Add icons to the index toolbar + change the behavior when clicking on 'remove 
all finished transfers'

Modified: trunk/apps/Thaw/images/folder-new.png
===================================================================
(Binary files differ)

Added: trunk/apps/Thaw/images/min-v_green.png
===================================================================
(Binary files differ)


Property changes on: trunk/apps/Thaw/images/min-v_green.png
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: trunk/apps/Thaw/images/min-x_red.png
===================================================================
(Binary files differ)


Property changes on: trunk/apps/Thaw/images/min-x_red.png
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: trunk/apps/Thaw/images/v_green.png
===================================================================
(Binary files differ)


Property changes on: trunk/apps/Thaw/images/v_green.png
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: trunk/apps/Thaw/images/x_red.png
===================================================================
(Binary files differ)


Property changes on: trunk/apps/Thaw/images/x_red.png
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Modified: trunk/apps/Thaw/readme.txt
===================================================================
--- trunk/apps/Thaw/readme.txt  2006-12-27 22:59:05 UTC (rev 11522)
+++ trunk/apps/Thaw/readme.txt  2006-12-28 22:23:00 UTC (rev 11523)
@@ -27,16 +27,12 @@
 COMPILATION
 ===========

-<!-- forget what follow, Hsqldb is not required for the moment -->
-<!-- it will be when I will start to deal with indexes -->
-<!--
 In order to compile Thaw, you need to obtain the latest version of hsqldb.jar.

 Here is a link to the current (06/11/2006) version of hsqldb:
 http://switch.dl.sourceforge.net/sourceforge/hsqldb/hsqldb_1_8_0_4.zip

 Extract the zip, and copy "hsqldb/lib/hsqldb.jar" to "Thaw/lib".
--->


 To compile:
@@ -52,12 +48,12 @@
 RUNNING
 =======

-On Unix / Linux / etc:
+With Unix / Linux / etc:
 $ cd lib ; java -jar Thaw.jar
 or
 $ ant run


-On Windows:
+With Windows:
 err ... we will see that later ...


Modified: trunk/apps/Thaw/src/thaw/core/Core.java
===================================================================
--- trunk/apps/Thaw/src/thaw/core/Core.java     2006-12-27 22:59:05 UTC (rev 
11522)
+++ trunk/apps/Thaw/src/thaw/core/Core.java     2006-12-28 22:23:00 UTC (rev 
11523)
@@ -465,13 +465,13 @@
                        if(nmbReconnect == Core.MAX_CONNECT_TRIES) {
                                while(!initNodeConnection()) {
                                        final int ret = 
JOptionPane.showOptionDialog((java.awt.Component)null,
-                                                                              
I18n.getMessage("thaw.warning.disconnected"),
-                                                                              
"Thaw - "+I18n.getMessage("thaw.warning.title"),
-                                                                              
JOptionPane.YES_NO_OPTION,
-                                                                              
JOptionPane.WARNING_MESSAGE,
-                                                                              
(javax.swing.Icon)null,
-                                                                              
(java.lang.Object[])null,
-                                                                              
(java.lang.Object)null);
+                                                                               
     I18n.getMessage("thaw.warning.disconnected"),
+                                                                               
     "Thaw - "+I18n.getMessage("thaw.warning.title"),
+                                                                               
     JOptionPane.YES_NO_OPTION,
+                                                                               
     JOptionPane.WARNING_MESSAGE,
+                                                                               
     (javax.swing.Icon)null,
+                                                                               
     (java.lang.Object[])null,
+                                                                               
     (java.lang.Object)null);
                                if((ret == JOptionPane.CLOSED_OPTION)
                                   || (ret == JOptionPane.CANCEL_OPTION)
                                   || (ret == JOptionPane.NO_OPTION))

Modified: trunk/apps/Thaw/src/thaw/core/IconBox.java
===================================================================
--- trunk/apps/Thaw/src/thaw/core/IconBox.java  2006-12-27 22:59:05 UTC (rev 
11522)
+++ trunk/apps/Thaw/src/thaw/core/IconBox.java  2006-12-28 22:23:00 UTC (rev 
11523)
@@ -45,6 +45,11 @@
        public static ImageIcon indexNew;
        public static ImageIcon indexReuse;

+       public static ImageIcon indexDelete;
+
+       public static ImageIcon error;
+       public static ImageIcon ok;
+
        public static ImageIcon refreshAction;

        public static ImageIcon clearAction;
@@ -130,6 +135,9 @@
                IconBox.minQuitAction = 
IconBox.loadIcon("min-system-log-out.png");
                IconBox.search = IconBox.loadIcon("system-search.png");
                IconBox.key = IconBox.loadIcon("key.png");
+               IconBox.indexDelete = IconBox.loadIcon("x_red.png");
+               IconBox.error = IconBox.loadIcon("min-x_red.png");
+               IconBox.ok = IconBox.loadIcon("min-v_green.png");
        }

 }

Modified: trunk/apps/Thaw/src/thaw/core/MainWindow.java
===================================================================
--- trunk/apps/Thaw/src/thaw/core/MainWindow.java       2006-12-27 22:59:05 UTC 
(rev 11522)
+++ trunk/apps/Thaw/src/thaw/core/MainWindow.java       2006-12-28 22:23:00 UTC 
(rev 11523)
@@ -194,13 +194,17 @@
                return tabbedPane;
        }

+       public Object getLastToolbarModifier() {
+               return lastToolBarModifier;
+       }
+
        /**
         * @param modifier Correspond to the caller object: it's a security to 
avoid that a modifier wipe out the buttons from another one
         */
        public void changeButtonsInTheToolbar(final Object modifier, final 
Vector newButtons) {
                JToolBar newToolBar;

-               Logger.debug(this, "changeButtonsInTheToolbar() : Called by 
"+modifier.getClass().getName());
+               Logger.info(this, "changeButtonsInTheToolbar() : Called by 
"+modifier.getClass().getName());

                if ((lastToolBarModifier == null) || (newButtons != null) || 
(lastToolBarModifier == modifier)) {
                        lastToolBarModifier = modifier;
@@ -208,6 +212,9 @@
                        /* Only the modifer who added the buttons can remove 
them */
                        return;

+               if (newButtons == null)
+                       lastToolBarModifier = null;
+
                newToolBar = new 
JToolBar(I18n.getMessage("thaw.toolbar.title"));

                newToolBar.add(connectButton);

Modified: trunk/apps/Thaw/src/thaw/fcp/FCPClientGet.java
===================================================================
--- trunk/apps/Thaw/src/thaw/fcp/FCPClientGet.java      2006-12-27 22:59:05 UTC 
(rev 11522)
+++ trunk/apps/Thaw/src/thaw/fcp/FCPClientGet.java      2006-12-28 22:23:00 UTC 
(rev 11523)
@@ -9,10 +9,6 @@

 import thaw.core.Logger;

-/**
- * notify() only when progress has really changes.
- * TODO: Use streams instead of writing directly the file.
- */
 public class FCPClientGet extends Observable implements Observer, 
FCPTransferQuery {
        private int maxRetries = -1;
        private final static int PACKET_SIZE = 1024;
@@ -41,6 +37,7 @@

        private boolean running = false;
        private boolean successful = true;
+       private boolean writingSuccessful = false;
        private boolean fatal = true;
        private boolean isLockOwner = false;

@@ -170,7 +167,7 @@
                if((identifier == null) || "".equals( identifier ))
                        identifier = queueManager.getAnID() + "-"+filename;;

-               Logger.info(this, "Requesting key : "+getFileKey());
+               Logger.debug(this, "Requesting key : "+getFileKey());

                final FCPMessage queryMessage = new FCPMessage();

@@ -247,8 +244,9 @@
                                                                status = 
"Requesting file from the node";
                                                                progress = 99;
                                                                running = true;
-                                                               successful = 
false;
-                                                               
this.saveFileTo(destinationDir, false);
+                                                               successful = 
true;
+                                                               
writingSuccessful = false;
+                                                               
saveFileTo(destinationDir, false);
                                                        } else {
                                                                status = 
"Available";
                                                                progress = 100;
@@ -413,13 +411,14 @@
                        setChanged();
                        this.notifyObservers();

+                       successful = true;

                        if(fetchDirectly(queryManager.getConnection(), 
fileSize, true)) {
-                               successful = true;
+                               writingSuccessful = false;
                                status = "Available";
                        } else {
                                Logger.warning(this, "Unable to fetch correctly 
the file. This may create problems on socket");
-                               successful = false;
+                               writingSuccessful = false;
                                status = "Error while receveing the file";
                        }

@@ -484,7 +483,7 @@
        }

        public boolean saveFileTo(final String dir) {
-               return this.saveFileTo(dir, true);
+               return saveFileTo(dir, true);
        }

        public synchronized boolean saveFileTo(final String dir, final boolean 
checkStatus) {
@@ -605,7 +604,7 @@
                final long origSize = size;
                long startTime = System.currentTimeMillis();

-               boolean writingSuccessful = true;
+               writingSuccessful = true;

                while(size > 0) {

@@ -623,7 +622,6 @@
                        if(amount <= -1) {
                                Logger.error(this, "Socket closed, damn !");
                                status = "Read error";
-                               successful = false;
                                writingSuccessful = false;
                                break;
                        }
@@ -633,9 +631,8 @@
                                        outputStream.write(read, 0, amount);
                                } catch(final java.io.IOException e) {
                                        Logger.error(this, "Unable to write 
file on disk ... out of space ? : "+e.toString());
-                                       status = "Write error";
+                                       status = "Unable to fetch / disk 
probably full !";
                                        writingSuccessful = false;
-                                       successful = false;
                                        return false;
                                }
                        }
@@ -846,6 +843,10 @@
                return successful;
        }

+       public boolean isWritingSuccessful() {
+               return writingSuccessful;
+       }
+
        public boolean isFatallyFailed() {
                return ((!successful) && fatal);
        }

Modified: trunk/apps/Thaw/src/thaw/i18n/thaw.properties
===================================================================
--- trunk/apps/Thaw/src/thaw/i18n/thaw.properties       2006-12-27 22:59:05 UTC 
(rev 11522)
+++ trunk/apps/Thaw/src/thaw/i18n/thaw.properties       2006-12-28 22:23:00 UTC 
(rev 11523)
@@ -212,8 +212,8 @@

 thaw.plugin.index.addIndex=Add a file index
 thaw.plugin.index.addIndexesFromLink=Add these indexes to your list
-thaw.plugin.index.createIndex=Create a file index
-thaw.plugin.index.addCategory=Add a folder
+thaw.plugin.index.createIndex=Create a new file index
+thaw.plugin.index.addCategory=Create a folder
 thaw.plugin.index.rename=Rename
 thaw.plugin.index.delete=Delete
 thaw.plugin.index.insertIndex=[Re]insert this index on Freenet

Modified: trunk/apps/Thaw/src/thaw/i18n/thaw_fr.properties
===================================================================
--- trunk/apps/Thaw/src/thaw/i18n/thaw_fr.properties    2006-12-27 22:59:05 UTC 
(rev 11522)
+++ trunk/apps/Thaw/src/thaw/i18n/thaw_fr.properties    2006-12-28 22:23:00 UTC 
(rev 11523)
@@ -194,7 +194,7 @@
 thaw.plugin.index.indexes=Indexes

 thaw.plugin.index.addIndex=Ajouter un index de fichiers
-thaw.plugin.index.createIndex=Cr?er un index de fichiers
+thaw.plugin.index.createIndex=Cr?er un nouvel index de fichiers
 thaw.plugin.index.addCategory=Ajouter un r?pertoire
 thaw.plugin.index.rename=Renommer
 thaw.plugin.index.delete=Effacer

Modified: trunk/apps/Thaw/src/thaw/plugins/IndexBrowser.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/IndexBrowser.java  2006-12-27 22:59:05 UTC 
(rev 11522)
+++ trunk/apps/Thaw/src/thaw/plugins/IndexBrowser.java  2006-12-28 22:23:00 UTC 
(rev 11523)
@@ -20,7 +20,7 @@
 import thaw.plugins.index.IndexTreeNode;
 import thaw.plugins.index.DatabaseManager;

-public class IndexBrowser extends ToolbarModifier implements Plugin, 
ChangeListener, java.util.Observer {
+public class IndexBrowser extends ToolbarModifier implements Plugin, 
ChangeListener {

        public static final String DEFAULT_INDEX = "USK at 
G-ofLp2KlhHBNPezx~GDWDKThJ-QUxJK8c2xiF~-jwE,-55vLnqo3U1H5qmKA1LLADoYGQdk-Y3hSLxyKeUyHNc,AQABAAE/Thaw/2/Thaw.xml";

@@ -62,8 +62,6 @@
                }

                browserPanel = new IndexBrowserPanel(hsqldb, 
core.getQueueManager(), core.getConfig(), core.getMainWindow());
-               browserPanel.getIndexTree().addObserver(this);
-
                setMainWindow(core.getMainWindow());
                core.getMainWindow().getTabbedPane().addChangeListener(this);

@@ -73,44 +71,17 @@

                browserPanel.restoreState();

-               JButton button;
-               toolbarActions = new Vector();
-               IndexManagementHelper.IndexAction action;
-
-               button = new JButton(IconBox.refreshAction);
-               
button.setToolTipText(I18n.getMessage("thaw.plugin.index.downloadIndexes"));
-               action = new IndexManagementHelper.IndexDownloader(button);
-               action.setTarget(browserPanel.getIndexTree().getRoot());
-               addButtonToTheToolbar(button);
-               toolbarActions.add(action);
-
-               button = new JButton(IconBox.indexReuse);
-               
button.setToolTipText(I18n.getMessage("thaw.plugin.index.addAlreadyExistingIndex"));
-               action = new 
IndexManagementHelper.IndexReuser(core.getQueueManager(), browserPanel, button);
-               action.setTarget(browserPanel.getIndexTree().getRoot());
-               addButtonToTheToolbar(button);
-               toolbarActions.add(action);
-
-               button = new JButton(IconBox.indexNew);
-               
button.setToolTipText(I18n.getMessage("thaw.plugin.index.createIndex"));
-               action = new 
IndexManagementHelper.IndexCreator(core.getQueueManager(), browserPanel, 
button);
-               action.setTarget(browserPanel.getIndexTree().getRoot());
-               addButtonToTheToolbar(button);
-               toolbarActions.add(action);
-
                if (newDb) {
                        IndexManagementHelper.addIndex(core.getQueueManager(), 
browserPanel, null, IndexBrowser.DEFAULT_INDEX);
                }

                stateChanged(null);

-
                return true;
        }

        public boolean stop() {
                core.getMainWindow().getTabbedPane().removeChangeListener(this);
-               purgeButtonList();

                if (browserPanel != null) {
                        core.getMainWindow().removeTab(browserPanel.getPanel());
@@ -141,23 +112,7 @@
                        return;
                }

-               if (core.getMainWindow().getTabbedPane().getSelectedIndex() == 
tabId) {
-                       displayButtonsInTheToolbar();
-               } else {
-                       hideButtonsInTheToolbar();
-               }
+               
browserPanel.isVisible(core.getMainWindow().getTabbedPane().getSelectedIndex() 
== tabId);
        }

-       public void update (final java.util.Observable o, final Object arg) {
-               if ((o == browserPanel.getIndexTree())
-                   && (arg instanceof IndexTreeNode)) {
-
-                       for (final Iterator it = toolbarActions.iterator();
-                            it.hasNext(); ) {
-                               final IndexManagementHelper.IndexAction action 
= (IndexManagementHelper.IndexAction)it.next();
-                               action.setTarget((IndexTreeNode)arg);
-                       }
-
-               }
-       }
 }

Modified: trunk/apps/Thaw/src/thaw/plugins/ToolbarModifier.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/ToolbarModifier.java       2006-12-27 
22:59:05 UTC (rev 11522)
+++ trunk/apps/Thaw/src/thaw/plugins/ToolbarModifier.java       2006-12-28 
22:23:00 UTC (rev 11523)
@@ -35,24 +35,34 @@
        public void addButtonToTheToolbar(final JButton button) {
                buttons.add(button);

-               if (areDisplayed)
+               if (areDisplayed) {
+                       areDisplayed = false;
                        displayButtonsInTheToolbar();
+               }
        }

        public void removeButtonFromTheToolbar(final JButton button) {
                buttons.remove(button);

-               if (areDisplayed)
+               if (areDisplayed) {
+                       areDisplayed = false;
                        displayButtonsInTheToolbar();
+               }
        }

        public void displayButtonsInTheToolbar() {
                if (mainWindow != null) {
-                       if (buttons.size() == 0) {
-                               Logger.notice(this, "No button to display ?");
+                       if (areDisplayed && mainWindow.getLastToolbarModifier() 
== this) {
+                               Logger.warning(this, "Already displayed !");
+                               return;
                        }

-                       mainWindow.changeButtonsInTheToolbar(this, buttons);
+                       if (buttons == null || buttons.size() == 0) {
+                               Logger.notice(this, "No button to display ?");
+                               mainWindow.changeButtonsInTheToolbar(this, 
null);
+                       } else
+                               mainWindow.changeButtonsInTheToolbar(this, 
buttons);
+
                        areDisplayed = true;
                } else
                        Logger.error(this, "MainWindow not SET !");

Modified: trunk/apps/Thaw/src/thaw/plugins/index/File.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/index/File.java    2006-12-27 22:59:05 UTC 
(rev 11522)
+++ trunk/apps/Thaw/src/thaw/plugins/index/File.java    2006-12-28 22:23:00 UTC 
(rev 11523)
@@ -179,6 +179,13 @@
        public void setPublicKey(final String publicKey) {
                this.publicKey = publicKey;

+               if (publicKey != null && !publicKey.equals(this.publicKey)) {
+                       this.publicKey = publicKey;
+                       update();
+               }
+               else
+                       this.publicKey = publicKey;
+
                setChanged();
                this.notifyObservers();
        }

Modified: trunk/apps/Thaw/src/thaw/plugins/index/Index.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/index/Index.java   2006-12-27 22:59:05 UTC 
(rev 11522)
+++ trunk/apps/Thaw/src/thaw/plugins/index/Index.java   2006-12-28 22:23:00 UTC 
(rev 11523)
@@ -225,6 +225,9 @@
                } catch(final SQLException e) {
                        Logger.error(this, "Unable to delete the index 
'"+displayName+"', because: "+e.toString());
                }
+
+               if (transfer != null)
+                       transfer.stop(queueManager);
        }



Modified: trunk/apps/Thaw/src/thaw/plugins/index/IndexBrowserPanel.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/index/IndexBrowserPanel.java       
2006-12-27 22:59:05 UTC (rev 11522)
+++ trunk/apps/Thaw/src/thaw/plugins/index/IndexBrowserPanel.java       
2006-12-28 22:23:00 UTC (rev 11523)
@@ -16,7 +16,7 @@
 import thaw.plugins.Hsqldb;


-public class IndexBrowserPanel implements 
javax.swing.event.TreeSelectionListener, ActionListener {
+public class IndexBrowserPanel implements 
javax.swing.event.TreeSelectionListener {
        private IndexTree indexTree;
        private Tables tables;
        private DetailPanel detailPanel;
@@ -183,7 +183,13 @@
        }


-       public void actionPerformed(final ActionEvent e) {
+       /**
+        * Called by IndexBrowser when the panel become visible
+        */
+       public void isVisible(boolean visibility) {
+               if (visibility) {
+                       
indexTree.getToolbarModifier().displayButtonsInTheToolbar();
+               }
+       }

-       }
 }

Modified: trunk/apps/Thaw/src/thaw/plugins/index/IndexManagementHelper.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/index/IndexManagementHelper.java   
2006-12-27 22:59:05 UTC (rev 11522)
+++ trunk/apps/Thaw/src/thaw/plugins/index/IndexManagementHelper.java   
2006-12-28 22:23:00 UTC (rev 11523)
@@ -59,7 +59,7 @@
        }


-       public static abstract class BasicIndexAction implements IndexAction {
+       public static abstract class BasicIndexAction implements IndexAction, 
Runnable {
                private FCPQueueManager queueManager;
                private AbstractButton actionSource;
                private IndexTreeNode target;
@@ -95,7 +95,19 @@
                        return indexBrowser;
                }

-               public abstract void actionPerformed(ActionEvent e);
+
+               public void actionPerformed(ActionEvent e) {
+                       if (e.getSource() == actionSource) {
+                               Thread th = new Thread(this);
+                               th.start();
+                       }
+               }
+
+               public void run() {
+                       apply();
+               }
+
+               public abstract void apply();
        }


@@ -110,7 +122,7 @@
                        getActionSource().setEnabled((node == null) || (node 
instanceof IndexCategory));
                }

-               public void actionPerformed(final ActionEvent e) {
+               public void apply() {
                        final String name = 
IndexManagementHelper.askAName(getIndexBrowserPanel().getMainWindow().getMainFrame(),
                                                                           
I18n.getMessage("thaw.plugin.index.indexName"),
                                                                           
I18n.getMessage("thaw.plugin.index.newIndex"));
@@ -307,7 +319,7 @@
                        getActionSource().setEnabled((node != null) || (node 
instanceof Index));
                }

-               public void run() {
+               public void apply() {
                        final Index index = ((Index)getTarget());

                        final String[] keys = KeyAsker.askKeys(true, 
index.getPublicKey(), index.getPrivateKey(), getIndexBrowserPanel());
@@ -318,13 +330,6 @@
                        index.setPrivateKey(keys[1]);
                        index.setPublicKey(keys[0]);
                }
-
-               public void actionPerformed(final ActionEvent e) {
-                       if (e.getSource() == getActionSource()) {
-                               final Thread th = new Thread(this);
-                               th.start();
-                       }
-               }
        }


@@ -338,7 +343,7 @@
                        getActionSource().setEnabled((node == null) || (node 
instanceof IndexCategory));
                }

-               public void run() {
+               public void apply() {
                        String keys[];
                        String publicKey = null;
                        String privateKey = null;
@@ -353,13 +358,6 @@

                        IndexManagementHelper.reuseIndex(getQueueManager(), 
getIndexBrowserPanel(), (IndexCategory)getTarget(), publicKey, privateKey);
                }
-
-               public void actionPerformed(final ActionEvent e) {
-                       if (e.getSource() == getActionSource()) {
-                               final Thread newThread = new Thread(this);
-                               newThread.start();
-                       }
-               }
        }


@@ -414,7 +412,7 @@
                        getActionSource().setEnabled((node == null) || (node 
instanceof IndexCategory));
                }

-               public void actionPerformed(final ActionEvent e) {
+               public void apply() {
                        final String name = 
IndexManagementHelper.askAName(getIndexBrowserPanel().getMainWindow().getMainFrame(),
                                                                           
I18n.getMessage("thaw.plugin.index.categoryName"),
                                                                           
I18n.getMessage("thaw.plugin.index.newCategory"));
@@ -445,12 +443,7 @@
                        super.setTarget(node);
                }

-               public void actionPerformed(final ActionEvent e) {
-                       final Thread newTh = new Thread(this);
-                       newTh.run();
-               }
-
-               public void run() {
+               public void apply() {
                        if (getTarget() != null)
                                getTarget().updateFromFreenet(-1);
                        else
@@ -468,12 +461,7 @@
                        getActionSource().setEnabled((node != null) && 
node.isModifiable());
                }

-               public void actionPerformed(final ActionEvent e) {
-                       final Thread newTh = new Thread(this);
-                       newTh.run();
-               }
-
-               public void run() {
+               public void apply() {
                        if (getTarget() != null)
                                getTarget().update();
                }
@@ -490,7 +478,7 @@
                        getActionSource().setEnabled(node != null);
                }

-               public void actionPerformed(final ActionEvent e) {
+               public void apply() {
                        IndexManagementHelper.copyPublicKeyFrom(getTarget());
                }
        }
@@ -517,7 +505,7 @@
                        getActionSource().setEnabled((node != null) && (node 
instanceof Index) && node.isModifiable());
                }

-               public void actionPerformed(final ActionEvent e) {
+               public void apply() {
                        IndexManagementHelper.copyPrivateKeyFrom(getTarget());
                }
        }
@@ -546,7 +534,7 @@
                        getActionSource().setEnabled(node != null);
                }

-               public void actionPerformed(final ActionEvent e) {
+               public void apply() {
                        String newName;

                        if (getTarget() instanceof Index) {
@@ -588,7 +576,7 @@
                        getActionSource().setEnabled((node != null) && (node 
instanceof Index));
                }

-               public void actionPerformed(final ActionEvent e) {
+               public void apply() {
                        java.io.File newFile;

                        final FileChooser fileChooser = new FileChooser();
@@ -624,7 +612,7 @@
                        getActionSource().setEnabled((node != null) && (node 
instanceof Index));
                }

-               public void actionPerformed(final ActionEvent e) {
+               public void apply() {
                        java.io.File newFile;

                        final FileChooser fileChooser = new FileChooser();
@@ -652,10 +640,12 @@

                public void setTarget(final IndexTreeNode node) {
                        super.setTarget(node);
-                       getActionSource().setEnabled(node != null);
+                       getActionSource().setEnabled(node != null
+                                                    && 
(getIndexBrowserPanel().getIndexTree() != null
+                                                        && node != 
getIndexBrowserPanel().getIndexTree().getRoot()));
                }

-               public void actionPerformed(final ActionEvent e) {
+               public void apply() {
                        
IndexManagementHelper.deleteNode(getIndexBrowserPanel(), getTarget());
                }
        }
@@ -691,7 +681,7 @@
                        getActionSource().setEnabled((node != null) && (node 
instanceof Index) && ((Index)node).isModifiable());
                }

-               public void actionPerformed(final ActionEvent e) {
+               public void apply() {
                        final FileChooser fileChooser = new FileChooser();

                        fileChooser.setDirectoryOnly(false);
@@ -720,7 +710,7 @@
                        getActionSource().setEnabled((node != null) && (node 
instanceof Index) && ((Index)node).isModifiable());
                }

-               public void actionPerformed(final ActionEvent e) {
+               public void apply() {
                        final FileChooser fileChooser = new FileChooser();

                        fileChooser.setDirectoryOnly(false);
@@ -796,7 +786,7 @@
                        getActionSource().setEnabled((node != null) && (node 
instanceof Index) && ((Index)node).isModifiable());
                }

-               public void run() {
+               public void apply() {
                        JLabel header = null;
                        JPanel buttonPanel = null;

@@ -834,11 +824,6 @@
                }

                public void actionPerformed(final ActionEvent e) {
-                       if (e.getSource() == getActionSource()) {
-                               final Thread newThread = new Thread(this);
-                               newThread.start();
-                       }
-
                        if (e.getSource() == okButton) {
                                final Vector keyVec = new Vector();

@@ -913,7 +898,7 @@
                        getActionSource().setEnabled((node != null) && (node 
instanceof Index) && ((Index)node).isModifiable());
                }

-               public void run() {
+               public void apply() {
                        final IndexSelecter indexSelecter = new 
IndexSelecter(getIndexBrowserPanel());
                        final String indexKey = 
indexSelecter.askForAnIndexURI(getIndexBrowserPanel().getDb());

@@ -921,11 +906,6 @@
                                
IndexManagementHelper.addLink(getIndexBrowserPanel(), (Index)getTarget(), 
indexKey);
                        }
                }
-
-               public void actionPerformed(final ActionEvent e) {
-                       final Thread newThread = new Thread(this);
-                       newThread.start();
-               }
        }

        /**

Modified: trunk/apps/Thaw/src/thaw/plugins/index/IndexTree.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/index/IndexTree.java       2006-12-27 
22:59:05 UTC (rev 11522)
+++ trunk/apps/Thaw/src/thaw/plugins/index/IndexTree.java       2006-12-28 
22:23:00 UTC (rev 11523)
@@ -33,6 +33,7 @@
 import thaw.fcp.FCPQueueManager;
 import thaw.gui.JDragTree;
 import thaw.plugins.Hsqldb;
+import thaw.plugins.ToolbarModifier;

 /**
  * Manages the index tree and its menu (right-click).
@@ -87,6 +88,8 @@
        private FCPQueueManager queueManager;
        private IndexBrowserPanel indexBrowser;

+       private ToolbarModifier toolbarModifier;
+       private Vector toolbarActions;

        /**
         * @param queueManager Not used if selectionOnly is set to true
@@ -236,8 +239,57 @@
                addTreeSelectionListener(this);

                panel.add(new JScrollPane(tree), BorderLayout.CENTER);
+
+
+               // Toolbar
+               JButton button;
+               IndexManagementHelper.IndexAction action;
+               toolbarActions = new Vector();
+
+               toolbarModifier = new 
ToolbarModifier(indexBrowser.getMainWindow());
+
+               button = new JButton(IconBox.refreshAction);
+               
button.setToolTipText(I18n.getMessage("thaw.plugin.index.downloadIndexes"));
+               action = new IndexManagementHelper.IndexDownloader(button);
+               action.setTarget(getRoot());
+               toolbarModifier.addButtonToTheToolbar(button);
+               toolbarActions.add(action);
+
+               button = new JButton(IconBox.insertAndAddToIndexAction);
+               
button.setToolTipText(I18n.getMessage("thaw.plugin.index.addCategory"));
+               action = new 
IndexManagementHelper.IndexCategoryAdder(queueManager, indexBrowser, button);
+               action.setTarget(getRoot());
+               toolbarModifier.addButtonToTheToolbar(button);
+               toolbarActions.add(action);
+
+               button = new JButton(IconBox.indexReuse);
+               
button.setToolTipText(I18n.getMessage("thaw.plugin.index.addAlreadyExistingIndex"));
+               action = new IndexManagementHelper.IndexReuser(queueManager, 
indexBrowser, button);
+               action.setTarget(getRoot());
+               toolbarModifier.addButtonToTheToolbar(button);
+               toolbarActions.add(action);
+
+               button = new JButton(IconBox.indexNew);
+               
button.setToolTipText(I18n.getMessage("thaw.plugin.index.createIndex"));
+               action = new IndexManagementHelper.IndexCreator(queueManager, 
indexBrowser, button);
+               action.setTarget(getRoot());
+               toolbarModifier.addButtonToTheToolbar(button);
+               toolbarActions.add(action);
+
+               button = new JButton(IconBox.indexDelete);
+               
button.setToolTipText(I18n.getMessage("thaw.plugin.index.delete"));
+               action = new IndexManagementHelper.IndexDeleter(indexBrowser, 
button);
+               action.setTarget(getRoot());
+               toolbarModifier.addButtonToTheToolbar(button);
+               toolbarActions.add(action);
        }

+       /**
+        * Used by IndexBrowserPanel when the visibility changed
+        */
+       public ToolbarModifier getToolbarModifier() {
+               return toolbarModifier;
+       }


        public javax.swing.JComponent getPanel() {
@@ -256,6 +308,18 @@

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

+
+               // Update toolbar
+               for (final Iterator it = toolbarActions.iterator();
+                    it.hasNext(); ) {
+                       final IndexManagementHelper.IndexAction action = 
(IndexManagementHelper.IndexAction)it.next();
+                       action.setTarget(selectedNode);
+               }
+
+               toolbarModifier.displayButtonsInTheToolbar();
+
+               // Notify observers
+
                setChanged();
                notifyObservers(selectedNode);
        }

Modified: trunk/apps/Thaw/src/thaw/plugins/queueWatcher/QueuePanel.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/queueWatcher/QueuePanel.java       
2006-12-27 22:59:05 UTC (rev 11522)
+++ trunk/apps/Thaw/src/thaw/plugins/queueWatcher/QueuePanel.java       
2006-12-28 22:23:00 UTC (rev 11523)
@@ -40,6 +40,7 @@
 import thaw.core.IconBox;
 import thaw.core.Logger;
 import thaw.fcp.FCPTransferQuery;
+import thaw.fcp.FCPClientGet;

 public class QueuePanel implements MouseListener, ActionListener, KeyListener {
        private Core core;
@@ -259,10 +260,15 @@

                                if(!query.isRunning() && !query.isFinished())
                                        cell.setBackground(PENDING);
-                               if(query.isFinished() && query.isSuccessful())
+
+                               if(query.isFinished() && query.isSuccessful() &&
+                                  ( (!(query instanceof FCPClientGet)) || 
((FCPClientGet)query).isWritingSuccessful()))
                                        cell.setBackground(SUCCESS);
-                               if(query.isFinished() && !query.isSuccessful())
+
+                               if(query.isFinished() && (!query.isSuccessful() 
||
+                                                         ((query instanceof 
FCPClientGet) && !((FCPClientGet)query).isWritingSuccessful())))
                                        cell.setBackground(FAILURE);
+
                                if(query.isRunning() && !query.isFinished())
                                        cell.setBackground(RUNNING);
                        }
@@ -486,9 +492,12 @@
                for(final Iterator it = queries.iterator();
                    it.hasNext(); ) {
                        final FCPTransferQuery query = 
(FCPTransferQuery)it.next();
-                       if(query.isFinished()) {
+                       if(query.isFinished() &&
+                          (!(query instanceof FCPClientGet) || 
(!query.isSuccessful() || ((FCPClientGet)query).isWritingSuccessful()))) {
+
                                if(query.stop(core.getQueueManager())) {
                                        core.getQueueManager().remove(query);
+
                                }
                        }
                }


Reply via email to