diff --git a/.classpath b/.classpath
index 462d0388..9f657fb2 100644
--- a/.classpath
+++ b/.classpath
@@ -32,5 +32,6 @@
+
diff --git a/lib/jars/AppleJavaExtensions.jar b/lib/jars/AppleJavaExtensions.jar
new file mode 100644
index 00000000..6659a81c
Binary files /dev/null and b/lib/jars/AppleJavaExtensions.jar differ
diff --git a/source/net/filebot/mac/MacAppUtilities.java b/source/net/filebot/mac/MacAppUtilities.java
index d1d33fa6..ff135e66 100644
--- a/source/net/filebot/mac/MacAppUtilities.java
+++ b/source/net/filebot/mac/MacAppUtilities.java
@@ -8,19 +8,23 @@ import java.awt.SecondaryLoop;
import java.awt.Toolkit;
import java.awt.Window;
import java.io.File;
-import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
+import java.util.logging.Level;
import javax.swing.JMenuBar;
import javax.swing.UIManager;
+import com.apple.eawt.Application;
+import com.apple.eawt.FullScreenUtilities;
+import com.apple.eawt.QuitStrategy;
+import com.apple.eio.FileManager;
+import com.sun.jna.Pointer;
+
import ca.weblite.objc.Client;
import ca.weblite.objc.Proxy;
-import com.sun.jna.Pointer;
-
public class MacAppUtilities {
private static Client _objc;
@@ -85,7 +89,7 @@ public class MacAppUtilities {
// Enter the loop to block the current event handler, but leave UI responsive
if (!secondaryLoop.enter()) {
- throw new IllegalStateException("SecondaryLoop.enter()");
+ throw new IllegalStateException("SecondaryLoop");
}
return result;
@@ -93,56 +97,41 @@ 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);
+ FullScreenUtilities.setWindowCanFullScreen(window, true);
} catch (Throwable t) {
- debug.warning("setWindowCanFullScreen not supported: " + t);
+ debug.log(Level.WARNING, t.getMessage(), t);
}
}
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);
+ Application.getApplication().requestForeground(true);
} catch (Throwable t) {
- debug.warning("requestForeground not supported: " + t);
+ debug.log(Level.WARNING, t.getMessage(), t);
}
}
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);
+ FileManager.revealInFinder(file);
} catch (Throwable t) {
- debug.warning("revealInFinder not supported: " + t);
+ debug.log(Level.WARNING, t.getMessage(), t);
}
}
public static void setDefaultMenuBar(JMenuBar menu) {
try {
- Class> application = Class.forName("com.apple.eawt.Application");
- Object instance = application.getMethod("getApplication").invoke(null);
- Method setDefaultMenuBar = application.getMethod("setDefaultMenuBar", new Class>[] { JMenuBar.class });
- setDefaultMenuBar.invoke(instance, menu);
+ Application.getApplication().setDefaultMenuBar(menu);
} catch (Throwable t) {
- debug.warning("setDefaultMenuBar not supported: " + t);
+ debug.log(Level.WARNING, t.getMessage(), t);
}
}
- public static void setQuitStrategy(String field) {
+ public static void setQuitStrategyCloseAll() {
try {
- Class> application = Class.forName("com.apple.eawt.Application");
- Object instance = application.getMethod("getApplication").invoke(null);
- Class> quitStrategy = Class.forName("com.apple.eawt.QuitStrategy");
- Method setQuitStrategy = application.getMethod("setQuitStrategy", quitStrategy);
- Object closeAllWindows = quitStrategy.getField(field).get(null);
- setQuitStrategy.invoke(instance, closeAllWindows);
+ Application.getApplication().setQuitStrategy(QuitStrategy.CLOSE_ALL_WINDOWS);
} catch (Throwable t) {
- debug.warning("setQuitStrategy not supported: " + t);
+ debug.log(Level.WARNING, t.getMessage(), t);
}
}
@@ -151,7 +140,7 @@ public class MacAppUtilities {
UIManager.put("TitledBorder.border", UIManager.getBorder("InsetBorder.aquaVariant"));
// make sure Application Quit Events get forwarded to normal Window Listeners
- setQuitStrategy("CLOSE_ALL_WINDOWS");
+ setQuitStrategyCloseAll();
}
public static boolean isLockedFolder(File folder) {