FileDocCategorySizeDatePackage
FinderIntegration.javaAPI DocExample10397Wed Jul 17 00:28:14 BST 2002com.wiverson.macosbook.plugin

FinderIntegration

public class FinderIntegration extends Object implements com.apple.mrj.MRJPrefsHandler, com.apple.mrj.MRJQuitHandler, com.apple.mrj.MRJOpenDocumentHandler, com.apple.mrj.MRJOpenApplicationHandler, com.apple.mrj.MRJAboutHandler
In order for this plugin to function properly, it must be loaded by the SimpleEdit application and the proper system properties set before execution. For example, the following command, entered on a single line, invokes the JVM and tells the system to display the About menu item in the Mac OS X application menu. java -Dcom.apple.mrj.application.apple.menu.about.name=SimpleEdit com.wiverson.macosbook.plugin.FinderIntegrationPlugin

Fields Summary
private static boolean
installed
static JDialog
AboutDialog
public static boolean
pref_askToClose
static JDialog
PrefsDialog
DoQuit
quitThread
Constructors Summary
public FinderIntegration()
Creates a new instance of FinderIntegration

    
Methods Summary
public voidexecute()

      
    
        if(!installed)
        {            
            // Enables the menu item
            MRJApplicationUtils.registerPrefsHandler(this);

            // Overrides the default System.exit() behavior.
            MRJApplicationUtils.registerQuitHandler(this);
            
            // Requires com.apple.mrj.application.apple.menu.about.name=Application
            // system property to be set to appear.
            MRJApplicationUtils.registerAboutHandler(this);
            
            // These require the application to be properly bundled for Mac OS X
            // for the events to be dispatched
            MRJApplicationUtils.registerOpenApplicationHandler(this);
            MRJApplicationUtils.registerOpenDocumentHandler(this);
            
            installed = true;
        }
    
public voidhandleAbout()

      
    
        new DoAbout().start();
    
public voidhandleOpenApplication()
Note that the application requires Mac OS X bundling (as described in a later chapter) to be enabled. The techniques for writing these handlers are similar to the rest of the add-ons. Typically, you will want to use these handlers to call your standard File -> Open... routines, simply bypassing the standard file dialogs.

        new DoOpenApplication().start();
    
public voidhandleOpenFile(java.io.File file)

        DoOpenFile myHandler = new DoOpenFile();
        myHandler.setFile(file);
        myHandler.start();
    
public voidhandlePrefs()

        new com.wiverson.macosbook.plugin.FinderIntegration.DoPrefs().start();
    
public voidhandleQuit()

        
    
        if(pref_askToClose)
        {
            if(quitThread == null)
            {
                quitThread = new DoQuit();
                // Make sure the application doesn't hang around
                // waiting for this thread.
                quitThread.setDaemon(true);
                quitThread.start();
            }
            else
                quitThread.show();
        } else
        {
            // If the user set a preference not to be 
            // prompted, go ahead and bail out.
            System.exit(0);
        }