diff --git a/.classpath b/.classpath
index a13796d5..d42ccdf4 100644
--- a/.classpath
+++ b/.classpath
@@ -30,6 +30,7 @@
+
diff --git a/build.xml b/build.xml
index a0982a13..8312d965 100644
--- a/build.xml
+++ b/build.xml
@@ -642,8 +642,7 @@
-
-
+
diff --git a/source/net/filebot/Main.java b/source/net/filebot/Main.java
index a81ae3ba..028de235 100644
--- a/source/net/filebot/Main.java
+++ b/source/net/filebot/Main.java
@@ -1,4 +1,3 @@
-//TODO MOVE package net.filebot to net.filebot
package net.filebot;
import static java.awt.GraphicsEnvironment.*;
@@ -284,8 +283,8 @@ public class Main {
});
// window settings
- if (Settings.isMacApp()) {
- MacAppUtilities.setUIDefaults();
+ if (isMacApp()) {
+ MacAppUtilities.initializeApplication();
MacAppUtilities.setWindowCanFullScreen(frame);
}
frame.setLocationByPlatform(true);
diff --git a/source/net/filebot/mac/MacAppUtilities.java b/source/net/filebot/mac/MacAppUtilities.java
index 9c0b2c9e..6628755d 100644
--- a/source/net/filebot/mac/MacAppUtilities.java
+++ b/source/net/filebot/mac/MacAppUtilities.java
@@ -1,8 +1,9 @@
package net.filebot.mac;
+import java.awt.EventQueue;
import java.awt.Window;
+import java.awt.event.WindowEvent;
import java.io.File;
-import java.lang.reflect.Method;
import java.util.logging.Level;
import java.util.logging.Logger;
@@ -10,6 +11,10 @@ import javax.swing.UIManager;
import ca.weblite.objc.Client;
+import com.apple.eawt.Application;
+import com.apple.eawt.ApplicationAdapter;
+import com.apple.eawt.ApplicationEvent;
+
public class MacAppUtilities {
private static Client _objc;
@@ -35,9 +40,7 @@ public class MacAppUtilities {
public static void setWindowCanFullScreen(Window window) {
try {
- Class> fullScreenUtilities = Class.forName("com.apple.eawt.FullScreenUtilities");
- Method setWindowCanFullScreen = fullScreenUtilities.getMethod("setWindowCanFullScreen", new Class>[] { Window.class, boolean.class });
- setWindowCanFullScreen.invoke(null, window, true);
+ com.apple.eawt.FullScreenUtilities.setWindowCanFullScreen(window, true);
} catch (Throwable t) {
Logger.getLogger(MacAppUtilities.class.getName()).log(Level.WARNING, "setWindowCanFullScreen not supported: " + t);
}
@@ -45,10 +48,7 @@ public class MacAppUtilities {
public static void requestForeground() {
try {
- Class> application = Class.forName("com.apple.eawt.Application");
- Object instance = application.getMethod("getApplication").invoke(null);
- Method requestForeground = application.getMethod("requestForeground", new Class>[] { boolean.class });
- requestForeground.invoke(instance, true);
+ com.apple.eawt.Application.getApplication().requestForeground(true);
} catch (Throwable t) {
Logger.getLogger(MacAppUtilities.class.getName()).log(Level.WARNING, "requestForeground not supported: " + t);
}
@@ -56,16 +56,32 @@ public class MacAppUtilities {
public static void revealInFinder(File file) {
try {
- Class> fileManager = Class.forName("com.apple.eio.FileManager");
- Method revealInFinder = fileManager.getMethod("revealInFinder", new Class>[] { File.class });
- revealInFinder.invoke(null, file);
+ com.apple.eio.FileManager.revealInFinder(file);
} catch (Throwable t) {
Logger.getLogger(MacAppUtilities.class.getName()).log(Level.WARNING, "revealInFinder not supported: " + t);
}
}
- public static void setUIDefaults() {
+ public static void initializeApplication() {
+ // improved UI defaults
UIManager.put("TitledBorder.border", UIManager.getBorder("InsetBorder.aquaVariant"));
+
+ // make sure Application Quit Events get forwarded to normal Window Listeners
+ Application.getApplication().addApplicationListener(new ApplicationAdapter() {
+
+ @Override
+ public void handleQuit(ApplicationEvent evt) {
+ for (Window window : Window.getOwnerlessWindows()) {
+ // close all windows
+ window.setVisible(false);
+
+ // call window listeners
+ EventQueue.invokeLater(() -> {
+ window.dispatchEvent(new WindowEvent(window, WindowEvent.WINDOW_CLOSING));
+ });
+ }
+ }
+ });
}
public static boolean isLockedFolder(File folder) {