1   package intellego;
2   
3   import main.*;
4   import util.*;
5   
6   import javax.swing.*;
7   
8   /**
9   * Startup class - starts the whole system
10  */
11  public class Intellego
12  {
13      private static boolean debugMode;   // debug mode flag
14      private static IntellegoLog log;    // the log for this run
15                 
16      /**
17      * Adds a message to the log
18      *
19      * @param message the message to be added
20      */
21      public static void addToLog(String message)
22      {
23          // if we're in debug mode, print the messages out to the scren as well
24          if(debugMode)
25          {
26              System.out.println("Log message: "+message);
27          }
28  
29          // add the message to the log
30          log.addMessage(message);
31      }
32  
33      /**
34      * Prints usage instructions to stdout
35      */
36      public static void printUsage()
37      {
38          System.out.println( "\nUsage: java Intellego [-option]\n"+
39                              "\nwhere option is one of:\n\n"+
40                              "\t-d -debug\truns Intellego in debug mode (prints messages to stdout)\n"+
41                              "\t-h -help\tdisplays this message");
42      }
43  
44      /**
45      * Fires up the whole system
46      */
47      public static void main(String args[])
48      {
49          // set debug mode
50          debugMode=false;
51  
52          // check command line args
53          if (args.length==0)
54          {
55              // do nothing
56          }
57          else if (args.length==1)
58          {
59              if (args[0].equalsIgnoreCase("-d") || args[0].equalsIgnoreCase("-debug"))
60              {
61                  debugMode=true;
62              }
63              else if (args[0].equalsIgnoreCase("-h") || args[0].equalsIgnoreCase("-help"))
64              {
65                  printUsage();
66                  System.exit(0);
67              }
68              else
69              {
70                  printUsage();
71                  System.exit(0);
72              }
73          }
74          else // unknown args
75          {
76              printUsage();
77              System.exit(0);
78          }
79  
80          // set up the log
81          log=new IntellegoLog();
82                  
83          // fire up the main GUI
84          MainInterface gui=new MainInterface();
85          gui.setVisible(true);
86  
87          addToLog("Intellego.main(): GUI set up successfully");
88      }
89  }
90