Mercurial Hosting > editor
comparison src/luan_editor/SpellCheckerLuan.java @ 37:b7ff52d45b9a
copy from luan
| author | Franklin Schmidt <fschmidt@gmail.com> |
|---|---|
| date | Mon, 21 Apr 2025 13:07:29 -0600 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| 36:0a8865de3d53 | 37:b7ff52d45b9a |
|---|---|
| 1 package luan_editor; | |
| 2 | |
| 3 import java.net.URL; | |
| 4 import java.net.MalformedURLException; | |
| 5 import javax.swing.text.JTextComponent; | |
| 6 import com.inet.jortho.SpellChecker; | |
| 7 import com.inet.jortho.DefaultMessageHandler; | |
| 8 import luan.LuanException; | |
| 9 import luan.LuanRuntimeException; | |
| 10 | |
| 11 | |
| 12 public class SpellCheckerLuan { | |
| 13 | |
| 14 public static void registerDictionaries( String baseURL, String activeLocale) throws MalformedURLException, LuanException { | |
| 15 SpellChecker.setMessageHandler(new DefaultMessageHandler(null) { | |
| 16 @Override public void handleException(java.lang.Throwable throwable) { | |
| 17 throw new LuanRuntimeException(new LuanException(throwable)); | |
| 18 } | |
| 19 } ); | |
| 20 URL url = new URL(baseURL); | |
| 21 try { | |
| 22 SpellChecker.registerDictionaries( url, activeLocale ); | |
| 23 } catch(LuanRuntimeException e) { | |
| 24 LuanException luanException = (LuanException)e.getCause(); | |
| 25 throw luanException; | |
| 26 } | |
| 27 } | |
| 28 | |
| 29 public static void register(JTextComponent text) { | |
| 30 SpellChecker.register(text); | |
| 31 } | |
| 32 | |
| 33 public static void unregister(JTextComponent text) { | |
| 34 SpellChecker.unregister(text); | |
| 35 } | |
| 36 } |
