Initial revision
[old-projects.git] / ekit / com / hexidec / ekit / EkitCoreSpell.java
1 /*
2 GNU Lesser General Public License
3
4 EkitCore - Base Java Swing HTML Editor & Viewer Class (Spellcheck Version)
5 Copyright (C) 2000 Howard Kistler
6
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation; either
10 version 2.1 of the License, or (at your option) any later version.
11
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Lesser General Public License for more details.
16
17 You should have received a copy of the GNU Lesser General Public
18 License along with this library; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 */
21
22 package com.hexidec.ekit;
23
24 import java.net.URL;
25 import javax.swing.text.Document;
26
27 import com.hexidec.ekit.EkitCore;
28 import com.hexidec.util.Translatrix;
29
30 import com.swabunga.spell.engine.*;
31 import com.swabunga.spell.event.*;
32 import com.swabunga.spell.swing.*;
33
34 /** EkitCoreSpell
35 * Extended main application class with additional spellchecking feature
36 *
37 * @author Howard Kistler
38 * @version 0.9h
39 *
40 * REQUIREMENTS
41 * Java 2 (JDK 1.3 or 1.4)
42 * Swing Library
43 */
44
45 public class EkitCoreSpell extends EkitCore implements SpellCheckListener
46 {
47 /* Spell Checker Settings */
48 private static String dictFile;
49 private SpellChecker spellCheck = null;
50 private JSpellDialog spellDialog;
51
52 /** Master Constructor
53 * @param sDocument [String] A text or HTML document to load in the editor upon startup.
54 * @param sStyleSheet [String] A CSS stylesheet to load in the editor upon startup.
55 * @param sRawDocument [String] A document encoded as a String to load in the editor upon startup.
56 * @param urlStyleSheet [URL] A URL reference to the CSS style sheet.
57 * @param includeToolBar [boolean] Specifies whether the app should include the toolbar.
58 * @param showViewSource [boolean] Specifies whether or not to show the View Source window on startup.
59 * @param showMenuIcons [boolean] Specifies whether or not to show icon pictures in menus.
60 * @param editModeExclusive [boolean] Specifies whether or not to use exclusive edit mode (recommended on).
61 * @param sLanguage [String] The language portion of the Internationalization Locale to run Ekit in.
62 * @param sCountry [String] The country portion of the Internationalization Locale to run Ekit in.
63 * @param base64 [boolean] Specifies whether the raw document is Base64 encoded or not.
64 * @param debugMode [boolean] Specifies whether to show the Debug menu or not.
65 * @param hasSpellChecker [boolean] Specifies whether or not this uses the SpellChecker module
66 * @param multiBar [boolean] Specifies whether to use multiple toolbars or one big toolbar.
67 */
68 public EkitCoreSpell(String sDocument, String sStyleSheet, String sRawDocument, URL urlStyleSheet, boolean includeToolBar, boolean showViewSource, boolean showMenuIcons, boolean editModeExclusive, String sLanguage, String sCountry, boolean base64, boolean debugMode, boolean useSpellChecker, boolean multiBar)
69 {
70 super(sDocument, sStyleSheet, sRawDocument, urlStyleSheet, includeToolBar, showViewSource, showMenuIcons, editModeExclusive, sLanguage, sCountry, base64, debugMode, true, multiBar);
71
72 /* Create spell checker */
73 try
74 {
75 dictFile = Translatrix.getTranslationString("DictionaryFile");
76 SpellDictionary dictionary = new SpellDictionary(dictFile); // uses my custom loader in SpellDictionary
77 spellCheck = new SpellChecker(dictionary);
78 spellCheck.addSpellCheckListener(this);
79 }
80 catch(Exception e)
81 {
82 e.printStackTrace();
83 }
84 spellDialog = new JSpellDialog(this.getFrame(), Translatrix.getTranslationString("ToolSpellcheckDialog"), true);
85 }
86
87 /** Common Constructor
88 * @param sDocument [String] A text or HTML document to load in the editor upon startup.
89 * @param sStyleSheet [String] A CSS stylesheet to load in the editor upon startup.
90 * @param includeToolBar [boolean] Specifies whether the app should include the toolbar.
91 * @param showViewSource [boolean] Specifies whether or not to show the View Source window on startup.
92 * @param showMenuIcons [boolean] Specifies whether or not to show icon pictures in menus.
93 * @param editModeExclusive [boolean] Specifies whether or not to use exclusive edit mode (recommended on).
94 * @param sLanguage [String] The language portion of the Internationalization Locale to run Ekit in.
95 * @param sCountry [String] The country portion of the Internationalization Locale to run Ekit in.
96 */
97 public EkitCoreSpell(String sDocument, String sStyleSheet, boolean includeToolBar, boolean showViewSource, boolean showMenuIcons, boolean editModeExclusive, String sLanguage, String sCountry, boolean base64)
98 {
99 this(sDocument, sStyleSheet, null, null, includeToolBar, showViewSource, showMenuIcons, editModeExclusive, sLanguage, sCountry, base64, false, true, false);
100 }
101
102 /** Default Language Constructor
103 * @param sDocument [String] A text or HTML document to load in the editor upon startup.
104 * @param sStyleSheet [String] A CSS stylesheet to load in the editor upon startup.
105 * @param includeToolBar [boolean] Specifies whether the app should include the toolbar.
106 * @param showViewSource [boolean] Specifies whether or not to show the View Source window on startup.
107 * @param showMenuIcons [boolean] Specifies whether or not to show icon pictures in menus.
108 * @param editModeExclusive [boolean] Specifies whether or not to use exclusive edit mode (recommended on).
109 */
110 public EkitCoreSpell(String sDocument, String sStyleSheet, boolean includeToolBar, boolean showViewSource, boolean showMenuIcons, boolean editModeExclusive, boolean base64)
111 {
112 this(sDocument, sStyleSheet, null, null, includeToolBar, showViewSource, showMenuIcons, editModeExclusive, null, null, base64, false, true, false);
113 }
114
115 /** Raw/Base64 Document & Style Sheet URL Constructor (Ideal for EkitApplet)
116 * @param sRawDocument [String] A document encoded as a String to load in the editor upon startup.
117 * @param sRawDocument [String] A document encoded as a String to load in the editor upon startup.
118 * @param includeToolBar [boolean] Specifies whether the app should include the toolbar.
119 * @param showViewSource [boolean] Specifies whether or not to show the View Source window on startup.
120 * @param showMenuIcons [boolean] Specifies whether or not to show icon pictures in menus.
121 * @param editModeExclusive [boolean] Specifies whether or not to use exclusive edit mode (recommended on).
122 * @param sLanguage [String] The language portion of the Internationalization Locale to run Ekit in.
123 * @param sCountry [String] The country portion of the Internationalization Locale to run Ekit in.
124 */
125 public EkitCoreSpell(String sRawDocument, URL urlStyleSheet, boolean includeToolBar, boolean showViewSource, boolean showMenuIcons, boolean editModeExclusive, String sLanguage, String sCountry, boolean base64, boolean multiBar)
126 {
127 this(null, null, sRawDocument, urlStyleSheet, includeToolBar, showViewSource, showMenuIcons, editModeExclusive, sLanguage, sCountry, base64, false, true, multiBar);
128 }
129
130 /** Document Constructor
131 * @param sRawDocument [String] A document encoded as a String to load in the editor upon startup.
132 * @param includeToolBar [boolean] Specifies whether the app should include the toolbar.
133 * @param showViewSource [boolean] Specifies whether or not to show the View Source window on startup.
134 * @param showMenuIcons [boolean] Specifies whether or not to show icon pictures in menus.
135 * @param editModeExclusive [boolean] Specifies whether or not to use exclusive edit mode (recommended on).
136 * @param sLanguage [String] The language portion of the Internationalization Locale to run Ekit in.
137 * @param sCountry [String] The country portion of the Internationalization Locale to run Ekit in.
138 */
139 public EkitCoreSpell(String sRawDocument, boolean includeToolBar, boolean showViewSource, boolean showMenuIcons, boolean editModeExclusive, String sLanguage, String sCountry, boolean base64)
140 {
141 this(null, null, sRawDocument, null, includeToolBar, showViewSource, showMenuIcons, editModeExclusive, sLanguage, sCountry, base64, false, true, false);
142 }
143
144 /** Default Language & Document Constructor
145 * @param sRawDocument [String] A document encoded as a String to load in the editor upon startup.
146 * @param includeToolBar [boolean] Specifies whether the app should include the toolbar.
147 * @param showViewSource [boolean] Specifies whether or not to show the View Source window on startup.
148 * @param showMenuIcons [boolean] Specifies whether or not to show icon pictures in menus.
149 * @param editModeExclusive [boolean] Specifies whether or not to use exclusive edit mode (recommended on).
150 */
151 public EkitCoreSpell(String sRawDocument, boolean includeToolBar, boolean showViewSource, boolean showMenuIcons, boolean editModeExclusive, boolean base64)
152 {
153 this(null, null, sRawDocument, null, includeToolBar, showViewSource, showMenuIcons, editModeExclusive, null, null, base64, false, true, false);
154 }
155
156 /** Flags & Language Constructor
157 * @param includeToolBar [boolean] Specifies whether the app should include the toolbar.
158 * @param showViewSource [boolean] Specifies whether or not to show the View Source window on startup.
159 * @param showMenuIcons [boolean] Specifies whether or not to show icon pictures in menus.
160 * @param editModeExclusive [boolean] Specifies whether or not to use exclusive edit mode (recommended on).
161 * @param sLanguage [String] The language portion of the Internationalization Locale to run Ekit in.
162 * @param sCountry [String] The country portion of the Internationalization Locale to run Ekit in.
163 */
164 public EkitCoreSpell(boolean includeToolBar, boolean showViewSource, boolean showMenuIcons, boolean editModeExclusive, String sLanguage, String sCountry)
165 {
166 this(null, null, null, null, includeToolBar, showViewSource, showMenuIcons, editModeExclusive, sLanguage, sCountry, false, false, true, false);
167 }
168
169 /** Flags Constructor
170 * @param includeToolBar [boolean] Specifies whether the app should include the toolbar.
171 * @param showViewSource [boolean] Specifies whether or not to show the View Source window on startup.
172 * @param showMenuIcons [boolean] Specifies whether or not to show icon pictures in menus.
173 * @param editModeExclusive [boolean] Specifies whether or not to use exclusive edit mode (recommended on).
174 */
175 public EkitCoreSpell(boolean includeToolBar, boolean showViewSource, boolean showMenuIcons, boolean editModeExclusive)
176 {
177 this(null, null, null, null, includeToolBar, showViewSource, showMenuIcons, editModeExclusive, null, null, false, false, true, false);
178 }
179
180 /** Language & Debug Constructor
181 * @param sLanguage [String] The language portion of the Internationalization Locale to run Ekit in.
182 * @param sCountry [String] The country portion of the Internationalization Locale to run Ekit in.
183 * @param debugMode [boolean] Specifies whether to show the Debug menu or not.
184 */
185 public EkitCoreSpell(String sLanguage, String sCountry, boolean debugMode)
186 {
187 this(null, null, null, null, true, false, true, true, sLanguage, sCountry, false, debugMode, true, false);
188 }
189
190 /** Language Constructor
191 * @param sLanguage [String] The language portion of the Internationalization Locale to run Ekit in.
192 * @param sCountry [String] The country portion of the Internationalization Locale to run Ekit in.
193 */
194 public EkitCoreSpell(String sLanguage, String sCountry)
195 {
196 this(null, null, null, null, true, false, true, true, sLanguage, sCountry, false, false, true, false);
197 }
198
199 /** Debug Constructor
200 * @param debugMode [boolean] Specifies whether to show the Debug menu or not.
201 */
202 public EkitCoreSpell(boolean debugMode)
203 {
204 this(null, null, null, null, true, false, true, true, null, null, false, debugMode, true, false);
205 }
206
207 /** Empty Constructor
208 */
209 public EkitCoreSpell()
210 {
211 this(null, null, null, null, true, false, true, true, null, null, false, false, true, false);
212 }
213
214 /* SpellCheckListener methods */
215 public void spellingError(SpellCheckEvent event)
216 {
217 spellDialog.show(event);
218 }
219
220 /* Spell checking method (overrides empty method in basic core) */
221 public void checkDocumentSpelling(Document doc)
222 {
223 spellCheck.checkSpelling(new DocumentWordTokenizer(doc));
224 }
225
226 }
227