source: AE/installer2/src/net/oni2/aeinstaller/AEInstaller2.java@ 592

Last change on this file since 592 was 592, checked in by alloc, 12 years ago

AEI - Current state

File size: 3.6 KB
Line 
1package net.oni2.aeinstaller;
2
3import java.io.File;
4import java.io.FileNotFoundException;
5import java.io.PrintStream;
6import java.util.ResourceBundle;
7
8import javax.swing.JFrame;
9import javax.swing.JOptionPane;
10import javax.swing.JToolBar;
11import javax.swing.SwingUtilities;
12import javax.swing.UIManager;
13import javax.swing.UIManager.LookAndFeelInfo;
14
15import net.oni2.aeinstaller.backend.Settings;
16import net.oni2.aeinstaller.backend.StuffToRefactorLater;
17import net.oni2.aeinstaller.backend.depot.DepotManager;
18import net.oni2.aeinstaller.gui.MainWin;
19
20import org.javabuilders.swing.SwingJavaBuilder;
21
22/**
23 * @author Christian Illy
24 * @version 0.1
25 */
26public class AEInstaller2 {
27
28 /**
29 * @param args
30 * Command line arguments
31 */
32 public static void main(String[] args) {
33 new File(Settings.getPrefsPath()).mkdirs();
34 new File(Settings.getDownloadPath()).mkdirs();
35
36 boolean debug = false;
37 for (String a : args)
38 if (a.equalsIgnoreCase("-debug"))
39 debug = true;
40 if (!debug) {
41 try {
42 System.setOut(new PrintStream(Settings.getPrefsPath()
43 + "aei_output.log"));
44 System.setErr(new PrintStream(Settings.getPrefsPath()
45 + "aei_error.log"));
46 } catch (FileNotFoundException e1) {
47 e1.printStackTrace();
48 }
49 }
50
51 Settings.deserializeFromFile();
52 Settings.setDebug(debug);
53 DepotManager.getInstance().loadFromFile(
54 new File(Settings.getDepotCacheFilename()));
55
56 ResourceBundle imagesBundle = ResourceBundle
57 .getBundle(AEInstaller2.class.getPackage().getName()
58 + ".Images");
59 ResourceBundle basicBundle = ResourceBundle
60 .getBundle(AEInstaller2.class.getPackage().getName()
61 + ".AEInstaller");
62
63 SwingJavaBuilder.getConfig().addResourceBundle(imagesBundle);
64 SwingJavaBuilder.getConfig().addResourceBundle(basicBundle);
65 SwingJavaBuilder.getConfig().setMarkInvalidResourceBundleKeys(true);
66 SwingJavaBuilder.getConfig().addType("JToolBarSeparator",
67 JToolBar.Separator.class);
68 // SwingJavaBuilder.getConfig().addType("ScreenshotBrowser",
69 // ScreenshotBrowser.class);
70 // SwingJavaBuilder.getConfig().addType("HTMLLinkLabel",
71 // HTMLLinkLabel.class);
72
73 System.setProperty("networkaddress.cache.ttl", "5");
74 System.setProperty("networkaddress.cache.negative.ttl", "1");
75
76 try {
77 String laf = Settings.getInstance().get("lookandfeel",
78 (String) null);
79 if (laf == null) {
80 for (LookAndFeelInfo lafInfo : UIManager
81 .getInstalledLookAndFeels()) {
82 if (lafInfo.getName().equals("Nimbus"))
83 laf = lafInfo.getClassName();
84 }
85 }
86 if (laf == null)
87 laf = UIManager.getSystemLookAndFeelClassName();
88 UIManager.setLookAndFeel(laf);
89 } catch (Exception e) {
90 e.printStackTrace();
91 }
92 JFrame.setDefaultLookAndFeelDecorated(true);
93
94 // TODO
95 System.out.println("JarPath: " + Settings.getJarPath());
96 System.out.println("PrefsPath: " + Settings.getPrefsPath());
97 System.out.println("DataPath: " + Settings.getDataPath());
98 System.out.println("DownPath: " + Settings.getDownloadPath());
99 System.out.println("TempPath: " + Settings.getTempPath());
100 System.out.println("ValidPath: "
101 + StuffToRefactorLater.verifyRunningDirectory());
102
103 if (!StuffToRefactorLater.verifyRunningDirectory()) {
104 JOptionPane.showMessageDialog(null,
105 basicBundle.getString("invalidPath.text"),
106 basicBundle.getString("invalidPath.title"),
107 JOptionPane.ERROR_MESSAGE);
108 if (!Settings.getDebug()) {
109 return;
110 }
111 }
112
113 SwingUtilities.invokeLater(new Runnable() {
114
115 public void run() {
116 try {
117 new MainWin().setVisible(true);
118 } catch (Exception e) {
119 e.printStackTrace();
120 }
121 }
122 });
123
124 }
125}
Note: See TracBrowser for help on using the repository browser.