Author: jflesch
Date: 2006-08-02 15:33:21 +0000 (Wed, 02 Aug 2006)
New Revision: 9848

Added:
   trunk/apps/Thaw/src/thaw/core/SplashScreen.java
Modified:
   trunk/apps/Thaw/src/thaw/core/Core.java
   trunk/apps/Thaw/src/thaw/core/PluginManager.java
   trunk/apps/Thaw/src/thaw/core/QueueKeeper.java
   trunk/apps/Thaw/src/thaw/i18n/thaw.properties
   trunk/apps/Thaw/src/thaw/plugins/StatusBar.java
   trunk/apps/Thaw/src/thaw/plugins/queueWatcher/DragAndDropManager.java
Log:
Add a splash screen

Modified: trunk/apps/Thaw/src/thaw/core/Core.java
===================================================================
--- trunk/apps/Thaw/src/thaw/core/Core.java     2006-08-02 12:10:39 UTC (rev 
9847)
+++ trunk/apps/Thaw/src/thaw/core/Core.java     2006-08-02 15:33:21 UTC (rev 
9848)
@@ -20,6 +20,7 @@
  * The Core has all the functions needed to initialize Thaw / stop Thaw.
  */
 public class Core implements Observer {
+       private SplashScreen splashScreen = null;

        private MainWindow mainWindow = null;
        private Config config = null;
@@ -55,6 +56,13 @@
        }

        /**
+        * Gives a ref to the object managing the splash screen.
+        */
+       public SplashScreen getSplashScreen() {
+               return splashScreen;
+       }
+
+       /**
         * Gives a ref to the object managing the main window.
         */
        public MainWindow getMainWindow() {
@@ -81,20 +89,33 @@
         * @return true is success, false if not
         */
        public boolean initAll() {
+               splashScreen = new SplashScreen();
+
+               splashScreen.display();
+
+               splashScreen.setProgressionAndStatus(0, "Loading configuration 
...");
                if(!initConfig())
                        return false;

+               splashScreen.setProgressionAndStatus(10, "Connecting ...");
                if(!initNodeConnection())
                        new WarningWindow(this, 
I18n.getMessage("thaw.warning.unableToConnectTo")+ " 
"+config.getValue("nodeAddress")+":"+ config.getValue("nodePort"));

+               splashScreen.setProgressionAndStatus(30, "Preparing the main 
window ...");
                if(!initGraphics())
                        return false;

+               splashScreen.setProgressionAndStatus(40, "Loading plugins ...");
                if(!initPluginManager())
                        return false;

+               splashScreen.setProgressionAndStatus(100, "Ready");
+
+
                mainWindow.setStatus("Thaw "+Main.VERSION+" : 
"+I18n.getMessage("thaw.statusBar.ready"));

+               splashScreen.hide();
+
                mainWindow.setVisible(true);

                return true;
@@ -330,6 +351,9 @@
                Logger.info(this, "Stopping scheduler ...");
                if(queueManager != null)
                    queueManager.stopScheduler();
+
+               Logger.info(this, "Hidding main window ...");
+               mainWindow.setVisible(false);

                Logger.info(this, "Stopping plugins ...");
                pluginManager.stopPlugins();

Modified: trunk/apps/Thaw/src/thaw/core/PluginManager.java
===================================================================
--- trunk/apps/Thaw/src/thaw/core/PluginManager.java    2006-08-02 12:10:39 UTC 
(rev 9847)
+++ trunk/apps/Thaw/src/thaw/core/PluginManager.java    2006-08-02 15:33:21 UTC 
(rev 9848)
@@ -56,8 +56,15 @@

                Iterator pluginIt = pluginNames.iterator();

+               int progressJump = 10 / pluginNames.size();
+               core.getSplashScreen().setProgression(40);
+
                while(pluginIt.hasNext()) {
                        String pluginName = (String)pluginIt.next();
+
+                       
core.getSplashScreen().setProgressionAndStatus(core.getSplashScreen().getProgression()+progressJump,
+                                                                      "Loading 
plugin '"+pluginName+"' ...");
+
                        loadPlugin(pluginName);
                }

@@ -73,11 +80,19 @@
                try {
                        pluginIt = plugins.values().iterator();

+                       int progressJump = 50 / plugins.size();
+
+                       core.getSplashScreen().setProgression(50);
+
                        while(pluginIt.hasNext()) {
                                Plugin plugin = (Plugin)pluginIt.next();

                                try {
                                        Logger.info(this, "Running plugin 
'"+plugin.getClass().getName()+"'");
+
+                                       
core.getSplashScreen().setProgressionAndStatus(core.getSplashScreen().getProgression()+progressJump,
+                                                                               
       "Starting plugin '"+plugin.getClass().getName()+"' ...");
+
                                        plugin.run(core);
                                } catch(Exception e) {
                                        Logger.error(this, "Unable to run the 
plugin '"+plugin.getClass().getName()+"' because: "+e+":");

Modified: trunk/apps/Thaw/src/thaw/core/QueueKeeper.java
===================================================================
--- trunk/apps/Thaw/src/thaw/core/QueueKeeper.java      2006-08-02 12:10:39 UTC 
(rev 9847)
+++ trunk/apps/Thaw/src/thaw/core/QueueKeeper.java      2006-08-02 15:33:21 UTC 
(rev 9848)
@@ -28,7 +28,7 @@
 import thaw.fcp.*;

 /**
- * Used when Thaw start and stop: Save the queue state.
+ * Used when Thaw start and stop: Save the query not running (-> waiting in 
the Thaw queue)
  */
 public class QueueKeeper {
        private final static int MIN_PRIORITY = 6;

Added: trunk/apps/Thaw/src/thaw/core/SplashScreen.java
===================================================================
--- trunk/apps/Thaw/src/thaw/core/SplashScreen.java     2006-08-02 12:10:39 UTC 
(rev 9847)
+++ trunk/apps/Thaw/src/thaw/core/SplashScreen.java     2006-08-02 15:33:21 UTC 
(rev 9848)
@@ -0,0 +1,95 @@
+package thaw.core;
+
+import javax.swing.JFrame;
+import javax.swing.JProgressBar;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import java.awt.BorderLayout;
+import java.awt.Dimension;
+import java.awt.Toolkit;
+import java.awt.Font;
+
+
+public class SplashScreen {
+       public final static int SIZE_X = 500;
+       public final static int SIZE_Y = 100;
+
+
+       public JFrame splashScreen;
+       public JProgressBar progressBar;
+       
+
+       public SplashScreen() {
+
+       }
+
+       public void display() {
+               splashScreen = new JFrame();
+
+               splashScreen.setLayout(new BorderLayout(10, 10));
+               
+
+               JLabel thawLabel = new JLabel("   Thaw");
+               thawLabel.setFont(new Font("Dialog", Font.BOLD, 30));
+
+               splashScreen.add(thawLabel, BorderLayout.CENTER);
+
+               progressBar = new JProgressBar(0, 100);
+               progressBar.setStringPainted(true);
+               progressBar.setString("Wake up Neo ...");
+
+               splashScreen.add(progressBar, BorderLayout.SOUTH);
+
+               splashScreen.pack();
+
+               splashScreen.setPreferredSize(new Dimension(SIZE_X, SIZE_Y));
+
+               Dimension screenSize =
+                       Toolkit.getDefaultToolkit().getScreenSize();
+
+               Dimension splashSize = splashScreen.getPreferredSize();
+               splashScreen.setLocation(screenSize.width/2 - 
(splashSize.width/2),
+                                        screenSize.height/2 - 
(splashSize.height/2));
+
+
+               splashScreen.setVisible(true);
+               splashScreen.pack();
+
+               splashScreen.setSize(SIZE_X, SIZE_Y);
+
+       }
+
+       /**
+        * @param progress In pourcent
+        */
+       public void setProgression(int progress) {
+               if(progressBar != null)
+                       progressBar.setValue(progress);
+       }
+
+       public int getProgression() {
+               if(progressBar != null)
+                       return progressBar.getValue();
+               else
+                       return -1;
+       }
+
+
+       public void setStatus(String status) {
+               if(progressBar != null)
+                       progressBar.setString(status);
+       }
+
+       public void setProgressionAndStatus(int progress, String status) {
+               setProgression(progress);
+               setStatus(status);
+       }
+
+
+       public void hide() {
+               splashScreen.setVisible(false);
+               splashScreen = null;
+               progressBar = null;
+       }
+
+}

Modified: trunk/apps/Thaw/src/thaw/i18n/thaw.properties
===================================================================
--- trunk/apps/Thaw/src/thaw/i18n/thaw.properties       2006-08-02 12:10:39 UTC 
(rev 9847)
+++ trunk/apps/Thaw/src/thaw/i18n/thaw.properties       2006-08-02 15:33:21 UTC 
(rev 9848)
@@ -165,3 +165,6 @@
 thaw.about.l3=2006(c) Freenet Project Incorporated
 thaw.about.l4=under GPLv2
 thaw.about.l6=Icon theme "Gorilla" created by Jimmac 
(http://jimmac.musichall.cz/icons.php)
+
+## HsqlDb
+thaw.plugin.hsqldb.database=Database

Modified: trunk/apps/Thaw/src/thaw/plugins/StatusBar.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/StatusBar.java     2006-08-02 12:10:39 UTC 
(rev 9847)
+++ trunk/apps/Thaw/src/thaw/plugins/StatusBar.java     2006-08-02 15:33:21 UTC 
(rev 9848)
@@ -62,7 +62,7 @@
                            it.hasNext(); ) {
                                FCPTransferQuery query = 
(FCPTransferQuery)it.next();

-                               if(query.isRunning()) {
+                               if(query.isRunning() && !query.isFinished()) {
                                        running++;
                                        progressTotal += 100;
                                        progressDone += query.getProgression();

Modified: trunk/apps/Thaw/src/thaw/plugins/queueWatcher/DragAndDropManager.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/queueWatcher/DragAndDropManager.java       
2006-08-02 12:10:39 UTC (rev 9847)
+++ trunk/apps/Thaw/src/thaw/plugins/queueWatcher/DragAndDropManager.java       
2006-08-02 15:33:21 UTC (rev 9848)
@@ -44,8 +44,8 @@

                for(int i = 0 ; i < queuePanels.length ; i++) {
                        
this.dragSource.createDefaultDragGestureRecognizer(queuePanels[i].getTable(),
-                                                                             
DnDConstants.ACTION_COPY_OR_MOVE,
-                                                                             
this);
+                                                                          
DnDConstants.ACTION_COPY_OR_MOVE,
+                                                                          
this);

                        //queuePanels[i].getTable().setTransferHandler(new 
FileTransferHandler());
                        //queuePanels[i].getTable().setDragEnabled(true);


Reply via email to