FileDocCategorySizeDatePackage
FinderIntegrationPlugin.javaAPI DocExample2142Wed Jul 17 00:28:14 BST 2002com.wiverson.macosbook.plugin

FinderIntegrationPlugin.java

package com.wiverson.macosbook.plugin;

import com.wiverson.macosbook.SimpleEdit;

public class FinderIntegrationPlugin implements com.wiverson.macosbook.SimpleEditPlugin
{
    
    /** Creates a new instance of FinderIntegrationPlugin */
    public FinderIntegrationPlugin()
    {
    }
    
    // Does nothing useful in this context.
    public void doAction(SimpleEdit frame, java.awt.event.ActionEvent evt)
    {
        return;
    }
    
    // Returns a status string only.
    public String getAction()
    {
        if(isMacOS)
            return "Mac OS Installed";
        else
            return "Mac OS Not Available";
    }
    
    boolean isMacOS = false;
    
    /** Checks to see if Mac OS is available. If so,
     * goes ahead and loads the class by name that
     * actually performs the initialization. If not,
     * the class is never loaded. This helps prevent
     * classloader problems on non-Mac OS systems.
     */
    
    public void init(SimpleEdit frame)
    {
        if(System.getProperty("mrj.version") != null)
            isMacOS = true;
        
        if(isMacOS)
        {
            try
            {
                // This requests the classloader to find a
                // given class by name.  We are using this to
                // establish a firewall between the application
                // and Mac OS X dependencies.  This helps isolate
                // the application logic for organizational purposes,
                // as well as ensure that we won't try to drag Mac OS
                // references into our crossplatform code.
                Class myClass = Class.forName("com.wiverson.macosbook.plugin.FinderIntegration");
                
                Object myObject = myClass.getConstructor(null).newInstance(null);
                myClass.getDeclaredMethod("execute", null).invoke(myObject, null);;
            } catch (Exception e)
            {
                System.out.println("Unable to load FinderIntegration module.");
                e.printStackTrace();
            }
        }
    }
}