01: /*
02: * :tabSize=8:indentSize=8:noTabs=false:
03: * :folding=explicit:collapseFolds=1:
04: *
05: * AppleScriptHandler.java
06: * Copyright (C) 2002 Kris Kopicki
07: *
08: * This program is free software; you can redistribute it and/or
09: * modify it under the terms of the GNU General Public License
10: * as published by the Free Software Foundation; either version 2
11: * of the License, or any later version.
12: *
13: * This program is distributed in the hope that it will be useful,
14: * but WITHOUT ANY WARRANTY; without even the implied warranty of
15: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16: * GNU General Public License for more details.
17: *
18: * You should have received a copy of the GNU General Public License
19: * along with this program; if not, write to the Free Software
20: * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21: */
22:
23: package macos.script;
24:
25: //{{{ Imports
26: import java.io.*;
27: import org.gjt.sp.jedit.*;
28: import macos.*;
29:
30: //}}}
31:
32: public class AppleScriptHandler extends Macros.Handler {
33: //{{{ accept() method
34: public boolean accept(String path) {
35: return ffilter.accept(new File(path));
36: } //}}}
37:
38: //{{{ createMacro() method
39: public Macros.Macro createMacro(String macroName, String path) {
40: if (macroName.toLowerCase().endsWith(".scpt"))
41: macroName = macroName.substring(0, macroName.length() - 5);
42: else if (macroName.toLowerCase().endsWith(".applescript"))
43: macroName = macroName.substring(0, macroName.length() - 12);
44: return new Macros.Macro(this , macroName, Macros.Macro
45: .macroNameToLabel(macroName), path);
46: } //}}}
47:
48: //{{{ runMacro() method
49: public void runMacro(View view, Macros.Macro macro) {
50: MacOSActions.runScript(macro.getPath());
51: }
52:
53: //}}}
54:
55: //{{{ runMacro() method
56: public void runMacro(View view, Macros.Macro macro,
57: boolean ownNamespace) {
58: runMacro(view, macro);
59: } //}}}
60:
61: //{{{ Handler constructor
62: public AppleScriptHandler() {
63: super ("applescript");
64: ffilter = new ScriptFilter();
65: } //}}}
66:
67: //{{{ Private members
68: private FileFilter ffilter;
69: //}}}
70: }
|