public class OSXAdapter extends Object implements InvocationHandler
| Modifier and Type | Field and Description |
|---|---|
protected String |
proxySignature |
protected Method |
targetMethod |
protected Object |
targetObject |
| Modifier | Constructor and Description |
|---|---|
protected |
OSXAdapter(String proxySignature,
Object target,
Method handler)
Each OSXAdapter has the name of the EAWT method it intends to listen for (handleAbout, for example),
the Object that will ultimately perform the task, and the Method to be called on that Object
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
callTarget(Object appleEvent)
Override this method to perform any operations on the event
that comes with the various callbacks.
|
Object |
invoke(Object proxy,
Method method,
Object[] args)
InvocationHandler implementation.
|
protected boolean |
isCorrectMethod(Method method,
Object[] args)
Compare the method that was called to the intended method when the OSXAdapter instance was created
(e.g.
|
static void |
setAboutHandler(Object target,
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
|
protected void |
setApplicationEventHandled(Object event,
boolean handled)
It is important to mark the ApplicationEvent as handled and cancel the default behavior.
|
static void |
setFileHandler(Object target,
Method fileHandler)
Pass this method an Object and a Method equipped to handle document events from the Finder.
|
static void |
setHandler(OSXAdapter adapter)
setHandler creates a Proxy object from the passed OSXAdapter and adds it as an ApplicationListener.
|
static void |
setPreferencesHandler(Object target,
Method prefsHandler)
Pass this method an Object and a Method equipped to display application options.
|
static void |
setQuitHandler(Object target,
Method quitHandler)
Pass this method an Object and Method equipped to perform application shutdown logic.
|
protected final Object targetObject
protected final Method targetMethod
protected final String proxySignature
protected OSXAdapter(String proxySignature, Object target, Method handler)
proxySignature - proxy signaturetarget - target objecthandler - handler methodpublic static void setQuitHandler(Object target, Method quitHandler) throws InvocationTargetException, ClassNotFoundException, NoSuchMethodException, InstantiationException, IllegalAccessException
target - target objectquitHandler - quit methodInvocationTargetException - on errorClassNotFoundException - on errorNoSuchMethodException - on errorInstantiationException - on errorIllegalAccessException - on errorpublic static void setAboutHandler(Object target, Method aboutHandler) throws InvocationTargetException, IllegalAccessException, NoSuchMethodException, ClassNotFoundException, InstantiationException
target - target objectaboutHandler - about methodInvocationTargetException - on errorClassNotFoundException - on errorNoSuchMethodException - on errorInstantiationException - on errorIllegalAccessException - on errorpublic static void setPreferencesHandler(Object target, Method prefsHandler) throws InvocationTargetException, IllegalAccessException, NoSuchMethodException, ClassNotFoundException, InstantiationException
target - target objectprefsHandler - preferences methodInvocationTargetException - on errorClassNotFoundException - on errorNoSuchMethodException - on errorInstantiationException - on errorIllegalAccessException - on errorpublic static void setFileHandler(Object target, Method fileHandler) throws InvocationTargetException, ClassNotFoundException, NoSuchMethodException, InstantiationException, IllegalAccessException
target - target objectfileHandler - file methodInvocationTargetException - on errorClassNotFoundException - on errorNoSuchMethodException - on errorInstantiationException - on errorIllegalAccessException - on errorpublic static void setHandler(OSXAdapter adapter) throws ClassNotFoundException, NoSuchMethodException, InvocationTargetException, IllegalAccessException, InstantiationException
adapter - OSX adapterInvocationTargetException - on errorClassNotFoundException - on errorNoSuchMethodException - on errorInstantiationException - on errorIllegalAccessException - on errorpublic boolean callTarget(Object appleEvent) throws InvocationTargetException, IllegalAccessException
appleEvent - apple event objectInvocationTargetException - on errorIllegalAccessException - on errorpublic Object invoke(Object proxy, Method method, Object[] args) throws Throwable
invoke in interface InvocationHandlerproxy - proxy objectmethod - handler methodargs - method argumentsThrowable - on errorprotected boolean isCorrectMethod(Method method, Object[] args)
method - handler methodargs - method argumentsprotected void setApplicationEventHandled(Object event, boolean handled) throws NoSuchMethodException, InvocationTargetException, IllegalAccessException
event - event objecthandled - true if event handledNoSuchMethodException - on errorInvocationTargetException - on errorIllegalAccessException - on errorCopyright © 2001–2019 MickaĆ«l Guessant. All rights reserved.