KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > columba > core > gui > externaltools > ASpellPlugin


1 //The contents of this file are subject to the Mozilla Public License Version 1.1
2
//(the "License"); you may not use this file except in compliance with the
3
//License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
4
//
5
//Software distributed under the License is distributed on an "AS IS" basis,
6
//WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
7
//for the specific language governing rights and
8
//limitations under the License.
9
//
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 JavaDoc;
19 import java.net.MalformedURLException JavaDoc;
20 import java.net.URL JavaDoc;
21
22 import org.columba.core.base.OSInfo;
23
24
25 /**
26  * Plugin for the aspell spell-checking package.
27  *
28  * @author fdietz
29  */

30 public class ASpellPlugin extends AbstractExternalToolsPlugin {
31     protected static File JavaDoc defaultLinux = new File JavaDoc("/usr/bin/aspell");
32     protected static File JavaDoc defaultLocalLinux = new File JavaDoc("/usr/local/bin/aspell");
33     protected static File JavaDoc defaultWin = new File JavaDoc(
34             "C:\\Program Files\\Aspell\\bin\\aspell.exe");
35     protected static URL JavaDoc websiteURL;
36
37     static {
38         try {
39             websiteURL = new URL JavaDoc("http://aspell.sourceforge.net/");
40         } catch (MalformedURLException JavaDoc 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 JavaDoc 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 JavaDoc getWebsite() {
59         return websiteURL;
60     }
61
62     public File JavaDoc 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 }
93
Popular Tags