Author: jflesch
Date: 2006-07-10 01:50:31 +0000 (Mon, 10 Jul 2006)
New Revision: 9539

Modified:
   trunk/apps/Thaw/build.xml
   trunk/apps/Thaw/src/thaw/core/Core.java
   trunk/apps/Thaw/src/thaw/core/Main.java
   trunk/apps/Thaw/src/thaw/core/QueueKeeper.java
   trunk/apps/Thaw/src/thaw/fcp/FCPClientGet.java
Log:
The look and feel can now be changed (thanks to ET, Frost)

Modified: trunk/apps/Thaw/build.xml
===================================================================
--- trunk/apps/Thaw/build.xml   2006-07-10 01:21:28 UTC (rev 9538)
+++ trunk/apps/Thaw/build.xml   2006-07-10 01:50:31 UTC (rev 9539)
@@ -1,6 +1,6 @@
 <?xml version="1.0"?>

-<project name="Thaw" default="compile">
+<project name="Thaw" default="jar">

   <property name="src.dir" value="src" />
   <property name="bin.dir" value="build" />

Modified: trunk/apps/Thaw/src/thaw/core/Core.java
===================================================================
--- trunk/apps/Thaw/src/thaw/core/Core.java     2006-07-10 01:21:28 UTC (rev 
9538)
+++ trunk/apps/Thaw/src/thaw/core/Core.java     2006-07-10 01:50:31 UTC (rev 
9539)
@@ -4,6 +4,11 @@
 import java.util.Observer;
 import java.util.Observable;

+import javax.swing.JDialog;
+import javax.swing.JFrame;
+import javax.swing.UIManager;
+import javax.swing.UIManager.LookAndFeelInfo;
+
 import thaw.i18n.I18n;
 import thaw.fcp.*;

@@ -23,7 +28,9 @@

        private FCPClientHello clientHello = null;

+       private static String lookAndFeel = null;

+
        /**
         * Creates a core, but do nothing else (no initialization).
         */
@@ -213,10 +220,45 @@
                return clientHello;
        }

+       
        /**
+        * To call before initGraphics() !
+        * @arg lAndF LookAndFeel name
+        */
+       public static void setLookAndFeel(String lAndF) {
+               lookAndFeel = lAndF;
+       }
+
+
+       /**
+        * This method sets the look and feel specified with setLookAndFeel().
+        * If none was specified, the System Look and Feel is set.
+        */
+       private void initializeLookAndFeel() { /* non static, else I can't call 
correctly Logger functions */
+
+               JFrame.setDefaultLookAndFeelDecorated(false); /* Don't touch my 
window decoration ! */
+               JDialog.setDefaultLookAndFeelDecorated(false);
+
+               try {
+                       if (lookAndFeel == null) {
+                               
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
+                       } else {
+                               UIManager.setLookAndFeel(lookAndFeel);
+                       }
+               } catch (Exception e) {
+                       Logger.warning(this, "Exception while setting the L&F : 
" + e.getMessage());
+                       Logger.warning(this, "Using the default lookAndFeel");
+               }
+
+       }
+
+
+       /**
         * Init graphics.
         */
        public boolean initGraphics() {
+               initializeLookAndFeel();
+
                mainWindow = new MainWindow(this);

                configWindow = new ConfigWindow(this);

Modified: trunk/apps/Thaw/src/thaw/core/Main.java
===================================================================
--- trunk/apps/Thaw/src/thaw/core/Main.java     2006-07-10 01:21:28 UTC (rev 
9538)
+++ trunk/apps/Thaw/src/thaw/core/Main.java     2006-07-10 01:50:31 UTC (rev 
9539)
@@ -1,5 +1,8 @@
 package thaw.core;

+import javax.swing.UIManager;
+import javax.swing.UIManager.LookAndFeelInfo;
+
 /**
  * Main class. Only used to display some informations and init the core.
  *
@@ -8,18 +11,86 @@
 public class Main {

        public final static String VERSION="0.1 WIP";
-       

        /**
+        * Look & feel use by GUI front end
+        */
+       private static String lookAndFeel = null;
+
+
+       /**
         * Used to start the program
         *
-        * @param args Arguments given to the program.
+        * @param args "-?", "-help", "--help", "/?", "/help", "-lf lookandfeel"
         */
        public static void main(String[] args) {
                Core core;

+               parseCommandLine(args);
+
                core = new Core();
+               core.setLookAndFeel(lookAndFeel);
                core.initAll();
        }
+
+
+
+
+       /**
+        * This method parses the command line arguments
+        * 
+        * @param args the arguments
+        */
+       private static void parseCommandLine(String[] args) {
+
+               int count = 0;
+
+               try {
+                       while (args.length > count) {
+                               if (args[count].equals("-?") || 
args[count].equals("-help")
+                                               || args[count].equals("--help")
+                                               || args[count].equals("/?")
+                                               || args[count].equals("/help")) 
{
+                                       showHelp();
+                                       count++;
+                               } else if (args[count].equals("-lf")) {
+                                       lookAndFeel = args[count + 1];
+                                       count = count + 2;
+                               } else {
+                                       showHelp();
+                               }
+                       }
+               } catch (ArrayIndexOutOfBoundsException exception) {
+                       showHelp();
+               }
+
+       }
+
+       /**
+        * This method shows a help message on the standard output and exits the
+        * program.
+        */
+       private static void showHelp() {
+
+               System.out.println("java -jar thaw.jar [-lf lookAndFeel]\n");
+               System.out.println("-lf     Sets the 'Look and Feel' will 
use.");
+               System.out.println("        (overriden by the skins 
preferences)\n");
+               System.out.println("        These ones are currently 
available:");
+               LookAndFeelInfo[] feels = UIManager.getInstalledLookAndFeels();
+               for (int i = 0; i < feels.length; i++) {
+                       System.out.println("           " + 
feels[i].getClassName());
+               }
+               System.out.println("\n         And this one is used by 
default:");
+               System.out.println("           " + 
UIManager.getSystemLookAndFeelClassName() + "\n");
+
+               System.exit(0);
+
+       }
+
+
+
+
+
+
 }


Modified: trunk/apps/Thaw/src/thaw/core/QueueKeeper.java
===================================================================
--- trunk/apps/Thaw/src/thaw/core/QueueKeeper.java      2006-07-10 01:21:28 UTC 
(rev 9538)
+++ trunk/apps/Thaw/src/thaw/core/QueueKeeper.java      2006-07-10 01:50:31 UTC 
(rev 9539)
@@ -180,6 +180,10 @@
                return queryEl;
        }

+
+       /**
+        * TODO : Queries which are persistent should not be save. They should 
be taken from the queue node.
+        */
        public static boolean saveQueue(FCPQueueManager queueManager, String 
fileName) {
                Vector runningQueue = queueManager.getRunningQueue();
                Vector[] pendingQueue = queueManager.getPendingQueues();

Modified: trunk/apps/Thaw/src/thaw/fcp/FCPClientGet.java
===================================================================
--- trunk/apps/Thaw/src/thaw/fcp/FCPClientGet.java      2006-07-10 01:21:28 UTC 
(rev 9538)
+++ trunk/apps/Thaw/src/thaw/fcp/FCPClientGet.java      2006-07-10 01:50:31 UTC 
(rev 9539)
@@ -69,6 +69,7 @@

                this.progress = 0;
                this.fileSize = 0;
+               this.attempt = 0;

                if(key.indexOf('/') == key.length()-1) {
                        filename = "index.html";


Reply via email to