[jsword-svn] r1695 - in trunk: bibledesktop/src/main/java/org/crosswire/bibledesktop/desktop common/src/main/java/org/crosswire/common/util jsword/src/main/java/org/crosswire/jsword/util

dmsmith at www.crosswire.org dmsmith at www.crosswire.org
Tue Aug 28 14:07:03 MST 2007


Author: dmsmith
Date: 2007-08-28 14:07:01 -0700 (Tue, 28 Aug 2007)
New Revision: 1695

Modified:
   trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/desktop/Translations.java
   trunk/common/src/main/java/org/crosswire/common/util/ResourceUtil.java
   trunk/jsword/src/main/java/org/crosswire/jsword/util/WebWarning.java
Log:
Changes for Portable BibleDesktop.

Modified: trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/desktop/Translations.java
===================================================================
--- trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/desktop/Translations.java	2007-08-28 11:21:36 UTC (rev 1694)
+++ trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/desktop/Translations.java	2007-08-28 21:07:01 UTC (rev 1695)
@@ -51,7 +51,7 @@
     {
         try
         {
-            Properties props = ResourceUtil.getProperties(getClass().getName());
+            Properties props = ResourceUtil.getProperties(getClass());
             translation = props.getProperty(TRANSLATION_KEY, DEFAULT_TRANSLATION);
         }
         catch (IOException e)

Modified: trunk/common/src/main/java/org/crosswire/common/util/ResourceUtil.java
===================================================================
--- trunk/common/src/main/java/org/crosswire/common/util/ResourceUtil.java	2007-08-28 11:21:36 UTC (rev 1694)
+++ trunk/common/src/main/java/org/crosswire/common/util/ResourceUtil.java	2007-08-28 21:07:01 UTC (rev 1695)
@@ -106,7 +106,7 @@
      * @throws IOException if the resource can not be loaded
      * @throws MissingResourceException if the resource can not be found
      */
-    public static Properties getProperties(String subject) throws IOException, MissingResourceException
+    public static Properties getProperties(String subject) throws IOException
     {
         return getProperties(CallContext.getCallingClass(), subject);
     }
@@ -119,7 +119,7 @@
      * @throws IOException if the resource can not be loaded
      * @throws MissingResourceException if the resource can not be found
      */
-    public static Properties getProperties(Class clazz) throws IOException, MissingResourceException
+    public static Properties getProperties(Class clazz) throws IOException
     {
         return getProperties(clazz, ClassUtil.getShortClassName(clazz));
     }
@@ -132,14 +132,20 @@
      * @throws IOException if the resource can not be loaded
      * @throws MissingResourceException if the resource can not be found
      */
-    private static Properties getProperties(Class clazz, String subject) throws IOException, MissingResourceException
+    private static Properties getProperties(Class clazz, String subject) throws IOException
     {
-        String lookup = subject + FileUtil.EXTENSION_PROPERTIES;
-        InputStream in = getResourceAsStream(clazz, lookup);
-
-        Properties prop = new Properties();
-        prop.load(in);
-
-        return prop;
+        try
+        {
+            String lookup = subject + FileUtil.EXTENSION_PROPERTIES;
+            InputStream in = getResourceAsStream(clazz, lookup);
+    
+            Properties prop = new Properties();
+            prop.load(in);
+            return prop;
+        }
+        catch (MissingResourceException e)
+        {
+            return new Properties();
+        }
     }
 }

Modified: trunk/jsword/src/main/java/org/crosswire/jsword/util/WebWarning.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/util/WebWarning.java	2007-08-28 11:21:36 UTC (rev 1694)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/util/WebWarning.java	2007-08-28 21:07:01 UTC (rev 1695)
@@ -25,7 +25,9 @@
 import java.net.URI;
 import java.util.Properties;
 
+import org.crosswire.common.util.Logger;
 import org.crosswire.common.util.NetUtil;
+import org.crosswire.common.util.ResourceUtil;
 
 /**
  * Provide a configurable warning that the Internet is going to be accessed.
@@ -45,8 +47,7 @@
     {
         try
         {
-            URI inputURI = Project.instance().getWritablePropertiesURI(getClass().getName());
-            Properties props = NetUtil.loadProperties(inputURI);
+            Properties props = ResourceUtil.getProperties(getClass().getName());
             shown = Boolean.valueOf(props.getProperty(SHOWN_KEY, Boolean.valueOf(DEFAULT_SHOWN).toString())).booleanValue();
         }
         catch (IOException e)
@@ -70,7 +71,18 @@
      */
     public void setShown(boolean newShown)
     {
-        shown = newShown;
+        try
+        {
+            shown = newShown;
+            Properties props = new Properties();
+            props.put(SHOWN_KEY, Boolean.valueOf(shown).toString());
+            URI outputURI = Project.instance().getWritablePropertiesURI(getClass().getName());
+            NetUtil.storeProperties(props, outputURI, "JSword WebWarning"); //$NON-NLS-1$
+        }
+        catch (IOException ex)
+        {
+            log.error("Failed to save JSword WebWarning", ex); //$NON-NLS-1$
+        }
     }
 
     /**
@@ -118,4 +130,9 @@
     private static final String  SHOWN_KEY     = "shown"; //$NON-NLS-1$
     private static final boolean DEFAULT_SHOWN = true;
     private boolean              shown;
+
+    /**
+     * The log stream
+     */
+    private static final Logger log = Logger.getLogger(WebWarning.class);
 }




More information about the jsword-svn mailing list