C:\Java WorkShop\Lexx\src\lexx\RunApp.java

1    package lexx; 
2     
3    import java.io.IOException; 
4    import java.util.*; 
5     
6    import javax.swing.JFrame; 
7    import javax.swing.JLabel; 
8    import javax.swing.UIManager; 
9     
10   import org.apache.log4j.BasicConfigurator; 
11   import lexx.utils.LocalSettings; 
12   import java.awt.*; 
13    
14   /** 
15    * <p>Class used to run IDE</p> 
16    * <p>Usage</p> 
17    *     run lexx IDE noramlly          - java -cp lexx.jar lexx.RunApp<br> 
18    *     run app in debug mode          - java -cp lexx.jar -Ddebug=true lexx.RunApp<br> 
19    *     include incomplete components  - java -cp lexx.jar -Dincomplete=true lexx.RunApp<br> 
20    *     enable old syntax highlighting - java -cp lexx.jar -Doldsyntax=true lexx.RunApp<br> 
21    *     enable incremental parsing     - java -cp lexx.jar -Dincrementalast=true lexx.RunApp<br> 
22    *     to run logger externally       - java -cp lexx.jar lexx.RunLogger<br> 
23    *     to run all automated test      - java -cp lexx.jar lexx.test.AllTest<br> 
24    *     to run applet                  - appletviewer -cp lexx.jar lexx.RunApplet<br> 
25    * <p>Copyright (c) 2002-2003</p> 
26    * @since 20/03/2003 
27    * @author Mohammed Imran 
28    * @version 1.0 
29    */ 
30    
31   public final class RunApp 
32   { 
33     private static final org.apache.log4j.Logger log = org.apache.log4j.Logger. 
34         getLogger(RunApp.class); 
35    
36     public static void main(String[] args) 
37     { 
38   /*    StringTokenizer st2 = new StringTokenizer(System.getProperties().toString(), 
39                                                 ","); 
40       while(st2.hasMoreTokens()) 
41         System.out.println(st2.nextToken()); 
42       //System.exit(0);*/ 
43    
44       setupLogger(); 
45    
46       //enables incremental lexing for syntax highlighting 
47       new satc.SettingsReader(); 
48    
49       setupProxy(); 
50    
51       try 
52       { 
53         UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); 
54    
55         log.info("Loading Lexx IDE"); 
56    
57         System.out.println("Usage:"); 
58         System.out.println("______\n"); 
59         System.out.println("run lexx IDE noramlly          - java -cp lexx.jar lexx.RunApp"); 
60         System.out.println("run app in debug mode          - java -cp lexx.jar -Ddebug=true lexx.RunApp"); 
61         System.out.println("include incomplete components  - java -cp lexx.jar -Dincomplete=true lexx.RunApp"); 
62         System.out.println("enable old syntax highlighting - java -cp lexx.jar -Doldsyntax=true lexx.RunApp"); 
63         System.out.println("enable incremental parsing     - java -cp lexx.jar -Dincrementalast=true lexx.RunApp"); 
64         System.out.println("to run logger externally       - java -cp lexx.jar lexx.RunLogger"); 
65         System.out.println("to run all automated test      - java -cp lexx.jar lexx.test.AllTest"); 
66         System.out.println("to run applet                  - appletviewer -cp lexx.jar lexx.RunApplet"); 
67         new lexx.gui.startup.StartupScreen(new JLabel()); 
68       } 
69       catch(Exception e) 
70       { 
71         e.printStackTrace(); 
72       } 
73     } 
74    
75     public static void setupProxy() 
76     { 
77       //Checking proxy settings 
78       Properties properties = System.getProperties(); 
79       if(LocalSettings.getProperty("http.proxyHost") != null) 
80       { 
81         properties.put("http.proxyHost", 
82                        LocalSettings.getProperty("http.proxyHost")); 
83       } 
84       if(LocalSettings.getProperty("http.proxyPort") != null) 
85       { 
86         properties.put("http.proxyPort", 
87                        LocalSettings.getProperty("http.proxyPort")); 
88    
89       } 
90       System.setProperties(properties); 
91    
92       if(!lexx.utils.Utilities.checkURL("http://www.google.com")) 
93       { 
94         new lexx.server.ProxySettings(new JFrame(), 
95                                       "Unable to connect to internet", true); 
96       } 
97     } 
98    
99     public static void setupLogger() 
100    { 
101      //Please do not remove this section of coding or logging will not work 
102      try 
103      { 
104        final java.net.Socket s = new java.net.Socket("127.0.0.1", 4445); 
105        s.close(); 
106        //this setups up the log4j gui 
107        BasicConfigurator.configure(new org.apache.log4j.net.SocketAppender( 
108            "127.0.0.1", 4445)); 
109        org.apache.log4j.LogManager.getRootLogger().setLevel(org.apache.log4j. 
110            Level.ALL); 
111  //      org.apache.log4j.LogManager.getRootLogger().setLevel(org.apache.log4j. 
112  //          Level.WARN ); 
113        log.info("Logger is turned on"); 
114      } 
115      catch(IOException ex) 
116      { //This turns off the logger 
117        org.apache.log4j.LogManager.getRootLogger().setLevel(org.apache.log4j. 
118            Level.OFF); 
119      } 
120      catch(Exception ex) 
121      { 
122        ex.printStackTrace(); 
123      } 
124    } 
125  }