Include OSX UI elements.
"OrangeExtensions" jar provides stubs for compilation and linking on other OSs.
This commit is contained in:
parent
51433fac5f
commit
26329cedec
@ -30,5 +30,6 @@
|
|||||||
<classpathentry kind="lib" path="lib/exp4j-0.2.9.jar"/>
|
<classpathentry kind="lib" path="lib/exp4j-0.2.9.jar"/>
|
||||||
<classpathentry kind="lib" path="lib/jogl/gluegen-rt.jar"/>
|
<classpathentry kind="lib" path="lib/jogl/gluegen-rt.jar"/>
|
||||||
<classpathentry kind="lib" path="lib/jogl/jogl.all.jar"/>
|
<classpathentry kind="lib" path="lib/jogl/jogl.all.jar"/>
|
||||||
|
<classpathentry kind="lib" path="lib/OrangeExtensions-1.2.jar"/>
|
||||||
<classpathentry kind="output" path="bin"/>
|
<classpathentry kind="output" path="bin"/>
|
||||||
</classpath>
|
</classpath>
|
||||||
|
@ -1,3 +1,9 @@
|
|||||||
|
2012-06-24 Bill Kuker
|
||||||
|
|
||||||
|
* OSX UI Elements: Screen menu bar, Application name, Dock Icon, Quit, About & Preference
|
||||||
|
handlers. Stubs for the "Apple Java Extensions" to allow other platforms to compile provided
|
||||||
|
by https://github.com/ymasory/OrangeExtensions.
|
||||||
|
|
||||||
2012-06-05 Doug Pedrick
|
2012-06-05 Doug Pedrick
|
||||||
|
|
||||||
* Most recently used design files added to File menu.
|
* Most recently used design files added to File menu.
|
||||||
|
@ -76,7 +76,7 @@
|
|||||||
<attribute name="Rsrc-Main-Class" value="${main-class}" />
|
<attribute name="Rsrc-Main-Class" value="${main-class}" />
|
||||||
<attribute name="SplashScreen-Image" value="pix/splashscreen.png" />
|
<attribute name="SplashScreen-Image" value="pix/splashscreen.png" />
|
||||||
<attribute name="Class-Path" value="." />
|
<attribute name="Class-Path" value="." />
|
||||||
<attribute name="Rsrc-Class-Path" value="./ main/${ant.project.name}-Core.jar lib/jfreechart-1.0.13.jar lib/jcommon-1.0.16.jar lib/gluegen-rt.jar lib/miglayout15-swing.jar lib/iText-5.0.2.jar lib/jogl.all.jar lib/opencsv-2.3.jar" />
|
<attribute name="Rsrc-Class-Path" value="./ main/${ant.project.name}-Core.jar lib/jfreechart-1.0.13.jar lib/jcommon-1.0.16.jar lib/gluegen-rt.jar lib/miglayout15-swing.jar lib/iText-5.0.2.jar lib/jogl.all.jar lib/opencsv-2.3.jar lib/OrangeExtensions-1.2.jar" />
|
||||||
</manifest>
|
</manifest>
|
||||||
|
|
||||||
<!-- Unzip the Eclipse JIJ Loader -->
|
<!-- Unzip the Eclipse JIJ Loader -->
|
||||||
|
BIN
core/lib/OrangeExtensions-1.2.jar
Normal file
BIN
core/lib/OrangeExtensions-1.2.jar
Normal file
Binary file not shown.
115
core/src/net/sf/openrocket/startup/OSXStartup.java
Normal file
115
core/src/net/sf/openrocket/startup/OSXStartup.java
Normal file
@ -0,0 +1,115 @@
|
|||||||
|
package net.sf.openrocket.startup;
|
||||||
|
|
||||||
|
import java.awt.Image;
|
||||||
|
import java.awt.Toolkit;
|
||||||
|
|
||||||
|
import net.sf.openrocket.arch.SystemInfo;
|
||||||
|
import net.sf.openrocket.arch.SystemInfo.Platform;
|
||||||
|
import net.sf.openrocket.gui.dialogs.AboutDialog;
|
||||||
|
import net.sf.openrocket.gui.dialogs.preferences.PreferencesDialog;
|
||||||
|
import net.sf.openrocket.gui.main.BasicFrame;
|
||||||
|
import net.sf.openrocket.logging.LogHelper;
|
||||||
|
|
||||||
|
import com.apple.eawt.AboutHandler;
|
||||||
|
import com.apple.eawt.PreferencesHandler;
|
||||||
|
import com.apple.eawt.QuitHandler;
|
||||||
|
import com.apple.eawt.QuitResponse;
|
||||||
|
import com.apple.eawt.AppEvent.AboutEvent;
|
||||||
|
import com.apple.eawt.AppEvent.PreferencesEvent;
|
||||||
|
import com.apple.eawt.AppEvent.QuitEvent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Static code for initialization of OSX UI Elements: Menu, Icon, Name and
|
||||||
|
* Application menu handlers.
|
||||||
|
*
|
||||||
|
* @author Bill Kuker <bkuker@billkuker.com>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
final class OSXStartup {
|
||||||
|
private static final LogHelper log = Application.getLogger();
|
||||||
|
|
||||||
|
// The name in the app menu
|
||||||
|
private static final String APP_NAME = "OpenRocket";
|
||||||
|
|
||||||
|
// The image resource to use for the Dock Icon
|
||||||
|
private static final String ICON_RSRC = "/pix/icon/icon-256.png";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The handler for the Quit item in the OSX app menu
|
||||||
|
*/
|
||||||
|
private static final QuitHandler qh = new QuitHandler() {
|
||||||
|
@Override
|
||||||
|
public void handleQuitRequestWith(final QuitEvent e, final QuitResponse r) {
|
||||||
|
BasicFrame.quitAction();
|
||||||
|
// if we get here the user canceled
|
||||||
|
r.cancelQuit();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The handler for the About item in the OSX app menu
|
||||||
|
*/
|
||||||
|
private static final AboutHandler ah = new AboutHandler() {
|
||||||
|
@Override
|
||||||
|
public void handleAbout(final AboutEvent a) {
|
||||||
|
new AboutDialog(null).setVisible(true);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The handler for the Preferences item in the OSX app menu
|
||||||
|
*/
|
||||||
|
private static final PreferencesHandler ph = new PreferencesHandler() {
|
||||||
|
@Override
|
||||||
|
public void handlePreferences(final PreferencesEvent p) {
|
||||||
|
PreferencesDialog.showPreferences(null);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets up the Application's Icon, Name, Menu and some menu item handlers
|
||||||
|
* for Apple OSX. This method needs to be called before other AWT or Swing
|
||||||
|
* things happen, or parts will fail to work.
|
||||||
|
*
|
||||||
|
* This function should fail gracefully if the OS is wrong.
|
||||||
|
*/
|
||||||
|
static void setupOSX() {
|
||||||
|
if (SystemInfo.getPlatform() != Platform.MAC_OS) {
|
||||||
|
log.warn("Attempting to set up OSX UI on non-MAC_OS");
|
||||||
|
}
|
||||||
|
log.debug("Setting up OSX UI Elements");
|
||||||
|
try {
|
||||||
|
// Put the menu bar at the top of the screen
|
||||||
|
System.setProperty("apple.laf.useScreenMenuBar", "true");
|
||||||
|
// Set the name in the menu
|
||||||
|
System.setProperty("com.apple.mrj.application.apple.menu.about.name", APP_NAME);
|
||||||
|
|
||||||
|
// This line must come AFTER the above properties are set, otherwise
|
||||||
|
// the name will not appear
|
||||||
|
final com.apple.eawt.Application osxApp = com.apple.eawt.Application.getApplication();
|
||||||
|
|
||||||
|
if (osxApp == null) {
|
||||||
|
// Application is null: Something is wrong, give up on OSX
|
||||||
|
// setup.
|
||||||
|
throw new NullPointerException("com.apple.eawt.Application.getApplication() returned NULL. "
|
||||||
|
+ "Aborting OSX UI Setup.");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set handlers
|
||||||
|
osxApp.setQuitHandler(qh);
|
||||||
|
osxApp.setAboutHandler(ah);
|
||||||
|
osxApp.setPreferencesHandler(ph);
|
||||||
|
|
||||||
|
// Set the dock icon to the largest icon
|
||||||
|
final Image dockIcon = Toolkit.getDefaultToolkit().getImage(
|
||||||
|
Startup2.class.getResource(ICON_RSRC));
|
||||||
|
osxApp.setDockIconImage(dockIcon);
|
||||||
|
|
||||||
|
} catch (final Throwable t) {
|
||||||
|
// None of the preceding is critical to the app,
|
||||||
|
// so at worst case log an error and continue
|
||||||
|
log.warn("Error setting up OSX UI:", t);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -9,6 +9,8 @@ import javax.swing.SwingUtilities;
|
|||||||
import javax.swing.Timer;
|
import javax.swing.Timer;
|
||||||
import javax.swing.ToolTipManager;
|
import javax.swing.ToolTipManager;
|
||||||
|
|
||||||
|
import net.sf.openrocket.arch.SystemInfo;
|
||||||
|
import net.sf.openrocket.arch.SystemInfo.Platform;
|
||||||
import net.sf.openrocket.communication.UpdateInfo;
|
import net.sf.openrocket.communication.UpdateInfo;
|
||||||
import net.sf.openrocket.communication.UpdateInfoRetriever;
|
import net.sf.openrocket.communication.UpdateInfoRetriever;
|
||||||
import net.sf.openrocket.database.ComponentPresetDatabase;
|
import net.sf.openrocket.database.ComponentPresetDatabase;
|
||||||
@ -52,6 +54,11 @@ public class Startup2 {
|
|||||||
VersionHelper.checkVersion();
|
VersionHelper.checkVersion();
|
||||||
VersionHelper.checkOpenJDK();
|
VersionHelper.checkOpenJDK();
|
||||||
|
|
||||||
|
// If running on a MAC set up OSX UI Elements.
|
||||||
|
if ( SystemInfo.getPlatform() == Platform.MAC_OS ){
|
||||||
|
OSXStartup.setupOSX();
|
||||||
|
}
|
||||||
|
|
||||||
// Run the actual startup method in the EDT since it can use progress dialogs etc.
|
// Run the actual startup method in the EDT since it can use progress dialogs etc.
|
||||||
log.info("Moving startup to EDT");
|
log.info("Moving startup to EDT");
|
||||||
SwingUtilities.invokeAndWait(new Runnable() {
|
SwingUtilities.invokeAndWait(new Runnable() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user