Author: jflesch
Date: 2006-12-05 21:29:25 +0000 (Tue, 05 Dec 2006)
New Revision: 11251

Modified:
   trunk/apps/Thaw/src/thaw/core/Main.java
   trunk/apps/Thaw/src/thaw/plugins/IndexBrowser.java
   trunk/apps/Thaw/src/thaw/plugins/insertPlugin/InsertPanel.java
Log:
Change toolbar buttons state according to the selected item in the index tree

Modified: trunk/apps/Thaw/src/thaw/core/Main.java
===================================================================
--- trunk/apps/Thaw/src/thaw/core/Main.java     2006-12-05 21:18:29 UTC (rev 
11250)
+++ trunk/apps/Thaw/src/thaw/core/Main.java     2006-12-05 21:29:25 UTC (rev 
11251)
@@ -12,17 +12,16 @@
  */
 public class Main {

-       public final static String VERSION;
-       final char
+       public final static char
                _major = 0,
                _minor = 6;
-       final String
+       public final static String
                _svnBuildNumber = "@custom@";

-       static{
+       public final static String
                VERSION = _major + '.' + _minor + " WIP r"+_svnBuildNumber;
-       }

+
        /**
         * Look & feel use by GUI front end
         */

Modified: trunk/apps/Thaw/src/thaw/plugins/IndexBrowser.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/IndexBrowser.java  2006-12-05 21:18:29 UTC 
(rev 11250)
+++ trunk/apps/Thaw/src/thaw/plugins/IndexBrowser.java  2006-12-05 21:29:25 UTC 
(rev 11251)
@@ -4,11 +4,14 @@
 import javax.swing.event.ChangeListener;
 import javax.swing.event.ChangeEvent;

+import java.util.Vector;
+import java.util.Iterator;
+
 import thaw.core.*;

 import thaw.plugins.index.*;

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

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

@@ -16,6 +19,7 @@
        private Hsqldb hsqldb;

        private IndexBrowserPanel browserPanel;
+       private Vector toolbarActions;

        public IndexBrowser() {

@@ -49,6 +53,7 @@
                }

                browserPanel = new IndexBrowserPanel(hsqldb, 
core.getQueueManager(), core.getConfig(), core.getMainWindow());
+               browserPanel.getIndexTree().addObserver(this);

                setMainWindow(core.getMainWindow());
                core.getMainWindow().getTabbedPane().addChangeListener(this);
@@ -60,6 +65,7 @@
                browserPanel.restoreState();

                JButton button;
+               toolbarActions = new Vector();
                IndexManagementHelper.IndexAction action;

                button = new JButton(IconBox.refreshAction);
@@ -67,18 +73,21 @@
                action = new IndexManagementHelper.IndexDownloader(button);
                action.setTarget(browserPanel.getIndexTree().getRoot()); /* 
TODO : Listen to tree to only refresh the selected node */
                addButtonToTheToolbar(button);
+               toolbarActions.add(action);

                button = new JButton(IconBox.indexReuse);
                
button.setToolTipText(I18n.getMessage("thaw.plugin.index.addAlreadyExistingIndex"));
                action = new IndexManagementHelper.IndexReuser(hsqldb, 
core.getQueueManager(), browserPanel.getUnknownIndexList(), 
browserPanel.getIndexTree(), core.getMainWindow(), 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(hsqldb, 
core.getQueueManager(), browserPanel.getUnknownIndexList(), 
browserPanel.getIndexTree(), button);
                action.setTarget(browserPanel.getIndexTree().getRoot());
                addButtonToTheToolbar(button);
+               toolbarActions.add(action);

                if (newDb) {
                        IndexManagementHelper.addIndex(hsqldb, 
core.getQueueManager(), browserPanel.getUnknownIndexList(), 
browserPanel.getIndexTree(),
@@ -127,4 +136,16 @@
                }
        }

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

Modified: trunk/apps/Thaw/src/thaw/plugins/insertPlugin/InsertPanel.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/insertPlugin/InsertPanel.java      
2006-12-05 21:18:29 UTC (rev 11250)
+++ trunk/apps/Thaw/src/thaw/plugins/insertPlugin/InsertPanel.java      
2006-12-05 21:29:25 UTC (rev 11251)
@@ -39,7 +39,7 @@
        private JPanel subPanel; /* because we won't use the whole space */

        private JLabel browseLabel;
-       private JTextField selectedFiles; /* TODO: it was planned to support 
directory insertion */
+       private JTextField selectedFiles;
        private JButton browseButton;

        private JLabel selectKeyLabel;


Reply via email to