[jsword-svn] r1278 - in trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop: book/install desktop display/textpane util

dmsmith at www.crosswire.org dmsmith at www.crosswire.org
Thu Apr 19 14:11:14 MST 2007


Author: dmsmith
Date: 2007-04-19 14:11:13 -0700 (Thu, 19 Apr 2007)
New Revision: 1278

Modified:
   trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/book/install/TextPaneBookMetaDataDisplay.java
   trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/desktop/Desktop.java
   trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/desktop/ViewSourcePane.java
   trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/desktop/XSLTProperty.java
   trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/display/textpane/TextPaneBookDataDisplay.java
   trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/util/ConfigurableSwingConverter.java
Log:
Added all simple.xslt parameters to XSLTProperty.

Modified: trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/book/install/TextPaneBookMetaDataDisplay.java
===================================================================
--- trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/book/install/TextPaneBookMetaDataDisplay.java	2007-04-19 19:32:30 UTC (rev 1277)
+++ trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/book/install/TextPaneBookMetaDataDisplay.java	2007-04-19 21:11:13 UTC (rev 1278)
@@ -27,6 +27,7 @@
 import javax.swing.text.html.HTMLEditorKit;
 import javax.xml.transform.TransformerException;
 
+import org.crosswire.bibledesktop.desktop.XSLTProperty;
 import org.crosswire.common.swing.AntiAliasedTextPane;
 import org.crosswire.common.util.Logger;
 import org.crosswire.common.util.Reporter;
@@ -76,6 +77,7 @@
 
             SAXEventProvider osissep = new JDOMSAXEventProvider(book.toOSIS());
             TransformingSAXEventProvider htmlsep = (TransformingSAXEventProvider) converter.convert(osissep);
+            XSLTProperty.FONT.setProperty(htmlsep);
             String text = XMLUtil.writeToString(htmlsep);
 
             txtView.setText(text);

Modified: trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/desktop/Desktop.java
===================================================================
--- trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/desktop/Desktop.java	2007-04-19 19:32:30 UTC (rev 1277)
+++ trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/desktop/Desktop.java	2007-04-19 21:11:13 UTC (rev 1278)
@@ -432,46 +432,46 @@
     {
         JMenu menuView = new JMenu(actions.getAction(DesktopActions.VIEW));
         JCheckBoxMenuItem toggle = new JCheckBoxMenuItem(actions.getAction(XSLTProperty.TINY_VERSE_NUMBERS.getName()));
-        toggle.setSelected(XSLTProperty.TINY_VERSE_NUMBERS.getDefault());
+        toggle.setSelected(XSLTProperty.TINY_VERSE_NUMBERS.getDefaultState());
         menuView.add(toggle).addMouseListener(barStatus);
         toggle = new JCheckBoxMenuItem(actions.getAction(XSLTProperty.START_VERSE_ON_NEWLINE.getName()));
-        toggle.setSelected(XSLTProperty.START_VERSE_ON_NEWLINE.getDefault());
+        toggle.setSelected(XSLTProperty.START_VERSE_ON_NEWLINE.getDefaultState());
         menuView.add(toggle).addMouseListener(barStatus);
         JMenu verseMenu = new JMenu(actions.getAction(DesktopActions.VERSE));
         menuView.add(verseMenu);
         ButtonGroup grpNumbering = new ButtonGroup();
         JRadioButtonMenuItem radio = new JRadioButtonMenuItem(actions.getAction(XSLTProperty.VERSE_NUMBERS.getName()));
         grpNumbering.add(radio);
-        radio.setSelected(XSLTProperty.VERSE_NUMBERS.getDefault());
+        radio.setSelected(XSLTProperty.VERSE_NUMBERS.getDefaultState());
         verseMenu.add(radio).addMouseListener(barStatus);
         radio = new JRadioButtonMenuItem(actions.getAction(XSLTProperty.CV.getName()));
         grpNumbering.add(radio);
-        radio.setSelected(XSLTProperty.CV.getDefault());
+        radio.setSelected(XSLTProperty.CV.getDefaultState());
         verseMenu.add(radio).addMouseListener(barStatus);
         radio = new JRadioButtonMenuItem(actions.getAction(XSLTProperty.BCV.getName()));
         grpNumbering.add(radio);
-        radio.setSelected(XSLTProperty.BCV.getDefault());
+        radio.setSelected(XSLTProperty.BCV.getDefaultState());
         verseMenu.add(radio).addMouseListener(barStatus);
         radio = new JRadioButtonMenuItem(actions.getAction(XSLTProperty.NO_VERSE_NUMBERS.getName()));
         grpNumbering.add(radio);
-        radio.setSelected(XSLTProperty.NO_VERSE_NUMBERS.getDefault());
+        radio.setSelected(XSLTProperty.NO_VERSE_NUMBERS.getDefaultState());
         verseMenu.add(radio).addMouseListener(barStatus);
 
         menuView.addSeparator();
         toggle = new JCheckBoxMenuItem(actions.getAction(XSLTProperty.HEADINGS.getName()));
-        toggle.setSelected(XSLTProperty.HEADINGS.getDefault());
+        toggle.setSelected(XSLTProperty.HEADINGS.getDefaultState());
         menuView.add(toggle).addMouseListener(barStatus);
         toggle = new JCheckBoxMenuItem(actions.getAction(XSLTProperty.NOTES.getName()));
-        toggle.setSelected(XSLTProperty.NOTES.getDefault());
+        toggle.setSelected(XSLTProperty.NOTES.getDefaultState());
         menuView.add(toggle).addMouseListener(barStatus);
         toggle = new JCheckBoxMenuItem(actions.getAction(XSLTProperty.XREF.getName()));
-        toggle.setSelected(XSLTProperty.XREF.getDefault());
+        toggle.setSelected(XSLTProperty.XREF.getDefaultState());
         menuView.add(toggle).addMouseListener(barStatus);
         toggle = new JCheckBoxMenuItem(actions.getAction(XSLTProperty.STRONGS_NUMBERS.getName()));
-        toggle.setSelected(XSLTProperty.STRONGS_NUMBERS.getDefault());
+        toggle.setSelected(XSLTProperty.STRONGS_NUMBERS.getDefaultState());
         menuView.add(toggle).addMouseListener(barStatus);
         toggle = new JCheckBoxMenuItem(actions.getAction(XSLTProperty.MORPH.getName()));
-        toggle.setSelected(XSLTProperty.MORPH.getDefault());
+        toggle.setSelected(XSLTProperty.MORPH.getDefaultState());
         menuView.add(toggle).addMouseListener(barStatus);
         menuView.addSeparator();
         menuView.add(views.getTdiView()).addMouseListener(barStatus);

Modified: trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/desktop/ViewSourcePane.java
===================================================================
--- trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/desktop/ViewSourcePane.java	2007-04-19 19:32:30 UTC (rev 1277)
+++ trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/desktop/ViewSourcePane.java	2007-04-19 21:11:13 UTC (rev 1278)
@@ -28,6 +28,7 @@
 import java.awt.Frame;
 import java.awt.Toolkit;
 import java.awt.datatransfer.StringSelection;
+import java.net.URL;
 import java.util.Iterator;
 
 import javax.swing.BorderFactory;
@@ -90,7 +91,6 @@
             BookData bdata = book.getText(key);
 
             BookMetaData bmd = book.getBookMetaData();
-            boolean direction = bmd.isLeftToRight();
 
             SAXEventProvider osissep = bdata.getSAXEventProvider();
 
@@ -100,11 +100,23 @@
             osissep.provideSAXEvents(osis);
 
             TransformingSAXEventProvider htmlsep = (TransformingSAXEventProvider) converter.convert(osissep);
+  
+            XSLTProperty.DIRECTION.setState(bmd.isLeftToRight() ? "ltr" : "rtl"); //$NON-NLS-1$ //$NON-NLS-2$
+
+            URL loc = bmd.getLocation();
+            XSLTProperty.BASE_URL.setState(loc == null ? "" : loc.toExternalForm()); //$NON-NLS-1$
+
             if (bmd.getBookCategory() == BookCategory.BIBLE)
             {
                 XSLTProperty.setProperties(htmlsep);
             }
-            htmlsep.setParameter("direction", direction ? "ltr" : "rtl"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+            else
+            {
+                XSLTProperty.CSS.setProperty(htmlsep);
+                XSLTProperty.FONT.setProperty(htmlsep);
+                XSLTProperty.BASE_URL.setProperty(htmlsep);
+                XSLTProperty.DIRECTION.setProperty(htmlsep);
+            }
 
             // This really looks nice but its performance was terrible.
 //            ContentHandler html = new HTMLSerializingContentHandler(FormatType.CLASSIC_INDENT);

Modified: trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/desktop/XSLTProperty.java
===================================================================
--- trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/desktop/XSLTProperty.java	2007-04-19 19:32:30 UTC (rev 1277)
+++ trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/desktop/XSLTProperty.java	2007-04-19 21:11:13 UTC (rev 1278)
@@ -35,7 +35,6 @@
  */
 public final class XSLTProperty implements Serializable
 {
-
     /**
      * Determines whether Strong's Numbers should show
      */
@@ -92,10 +91,43 @@
     public static final XSLTProperty XREF = new XSLTProperty("XRef", true); //$NON-NLS-1$
 
     /**
+     * What is the base of the current document.
+     * Note this needs to be set each time the document is shown.
+     */
+    public static final XSLTProperty BASE_URL = new XSLTProperty("baseURL", ""); //$NON-NLS-1$ //$NON-NLS-2$
+
+    /**
+     * What is the base of the current document.
+     *  Note this needs to be set each time the document is shown.
+     */
+    public static final XSLTProperty DIRECTION = new XSLTProperty("direction", ""); //$NON-NLS-1$ //$NON-NLS-2$
+
+    /**
+     * What is the base of the current document.
+     * Note this needs to be set each time the font changes.
+     */
+    public static final XSLTProperty FONT = new XSLTProperty("font", "Serif,0,14"); //$NON-NLS-1$ //$NON-NLS-2$
+
+    /**
+     * What is the base of the current document.
+     */
+    public static final XSLTProperty CSS = new XSLTProperty("css", ""); //$NON-NLS-1$ //$NON-NLS-2$
+
+    /**
      * @param name The name of this property
+     * @param defaultState The initial state of the property.
      */
     private XSLTProperty(String name, boolean defaultState)
     {
+        this(name, Boolean.toString(defaultState));
+    }
+
+    /**
+     * @param name The name of this property
+     * @param defaultState The initial state of the property.
+     */
+    private XSLTProperty(String name, String defaultState)
+    {
         this.name = name;
         this.defaultState = defaultState;
         this.state = defaultState;
@@ -109,24 +141,32 @@
         return name;
     }
 
-    public boolean getDefault()
+    public boolean getDefaultState()
     {
-        return defaultState;
+        return Boolean.valueOf(defaultState).booleanValue();
     }
 
     public boolean getState()
     {
-        return state;
+        return Boolean.valueOf(state).booleanValue();
     }
 
     public void setState(boolean newState)
     {
+        state = Boolean.toString(newState);
+    }
+
+    public void setState(String newState)
+    {
         state = newState;
     }
 
     public void setProperty(TransformingSAXEventProvider provider)
     {
-        provider.setParameter(name, Boolean.toString(state));
+        if (state != null && state.length() > 0)
+        {
+            provider.setParameter(name, state);
+        }
     }
 
     public static void setProperties(TransformingSAXEventProvider provider)
@@ -178,12 +218,12 @@
     /**
      * The default state of the XSLTProperty
      */
-    private boolean defaultState;
+    private String defaultState;
 
     /**
      * The current state of the XSLTProperty
      */
-    private boolean state;
+    private String state;
 
     // Support for serialization
     private static int nextObj;
@@ -207,6 +247,10 @@
         HEADINGS,
         NOTES,
         XREF,
+        BASE_URL,
+        DIRECTION,
+        FONT,
+        CSS,
     };
 
     /**

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-04-19 19:32:30 UTC (rev 1277)
+++ trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/display/textpane/TextPaneBookDataDisplay.java	2007-04-19 21:11:13 UTC (rev 1278)
@@ -128,18 +128,29 @@
 
             SAXEventProvider osissep = bdata.getSAXEventProvider();
             TransformingSAXEventProvider htmlsep = (TransformingSAXEventProvider) converter.convert(osissep);
+
+            XSLTProperty.DIRECTION.setState(bmd.isLeftToRight() ? "ltr" : "rtl"); //$NON-NLS-1$ //$NON-NLS-2$
+
+            URL loc = bmd.getLocation();
+            XSLTProperty.BASE_URL.setState(loc == null ? "" : loc.toExternalForm()); //$NON-NLS-1$
+
             if (bmd.getBookCategory() == BookCategory.BIBLE)
             {
                 XSLTProperty.setProperties(htmlsep);
             }
+            else
+            {
+                XSLTProperty.CSS.setProperty(htmlsep);
+                XSLTProperty.FONT.setProperty(htmlsep);
+                XSLTProperty.BASE_URL.setProperty(htmlsep);
+                XSLTProperty.DIRECTION.setProperty(htmlsep);
+            }
 
-            URL loc = bmd.getLocation();
-            if (loc != null)
+            if (bmd.getBookCategory() == BookCategory.BIBLE)
             {
-                htmlsep.setParameter("baseURL", loc.toExternalForm()); //$NON-NLS-1$
+                XSLTProperty.setProperties(htmlsep);
             }
 
-            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.

Modified: trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/util/ConfigurableSwingConverter.java
===================================================================
--- trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/util/ConfigurableSwingConverter.java	2007-04-19 19:32:30 UTC (rev 1277)
+++ trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/util/ConfigurableSwingConverter.java	2007-04-19 21:11:13 UTC (rev 1278)
@@ -28,6 +28,7 @@
 
 import javax.xml.transform.TransformerException;
 
+import org.crosswire.bibledesktop.desktop.XSLTProperty;
 import org.crosswire.common.util.FileUtil;
 import org.crosswire.common.util.NetUtil;
 import org.crosswire.common.util.ResourceUtil;
@@ -123,6 +124,7 @@
     public static void setFont(String font)
     {
         ConfigurableSwingConverter.font = font;
+        XSLTProperty.FONT.setState(font);
     }
 
     /**




More information about the jsword-svn mailing list