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

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

AEI2: .NET detection

File size: 4.8 KB
RevLine 
[591]1package net.oni2.aeinstaller;
2
[593]3import java.awt.image.BufferedImage;
[591]4import java.io.File;
5import java.io.FileNotFoundException;
[593]6import java.io.IOException;
[591]7import java.io.PrintStream;
[593]8import java.net.URL;
[592]9import java.util.ResourceBundle;
[591]10
[593]11import javax.imageio.ImageIO;
[591]12import javax.swing.JFrame;
[592]13import javax.swing.JOptionPane;
[591]14import javax.swing.JToolBar;
15import javax.swing.SwingUtilities;
16import javax.swing.UIManager;
17import javax.swing.UIManager.LookAndFeelInfo;
18
[594]19import net.oni2.aeinstaller.backend.OniSplit;
[591]20import net.oni2.aeinstaller.backend.Settings;
[593]21import net.oni2.aeinstaller.backend.Settings.Platform;
[591]22import net.oni2.aeinstaller.backend.StuffToRefactorLater;
23import net.oni2.aeinstaller.backend.depot.DepotManager;
24import net.oni2.aeinstaller.gui.MainWin;
25
26import org.javabuilders.swing.SwingJavaBuilder;
[593]27import org.simplericity.macify.eawt.Application;
28import org.simplericity.macify.eawt.DefaultApplication;
[591]29
30/**
31 * @author Christian Illy
32 */
33public class AEInstaller2 {
34
[593]35 private static ResourceBundle imagesBundle = ResourceBundle
36 .getBundle(AEInstaller2.class.getPackage().getName() + ".Images");
37 private static ResourceBundle basicBundle = ResourceBundle
38 .getBundle(AEInstaller2.class.getPackage().getName()
39 + ".AEInstaller");
40
41 private static Application app = null;
42
43 private static void initMacOS() {
44 System.setProperty("apple.laf.useScreenMenuBar", "true");
45 System.setProperty("com.apple.mrj.application.apple.menu.about.name",
46 basicBundle.getString("appname"));
47 app = new DefaultApplication();
48
49 URL icon = AEInstaller2.class.getResource("images/AElogo.png");
50 try {
51 BufferedImage img = ImageIO.read(icon);
52 app.setApplicationIconImage(img);
53 } catch (IOException e) {
54 // TODO Auto-generated catch block
55 e.printStackTrace();
56 }
57 }
58
[591]59 /**
60 * @param args
61 * Command line arguments
62 */
63 public static void main(String[] args) {
64 new File(Settings.getPrefsPath()).mkdirs();
65 new File(Settings.getDownloadPath()).mkdirs();
66
67 boolean debug = false;
68 for (String a : args)
69 if (a.equalsIgnoreCase("-debug"))
70 debug = true;
71 if (!debug) {
72 try {
73 System.setOut(new PrintStream(Settings.getPrefsPath()
74 + "aei_output.log"));
75 System.setErr(new PrintStream(Settings.getPrefsPath()
76 + "aei_error.log"));
77 } catch (FileNotFoundException e1) {
78 e1.printStackTrace();
79 }
80 }
81
[593]82 if (Settings.getPlatform() == Platform.MACOS)
83 initMacOS();
84
[591]85 Settings.deserializeFromFile();
86 Settings.setDebug(debug);
87 DepotManager.getInstance().loadFromFile(
88 new File(Settings.getDepotCacheFilename()));
89
[592]90 SwingJavaBuilder.getConfig().addResourceBundle(imagesBundle);
91 SwingJavaBuilder.getConfig().addResourceBundle(basicBundle);
[591]92 SwingJavaBuilder.getConfig().setMarkInvalidResourceBundleKeys(true);
93 SwingJavaBuilder.getConfig().addType("JToolBarSeparator",
94 JToolBar.Separator.class);
95
96 System.setProperty("networkaddress.cache.ttl", "5");
97 System.setProperty("networkaddress.cache.negative.ttl", "1");
[593]98
[591]99 try {
100 String laf = Settings.getInstance().get("lookandfeel",
101 (String) null);
102 if (laf == null) {
[593]103 if (Settings.getPlatform() == Platform.MACOS) {
104 laf = UIManager.getSystemLookAndFeelClassName();
105 } else {
106 for (LookAndFeelInfo lafInfo : UIManager
107 .getInstalledLookAndFeels()) {
108 if (lafInfo.getName().equals("Nimbus"))
109 laf = lafInfo.getClassName();
110 }
[591]111 }
112 }
113 if (laf == null)
114 laf = UIManager.getSystemLookAndFeelClassName();
115 UIManager.setLookAndFeel(laf);
116 } catch (Exception e) {
117 e.printStackTrace();
118 }
119 JFrame.setDefaultLookAndFeelDecorated(true);
120
121 // TODO
122 System.out.println("JarPath: " + Settings.getJarPath());
123 System.out.println("PrefsPath: " + Settings.getPrefsPath());
124 System.out.println("DataPath: " + Settings.getDataPath());
125 System.out.println("DownPath: " + Settings.getDownloadPath());
126 System.out.println("TempPath: " + Settings.getTempPath());
127 System.out.println("ValidPath: "
128 + StuffToRefactorLater.verifyRunningDirectory());
[594]129 System.out.println("Platform: " + Settings.getPlatform());
130 System.out.println("Architect: " + Settings.getArchitecture());
131 System.out.println(".NET: " + OniSplit.isDotNETInstalled());
[591]132
[592]133 if (!StuffToRefactorLater.verifyRunningDirectory()) {
134 JOptionPane.showMessageDialog(null,
135 basicBundle.getString("invalidPath.text"),
136 basicBundle.getString("invalidPath.title"),
137 JOptionPane.ERROR_MESSAGE);
138 if (!Settings.getDebug()) {
139 return;
140 }
141 }
142
[591]143 SwingUtilities.invokeLater(new Runnable() {
144
145 public void run() {
146 try {
[593]147 MainWin mw = new MainWin();
148 if (app != null) {
149 app.addAboutMenuItem();
150 app.setEnabledAboutMenu(true);
151 app.addPreferencesMenuItem();
152 app.setEnabledPreferencesMenu(true);
153 app.addApplicationListener(mw);
154 }
155 mw.setVisible(true);
[591]156 } catch (Exception e) {
157 e.printStackTrace();
158 }
159 }
160 });
161
162 }
163}
Note: See TracBrowser for help on using the repository browser.