| 1 |
|
package net.oni2.aeinstaller; |
| 2 |
|
|
| 3 |
+ |
import java.awt.image.BufferedImage; |
| 4 |
|
import java.io.File; |
| 5 |
|
import java.io.FileNotFoundException; |
| 6 |
+ |
import java.io.IOException; |
| 7 |
|
import java.io.PrintStream; |
| 8 |
+ |
import java.net.URL; |
| 9 |
|
import java.util.ResourceBundle; |
| 10 |
|
|
| 11 |
+ |
import javax.imageio.ImageIO; |
| 12 |
|
import javax.swing.JFrame; |
| 13 |
|
import javax.swing.JOptionPane; |
| 14 |
|
import javax.swing.JToolBar; |
| 17 |
|
import javax.swing.UIManager.LookAndFeelInfo; |
| 18 |
|
|
| 19 |
|
import net.oni2.aeinstaller.backend.Settings; |
| 20 |
+ |
import net.oni2.aeinstaller.backend.Settings.Platform; |
| 21 |
|
import net.oni2.aeinstaller.backend.StuffToRefactorLater; |
| 22 |
|
import net.oni2.aeinstaller.backend.depot.DepotManager; |
| 23 |
|
import net.oni2.aeinstaller.gui.MainWin; |
| 24 |
|
|
| 25 |
|
import org.javabuilders.swing.SwingJavaBuilder; |
| 26 |
+ |
import org.simplericity.macify.eawt.Application; |
| 27 |
+ |
import org.simplericity.macify.eawt.DefaultApplication; |
| 28 |
|
|
| 29 |
|
/** |
| 30 |
|
* @author Christian Illy |
| 24 |
– |
* @version 0.1 |
| 31 |
|
*/ |
| 32 |
|
public class AEInstaller2 { |
| 33 |
|
|
| 34 |
+ |
private static ResourceBundle imagesBundle = ResourceBundle |
| 35 |
+ |
.getBundle(AEInstaller2.class.getPackage().getName() + ".Images"); |
| 36 |
+ |
private static ResourceBundle basicBundle = ResourceBundle |
| 37 |
+ |
.getBundle(AEInstaller2.class.getPackage().getName() |
| 38 |
+ |
+ ".AEInstaller"); |
| 39 |
+ |
|
| 40 |
+ |
private static Application app = null; |
| 41 |
+ |
|
| 42 |
+ |
private static void initMacOS() { |
| 43 |
+ |
System.setProperty("apple.laf.useScreenMenuBar", "true"); |
| 44 |
+ |
System.setProperty("com.apple.mrj.application.apple.menu.about.name", |
| 45 |
+ |
basicBundle.getString("appname")); |
| 46 |
+ |
app = new DefaultApplication(); |
| 47 |
+ |
|
| 48 |
+ |
URL icon = AEInstaller2.class.getResource("images/AElogo.png"); |
| 49 |
+ |
try { |
| 50 |
+ |
BufferedImage img = ImageIO.read(icon); |
| 51 |
+ |
app.setApplicationIconImage(img); |
| 52 |
+ |
} catch (IOException e) { |
| 53 |
+ |
// TODO Auto-generated catch block |
| 54 |
+ |
e.printStackTrace(); |
| 55 |
+ |
} |
| 56 |
+ |
} |
| 57 |
+ |
|
| 58 |
|
/** |
| 59 |
|
* @param args |
| 60 |
|
* Command line arguments |
| 78 |
|
} |
| 79 |
|
} |
| 80 |
|
|
| 81 |
+ |
if (Settings.getPlatform() == Platform.MACOS) |
| 82 |
+ |
initMacOS(); |
| 83 |
+ |
|
| 84 |
|
Settings.deserializeFromFile(); |
| 85 |
|
Settings.setDebug(debug); |
| 86 |
|
DepotManager.getInstance().loadFromFile( |
| 87 |
|
new File(Settings.getDepotCacheFilename())); |
| 88 |
|
|
| 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 |
– |
|
| 89 |
|
SwingJavaBuilder.getConfig().addResourceBundle(imagesBundle); |
| 90 |
|
SwingJavaBuilder.getConfig().addResourceBundle(basicBundle); |
| 91 |
|
SwingJavaBuilder.getConfig().setMarkInvalidResourceBundleKeys(true); |
| 92 |
|
SwingJavaBuilder.getConfig().addType("JToolBarSeparator", |
| 93 |
|
JToolBar.Separator.class); |
| 68 |
– |
// SwingJavaBuilder.getConfig().addType("ScreenshotBrowser", |
| 69 |
– |
// ScreenshotBrowser.class); |
| 70 |
– |
// SwingJavaBuilder.getConfig().addType("HTMLLinkLabel", |
| 71 |
– |
// HTMLLinkLabel.class); |
| 94 |
|
|
| 95 |
|
System.setProperty("networkaddress.cache.ttl", "5"); |
| 96 |
|
System.setProperty("networkaddress.cache.negative.ttl", "1"); |
| 97 |
< |
|
| 97 |
> |
|
| 98 |
|
try { |
| 99 |
|
String laf = Settings.getInstance().get("lookandfeel", |
| 100 |
|
(String) null); |
| 101 |
|
if (laf == null) { |
| 102 |
< |
for (LookAndFeelInfo lafInfo : UIManager |
| 103 |
< |
.getInstalledLookAndFeels()) { |
| 104 |
< |
if (lafInfo.getName().equals("Nimbus")) |
| 105 |
< |
laf = lafInfo.getClassName(); |
| 102 |
> |
if (Settings.getPlatform() == Platform.MACOS) { |
| 103 |
> |
laf = UIManager.getSystemLookAndFeelClassName(); |
| 104 |
> |
} else { |
| 105 |
> |
for (LookAndFeelInfo lafInfo : UIManager |
| 106 |
> |
.getInstalledLookAndFeels()) { |
| 107 |
> |
if (lafInfo.getName().equals("Nimbus")) |
| 108 |
> |
laf = lafInfo.getClassName(); |
| 109 |
> |
} |
| 110 |
|
} |
| 111 |
|
} |
| 112 |
|
if (laf == null) |
| 140 |
|
|
| 141 |
|
public void run() { |
| 142 |
|
try { |
| 143 |
< |
new MainWin().setVisible(true); |
| 143 |
> |
MainWin mw = new MainWin(); |
| 144 |
> |
if (app != null) { |
| 145 |
> |
app.addAboutMenuItem(); |
| 146 |
> |
app.setEnabledAboutMenu(true); |
| 147 |
> |
app.addPreferencesMenuItem(); |
| 148 |
> |
app.setEnabledPreferencesMenu(true); |
| 149 |
> |
app.addApplicationListener(mw); |
| 150 |
> |
} |
| 151 |
> |
mw.setVisible(true); |
| 152 |
|
} catch (Exception e) { |
| 153 |
|
e.printStackTrace(); |
| 154 |
|
} |