Sophie

Sophie

distrib > Mageia > 5 > i586 > media > core-release-src > by-pkgid > 9e7acea0e742f6cc4257ce87519c4e0f > files > 1

jortho-1.0-1.mga5.src.rpm

From 97dfe00f48b3cb8272a6eee15e4ef7b4d64fae52 Mon Sep 17 00:00:00 2001
From: Michael Simacek <msimacek@redhat.com>
Date: Fri, 6 Jun 2014 01:24:03 +0200
Subject: [PATCH] Load data from system-wide location

Signed-off-by: Michael Simacek <msimacek@redhat.com>
---
 com/inet/jortho/SpellChecker.java | 20 +++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)

diff --git a/com/inet/jortho/SpellChecker.java b/com/inet/jortho/SpellChecker.java
index a092349..1cc28c6 100644
--- a/com/inet/jortho/SpellChecker.java
+++ b/com/inet/jortho/SpellChecker.java
@@ -31,6 +31,7 @@ import java.awt.event.KeyEvent;
 import java.awt.event.MouseListener;
 import java.io.IOException;
 import java.io.InputStream;
+import java.io.File;
 import java.net.MalformedURLException;
 import java.net.URL;
 import java.util.ArrayList;
@@ -220,12 +221,7 @@ public class SpellChecker {
     public static void registerDictionaries( URL baseURL, String activeLocale ) {
         if( baseURL == null ){
             try {
-                baseURL = SpellChecker.class.getResource( "/dictionaries.cnf" );
-                if( baseURL != null ) {
-                    baseURL = new URL( baseURL, "." );
-                } else {
-                    baseURL = new URL( "file", null, "" );
-                }
+                baseURL = new File("/usr/share/jortho/").toURI().toURL();
             } catch( MalformedURLException e ) {
                 // should never occur because the URL is valid
             	SpellChecker.getMessageHandler().handleException( e );
@@ -339,7 +335,7 @@ public class SpellChecker {
     public static void registerDictionaries( URL baseURL, String availableLocales, String activeLocale, String extension ) {
         if( baseURL == null ){
             try {
-                baseURL = new URL("file", null, "");
+                baseURL = new File("/usr/share/jortho/").toURI().toURL();
             } catch( MalformedURLException e ) {
                 // should never occur because the URL is valid
             	SpellChecker.getMessageHandler().handleException( e );
@@ -818,7 +814,17 @@ public class SpellChecker {
                     try {
                         DictionaryFactory factory = new DictionaryFactory();
                         try {
+                            try {
                             factory.loadWordList( new URL( baseURL, "dictionary_" + locale + extension ) );
+                            } catch( java.io.FileNotFoundException ex) {
+                                if (baseURL.toString().contains("usr/share/jortho")) {
+                                    throw new java.io.FileNotFoundException("Dictionary for locale " + locale +
+                                        " is not installed. To get it, install the package jortho-dictionary-" +
+                                        locale);
+                                } else {
+                                    throw ex;
+                                }
+                            }
                         } catch( Exception ex ) {
                         	SpellChecker.getMessageHandler().handleError( ex.toString(), "Error", ex );
                         }
-- 
1.9.3