01: //The contents of this file are subject to the Mozilla Public License Version 1.1
02: //(the "License"); you may not use this file except in compliance with the
03: //License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
04: //
05: //Software distributed under the License is distributed on an "AS IS" basis,
06: //WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
07: //for the specific language governing rights and
08: //limitations under the License.
09: //
10: //The Original Code is "The Columba Project"
11: //
12: //The Initial Developers of the Original Code are Frederik Dietz and Timo Stich.
13: //Portions created by Frederik Dietz and Timo Stich are Copyright (C) 2003.
14: //
15: //All Rights Reserved.
16: package org.columba.core.gui.externaltools;
17:
18: import java.io.File;
19: import java.net.MalformedURLException;
20: import java.net.URL;
21:
22: import org.columba.core.base.OSInfo;
23:
24: /**
25: * Plugin for the aspell spell-checking package.
26: *
27: * @author fdietz
28: */
29: public class ASpellPlugin extends AbstractExternalToolsPlugin {
30: protected static File defaultLinux = new File("/usr/bin/aspell");
31: protected static File defaultLocalLinux = new File(
32: "/usr/local/bin/aspell");
33: protected static File defaultWin = new File(
34: "C:\\Program Files\\Aspell\\bin\\aspell.exe");
35: protected static URL websiteURL;
36:
37: static {
38: try {
39: websiteURL = new URL("http://aspell.sourceforge.net/");
40: } catch (MalformedURLException mue) {
41: }
42:
43: //does not happen
44: }
45:
46: /**
47: * Construct the default ASpell plugin.
48: */
49: public ASpellPlugin() {
50: super ();
51: }
52:
53: public String getDescription() {
54: // TODO (@author fdietz): i18n
55: return "<html><body><p>GNU Aspell is a Free and Open Source spell checker designed to eventually replace Ispell.</p><p>It can either be used as a library or as an independent spell checker. Its main feature is that it does a much better job of coming up with possible suggestions than just about any other spell checker out there for the English language, including Ispell and Microsoft Word.</p></p>It also has many other technical enhancements over Ispell such as using shared memory for dictionaries and intelligently handling personal dictionaries when more than one Aspell process is open at once.</p></body></html>";
56: }
57:
58: public URL getWebsite() {
59: return websiteURL;
60: }
61:
62: public File locate() {
63: /* If this is a unix-based system, check the 2 best-known areas for the
64: * aspell binary.
65: */
66: if (OSInfo.isLinux() || OSInfo.isSolaris()) {
67: if (defaultLinux.exists()) {
68: return defaultLinux;
69: } else if (defaultLocalLinux.exists()) {
70: return defaultLocalLinux;
71: }
72: }
73:
74: /* RIYAD: The Prefs API cannot be used to read the Window's registry,
75: * it is coded to use the registry (if available) as a backing store
76: * on in the SOFTWARE/JavaSoft/Prefs registry keys for HKEY_CURRENT_USER
77: * and HKEY_LOCAL_MACHINE paths. I have seen a few java apps that use
78: * the Windows registry and they all required a native lib to do it.
79: */
80: /* If this is windows, check the default installation location for the
81: * aspell.exe binary.
82: */
83: if (OSInfo.isWin32Platform() && defaultWin.exists()) {
84: return defaultWin;
85: }
86:
87: /* Couldn't find anything, so return null and let the wizard ask the
88: * user.
89: */
90: return null;
91: }
92: }
|