Merge pull request #589 from itshanney/feature/fix-macos-after-java11-upgrade
Fix macOS after java11 upgrade
This commit is contained in:
commit
d7f0fcb91c
@ -6,7 +6,7 @@ addons:
|
|||||||
packages:
|
packages:
|
||||||
- ant-optional
|
- ant-optional
|
||||||
jdk:
|
jdk:
|
||||||
- openjdk8
|
- openjdk11
|
||||||
- openjdk13
|
- openjdk13
|
||||||
script:
|
script:
|
||||||
- "ant -buildfile build.xml clean check jar unittest"
|
- "ant -buildfile build.xml clean check jar unittest"
|
||||||
|
@ -108,7 +108,6 @@
|
|||||||
<zipfileset src="${lib.dir}/jcommon-1.0.18.jar"/>
|
<zipfileset src="${lib.dir}/jcommon-1.0.18.jar"/>
|
||||||
<zipfileset src="${lib.dir}/jfreechart-1.0.15.jar"/>
|
<zipfileset src="${lib.dir}/jfreechart-1.0.15.jar"/>
|
||||||
<zipfileset src="${core.dir}/lib/opencsv-4.3.2.jar"/>
|
<zipfileset src="${core.dir}/lib/opencsv-4.3.2.jar"/>
|
||||||
<zipfileset src="${lib.dir}/OrangeExtensions-1.2.jar"/>
|
|
||||||
<zipfileset src="${core.dir}/lib/annotation-detector-3.0.5.jar"/>
|
<zipfileset src="${core.dir}/lib/annotation-detector-3.0.5.jar"/>
|
||||||
<zipfileset src="${core.dir}/lib/slf4j-api-1.7.30.jar"/>
|
<zipfileset src="${core.dir}/lib/slf4j-api-1.7.30.jar"/>
|
||||||
<zipfileset src="${core.dir}/lib/logback-classic-1.2.3.jar"/>
|
<zipfileset src="${core.dir}/lib/logback-classic-1.2.3.jar"/>
|
||||||
|
Binary file not shown.
@ -1,7 +1,12 @@
|
|||||||
package net.sf.openrocket.startup;
|
package net.sf.openrocket.startup;
|
||||||
|
|
||||||
|
import java.awt.Desktop;
|
||||||
import java.awt.Image;
|
import java.awt.Image;
|
||||||
|
import java.awt.Taskbar;
|
||||||
import java.awt.Toolkit;
|
import java.awt.Toolkit;
|
||||||
|
import java.awt.desktop.AboutHandler;
|
||||||
|
import java.awt.desktop.PreferencesHandler;
|
||||||
|
import java.awt.desktop.QuitHandler;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
@ -11,13 +16,6 @@ import net.sf.openrocket.arch.SystemInfo.Platform;
|
|||||||
import net.sf.openrocket.gui.dialogs.AboutDialog;
|
import net.sf.openrocket.gui.dialogs.AboutDialog;
|
||||||
import net.sf.openrocket.gui.dialogs.preferences.PreferencesDialog;
|
import net.sf.openrocket.gui.dialogs.preferences.PreferencesDialog;
|
||||||
import net.sf.openrocket.gui.main.BasicFrame;
|
import net.sf.openrocket.gui.main.BasicFrame;
|
||||||
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
|
* Static code for initialization of OSX UI Elements: Menu, Icon, Name and
|
||||||
@ -38,34 +36,21 @@ final class OSXSetup {
|
|||||||
/**
|
/**
|
||||||
* The handler for the Quit item in the OSX app menu
|
* The handler for the Quit item in the OSX app menu
|
||||||
*/
|
*/
|
||||||
private static final QuitHandler qh = new QuitHandler() {
|
private static final QuitHandler QUIT_HANDLER = (e, r) -> {
|
||||||
@Override
|
|
||||||
public void handleQuitRequestWith(final QuitEvent e, final QuitResponse r) {
|
|
||||||
BasicFrame.quitAction();
|
BasicFrame.quitAction();
|
||||||
// if we get here the user canceled
|
// if we get here the user canceled
|
||||||
r.cancelQuit();
|
r.cancelQuit();
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The handler for the About item in the OSX app menu
|
* The handler for the About item in the OSX app menu
|
||||||
*/
|
*/
|
||||||
private static final AboutHandler ah = new AboutHandler() {
|
private static final AboutHandler ABOUT_HANDLER = a -> new AboutDialog(null).setVisible(true);
|
||||||
@Override
|
|
||||||
public void handleAbout(final AboutEvent a) {
|
|
||||||
new AboutDialog(null).setVisible(true);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The handler for the Preferences item in the OSX app menu
|
* The handler for the Preferences item in the OSX app menu
|
||||||
*/
|
*/
|
||||||
private static final PreferencesHandler ph = new PreferencesHandler() {
|
private static final PreferencesHandler PREFERENCES_HANDLER = p -> PreferencesDialog.showPreferences(null);
|
||||||
@Override
|
|
||||||
public void handlePreferences(final PreferencesEvent p) {
|
|
||||||
PreferencesDialog.showPreferences(null);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets up the Application's Icon, Name, Menu and some menu item handlers
|
* Sets up the Application's Icon, Name, Menu and some menu item handlers
|
||||||
@ -87,24 +72,24 @@ final class OSXSetup {
|
|||||||
|
|
||||||
// This line must come AFTER the above properties are set, otherwise
|
// This line must come AFTER the above properties are set, otherwise
|
||||||
// the name will not appear
|
// the name will not appear
|
||||||
final com.apple.eawt.Application osxApp = com.apple.eawt.Application.getApplication();
|
final Desktop osxDesktop = Desktop.getDesktop();
|
||||||
|
|
||||||
if (osxApp == null) {
|
if (osxDesktop == null) {
|
||||||
// Application is null: Something is wrong, give up on OSX
|
// Application is null: Something is wrong, give up on OS setup
|
||||||
// setup.
|
|
||||||
throw new NullPointerException("com.apple.eawt.Application.getApplication() returned NULL. "
|
throw new NullPointerException("com.apple.eawt.Application.getApplication() returned NULL. "
|
||||||
+ "Aborting OSX UI Setup.");
|
+ "Aborting OSX UI Setup.");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set handlers
|
// Set handlers
|
||||||
osxApp.setQuitHandler(qh);
|
osxDesktop.setAboutHandler(ABOUT_HANDLER);
|
||||||
osxApp.setAboutHandler(ah);
|
osxDesktop.setPreferencesHandler(PREFERENCES_HANDLER);
|
||||||
osxApp.setPreferencesHandler(ph);
|
osxDesktop.setQuitHandler(QUIT_HANDLER);
|
||||||
|
|
||||||
// Set the dock icon to the largest icon
|
// Set the dock icon to the largest icon
|
||||||
final Image dockIcon = Toolkit.getDefaultToolkit().getImage(
|
final Image dockIcon = Toolkit.getDefaultToolkit().getImage(
|
||||||
SwingStartup.class.getResource(ICON_RSRC));
|
SwingStartup.class.getResource(ICON_RSRC));
|
||||||
osxApp.setDockIconImage(dockIcon);
|
final Taskbar osxTaskbar = Taskbar.getTaskbar();
|
||||||
|
osxTaskbar.setIconImage(dockIcon);
|
||||||
|
|
||||||
} catch (final Throwable t) {
|
} catch (final Throwable t) {
|
||||||
// None of the preceding is critical to the app,
|
// None of the preceding is critical to the app,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user