| 1 22 23 package macos; 24 25 import java.util.Vector ; 27 import javax.swing.*; 28 import org.gjt.sp.jedit.*; 29 import org.gjt.sp.jedit.gui.*; 30 import org.gjt.sp.jedit.msg.*; 31 import org.gjt.sp.util.Log; 32 import macos.menu.*; 33 import macos.script.*; 34 import com.apple.cocoa.application.*; 35 import com.apple.eawt.Application; 36 38 public class MacOSPlugin extends EBPlugin 39 { 40 static boolean started = false; 42 private boolean osok; 43 private Delegate delegate; 44 46 public void start() 48 { 49 if(osok = osok()) 50 { 51 delegate = new Delegate(); 52 NSApplication app = NSApplication.sharedApplication(); 53 54 Macros.registerHandler(new AppleScriptHandler()); 55 Application app2 = new Application(); 56 app2.addApplicationListener(delegate); 57 app2.setEnabledPreferencesMenu(true); 58 app2.setEnabledAboutMenu(true); 59 60 app.setDelegate(delegate); 61 } 63 } 65 public void handleMessage(EBMessage message) 67 { 68 if (osok) 69 { 70 if (message instanceof BufferUpdate) 72 delegate.handleFileCodes((BufferUpdate)message); 73 else if (message instanceof PropertiesChanged) 74 { 75 boolean b = jEdit.getBooleanProperty("MacOSPlugin.useSelection", 76 jEdit.getBooleanProperty("MacOSPlugin.default.useSelection")); 77 if (b) 78 jEdit.setColorProperty("view.selectionColor", 79 UIManager.getColor("textHighlight")); 80 } 81 else if (!started && message instanceof ViewUpdate) 85 delegate.handleOpenFile((ViewUpdate)message); 86 } 87 } 89 private boolean osok() 91 { 92 final String osname = jEdit.getProperty("MacOSPlugin.depend.os.name"); 93 final String mrjversion = jEdit.getProperty("MacOSPlugin.depend.mrj.version"); 94 95 if (!System.getProperty("os.name").equals(osname)) 96 { 97 Log.log(Log.ERROR,this,jEdit.getProperty("MacOSPlugin.dialog.osname.message")); 99 return false; 100 } 101 if (MiscUtilities.compareStrings( 102 System.getProperty("mrj.version"),mrjversion,false) < 0) 103 { 104 SwingUtilities.invokeLater( new Runnable () { public void run() { 105 GUIUtilities.error(null,"MacOSPlugin.dialog.mrjversion",new Object [] {mrjversion}); 106 }}); 107 return false; 108 } 109 110 return true; 111 }} 113 | Popular Tags |