Class 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's com.apple.eawt.Application class. Adapted from Apple's OSXAdapter, which allows redistribution and modification.
    • 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.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • targetObject

        protected java.lang.Object targetObject
      • targetMethod

        protected java.lang.reflect.Method targetMethod
      • proxySignature

        protected java.lang.String proxySignature
      • macOSXApplication

        protected static java.lang.Object macOSXApplication
    • Constructor Detail

      • OSXAdapter

        protected OSXAdapter​(java.lang.String proxySignature,
                             java.lang.Object target,
                             java.lang.reflect.Method handler)
    • 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 interface java.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)