[Thaw-dev] r17969 - in trunk/apps/Thaw/src/thaw: core plugin…

Top Page
Delete this message
Reply to this message
Author: jflesch
Date:  
To: thaw
Subject: [Thaw-dev] r17969 - in trunk/apps/Thaw/src/thaw: core plugins/index
Author: jflesch
Date: 2008-02-16 01:13:31 +0000 (Sat, 16 Feb 2008)
New Revision: 17969

Added:
trunk/apps/Thaw/src/thaw/core/PleaseWaitDialog.java
Modified:
trunk/apps/Thaw/src/thaw/core/ConfigWindow.java
trunk/apps/Thaw/src/thaw/plugins/index/IndexManagementHelper.java
Log:
IndexBrowser : Add a dialog 'please wait' with reordering many indexes

Modified: trunk/apps/Thaw/src/thaw/core/ConfigWindow.java
===================================================================
--- trunk/apps/Thaw/src/thaw/core/ConfigWindow.java    2008-02-16 01:12:47 UTC (rev 17968)
+++ trunk/apps/Thaw/src/thaw/core/ConfigWindow.java    2008-02-16 01:13:31 UTC (rev 17969)
@@ -11,10 +11,6 @@
import javax.swing.JDialog;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
-import javax.swing.JLabel;
-import java.awt.Dimension;
-import java.awt.Toolkit;
-
import thaw.gui.TabbedPane;
import thaw.gui.IconBox;

@@ -237,35 +233,10 @@
        }

        public void apply() {
-            JDialog dialog = null;
+            PleaseWaitDialog dialog = null;

            if (resetConnection) {
-                dialog = new JDialog(core.getMainWindow().getMainFrame(),
-                         " "+I18n.getMessage("thaw.common.pleaseWait"));
-
-                dialog.getContentPane().setLayout(new GridLayout(1, 1));
-                dialog.getContentPane().add(new JLabel(I18n.getMessage("thaw.common.pleaseWait"),
-                                 JLabel.CENTER));
-
-                //dialog.setUndecorated(true);
-                dialog.setResizable(false);
-
-                dialog.setSize(150, 30);
-
-                Dimension screenSize =
-                    Toolkit.getDefaultToolkit().getScreenSize();
-
-                Dimension dialogSize = dialog.getSize();
-                dialog.setLocation(screenSize.width/2 - (dialogSize.width/2),
-                         screenSize.height/2 - (dialogSize.height/2));
-
-                dialog.setVisible(true);
-
-                dialog.setSize(150, 30);
-
-                dialogSize = dialog.getSize();
-                dialog.setLocation(screenSize.width/2 - (dialogSize.width/2),
-                         screenSize.height/2 - (dialogSize.height/2));
+                dialog = new PleaseWaitDialog(core.getMainWindow());
            }

            /* Imply a whole reset => all the plugins will be reloaded
@@ -284,7 +255,7 @@
                                     " "+core.getConfig().getValue("nodeAddress")+
                                     ":"+ core.getConfig().getValue("nodePort"));
                    else
-                        new thaw.gui.WarningWindow(dialog,
+                        new thaw.gui.WarningWindow(dialog.getDialog(),
                                     I18n.getMessage("thaw.warning.unableToConnectTo")+
                                     " "+core.getConfig().getValue("nodeAddress")+
                                     ":"+ core.getConfig().getValue("nodePort"));
@@ -305,7 +276,6 @@
            }

            if (resetConnection) {
-                dialog.setVisible(false);
                dialog.dispose();
            }
        }

Added: trunk/apps/Thaw/src/thaw/core/PleaseWaitDialog.java
===================================================================
--- trunk/apps/Thaw/src/thaw/core/PleaseWaitDialog.java     (rev 0)
+++ trunk/apps/Thaw/src/thaw/core/PleaseWaitDialog.java    2008-02-16 01:13:31 UTC (rev 17969)
@@ -0,0 +1,50 @@
+package thaw.core;
+
+import java.awt.Dimension;
+import java.awt.GridLayout;
+import java.awt.Toolkit;
+
+import javax.swing.JDialog;
+import javax.swing.JLabel;
+
+public class PleaseWaitDialog {
+    private JDialog dialog;
+
+    public PleaseWaitDialog(MainWindow mainWindow) {
+        dialog = new JDialog(mainWindow.getMainFrame(),
+                            " "+I18n.getMessage("thaw.common.pleaseWait"));
+
+        dialog.getContentPane().setLayout(new GridLayout(1, 1));
+        dialog.getContentPane().add(new JLabel(I18n.getMessage("thaw.common.pleaseWait"),
+                JLabel.CENTER));
+        
+//        dialog.setUndecorated(true);
+//        dialog.setResizable(false);
+
+        dialog.setSize(200, 75);
+
+        Dimension screenSize =
+            Toolkit.getDefaultToolkit().getScreenSize();
+
+        Dimension dialogSize = dialog.getSize();
+        dialog.setLocation(screenSize.width/2 - (dialogSize.width/2),
+                 screenSize.height/2 - (dialogSize.height/2));
+
+        dialog.setVisible(true);
+        
+        dialog.setSize(200, 75);
+
+        dialogSize = dialog.getSize();
+        dialog.setLocation(screenSize.width/2 - (dialogSize.width/2),
+                 screenSize.height/2 - (dialogSize.height/2));
+    }
+    
+    public JDialog getDialog() {
+        return dialog;
+    }
+    
+    public void dispose() {
+        dialog.setVisible(false);
+        dialog.dispose();
+    }
+}

Modified: trunk/apps/Thaw/src/thaw/plugins/index/IndexManagementHelper.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/index/IndexManagementHelper.java    2008-02-16 01:12:47 UTC (rev 17968)
+++ trunk/apps/Thaw/src/thaw/plugins/index/IndexManagementHelper.java    2008-02-16 01:13:31 UTC (rev 17969)
@@ -43,6 +43,7 @@
import thaw.gui.IconBox;

import thaw.core.Config;
+import thaw.core.PleaseWaitDialog;
import thaw.core.ThawThread;
import thaw.core.ThawRunnable;
import thaw.gui.FileChooser;
@@ -709,7 +710,7 @@
        IndexFolder oldParent = (IndexFolder)index.getParent();

        if (oldParent == dst) {
-            Logger.notice(new IndexManagementHelper(), "Index already sorted.");
+            Logger.notice(new IndexManagementHelper(), "Index '"+index.toString()+"'already sorted.");
            return false;
        }

@@ -727,16 +728,23 @@
        return true;
    }

+    public static boolean autoSortIndexes(IndexBrowserPanel indexBrowser,
+                                        IndexTreeNode node,
+                                        MainWindow mainWindow) {
+        return autoSortIndexes(indexBrowser, node, mainWindow, true);
+    }
+    

    public static boolean autoSortIndexes(IndexBrowserPanel indexBrowser,
-                     IndexTreeNode node) {
+                                     IndexTreeNode node, MainWindow mainWindow,
+                                     boolean showDialog) {
        if (node instanceof Index) {
            String cat = ((Index)node).getCategory();

            if (cat != null)
                return autoSortIndex(indexBrowser, (Index)node, cat);
            else
-                Logger.notice(indexBrowser, "No category ; can't sort");
+                Logger.notice(indexBrowser, "No category for '"+((Index)node).toString()+"'; can't sort");

        } else if (node instanceof IndexFolder) {

@@ -745,15 +753,23 @@
            if (folder == null || "".equals(folder.toString())) {
                return false;
            }
+            
+            PleaseWaitDialog dialog = null;
+            
+            if (showDialog)
+                dialog = new PleaseWaitDialog(mainWindow);

            for (java.util.Enumeration children = folder.children();
             children.hasMoreElements();) {

                /* dirty recursivity */
                IndexTreeNode subNode = (IndexTreeNode)children.nextElement();
-                autoSortIndexes(indexBrowser, subNode);
+                autoSortIndexes(indexBrowser, subNode, null, false);

            }
+            
+            if (showDialog && dialog != null)
+                dialog.dispose();
        }

        return true;
@@ -761,10 +777,9 @@


    public static boolean autoSortIndex(IndexBrowserPanel indexBrowser,
-                     Index index,
-                     String cat) {
+                                        Index index, String cat) {
        if (cat == null) {
-            Logger.warning(new IndexManagementHelper(), "No category ; Can't sort the index");
+            Logger.info(new IndexManagementHelper(), "No category ; Can't sort the index");
            return false;
        }

@@ -805,7 +820,8 @@
            }

            autoSortIndexes(getIndexBrowserPanel(),
-                    (IndexTreeNode)getTarget());
+                            (IndexTreeNode)getTarget(),
+                            getIndexBrowserPanel().getMainWindow());
        }
    }