Package ca.cgjennings.platform
Class OSXAdapter
- java.lang.Object
-
- ca.cgjennings.platform.OSXAdapter
-
- All Implemented Interfaces:
java.lang.reflect.InvocationHandler
public class OSXAdapter extends java.lang.Object implements java.lang.reflect.InvocationHandler
Proxy class that reflectively installs handlers through Apple'scom.apple.eawt.Application
class. Adapted from Apple's OSXAdapter, which allows redistribution and modification.
-
-
Field Summary
Fields Modifier and Type Field Description protected static java.lang.Object
macOSXApplication
protected java.lang.String
proxySignature
protected java.lang.reflect.Method
targetMethod
protected java.lang.Object
targetObject
-
Constructor Summary
Constructors Modifier Constructor Description protected
OSXAdapter(java.lang.String proxySignature, java.lang.Object target, java.lang.reflect.Method handler)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
callTarget(java.lang.Object appleEvent)
java.lang.Object
invoke(java.lang.Object proxy, java.lang.reflect.Method method, java.lang.Object[] args)
protected boolean
isCorrectMethod(java.lang.reflect.Method method, java.lang.Object[] args)
static void
setAboutHandler(java.lang.Object target, java.lang.reflect.Method aboutHandler)
Pass this method an Object and Method equipped to display application info.protected void
setApplicationEventHandled(java.lang.Object event, boolean handled)
static void
setFileHandler(java.lang.Object target, java.lang.reflect.Method fileHandler)
Pass this method an Object and a Method equipped to handle document events from the Finder Documents are registered with the Finder via the CFBundleDocumentTypes dictionary in the application bundle's Info.plist.static void
setHandler(OSXAdapter adapter)
static void
setPreferencesHandler(java.lang.Object target, java.lang.reflect.Method prefsHandler)
Pass this method an Object and a Method equipped to display application options.static void
setQuitHandler(java.lang.Object target, java.lang.reflect.Method quitHandler)
Pass this method an Object and Method equipped to perform application shutdown logic.
-
-
-
Method Detail
-
setQuitHandler
public static void setQuitHandler(java.lang.Object target, java.lang.reflect.Method quitHandler)
Pass this method an Object and Method equipped to perform application shutdown logic. The method passed should return a boolean stating whether or not the quit should occur.
-
setAboutHandler
public static void setAboutHandler(java.lang.Object target, java.lang.reflect.Method aboutHandler)
Pass this method an Object and Method equipped to display application info. They will be called when the About menu item is selected from the application menu.
-
setPreferencesHandler
public static void setPreferencesHandler(java.lang.Object target, java.lang.reflect.Method prefsHandler)
Pass this method an Object and a Method equipped to display application options. They will be called when the Preferences menu item is selected from the application menu.
-
setFileHandler
public static void setFileHandler(java.lang.Object target, java.lang.reflect.Method fileHandler)
Pass this method an Object and a Method equipped to handle document events from the Finder Documents are registered with the Finder via the CFBundleDocumentTypes dictionary in the application bundle's Info.plist.
-
setHandler
public static void setHandler(OSXAdapter adapter)
-
callTarget
public boolean callTarget(java.lang.Object appleEvent) throws java.lang.reflect.InvocationTargetException, java.lang.IllegalAccessException
- Throws:
java.lang.reflect.InvocationTargetException
java.lang.IllegalAccessException
-
invoke
public java.lang.Object invoke(java.lang.Object proxy, java.lang.reflect.Method method, java.lang.Object[] args) throws java.lang.Throwable
- Specified by:
invoke
in interfacejava.lang.reflect.InvocationHandler
- Throws:
java.lang.Throwable
-
isCorrectMethod
protected boolean isCorrectMethod(java.lang.reflect.Method method, java.lang.Object[] args)
-
setApplicationEventHandled
protected void setApplicationEventHandled(java.lang.Object event, boolean handled)
-
-