[jsword-svn] r1263 - in trunk: bibledesktop/src/main/java/org/crosswire/bibledesktop/desktop bibledesktop/src/main/java/org/crosswire/bibledesktop/display/textpane bibledesktop/src/main/resources/xsl/cswing common/src/main/java/org/crosswire/common/util common-swing/src/main/java/org/crosswire/common/swing jsword/src/main/java/org/crosswire/jsword/book jsword/src/main/java/org/crosswire/jsword/book/filter/thml jsword/src/main/java/org/crosswire/jsword/book/readings jsword/src/main/java/org/crosswire/jsword/util

dmsmith at www.crosswire.org dmsmith at www.crosswire.org
Sat Mar 24 19:05:02 MST 2007


Author: dmsmith
Date: 2007-03-24 19:05:01 -0700 (Sat, 24 Mar 2007)
New Revision: 1263

Added:
   trunk/jsword/src/main/java/org/crosswire/jsword/book/filter/thml/HTag.java
Modified:
   trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/desktop/Desktop.java
   trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/display/textpane/TextPaneBookDataDisplay.java
   trunk/bibledesktop/src/main/resources/xsl/cswing/simple.xsl
   trunk/common-swing/src/main/java/org/crosswire/common/swing/FixedSplitPane.java
   trunk/common-swing/src/main/java/org/crosswire/common/swing/FontChooser.java
   trunk/common/src/main/java/org/crosswire/common/util/Logger.java
   trunk/jsword/src/main/java/org/crosswire/jsword/book/Defaults.java
   trunk/jsword/src/main/java/org/crosswire/jsword/book/OSISUtil.java
   trunk/jsword/src/main/java/org/crosswire/jsword/book/filter/thml/CustomHandler.java
   trunk/jsword/src/main/java/org/crosswire/jsword/book/readings/ReadingsBook.java
   trunk/jsword/src/main/java/org/crosswire/jsword/book/readings/ReadingsBookDriver.java
   trunk/jsword/src/main/java/org/crosswire/jsword/util/Project.java
Log:
Hacked a fix for a JTextPane bug for Java 1.4.2.
Fixed a bug that limited Readings to the first listed.
Fixed a bug that prevented the JSword app dir from being found correctly.
Fixed a ThML bug.
Improved the XSLT for ThML h1..h6 tags.

Modified: trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/desktop/Desktop.java
===================================================================
--- trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/desktop/Desktop.java	2007-03-22 21:44:01 UTC (rev 1262)
+++ trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/desktop/Desktop.java	2007-03-25 02:05:01 UTC (rev 1263)
@@ -111,6 +111,14 @@
  */
 public class Desktop extends JFrame implements URLEventListener, ViewEventListener, DisplaySelectListener, ViewGenerator
 {
+    // This must be the first static in the program.
+    // To ensure this we place it at the top of the class!
+    // Calling Project.instance() will set up the project's home directory
+    //     ~/.jsword
+    // This will set it as a place to look for overrides for
+    // ResourceBundles, properties and other resources
+    private static final Project project = Project.instance();
+
     /**
      * Central start point.
      * @param args The command line arguments
@@ -137,12 +145,6 @@
      */
     public Desktop()
     {
-        // Calling Project.instance() will set up the project's home directory
-        //     ~/.jsword
-        // This will set it as a place to look for overrides for
-        // ResourceBundles, properties and other resources
-        Project project = Project.instance();
-
         // Allow the setting of user.language and user.country to influence the default locale
         String language = System.getProperty("user.language"); //$NON-NLS-1$
         String locale = null;

Modified: trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/display/textpane/TextPaneBookDataDisplay.java
===================================================================
--- trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/display/textpane/TextPaneBookDataDisplay.java	2007-03-22 21:44:01 UTC (rev 1262)
+++ trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/display/textpane/TextPaneBookDataDisplay.java	2007-03-25 02:05:01 UTC (rev 1263)
@@ -141,7 +141,19 @@
 
             htmlsep.setParameter("direction", direction ? "ltr" : "rtl"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
             String text = XMLUtil.writeToString(htmlsep);
-
+            /* BUG_PARADE(DMS): 4775730
+             * This bug shows up before Java 5 in GenBook Practice "/Part 1/THE THIRD STAGE" and elsewhere.
+             * It appears that it is a line too long issue.
+             */
+            /* Apply the fix if the text is too long and we are not Java 1.5 or greater */
+            if (text.length() > 32768)
+            {
+                String javaVersion = System.getProperty("java.specification.version"); //$NON-NLS-1$
+                if (javaVersion == null || "1.5".compareTo(javaVersion) > 0) //$NON-NLS-1$
+                {
+                    text = text.substring(0,32760) + "..."; //$NON-NLS-1$
+                }
+            }
             txtView.setText(text);
             txtView.select(0, 0);
         }

Modified: trunk/bibledesktop/src/main/resources/xsl/cswing/simple.xsl
===================================================================
--- trunk/bibledesktop/src/main/resources/xsl/cswing/simple.xsl	2007-03-22 21:44:01 UTC (rev 1262)
+++ trunk/bibledesktop/src/main/resources/xsl/cswing/simple.xsl	2007-03-25 02:05:01 UTC (rev 1263)
@@ -147,8 +147,14 @@
           FONT.divineName { font-variant: small-caps; }
           FONT.normal { font-variant: normal; }
           FONT.caps { text-transform: uppercase; }
-          h3 { font-size: 110%; color: #666699; font-weight: bold; }
-          h2 { font-size: 115%; color: #669966; font-weight: bold; }
+          H1.level { text-align: center; font-size: 115%; color: #000000; }
+          H2.level { text-align: center; font-size: 110%; color: #000000; }
+          H3.level { text-align: center; font-size: 100%; }
+          H4.level { text-align: center; font-size: 90%; }
+          H5.level { text-align: center; font-size: 85%; }
+          H6.level { text-align: center; font-size: 80%; }
+          H3.heading { font-size: 110%; color: #666699; font-weight: bold; }
+          H2.heading { font-size: 115%; color: #669966; font-weight: bold; }
           div.margin { font-size:90%; }
           TD.notes { width:20%; background:#f4f4e8; }
           TD.text { width:80%; }
@@ -287,7 +293,7 @@
         <xsl:when test="local-name() = 'title'">
           <!-- Always show canonical titles or if headings is turned on -->
           <xsl:if test="@canonical = 'true' or $Headings = 'true'">
-            <h3><xsl:apply-templates /></h3>
+            <h3 class="heading"><xsl:apply-templates /></h3>
           </xsl:if>
         </xsl:when>
         <xsl:otherwise>
@@ -320,7 +326,7 @@
     </xsl:if>
     <xsl:variable name="title" select=".//title"/>
     <xsl:if test="string-length($title) > 0">
-      <h3><xsl:value-of select="$title"/></h3>
+      <h3 class="heading"><xsl:value-of select="$title"/></h3>
     </xsl:if>
     <!-- Handle the KJV paragraph marker. -->
     <xsl:if test="milestone[@type = 'x-p']"><br/><br/></xsl:if>
@@ -728,7 +734,7 @@
   <!--=======================================================================-->
   <xsl:template match="title[@subType ='x-preverse' or @subtype = 'x-preverse']">
   <!-- Done by a line in [verse]
-    <h3>
+    <h3 class="heading">
       <xsl:apply-templates/>
     </h3>
   -->
@@ -736,24 +742,77 @@
 
   <xsl:template match="title[@subType ='x-preverse' or @subtype = 'x-preverse']" mode="jesus">
   <!-- Done by a line in [verse]
-    <h3>
+    <h3 class="heading">
       <xsl:apply-templates/>
     </h3>
   -->
   </xsl:template>
 
   <!--=======================================================================-->
+  <xsl:template match="title[@level]">
+    <!-- Always show canonical titles or if headings is turned on -->
+    <xsl:if test="@canonical = 'true' or $Headings = 'true'">
+      <xsl:choose>
+        <xsl:when test="@level = '1'">
+          <h1 class="level"><xsl:apply-templates/></h1>
+        </xsl:when>
+        <xsl:when test="@level = '2'">
+          <h2 class="level"><xsl:apply-templates/></h2>
+        </xsl:when>
+        <xsl:when test="@level = '3'">
+          <h3 class="level"><xsl:apply-templates/></h3>
+        </xsl:when>
+        <xsl:when test="@level = '4'">
+          <h4 class="level"><xsl:apply-templates/></h4>
+        </xsl:when>
+        <xsl:when test="@level = '5'">
+          <h5 class="level"><xsl:apply-templates/></h5>
+        </xsl:when>
+        <xsl:otherwise>
+          <h6 class="level"><xsl:apply-templates/></h6>
+        </xsl:otherwise>
+      </xsl:choose>
+    </xsl:if>
+  </xsl:template>
+
+  <xsl:template match="title[@level]" mode="jesus">
+    <!-- Always show canonical titles or if headings is turned on -->
+    <xsl:if test="@canonical = 'true' or $Headings = 'true'">
+      <xsl:choose>
+        <xsl:when test="@level = '1'">
+          <h1 class="level"><xsl:apply-templates/></h1>
+        </xsl:when>
+        <xsl:when test="@level = '2'">
+          <h2 class="level"><xsl:apply-templates/></h2>
+        </xsl:when>
+        <xsl:when test="@level = '3'">
+          <h3 class="level"><xsl:apply-templates/></h3>
+        </xsl:when>
+        <xsl:when test="@level = '4'">
+          <h4 class="level"><xsl:apply-templates/></h4>
+        </xsl:when>
+        <xsl:when test="@level = '5'">
+          <h5 class="level"><xsl:apply-templates/></h5>
+        </xsl:when>
+        <xsl:otherwise>
+          <h6 class="level"><xsl:apply-templates/></h6>
+        </xsl:otherwise>
+      </xsl:choose>
+    </xsl:if>
+  </xsl:template>
+
+  <!--=======================================================================-->
   <xsl:template match="title">
     <!-- Always show canonical titles or if headings is turned on -->
     <xsl:if test="@canonical = 'true' or $Headings = 'true'">
-      <h2><xsl:apply-templates/></h2>
+      <h2 class="heading"><xsl:apply-templates/></h2>
     </xsl:if>
   </xsl:template>
 
   <xsl:template match="title" mode="jesus">
     <!-- Always show canonical titles or if headings is turned on -->
     <xsl:if test="@canonical = 'true' or $Headings = 'true'">
-      <h2><xsl:apply-templates/></h2>
+      <h2 class="heading"><xsl:apply-templates/></h2>
     </xsl:if>
   </xsl:template>
 

Modified: trunk/common/src/main/java/org/crosswire/common/util/Logger.java
===================================================================
--- trunk/common/src/main/java/org/crosswire/common/util/Logger.java	2007-03-22 21:44:01 UTC (rev 1262)
+++ trunk/common/src/main/java/org/crosswire/common/util/Logger.java	2007-03-25 02:05:01 UTC (rev 1263)
@@ -27,9 +27,12 @@
 
 /**
  * This class is very similar to Commons-Logging except it should be even
- * smaller and have an API closer to the Log4J API (and even J2SE 1.4 logging)
- * to help us to move over.
- * Having our own class will also help with re-factoring.
+ * smaller and have an API closer to the Log4J API (and even J2SE 1.4 logging).
+ * 
+ * This implementation is lazy. The actual internal logger is not initialized
+ * until first use. Turns out that this class indirectly depends upon JSword's
+ * Project class to help find the logging configuration file. If it is not
+ * lazy, it looks in the wrong places for the configuration file.
  *
  * @see gnu.lgpl.License for license details.<br>
  *      The copyright to this program is held by it's authors.
@@ -51,7 +54,7 @@
      */
     public static void outputNothing()
     {
-        java.util.logging.Logger.getLogger(ROOT_LOGGER).setLevel(Level.OFF);
+        level = Level.OFF;
     }
 
     /**
@@ -59,7 +62,7 @@
      */
     public static void outputInfoMinimum()
     {
-        java.util.logging.Logger.getLogger(ROOT_LOGGER).setLevel(Level.WARNING);
+        level = Level.WARNING;
     }
 
     /**
@@ -67,7 +70,7 @@
      */
     public static void outputEverything()
     {
-        java.util.logging.Logger.getLogger(ROOT_LOGGER).setLevel(Level.FINEST);
+        level = Level.FINEST;
     }
 
     /**
@@ -75,7 +78,7 @@
      */
     private Logger(Class id)
     {
-        logger = java.util.logging.Logger.getLogger(id.getName());
+        clazz = id;
     }
 
     /**
@@ -156,17 +159,22 @@
      */
     public void debug(String message)
     {
+        initialize();
         logger.fine(message);
     }
 
     // Private method to infer the caller's class and method names
-    private void doLogging(Level level, String message, Throwable th)
+    private void doLogging(Level theLevel, String message, Throwable th)
     {
+        initialize();
+
         String className = null;
         String methodName = null;
         int lineNumber = -1;
+ 
         // Get the stack trace.
         StackTraceElement[] stack = (new Throwable()).getStackTrace();
+
         // First, search back to a method in the Logger class.
         int ix = 0;
         while (ix < stack.length)
@@ -179,6 +187,7 @@
             }
             ix++;
         }
+
         // Now search for the first frame before the "Logger" class.
         while (ix < stack.length)
         {
@@ -194,7 +203,8 @@
             }
             ix++;
         }
-        LogRecord logRecord = new LogRecord(level, message);
+
+        LogRecord logRecord = new LogRecord(theLevel, message);
         logRecord.setLoggerName(logger.getName());
         logRecord.setSourceClassName(className);
         logRecord.setSourceMethodName(methodName);
@@ -205,13 +215,30 @@
         logger.log(logRecord);
     }
 
-    static
+    private void initialize()
     {
         // Establish a class that will load logging properties into java.util.logging.LogManager
         System.setProperty("java.util.logging.config.class", LogConfig.class.getName()); //$NON-NLS-1$
+
+        // If we don't have a logger, create one now.
+        if (logger == null)
+        {
+            logger = java.util.logging.Logger.getLogger(clazz.getName());            
+        }
+    
+        // If there was a request to change the mimimum level of logging
+        // handle it now.
+        if (level != null)
+        {
+            java.util.logging.Logger.getLogger(ROOT_LOGGER).setLevel(level);
+            level = null;
+        }
     }
 
     private static final String ROOT_LOGGER = ""; //$NON-NLS-1$
     private static final String CLASS_NAME = Logger.class.getName();
+    private static Level level;
+
+    private Class clazz;
     private java.util.logging.Logger logger;
 }

Modified: trunk/common-swing/src/main/java/org/crosswire/common/swing/FixedSplitPane.java
===================================================================
--- trunk/common-swing/src/main/java/org/crosswire/common/swing/FixedSplitPane.java	2007-03-22 21:44:01 UTC (rev 1262)
+++ trunk/common-swing/src/main/java/org/crosswire/common/swing/FixedSplitPane.java	2007-03-25 02:05:01 UTC (rev 1263)
@@ -62,6 +62,7 @@
  *      The copyright to this program is held by it's authors.
  * @author DM Smith [dmsmith555 at yahoo dot com]
  */
+/* BUG_PARADE(DMS): many bugs here */
 public class FixedSplitPane extends JSplitPane
 {
     /**

Modified: trunk/common-swing/src/main/java/org/crosswire/common/swing/FontChooser.java
===================================================================
--- trunk/common-swing/src/main/java/org/crosswire/common/swing/FontChooser.java	2007-03-22 21:44:01 UTC (rev 1262)
+++ trunk/common-swing/src/main/java/org/crosswire/common/swing/FontChooser.java	2007-03-25 02:05:01 UTC (rev 1263)
@@ -256,7 +256,7 @@
             for (int i = 0; i < fonts.length; i++)
             {
                 // We need to exclude certain fonts that cause the JVM to crash.
-                // See Bug Parade 6376296
+                // BUG_PARADE(DMS): 6376296
                 // It will be fixed in Java 1.6 (Mustang)
                 if (names[i].equals("padmaa") || names[i].equals("Rekha") || names[i].indexOf("Lohit") > -1 || names[i].indexOf("aakar") > -1) //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
                 {

Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/Defaults.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/Defaults.java	2007-03-22 21:44:01 UTC (rev 1262)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/Defaults.java	2007-03-25 02:05:01 UTC (rev 1263)
@@ -454,7 +454,6 @@
         // Create the array of DailyDevotionals
         String[] rnames = getFullNameArray(BookFilters.getDailyDevotionals());
         ChoiceFactory.getDataMap().put(DAILY_DEVOTIONALS_KEY, rnames);
-        //ChoiceFactory.getDataMap().put(DAILY_DEVOTIONALS_KEY, ReadingsBookDriver.getInstalledReadingsSets());
 
         // Create the array of Dictionaries
         String[] greekDef = getFullNameArray(BookFilters.getGreekDefinitions());

Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/OSISUtil.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/OSISUtil.java	2007-03-22 21:44:01 UTC (rev 1262)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/OSISUtil.java	2007-03-25 02:05:01 UTC (rev 1263)
@@ -247,6 +247,7 @@
     public static final String OSIS_ATTR_TYPE = "type"; //$NON-NLS-1$
     public static final String OSIS_ATTR_SUBTYPE = "subType"; //$NON-NLS-1$
     public static final String OSIS_ATTR_REF = "osisRef"; //$NON-NLS-1$
+    public static final String OSIS_ATTR_LEVEL = "level"; //$NON-NLS-1$
     public static final String ATTRIBUTE_SPEAKER_WHO = "who"; //$NON-NLS-1$
     public static final String ATTRIBUTE_W_MORPH = "morph"; //$NON-NLS-1$
     public static final String ATTRIBUTE_OSISTEXT_OSISIDWORK = "osisIDWork"; //$NON-NLS-1$

Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/filter/thml/CustomHandler.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/filter/thml/CustomHandler.java	2007-03-22 21:44:01 UTC (rev 1262)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/filter/thml/CustomHandler.java	2007-03-25 02:05:01 UTC (rev 1263)
@@ -262,10 +262,12 @@
             new UlTag(),
             new AliasTag("em", new ITag()), //$NON-NLS-1$
             new AliasTag("strong", new BTag()), //$NON-NLS-1$
-            new AliasTag("h1", new BTag()), //$NON-NLS-1$
-            new AliasTag("h2", new BTag()), //$NON-NLS-1$
-            new AliasTag("h3", new BTag()), //$NON-NLS-1$
-            new AliasTag("h4", new BTag()), //$NON-NLS-1$
+            new AliasTag("h1", new HTag(1)), //$NON-NLS-1$
+            new AliasTag("h2", new HTag(2)), //$NON-NLS-1$
+            new AliasTag("h3", new HTag(3)), //$NON-NLS-1$
+            new AliasTag("h4", new HTag(4)), //$NON-NLS-1$
+            new AliasTag("h5", new HTag(5)), //$NON-NLS-1$
+            new AliasTag("h6", new HTag(6)), //$NON-NLS-1$
             new AliasTag("dl", new UlTag()), //$NON-NLS-1$
             new AliasTag("dd", new LiTag()), //$NON-NLS-1$
             new AliasTag("dt", new LiTag()), //$NON-NLS-1$

Added: trunk/jsword/src/main/java/org/crosswire/jsword/book/filter/thml/HTag.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/filter/thml/HTag.java	                        (rev 0)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/filter/thml/HTag.java	2007-03-25 02:05:01 UTC (rev 1263)
@@ -0,0 +1,76 @@
+/**
+ * Distribution License:
+ * JSword is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License, version 2.1 as published by
+ * the Free Software Foundation. This program is distributed in the hope
+ * that it will be useful, but WITHOUT ANY WARRANTY; without even the
+ * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU Lesser General Public License for more details.
+ *
+ * The License is available on the internet at:
+ *       http://www.gnu.org/copyleft/lgpl.html
+ * or by writing to:
+ *      Free Software Foundation, Inc.
+ *      59 Temple Place - Suite 330
+ *      Boston, MA 02111-1307, USA
+ *
+ * Copyright: 2005
+ *     The copyright to this program is held by it's authors.
+ *
+ * ID: $Id: BTag.java 1185 2006-11-13 08:32:18 -0500 (Mon, 13 Nov 2006) dmsmith $
+ */
+package org.crosswire.jsword.book.filter.thml;
+
+import org.crosswire.jsword.book.OSISUtil;
+import org.jdom.Element;
+import org.xml.sax.Attributes;
+
+/**
+ * THML Tag to process the H1, h2, h3, h4, h5, and h6 elements.
+ * 
+ * @see gnu.lgpl.License for license details.
+ *      The copyright to this program is held by it's authors.
+ * @author DM Smith [dmsmith at yahoo dot com]
+ */
+public class HTag extends AbstractTag
+{
+    /**
+     * Create an H tag of the given level
+     * @param level
+     */
+    public HTag(int level)
+    {
+        super();
+        this.level = level;
+    }
+
+    /* (non-Javadoc)
+     * @see org.crosswire.jsword.book.filter.thml.Tag#getTagName()
+     */
+    public String getTagName()
+    {
+        return "h" + level; //$NON-NLS-1$
+    }
+
+    /* (non-Javadoc)
+     * @see org.crosswire.jsword.book.filter.thml.Tag#processTag(org.jdom.Element, org.xml.sax.Attributes)
+     */
+    /* @Override */
+    public Element processTag(Element ele, Attributes attrs)
+    {
+        Element title = OSISUtil.factory().createTitle();
+        title.setAttribute(OSISUtil.OSIS_ATTR_LEVEL, Integer.toString(level));
+
+        if (ele != null)
+        {
+            ele.addContent(title);
+        }
+
+        return title;
+    }
+
+    /**
+     * The level of the title
+     */
+    private int level;
+}

Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/readings/ReadingsBook.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/readings/ReadingsBook.java	2007-03-22 21:44:01 UTC (rev 1262)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/readings/ReadingsBook.java	2007-03-25 02:05:01 UTC (rev 1263)
@@ -65,14 +65,12 @@
     /**
      * Constructor for ReadingsBook.
      */
-    public ReadingsBook(ReadingsBookDriver driver, BookCategory type)
+    public ReadingsBook(ReadingsBookDriver driver, String setname, BookCategory type)
     {
         super(null); // set the book metadata later
 
         hash = new TreeMap();
 
-        String setname = ReadingsBookDriver.getReadingsSet();
-
         Locale defaultLocale = Locale.getDefault();
         ResourceBundle prop = ResourceBundle.getBundle(setname, defaultLocale, CWClassLoader.instance(ReadingsBookDriver.class));
 

Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/readings/ReadingsBookDriver.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/readings/ReadingsBookDriver.java	2007-03-22 21:44:01 UTC (rev 1262)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/readings/ReadingsBookDriver.java	2007-03-25 02:05:01 UTC (rev 1263)
@@ -23,6 +23,8 @@
 
 import java.io.IOException;
 import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
 
 import org.crosswire.common.util.NetUtil;
 import org.crosswire.common.util.ResourceUtil;
@@ -46,10 +48,14 @@
      */
     public ReadingsBookDriver()
     {
-        books = new Book[]
+        List bookList = new ArrayList();
+        String[] installedBooks = getInstalledReadingsSets();
+        for (int i = 0; i < installedBooks.length; i++)
         {
-            new ReadingsBook(this, BookCategory.DAILY_DEVOTIONS),
-        };
+            bookList.add(new ReadingsBook(this, installedBooks[i], BookCategory.DAILY_DEVOTIONS));
+        }
+
+        books = (Book[]) bookList.toArray(new Book[bookList.size()]);
     }
 
     /* (non-Javadoc)
@@ -82,7 +88,7 @@
     /**
      * Get a list of the available readings sets
      */
-    public static String[] getInstalledReadingsSets()
+    public String[] getInstalledReadingsSets()
     {
         try
         {
@@ -102,31 +108,6 @@
     }
 
     /**
-     * Accessor for the current readings set
-     */
-    public static String getReadingsSet()
-    {
-        if (set == null)
-        {
-            String[] readings = getInstalledReadingsSets();
-            if (readings.length > 0)
-            {
-                set = readings[0];
-            }
-        }
-
-        return set;
-    }
-
-    /**
-     * Accessor for the current readings set
-     */
-    public static void setReadingsSet(String set)
-    {
-        ReadingsBookDriver.set = set;
-    }
-
-    /**
      * The meta data array
      */
     private Book[] books;
@@ -140,9 +121,4 @@
      * A shared instance of this driver.
      */
     private static final BookDriver INSTANCE = new ReadingsBookDriver();
-
-    /**
-     * The current readings set
-     */
-    private static String set;
 }

Modified: trunk/jsword/src/main/java/org/crosswire/jsword/util/Project.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/util/Project.java	2007-03-22 21:44:01 UTC (rev 1262)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/util/Project.java	2007-03-25 02:05:01 UTC (rev 1263)
@@ -181,7 +181,11 @@
         {
             File oldDir = new File(oldPath.getFile());
             File newDir = new File(newPath.getFile());
-            if (oldDir.renameTo(newDir))
+
+            // This will return false if it could not rename.
+            // This will happen if the directory already exists.
+            oldDir.renameTo(newDir);
+            if (NetUtil.isDirectory(newPath))
             {
                 return newPath;
             }




More information about the jsword-svn mailing list