Author: jflesch
Date: 2007-03-07 15:49:23 +0000 (Wed, 07 Mar 2007)
New Revision: 12010

Modified:
   trunk/apps/Thaw/src/thaw/core/ConfigWindow.java
   trunk/apps/Thaw/src/thaw/i18n/thaw.properties
   trunk/apps/Thaw/src/thaw/plugins/index/IndexConfigPanel.java
   trunk/apps/Thaw/src/thaw/plugins/index/IndexFolder.java
   trunk/apps/Thaw/src/thaw/plugins/index/IndexRoot.java
   trunk/apps/Thaw/src/thaw/plugins/index/IndexTree.java
Log:
Thaw loads now the whole index tree at startup.
This behavior can be change in the configuration window (advanced mode). As 
this option is not really useful, it may be removed in the future.



Modified: trunk/apps/Thaw/src/thaw/core/ConfigWindow.java
===================================================================
--- trunk/apps/Thaw/src/thaw/core/ConfigWindow.java     2007-03-07 14:26:47 UTC 
(rev 12009)
+++ trunk/apps/Thaw/src/thaw/core/ConfigWindow.java     2007-03-07 15:49:23 UTC 
(rev 12010)
@@ -151,6 +151,10 @@
                return cancelButton;
        }

+       /**
+        * Call this function if a change made by the user
+        * need a connection reset with the plugins reset
+        */
        public void willNeedConnectionReset() {
                needConnectionReset = true;
        }

Modified: trunk/apps/Thaw/src/thaw/i18n/thaw.properties
===================================================================
--- trunk/apps/Thaw/src/thaw/i18n/thaw.properties       2007-03-07 14:26:47 UTC 
(rev 12009)
+++ trunk/apps/Thaw/src/thaw/i18n/thaw.properties       2007-03-07 15:49:23 UTC 
(rev 12010)
@@ -296,4 +296,6 @@

 thaw.plugin.index.indexWithNoLink=The index '?' has no link.\nAre you sure 
that you want to insert it as it ?

-thaw.plugin.index.sortAlphabetically=Sort by alphabetic order
\ No newline at end of file
+thaw.plugin.index.sortAlphabetically=Sort by alphabetic order
+
+thaw.plugin.index.loadOnTheFly=Load the index tree on the fly (means less 
memory consumption but more CPU usage)

Modified: trunk/apps/Thaw/src/thaw/plugins/index/IndexConfigPanel.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/index/IndexConfigPanel.java        
2007-03-07 14:26:47 UTC (rev 12009)
+++ trunk/apps/Thaw/src/thaw/plugins/index/IndexConfigPanel.java        
2007-03-07 15:49:23 UTC (rev 12010)
@@ -20,7 +20,9 @@
        private JTextField refreshInterval;
        private JTextField indexPerRefresh;

+       private JCheckBox loadOnTheFly;

+
        public IndexConfigPanel(ConfigWindow configWindow, Config config) {
                this.configWindow = configWindow;
                this.config = config;
@@ -36,6 +38,9 @@
                JLabel indexPerRefreshLabel = new 
JLabel(I18n.getMessage("thaw.plugin.index.nmbIndexPerRefresh"));
                indexPerRefresh = new JTextField("");

+               loadOnTheFly = new 
JCheckBox(I18n.getMessage("thaw.plugin.index.loadOnTheFly"));
+
+
                resetValues();

                autorefreshActivated.addActionListener(this);
@@ -48,6 +53,11 @@
                panel.add(indexPerRefreshLabel);
                panel.add(indexPerRefresh);

+               if 
(Boolean.valueOf(config.getValue("advancedMode")).booleanValue()) {
+                       panel.add(new JLabel(" "));
+                       panel.add(loadOnTheFly);
+               }
+
                updateTextFieldState();
        }

@@ -74,6 +84,7 @@
                boolean activated = AutoRefresh.DEFAULT_ACTIVATED;
                int refreshIntervalInt = AutoRefresh.DEFAULT_INTERVAL;
                int nmbIndexInt = AutoRefresh.DEFAULT_INDEX_NUMBER;
+               boolean loadOnTheFlyBoolean = false;

                try {
                        if (config.getValue("indexAutoRefreshActivated") != 
null) {
@@ -87,6 +98,12 @@
                        if (config.getValue("nmbIndexesPerRefreshInterval") != 
null) {
                                nmbIndexInt = 
Integer.parseInt(config.getValue("nmbIndexesPerRefreshInterval"));
                        }
+
+
+                       if (config.getValue("loadIndexTreeOnTheFly") != null) {
+                               loadOnTheFlyBoolean = 
Boolean.valueOf(config.getValue("loadIndexTreeOnTheFly")).booleanValue();
+                       }
+
                } catch(NumberFormatException e) {
                        Logger.error(this, "Error while parsing config !");
                }
@@ -95,6 +112,7 @@
                autorefreshActivated.setSelected(activated);
                refreshInterval.setText(Integer.toString(refreshIntervalInt));
                indexPerRefresh.setText(Integer.toString(nmbIndexInt));
+               loadOnTheFly.setSelected(loadOnTheFlyBoolean);
        }


@@ -105,6 +123,8 @@
                                refreshInterval.getText());
                config.setValue("nmbIndexesPerRefreshInterval",
                                indexPerRefresh.getText());
+               config.setValue("loadIndexTreeOnTheFly",
+                               Boolean.toString(loadOnTheFly.isSelected()));
        }

        public void actionPerformed(ActionEvent e) {

Modified: trunk/apps/Thaw/src/thaw/plugins/index/IndexFolder.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/index/IndexFolder.java     2007-03-07 
14:26:47 UTC (rev 12009)
+++ trunk/apps/Thaw/src/thaw/plugins/index/IndexFolder.java     2007-03-07 
15:49:23 UTC (rev 12010)
@@ -33,16 +33,22 @@

        private Vector children = null;

-       public IndexFolder(final Hsqldb db, final int id) {
+       private boolean loadOnTheFly = true;
+
+
+
+       public IndexFolder(final Hsqldb db, final int id, boolean loadOnTheFly) 
{
                this.id = id;
                this.db = db;
+               this.loadOnTheFly = loadOnTheFly;
        }

        /**
         * @param parentNode only required if in a tree
         */
-       public IndexFolder(final Hsqldb db, final int id, TreeNode parentNode, 
String name) {
-               this(db, id);
+       public IndexFolder(final Hsqldb db, final int id, TreeNode parentNode, 
String name, boolean loadOnTheFly) {
+               this(db, id, loadOnTheFly);
+
                this.parentNode = parentNode;
                this.name = name;
        }
@@ -58,8 +64,11 @@
                while(set.next()) {
                        IndexTreeNode n;

-                       if (folder)
-                               n = new IndexFolder(db, set.getInt("id"), this, 
set.getString("name"));
+                       if (folder) {
+                               n = new IndexFolder(db, set.getInt("id"), this, 
set.getString("name"), loadOnTheFly);
+                               if (!loadOnTheFly) /* => load immediatly */
+                                       ((IndexFolder)n).loadChildren();
+                       }
                        else
                                n = new Index(db, set.getInt("id"), this, 
set.getString("publicKey"),
                                              set.getInt("revision"), 
set.getString("privateKey"),
@@ -321,7 +330,7 @@
                                if (index)
                                        node = new Index(db, target_id);
                                else
-                                       node = new IndexFolder(db, target_id);
+                                       node = new IndexFolder(db, target_id, 
false);

                                children.remove(node);
                        }

Modified: trunk/apps/Thaw/src/thaw/plugins/index/IndexRoot.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/index/IndexRoot.java       2007-03-07 
14:26:47 UTC (rev 12009)
+++ trunk/apps/Thaw/src/thaw/plugins/index/IndexRoot.java       2007-03-07 
15:49:23 UTC (rev 12010)
@@ -12,10 +12,17 @@
        private FCPQueueManager queueManager;
        private IndexBrowserPanel indexBrowser;

-       public IndexRoot(final FCPQueueManager queueManager, final 
IndexBrowserPanel indexBrowser, final String name) {
-               super(indexBrowser.getDb(), -1);
+       public IndexRoot(final FCPQueueManager queueManager,
+                        final IndexBrowserPanel indexBrowser,
+                        final String name,
+                        final boolean loadOnTheFly) {
+               super(indexBrowser.getDb(), -1, loadOnTheFly);
+
                this.queueManager = queueManager;
                this.indexBrowser = indexBrowser;
+
+               if (!loadOnTheFly) /* anyway loading for this folder will be 
done immediatly ... :p */
+                       loadChildren();
        }



Modified: trunk/apps/Thaw/src/thaw/plugins/index/IndexTree.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/index/IndexTree.java       2007-03-07 
14:26:47 UTC (rev 12009)
+++ trunk/apps/Thaw/src/thaw/plugins/index/IndexTree.java       2007-03-07 
15:49:23 UTC (rev 12010)
@@ -111,8 +111,13 @@
                panel = new JPanel();
                panel.setLayout(new BorderLayout(10, 10));

-               root = new IndexRoot(queueManager, indexBrowser, rootName);
+               boolean loadOnTheFly = false;

+               if (config.getValue("loadIndexTreeOnTheFly") != null)
+                       loadOnTheFly = 
Boolean.valueOf(config.getValue("loadIndexTreeOnTheFly")).booleanValue();
+
+               root = new IndexRoot(queueManager, indexBrowser, rootName, 
loadOnTheFly);
+
                treeModel = new DefaultTreeModel(root);

                if (!selectionOnly) {


Reply via email to