KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > edu > umd > cs > findbugs > gui2 > Driver


1 /*
2  * FindBugs - Find Bugs in Java programs
3  * Copyright (C) 2006, University of Maryland
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston MA 02111-1307, USA
18  */

19
20 package edu.umd.cs.findbugs.gui2;
21
22 import java.io.File JavaDoc;
23 import java.io.IOException JavaDoc;
24 import java.lang.management.ManagementFactory JavaDoc;
25 import java.lang.management.ThreadMXBean JavaDoc;
26 import java.lang.reflect.Method JavaDoc;
27 import java.util.ArrayList JavaDoc;
28 import java.util.Iterator JavaDoc;
29
30 import javax.swing.JOptionPane JavaDoc;
31 import javax.swing.UIManager JavaDoc;
32
33 import org.dom4j.DocumentException;
34
35 import com.apple.eawt.Application;
36
37 import edu.umd.cs.findbugs.BugInstance;
38 import edu.umd.cs.findbugs.DetectorFactory;
39 import edu.umd.cs.findbugs.DetectorFactoryCollection;
40 import edu.umd.cs.findbugs.FindBugs;
41 import edu.umd.cs.findbugs.Project;
42 import edu.umd.cs.findbugs.SortedBugCollection;
43 import edu.umd.cs.findbugs.SystemProperties;
44 import edu.umd.cs.findbugs.config.UserPreferences;
45 import edu.umd.cs.findbugs.gui.FindBugsFrame;
46
47 /**
48  * This is where it all begins
49  * run with -f int to set font size
50  * run with -clear to clear recent projects menu, or any other issues with program not starting properly due to
51  * something being corrupted (or just faulty) in backend store for GUISaveState.
52  *
53  */

54 public class Driver {
55     
56     private static float fontSize = 12;
57     private static boolean docking = true;
58     private static SplashFrame splash;
59     
60     public static void main(String JavaDoc[] args) throws Exception JavaDoc {
61         if (SystemProperties.getProperty("os.name").startsWith("Mac"))
62         {
63             System.setProperty("apple.laf.useScreenMenuBar","true");
64             System.setProperty("com.apple.mrj.application.apple.menu.about.name", "FindBugs");
65             Debug.println("Mac OS detected");
66         }
67         
68         splash = new SplashFrame();
69         splash.setVisible(true);
70         
71                 
72         try {
73             Class.forName("net.infonode.docking.DockingWindow");
74             Class.forName("edu.umd.cs.findbugs.gui2.DockLayout");
75         } catch (Exception JavaDoc e) {
76             docking = false;
77         }
78         for(int i = 0; i < args.length; i++){
79             if((args[i].equals("-f")) && (i+1 < args.length)){
80                 float num = 0;
81                 try{
82                     i++;
83                     num = Integer.valueOf(args[i]);
84                 }
85                 catch(NumberFormatException JavaDoc exc){
86                     num = fontSize;
87                 }
88                 fontSize = num;
89             }
90             
91             if(args[i].startsWith("--font=")){
92                 float num = 0;
93                 try{
94                     num = Integer.valueOf(args[i].substring("--font=".length()));
95                 }
96                 catch(NumberFormatException JavaDoc exc){
97                     num = fontSize;
98                 }
99                 fontSize = num;
100             }
101             
102             if(args[i].equals("-clear")){
103                 GUISaveState.clear();
104                 System.exit(0);
105             }
106             
107             if (args[i].equals("-d") || args[i].equals("--nodock"))
108                 docking = false;
109         }
110
111         try {
112         GUISaveState.loadInstance();
113         } catch (RuntimeException JavaDoc e) {
114             GUISaveState.clear();
115             e.printStackTrace();
116         }
117
118         // System.setProperty("findbugs.home",".."+File.separator+"findbugs");
119
DetectorFactoryCollection.instance();
120
121 // The bug with serializable idiom detection has been fixed on the findbugs end.
122
// DetectorFactory serializableIdiomDetector=DetectorFactoryCollection.instance().getFactory("SerializableIdiom");
123
// System.out.println(serializableIdiomDetector.getFullName());
124
// UserPreferences.getUserPreferences().enableDetector(serializableIdiomDetector,false);
125

126         FindBugsLayoutManagerFactory factory;
127
128         if (isDocking())
129             factory = new FindBugsLayoutManagerFactory("edu.umd.cs.findbugs.gui2.DockLayout");
130         else
131             factory = new FindBugsLayoutManagerFactory(SplitLayout.class.getName());
132         MainFrame.makeInstance(factory);
133         
134         splash.setVisible(false);
135         splash.dispose();
136     }
137     
138     public static void removeSplashScreen() {
139         splash.setVisible(false);
140         splash.dispose();
141     }
142     public static boolean isDocking()
143     {
144         return docking;
145     }
146     
147     public static float getFontSize(){
148         return fontSize;
149     }
150 }
Popular Tags