1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25 package net.sf.bluecove.se;
26
27 import java.awt.GraphicsEnvironment;
28 import java.util.Iterator;
29 import java.util.Properties;
30 import java.util.Vector;
31
32 import net.sf.bluecove.util.CollectionUtils;
33
34
35
36
37
38 public class Main {
39
40 public static void main(String[] args) {
41 for (int i = 0; i < args.length; i++) {
42 if (args[i].equalsIgnoreCase("--debug") || args[i].equals("-d")) {
43 System.setProperty("bluecove.debug", "true");
44 } else if (args[i].equalsIgnoreCase("--agui")) {
45 runAGUI(args);
46 return;
47 } else if (args[i].equalsIgnoreCase("--swing") || args[i].equals("-s")) {
48 runAGUI(args);
49 return;
50 } else if (args[i].equalsIgnoreCase("--awt") || args[i].equals("-a")) {
51 runAWT(args);
52 return;
53 } else if (args[i].equalsIgnoreCase("--console") || args[i].equals("-c")) {
54 runConsole(args);
55 return;
56 } else if (args[i].equalsIgnoreCase("--help") || args[i].equals("-h")) {
57 System.out.println(" --swing|--agui|-s\n --console|-c\n --awt|-a (--debug)");
58 return;
59 }
60 }
61
62
63 if ("true".equals(System.getProperty("java.awt.headless"))) {
64 runConsole(args);
65 return;
66 }
67 if (GraphicsEnvironment.isHeadless()) {
68 runConsole(args);
69 return;
70 }
71 String gui = System.getProperty("awt.toolkit");
72 if ((gui != null) && (gui.indexOf("AGUI") != -1)) {
73 runAGUI(args);
74 return;
75 }
76
77 String vm = System.getProperty("java.vm.name");
78 if ((vm != null) && (vm.indexOf("CDC") != -1)) {
79 runAGUI(args);
80 return;
81 }
82 runAWT(args);
83 }
84
85 static void runConsole(String[] args) {
86 Console.main(args);
87 }
88
89 static void runAGUI(String[] args) {
90 net.sf.bluecove.swing.Main.main(args);
91 }
92
93 static void runAWT(String[] args) {
94 net.sf.bluecove.awt.Main.main(args);
95 }
96
97 public static void printSystemProperties() {
98 StringBuffer sysProperties = new StringBuffer();
99 Properties properties = System.getProperties();
100
101 Vector list2sort = new Vector();
102 int max_key = 0;
103 for (Iterator iterator = properties.keySet().iterator(); iterator.hasNext();) {
104 Object keyObj = (Object) iterator.next();
105 String key = keyObj.toString();
106 list2sort.add(key);
107 int len = key.length();
108 if (len > max_key) {
109 max_key = len;
110 }
111 }
112 CollectionUtils.sort(list2sort);
113 if (max_key > 41) {
114 max_key = 41;
115 }
116
117 for (Iterator iterator = list2sort.iterator(); iterator.hasNext();) {
118 String key = (String) iterator.next();
119 StringBuffer key_p = new StringBuffer(key);
120 while (key_p.length() < max_key) {
121 key_p.append(" ");
122 }
123 String value = (String) properties.get(key);
124 if (value == null) {
125 value = "{null}";
126 }
127 StringBuffer value_p = new StringBuffer(value);
128 value_p.append("]");
129 while (value_p.length() < 60) {
130 value_p.append(" ");
131 }
132 sysProperties.append(" \t" + key_p.toString() + " = [" + value_p.toString() + "\n");
133 }
134 System.out.println("System Properties:\n" + sysProperties.toString());
135 }
136 }