|
JHotDraw 7.5.1 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.jhotdraw.app.osx.OSXAdapter
public class OSXAdapter
OSXAdapter
uses a Proxy object to dynamically implement the
com.apple.eawt.ApplicationListener
interface and register it with the
com.apple.eawt.Application object
. This allows the complete project
to be both built and run on any platform without any stubs or
placeholders. Useful for developers looking to implement Mac OS X
features while supporting multiple platforms with minimal impact.
This class has been derived from OSXAdapter 2.0 © Apple Inc., All Rights Rserved.
Field Summary | |
---|---|
protected java.lang.String |
proxySignature
|
protected java.awt.event.ActionListener |
targetAction
|
protected java.lang.reflect.Method |
targetMethod
|
protected java.lang.Object |
targetObject
|
Constructor Summary | |
---|---|
protected |
OSXAdapter(java.lang.String proxySignature,
java.awt.event.ActionListener 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. |
protected |
OSXAdapter(java.lang.String proxySignature,
java.lang.Object target,
java.lang.reflect.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. |
Method Summary | |
---|---|
boolean |
callTarget(java.lang.Object appleEvent)
Override this method to perform any operations on the event that comes with the various callbacks. |
java.lang.Object |
invoke(java.lang.Object proxy,
java.lang.reflect.Method method,
java.lang.Object[] args)
InvocationHandler implementation. |
protected boolean |
isCorrectMethod(java.lang.reflect.Method method,
java.lang.Object[] args)
Compare the method that was called to the intended method when the OSXAdapter instance was created (e.g. |
static void |
setAboutHandler(java.awt.event.ActionListener aboutHandler)
The action listener will be called when the user selects the About item in the application menu. |
protected void |
setApplicationEventHandled(java.lang.Object event,
boolean handled)
It is important to mark the ApplicationEvent as handled and cancel the default behavior. |
static void |
setHandler(OSXAdapter adapter)
setHandler creates a Proxy object from the passed
OSXAdapter and adds it as an ApplicationListener . |
static void |
setOpenApplicationHandler(java.awt.event.ActionListener openHandler)
The action listener will be called when the application receives an Open Application event from the Finder or another application. |
static void |
setOpenFileHandler(java.awt.event.ActionListener fileHandler)
Pass this method an ActionListener equipped to
handle document events from the Finder. |
static void |
setPreferencesHandler(java.awt.event.ActionListener prefsHandler)
Pass this method an ActionListener equipped to
display application options. |
static void |
setPrintFileHandler(java.awt.event.ActionListener fileHandler)
Pass this method an ActionListener equipped to
handle document events from the Finder. |
static void |
setQuitHandler(java.awt.event.ActionListener aboutHandler)
The action listener will be called when the Quit menu item is selected from the application menu. |
static void |
setReOpenApplicationHandler(java.awt.event.ActionListener reopenHandler)
Called when the application receives a Reopen Application event from the Finder or another application. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected java.awt.event.ActionListener targetAction
protected java.lang.Object targetObject
protected java.lang.reflect.Method targetMethod
protected java.lang.String proxySignature
Constructor Detail |
---|
protected OSXAdapter(java.lang.String proxySignature, java.lang.Object target, java.lang.reflect.Method handler)
protected OSXAdapter(java.lang.String proxySignature, java.awt.event.ActionListener handler)
Method Detail |
---|
public static void setOpenApplicationHandler(java.awt.event.ActionListener openHandler)
public static void setReOpenApplicationHandler(java.awt.event.ActionListener reopenHandler)
public static void setQuitHandler(java.awt.event.ActionListener aboutHandler)
public static void setAboutHandler(java.awt.event.ActionListener aboutHandler)
public static void setPreferencesHandler(java.awt.event.ActionListener prefsHandler)
ActionListener
equipped to
display application options.
They will be called when the Preferences menu item is selected from the
application menu.
public static void setOpenFileHandler(java.awt.event.ActionListener fileHandler)
ActionListener
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.
The filename is passed as the actionCommand
.
public static void setPrintFileHandler(java.awt.event.ActionListener fileHandler)
ActionListener
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.
The filename is passed as the actionCommand
.
public static void setHandler(OSXAdapter adapter)
setHandler
creates a Proxy object from the passed
OSXAdapter
and adds it as an ApplicationListener
.
public boolean callTarget(java.lang.Object appleEvent) throws java.lang.reflect.InvocationTargetException, java.lang.IllegalAccessException
java.lang.reflect.InvocationTargetException
java.lang.IllegalAccessException
public java.lang.Object invoke(java.lang.Object proxy, java.lang.reflect.Method method, java.lang.Object[] args) throws java.lang.Throwable
invoke
in interface java.lang.reflect.InvocationHandler
java.lang.Throwable
protected boolean isCorrectMethod(java.lang.reflect.Method method, java.lang.Object[] args)
protected void setApplicationEventHandled(java.lang.Object event, boolean handled)
|
Copyright 1996-2010 (c) by the authors and contributors of the JHotDraw project. Some rights reserved. |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |