Compile against com.apple.eawt.* stub
This commit is contained in:
parent
22ece907de
commit
adda35edd4
|
@ -32,5 +32,6 @@
|
|||
<classpathentry kind="lib" path="lib/ivy/jar/language-detector.jar"/>
|
||||
<classpathentry kind="lib" path="lib/ivy/bundle/guava.jar"/>
|
||||
<classpathentry kind="lib" path="lib/ivy/jar/streamex.jar"/>
|
||||
<classpathentry kind="lib" path="lib/jars/AppleJavaExtensions.jar"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
|
|
Binary file not shown.
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue