[sword-svn] r219 - in trunk: . src src/org/crosswire/swordweb

jansorg at crosswire.org jansorg at crosswire.org
Sat Oct 8 11:38:15 MST 2005


Author: jansorg
Date: 2005-10-08 11:38:15 -0700 (Sat, 08 Oct 2005)
New Revision: 219

Modified:
   trunk/parallelstudy.jsp
   trunk/passagestudy.jsp
   trunk/src/Makefile
   trunk/src/org/crosswire/swordweb/HorizontallyParallelTextRendering.java
   trunk/src/org/crosswire/swordweb/ModuleEntryRenderer.java
   trunk/src/org/crosswire/swordweb/ModuleTextRendering.java
   trunk/src/org/crosswire/swordweb/RangeInformation.java
   trunk/src/org/crosswire/swordweb/SidebarItemRenderer.java
   trunk/src/org/crosswire/swordweb/SidebarModuleView.java
   trunk/src/org/crosswire/swordweb/SimpleEntryRenderer.java
   trunk/src/org/crosswire/swordweb/SimpleModuleView.java
   trunk/src/org/crosswire/swordweb/StandardEntryRenderer.java
   trunk/src/org/crosswire/swordweb/VerticallyParallelTextRendering.java
Log:
fixes, cleanups, merging back lost changes, makefile update for new classes

Modified: trunk/parallelstudy.jsp
===================================================================
--- trunk/parallelstudy.jsp	2005-10-07 21:17:23 UTC (rev 218)
+++ trunk/parallelstudy.jsp	2005-10-08 18:38:15 UTC (rev 219)
@@ -49,15 +49,15 @@
 
 	boolean startList = false;
 
-	String parallelViewType = (String) session.getAttribute("parallelViewType");
-	buf = request.getParameter("parallelViewType");
+	String parallelViewType = (String) session.getAttribute("parallel");
+	buf = request.getParameter("parallel");
 	if (buf != null) {
 		parallelViewType = buf;
 	}
 	if (parallelViewType == null) {
 		parallelViewType = "sidebyside";
 	}
-	session.setAttribute("parallelViewType", parallelViewType);
+	session.setAttribute("parallel", parallelViewType);
 	
 	SidebarModuleView sidebarView = new SimpleModuleView(mgr);
 	SidebarItemRenderer delModRenderer = new SidebarItemRenderer() {
@@ -103,29 +103,24 @@
 		<p><t:t>click to remove</t:t></p>
 		<%
 			Vector modules = new Vector();
-			
-			modules.clear();
 			for (int i = 0; i < parDispModules.size(); i++) {
 				SWModule module = mgr.getModuleByName((String)parDispModules.get(i));
 				if (module != null && ((module.getCategory().equals(SwordOrb.BIBLES))||(module.getCategory().equals("Cults / Unorthodox / Questionable Material")))) {
 					modules.add(module.getName());
 				}
 			}
-
 			out.print( sidebarView.renderView(modules, delModRenderer) );
 		%>
 
 		<h3><t:t>Available modules</t:t></h3>
 		<p><t:t>click to add</t:t></p>
-		<%
-			
+		<%			
 			modules.clear();
 			for (int i = 0; i < modInfo.length; i++) {
 				if (modInfo[i].category.equals(SwordOrb.BIBLES) && !parDispModules.contains(modInfo[i].name)) {
 					modules.add(modInfo[i].name);
 				}
 			}
-
 			out.print( sidebarView.renderView(modules, addModRenderer) );
 		%>
 
@@ -137,7 +132,6 @@
 					modules.add(modInfo[i].name);
 				}
 			}
-
 			out.print( sidebarView.renderView(modules, addModRenderer) );	
 		%>
 
@@ -158,8 +152,8 @@
 		<div id="studytools">
 			<h2><t:t>Parallel viewing:</t:t></h2>
 			<ul>
-				<li><a href="parallelstudy.jsp?parallelViewType=sidebyside">Side by side</a></li>
-				<li><a href="parallelstudy.jsp?parallelViewType=toptobottom">Top to bottom</a></li>
+				<li><a href="parallelstudy.jsp?parallel=sidebyside">Side by side</a></li>
+				<li><a href="parallelstudy.jsp?parallel=toptobottom">Top to bottom</a></li>
 			</ul>
 		</div>
 
@@ -169,7 +163,7 @@
 		<h3><t:t>Displayed modules</t:t></h3>
 		<p><t:t>click to remove</t:t></p>
 		<%
-			Vector modules =  new Vector();
+			Vector modules = new Vector();
 			for (int i = 0; i < parDispModules.size(); i++) {
 				SWModule module = mgr.getModuleByName((String)parDispModules.get(i));
 				if (module != null && module.getCategory().equals(SwordOrb.COMMENTARIES)) {
@@ -268,8 +262,6 @@
 				copyLine = "<t:t>WARNING: This text is considered unorthodox by most of Christendom.</t:t> " + copyLine;
 			}
 		%>
-
-
 		</div>
 	</tiles:put>
 </tiles:insert>

Modified: trunk/passagestudy.jsp
===================================================================
--- trunk/passagestudy.jsp	2005-10-07 21:17:23 UTC (rev 218)
+++ trunk/passagestudy.jsp	2005-10-08 18:38:15 UTC (rev 219)
@@ -116,7 +116,7 @@
 						modules.add(modInfo[i].name);
 					}
 				}
-				modules.removeAll( prefBibles );
+				modules.removeAll( prefBibles ); //don't include the prefered bibles in the long module list
 				out.print( sidebarView.renderView(modules, displayModRenderer) ); //render the complete Bible modules list
 			}
 		%>
@@ -173,8 +173,7 @@
 						modules.add(modInfo[i].name);
 					}
 				}
-				modules.removeAll( prefCommentaries );
-				
+				modules.removeAll( prefCommentaries ); //no preferred commentaries in the long list				
 				out.print( sidebarView.renderView(modules, displayModRenderer) ); //render the complete Commentary module list
 			}
 		%>
@@ -204,7 +203,7 @@
 			Vector moduleList = new Vector();
 			moduleList.add( activeModule );
 			
-			Vector entryList;
+			Vector entryList = null;
 			if ((activeModule.getCategory().equals("Cults / Unorthodox / Questionable Material")) || (activeModule.getCategory().equals(SwordOrb.BIBLES))) {
 				entryList = RangeInformation.getChapterEntryList(activeKey, activeModule);
 			}
@@ -212,7 +211,7 @@
 				entryList = new Vector();
 				entryList.add(activeKey);
 			}
-				
+
 			ModuleTextRendering rendering = new HorizontallyParallelTextRendering(); //passagestudy is a parallel view with just one module at the same time
 			ModuleEntryRenderer entryRenderer = new StandardEntryRenderer( new String("passagestudy.jsp"), activeKey, mgr );
 			if (strongs) {
@@ -235,11 +234,6 @@
 		%>
 		
 		<div class="copyLine"><%= copyLine %></div>
-<%-- 		<ul class="booknav">
-			<li><a href="passagestudy.jsp?key=<%= URLEncoder.encode(prevChapterString) %>" title="Display <%= prevChapterString %>"><t:t>previous chapter</t:t></a></li>
-			<li><h3><%= activeKey %></h3></li>
-			<li><a href="passagestudy.jsp?key=<%= URLEncoder.encode(nextChapterString) %>" title="Display <%= nextChapterString %>"><t:t>next chapter</t:t></a></li>
-		</ul> --%>
 		<div class="promoLine"><%= promoLine %></div>
 		</div>
 	</tiles:put>

Modified: trunk/src/Makefile
===================================================================
--- trunk/src/Makefile	2005-10-07 21:17:23 UTC (rev 218)
+++ trunk/src/Makefile	2005-10-08 18:38:15 UTC (rev 219)
@@ -1,7 +1,9 @@
 TOMCAT_HOME=/usr/local/tomcat
+#TOMCAT_HOME=/usr/share/tomcat5
 instdir=..
 all: ../WEB-INF/classes/org/crosswire/web/i18n/TranslateTag.class
-
+	javac -Xlint -Xlint:unchecked:deprecation -classpath ../WEB-INF/classes/ -d ../WEB-INF/classes/ ./org/crosswire/swordweb/*.java
+	
 ../WEB-INF/classes/org/crosswire/web/i18n/TranslateTag.class: org/crosswire/web/i18n/TranslateTag.java
 	javac -classpath ${TOMCAT_HOME}/common/lib/jsp-api.jar:${TOMCAT_HOME}/common/lib/servlet-api.jar -d ../WEB-INF/classes -sourcepath . ./org/crosswire/web/i18n/*.java ./org/crosswire/web/util/*.java
 

Modified: trunk/src/org/crosswire/swordweb/HorizontallyParallelTextRendering.java
===================================================================
--- trunk/src/org/crosswire/swordweb/HorizontallyParallelTextRendering.java	2005-10-07 21:17:23 UTC (rev 218)
+++ trunk/src/org/crosswire/swordweb/HorizontallyParallelTextRendering.java	2005-10-08 18:38:15 UTC (rev 219)
@@ -1,59 +1,63 @@
 package org.crosswire.swordweb;
 
+import java.io.UnsupportedEncodingException;
+import java.net.URLEncoder;
+import java.util.Enumeration;
 import java.util.Vector;
-import java.util.Enumeration;
-import java.net.URLEncoder;
+import org.crosswire.sword.orb.*;
 
-import org.crosswire.sword.orb.SWModule;
-import org.crosswire.sword.orb.SWMgr;
-
 public class HorizontallyParallelTextRendering implements ModuleTextRendering {
-	private Vector _modules;
-	private String _range;
-	
-	public String render( Vector modules, Vector entryList, ModuleEntryRenderer renderer ) {
-		StringBuffer ret = new StringBuffer();
-		ret.append("<table>");
-		
-		ret.append("<colgroup>");//setup col attributes
-		for (int i = 0; i < modules.size(); i++) {
-			ret.append("<col width=\"").append(100/modules.size()).append("%\" />");
-		}
-		ret.append("</colgroup>");
-		
-		ret.append("<thead><tr>");
-		
-		Enumeration moduleEnum = modules.elements();
-		while (moduleEnum.hasMoreElements()) {
-			SWModule mod = (SWModule)moduleEnum.nextElement();
-			ret.append("<th><a href=\"fulllibrary.jsp?show=").append(URLEncoder.encode(mod.getName())).append("\">");
-			ret.append( mod.getDescription().replaceAll("&", "&amp;")).append(" (").append(mod.getName()).append(")");
-			ret.append("</a></th>");
+    public String render(Vector modules, Vector entryList,
+            ModuleEntryRenderer renderer) {
+        StringBuffer ret = new StringBuffer();
+        ret.append("<table>");
+        
+        ret.append("<colgroup>");// setup col attributes
+        for (int i = 0; i < modules.size(); i++) {
+            ret.append("<col width=\"").append(100 / modules.size());
+            ret.append("%\" />");
+        }
+        ret.append("</colgroup>");
+        
+        ret.append("<thead><tr>");
 
-		}
-		ret.append("</tr></thead>");
-		
-		ret.append("<tbody>");
-		
-		Vector swordMods = new Vector();
-		moduleEnum = modules.elements();
-		while ( moduleEnum.hasMoreElements() ) {
-			try {
-				SWModule mod = (SWModule)moduleEnum.nextElement();
-				swordMods.add(mod);
-			}
-			catch (Exception e){
-				break;
-			}
-		}	
-			
-		Enumeration entryEnum = entryList.elements();
-		while ( entryEnum.hasMoreElements() ) {						
-			ret.append( renderer.render(swordMods, (String)entryEnum.nextElement()) );
-		}
-		
-		ret.append("</tbody>").append("</table>");
-		
-		return ret.toString();
-	}
+        Enumeration moduleEnum = modules.elements();
+        while (moduleEnum.hasMoreElements()) {
+            SWModule mod = (SWModule) moduleEnum.nextElement();
+            try {
+                ret.append("<th><a href=\"fulllibrary.jsp?show=");
+                ret.append(URLEncoder.encode(mod.getName(), "UTF-8"));
+                ret.append("\">");
+                ret.append(mod.getDescription().replaceAll("&", "&amp;"));
+                ret.append(" (").append(mod.getName()).append(")");
+                ret.append("</a></th>");
+            } catch (UnsupportedEncodingException e) {
+                // TODO Auto-generated catch block
+                e.printStackTrace();
+            }
+
+        }
+        ret.append("</tr></thead>");
+        ret.append("<tbody>");
+
+        Vector swordMods = new Vector();
+        moduleEnum = modules.elements();
+        while (moduleEnum.hasMoreElements()) {
+            try {
+                SWModule mod = (SWModule) moduleEnum.nextElement();
+                swordMods.add(mod);
+            } catch (Exception e) {
+                break;
+            }
+        }
+
+        Enumeration entryEnum = entryList.elements();
+        while (entryEnum.hasMoreElements()) {
+            ret.append(renderer.render(swordMods, (String) entryEnum.nextElement()));
+        }
+
+        ret.append("</tbody>").append("</table>");
+
+        return ret.toString();
+    }
 }

Modified: trunk/src/org/crosswire/swordweb/ModuleEntryRenderer.java
===================================================================
--- trunk/src/org/crosswire/swordweb/ModuleEntryRenderer.java	2005-10-07 21:17:23 UTC (rev 218)
+++ trunk/src/org/crosswire/swordweb/ModuleEntryRenderer.java	2005-10-08 18:38:15 UTC (rev 219)
@@ -1,10 +1,12 @@
 package org.crosswire.swordweb;
 
 import java.util.Vector;
-import org.crosswire.sword.orb.*;
+import org.crosswire.sword.orb.SWModule;
 
 public interface ModuleEntryRenderer {
-		public String render( SWModule module, String key );
-		public String render( Vector modules, String key );
-		public void enableFilterOption(String name);
+    public String render(SWModule module, String key);
+
+    public String render(Vector modules, String key);
+
+    public void enableFilterOption(String name);
 }

Modified: trunk/src/org/crosswire/swordweb/ModuleTextRendering.java
===================================================================
--- trunk/src/org/crosswire/swordweb/ModuleTextRendering.java	2005-10-07 21:17:23 UTC (rev 218)
+++ trunk/src/org/crosswire/swordweb/ModuleTextRendering.java	2005-10-08 18:38:15 UTC (rev 219)
@@ -1,8 +1,9 @@
 package org.crosswire.swordweb;
 
-import java.util.*;
+import java.util.Vector;
 
 public interface ModuleTextRendering {
 
-	public String render( Vector modules, Vector entryList, ModuleEntryRenderer renderer );
+    public String render(Vector modules, Vector entryList,
+            ModuleEntryRenderer renderer);
 }

Modified: trunk/src/org/crosswire/swordweb/RangeInformation.java
===================================================================
--- trunk/src/org/crosswire/swordweb/RangeInformation.java	2005-10-07 21:17:23 UTC (rev 218)
+++ trunk/src/org/crosswire/swordweb/RangeInformation.java	2005-10-08 18:38:15 UTC (rev 219)
@@ -1,56 +1,79 @@
 package org.crosswire.swordweb;
 
 import java.util.Vector;
-import java.net.URLEncoder;
-
 import org.crosswire.sword.orb.SWModule;
 
 public final class RangeInformation {
-	public static Vector getChapterEntryList(String keyInChapter, SWModule module) {
-		Vector ret = new Vector();
-		
-		if (keyInChapter.contains(":")) {			
-			String chapterPrefix = keyInChapter.substring(0, keyInChapter.indexOf(":"));
-			int i = 0;
-			for (module.setKeyText(chapterPrefix + ":1"); (module.error() == (char)0); module.next()) {
-				if (!module.getKeyText().startsWith(chapterPrefix)) { //don't continue if we're int he next chapter
-					break;
-				}
-				if (i > 50)
-					break;
-				i++;
-				ret.addElement( module.getKeyText() );						
-			}
-		}
-		
-		return ret;		
-	}
+    public static Vector getChapterEntryList(String keyInChapter,
+            SWModule module) {
+        Vector ret = new Vector();
 
-	public static String getPreviousChapter(String keyInChapter, SWModule module) {
-		StringBuffer ret = new StringBuffer();
-		
-		final String bookname = keyInChapter.substring(0, keyInChapter.lastIndexOf(" "));
-		final int chapter = Integer.parseInt( keyInChapter.substring(keyInChapter.lastIndexOf(" ")+1, keyInChapter.indexOf(":")) );
+        if (keyInChapter.contains(":")) {
+            String chapterPrefix = keyInChapter.substring(0, keyInChapter
+                    .indexOf(":"));
+            int i = 0;
+            for (module.setKeyText(chapterPrefix + ":1"); (module.error() == (char) 0); module
+                    .next()) {
+                //don't continue if we're in the next chapter
+                if (!module.getKeyText().startsWith(chapterPrefix)) { 
+                    break;
+                }
+                if (i > 50)
+                    break;
+                i++;
+                ret.addElement(module.getKeyText());
+            }
+        }
 
-		ret.append(bookname).append(" ").append(String.valueOf(chapter-1)).append(":1");
+        return ret;
+    }
 
-		module.setKeyText(ret.toString());
-		ret = new StringBuffer( module.getKeyText() );
-		return ret.substring(0, ret.indexOf(":"));
-	}
-	
-	public static String getNextChapter(String keyInChapter, SWModule module) {
-		StringBuffer ret = new StringBuffer();
-		
-		final String bookname = keyInChapter.substring(0, keyInChapter.lastIndexOf(" "));
-		final int chapter = Integer.parseInt( keyInChapter.substring(keyInChapter.lastIndexOf(" ")+1, keyInChapter.indexOf(":")) );
+    public static String getPreviousChapter(String keyInChapter, SWModule module) {
+        StringBuffer ret = new StringBuffer();
 
-		ret.append(bookname).append(" ").append(String.valueOf(chapter+1)).append(":1");
-		
-		module.setKeyText(ret.toString());
-		
-		ret = new StringBuffer( module.getKeyText() );
-		return ret.substring(0, ret.indexOf(":"));
-	}
+        final String bookname = keyInChapter.substring(0, keyInChapter
+                .lastIndexOf(" "));
+        final int chapter = Integer.parseInt(keyInChapter.substring(
+                keyInChapter.lastIndexOf(" ") + 1, keyInChapter.indexOf(":")));
 
+        ret.append(bookname).append(" ").append(String.valueOf(chapter - 1))
+                .append(":1");
+
+        module.setKeyText(ret.toString());
+        ret = new StringBuffer(module.getKeyText());
+        return ret.substring(0, ret.indexOf(":"));
+    }
+
+    public static String getNextChapter(String keyInChapter, SWModule module) {
+        StringBuffer ret = new StringBuffer();
+
+        final String bookname = keyInChapter.substring(0, keyInChapter
+                .lastIndexOf(" "));
+        final int chapter = Integer.parseInt(keyInChapter.substring(
+                keyInChapter.lastIndexOf(" ") + 1, keyInChapter.indexOf(":")));
+
+        ret.append(bookname).append(" ").append(String.valueOf(chapter + 1))
+                .append(":1");
+
+        module.setKeyText(ret.toString());
+
+        ret = new StringBuffer(module.getKeyText());
+        return ret.substring(0, ret.indexOf(":"));
+    }
+    
+    /** Parses the passage and gives the verse number back if there's any.
+     * 
+     * @param passage The key in the format "Book chapter:verse"
+     * @return The verse number found in the passage string.
+     */
+    public static int getVerseNumber(String passage) {
+        try {
+            final int verse = Integer.parseInt(passage.substring(passage.indexOf(":") + 1));
+            return verse;
+        }
+        catch (NumberFormatException e){
+            return -1;
+        }
+    }
+
 }
\ No newline at end of file

Modified: trunk/src/org/crosswire/swordweb/SidebarItemRenderer.java
===================================================================
--- trunk/src/org/crosswire/swordweb/SidebarItemRenderer.java	2005-10-07 21:17:23 UTC (rev 218)
+++ trunk/src/org/crosswire/swordweb/SidebarItemRenderer.java	2005-10-08 18:38:15 UTC (rev 219)
@@ -2,13 +2,17 @@
 
 import org.crosswire.sword.orb.SWModule;
 
-/** Renders a single module into something useful, e.g. a HTML link. 
+/**
+ * Renders a single module into something useful, e.g. a HTML link.
  * 
  */
 public interface SidebarItemRenderer {
-	/** Does the actual rendering.
-	 * @param module The module to use for the rendering.
-	 * @return A HTML text string for this module.
-	 */
-	public String renderModuleItem(SWModule module);
+    /**
+     * Does the actual rendering.
+     * 
+     * @param module
+     *            The module to use for the rendering.
+     * @return A HTML text string for this module.
+     */
+    public String renderModuleItem(SWModule module);
 }

Modified: trunk/src/org/crosswire/swordweb/SidebarModuleView.java
===================================================================
--- trunk/src/org/crosswire/swordweb/SidebarModuleView.java	2005-10-07 21:17:23 UTC (rev 218)
+++ trunk/src/org/crosswire/swordweb/SidebarModuleView.java	2005-10-08 18:38:15 UTC (rev 219)
@@ -1,17 +1,25 @@
 package org.crosswire.swordweb;
 
-import org.crosswire.sword.orb.SWModule;
 import java.util.Vector;
 
-/** Renders a sidebar module list.
- * Pages like passagestudy or parallelstudy share the same code to render the list of modules on their sidebars (left and right).
- * This class supports to reuse this code. It offers a method to render a module list in a style which is set by the displayed page.
+/**
+ * Renders a sidebar module list. Pages like passagestudy or parallelstudy share
+ * the same code to render the list of modules on their sidebars (left and
+ * right). This class supports to reuse this code. It offers a method to render
+ * a module list in a style which is set by the displayed page.
  */
 public interface SidebarModuleView {
-	/** Render a sidebar module list using a provided renderer object.
-	 * @param mods
-	 * @param renderer This renderer object is used to insert the rendered HTML items for each module. This is necessary because each page has different needs for these items.
-	 * @return The complete list of modules. It includes HTML list markers like ul and /ul around it if the renderer uses HTML ul list. No need to insert them on your own.
-	 */
-	public String renderView(Vector mods, SidebarItemRenderer renderer);
+    /**
+     * Render a sidebar module list using a provided renderer object.
+     * 
+     * @param mods
+     * @param renderer
+     *            This renderer object is used to insert the rendered HTML items
+     *            for each module. This is necessary because each page has
+     *            different needs for these items.
+     * @return The complete list of modules. It includes HTML list markers like
+     *         ul and /ul around it if the renderer uses HTML ul list. No need
+     *         to insert them on your own.
+     */
+    public String renderView(Vector mods, SidebarItemRenderer renderer);
 }

Modified: trunk/src/org/crosswire/swordweb/SimpleEntryRenderer.java
===================================================================
--- trunk/src/org/crosswire/swordweb/SimpleEntryRenderer.java	2005-10-07 21:17:23 UTC (rev 218)
+++ trunk/src/org/crosswire/swordweb/SimpleEntryRenderer.java	2005-10-08 18:38:15 UTC (rev 219)
@@ -1,100 +1,73 @@
 package org.crosswire.swordweb;
 
-import java.util.Vector;
-import java.util.Enumeration;
+import java.io.UnsupportedEncodingException;
 import java.net.URLEncoder;
+import java.util.Enumeration;
+import java.util.Vector;
+import org.crosswire.sword.orb.SWModule;
+import org.crosswire.sword.orb.SWMgr;
 
-import org.crosswire.sword.orb.*;
+public class SimpleEntryRenderer extends StandardEntryRenderer {
+    public SimpleEntryRenderer(String scriptName, String highlightKey, SWMgr mgr) {
+        super(scriptName, highlightKey, mgr);
+        insertVerseLinks = false;
+    }
 
-public class SimpleEntryRenderer implements ModuleEntryRenderer {
-	private String _scriptName;
-	private String _highlightKey;
-	private SWMgr _mgr;
-	private Vector _filterOptions = new Vector(); 
-	
-	public SimpleEntryRenderer( String scriptName, String highlightKey, SWMgr mgr ) {
-		_scriptName = scriptName;
-		_highlightKey = highlightKey;
-		_mgr = mgr;
-	}
-	
-	public void enableFilterOption(String name) {
-		_filterOptions.add(name);
-	}
-	
-	public String render( Vector modules, String key ) {
-		StringBuffer ret = new StringBuffer();
-		ret.append("<tr>");
-		final int verse = Integer.parseInt( key.substring(key.indexOf(":") + 1) );
-		
-		boolean insertedVerse = false;
-		SWModule mod = null;
-		Enumeration modEnum = modules.elements();
-		while (modEnum.hasMoreElements()) {		
-			mod = (SWModule)modEnum.nextElement();
+    public String render(Vector modules, String key) {
+        StringBuffer ret = new StringBuffer();
+        ret.append("<tr>");
 
-			ret.append("<tr>");			
-			if (!insertedVerse) {
-				StringBuffer verseLink;
-				final String hrefURL = URLEncoder.encode(key);
-				if (key.equals(_highlightKey)) { //highlight this key, insert the #cv marker in the link
-					verseLink = new StringBuffer("<a id=\"cv\" href=\"" + _scriptName + "?key=" + hrefURL  + "#cv\">");
-				}
-				else { //just a normal verse, no currentverse class and no cv marker
-					verseLink = new StringBuffer("<a href=\"" + _scriptName + "?key=" + hrefURL  + "#cv\">");
-				}		
-				verseLink.append(verse).append("</a>"); //link end is the same for both (highlighted and plain link)
+        final int verse = RangeInformation.getVerseNumber(key);
 
-				ret.append("<td><span class=\"versenum\">").append(verseLink).append("</span></td>");				
-				insertedVerse = true;
-			}
-			else {
-				ret.append("<td></td>");
-			}
-			ret.append("<td>").append(mod.getName()).append("</td>");
-			
-			final boolean rtol = ("RtoL".equalsIgnoreCase(mod.getConfigEntry("Direction")));
-			if (rtol) {				
-				ret.append("<td dir=\"rtl\">");
-			}
-			else {
-				ret.append("<td>");
-			}
-			ret.append( this.render(mod, key) ).append("</td>");
-			ret.append("</tr>");
-		}
-		
-		ret.append("</tr>");		
-		return ret.toString();
-	}
+        boolean insertedVerseLink = false;
+        SWModule mod = null;
+        Enumeration modEnum = modules.elements();
+        while (modEnum.hasMoreElements()) {
+            mod = (SWModule) modEnum.nextElement();
 
-	public String render( SWModule module, String key ) {
-		StringBuffer ret = new StringBuffer();
+            ret.append("<tr>");
+            if (!insertedVerseLink) {
+                StringBuffer verseLink;
+                String hrefURL = null;
+                try {
+                    hrefURL = URLEncoder.encode(key, "UTF-8");
+                } catch (UnsupportedEncodingException e) {
+                }
 
-		final int verse = Integer.parseInt( key.substring(key.indexOf(":") + 1) );
-		final int highlightVerse = Integer.parseInt( _highlightKey.substring(key.indexOf(":") + 1) );
-		final boolean enableFilterOptions = (verse >= highlightVerse -1) && (verse <= highlightVerse + 1);
-		
-		Enumeration filterEnum = _filterOptions.elements();
-		while (filterEnum.hasMoreElements()) {
-				_mgr.setGlobalOption((String)filterEnum.nextElement(), enableFilterOptions ? "on" : "off");
-		}
-		
-		if (key.equals(_highlightKey)) { //highlight this key, insert the #cv marker in the link
-			ret.append("<div class=\"currentverse\">");
-		}
-		else { //just a normal verse, no currentverse class and no cv marker
-			ret.append("<div class=\"verse\">");
-		}		
+                if (key.equals(highlightKey)) { // highlight this key,
+                    // insert the #cv marker in
+                    // the link
+                    verseLink = new StringBuffer("<a id=\"cv\" href=\""
+                            + scriptName + "?key=" + hrefURL + "#cv\">");
+                } else { // just a normal verse, no currentverse class and no
+                    // cv marker
+                    verseLink = new StringBuffer("<a href=\"" + scriptName
+                            + "?key=" + hrefURL + "#cv\">");
+                }
+                verseLink.append(verse).append("</a>"); // link end is the same
+                // for both (highlighted
+                // and plain link)
 
-		try {
-			module.setKeyText(key);
-			ret.append(new String(module.getRenderText().getBytes("iso8859-1"), "UTF-8"));  
-		}
-		catch (Exception e) {
-		}
-		
-		ret.append("</div>");		
-		return ret.toString();
-	}
-} 
+                ret.append("<td><span class=\"versenum\">").append(verseLink)
+                        .append("</span></td>");
+                insertedVerseLink = true;
+            } else {
+                ret.append("<td></td>");
+            }
+            ret.append("<td>").append(mod.getName()).append("</td>");
+
+            final boolean rtol = ("RtoL".equalsIgnoreCase(mod
+                    .getConfigEntry("Direction")));
+            if (rtol) {
+                ret.append("<td dir=\"rtl\">");
+            } else {
+                ret.append("<td>");
+            }
+            ret.append(this.render(mod, key)).append("</td>");
+            ret.append("</tr>");
+        }
+
+        ret.append("</tr>\n");
+        return ret.toString();
+    }
+}

Modified: trunk/src/org/crosswire/swordweb/SimpleModuleView.java
===================================================================
--- trunk/src/org/crosswire/swordweb/SimpleModuleView.java	2005-10-07 21:17:23 UTC (rev 218)
+++ trunk/src/org/crosswire/swordweb/SimpleModuleView.java	2005-10-08 18:38:15 UTC (rev 219)
@@ -2,33 +2,32 @@
 
 import java.util.Enumeration;
 import java.util.Vector;
-
 import org.crosswire.sword.orb.SWModule;
 import org.crosswire.sword.orb.SWMgr;
 
 public class SimpleModuleView implements SidebarModuleView {
-	private SWMgr _mgr;
-	
-	public SimpleModuleView(SWMgr mgr) {
-		_mgr = mgr;
-	}
-	
-	public String renderView(Vector mods, SidebarItemRenderer renderer) {
-		StringBuffer ret = new StringBuffer();
-		
-		if (mods.size() > 0) {
-			ret.append("<ul>");
-			Enumeration e = mods.elements();
-			while (e.hasMoreElements()) {
-				SWModule mod = _mgr.getModuleByName( (String)e.nextElement() );
-				if (mod != null) {
-					ret.append(renderer.renderModuleItem(mod));
-				}
-			}
-			
-			ret.append("</ul>");
-		}
-		
-		return ret.toString();		
-	}
+    private SWMgr _mgr;
+
+    public SimpleModuleView(SWMgr mgr) {
+        _mgr = mgr;
+    }
+
+    public String renderView(Vector mods, SidebarItemRenderer renderer) {
+        StringBuffer ret = new StringBuffer();
+
+        if (mods.size() > 0) {
+            ret.append("<ul>");
+            Enumeration e = mods.elements();
+            while (e.hasMoreElements()) {
+                SWModule mod = _mgr.getModuleByName((String) e.nextElement());
+                if (mod != null) {
+                    ret.append(renderer.renderModuleItem(mod));
+                }
+            }
+
+            ret.append("</ul>");
+        }
+
+        return ret.toString();
+    }
 }
\ No newline at end of file

Modified: trunk/src/org/crosswire/swordweb/StandardEntryRenderer.java
===================================================================
--- trunk/src/org/crosswire/swordweb/StandardEntryRenderer.java	2005-10-07 21:17:23 UTC (rev 218)
+++ trunk/src/org/crosswire/swordweb/StandardEntryRenderer.java	2005-10-08 18:38:15 UTC (rev 219)
@@ -1,84 +1,148 @@
 package org.crosswire.swordweb;
 
+import java.io.UnsupportedEncodingException;
+import java.net.URLEncoder;
+import java.util.Enumeration;
 import java.util.Vector;
-import java.util.Enumeration;
-import java.net.URLEncoder;
+import org.crosswire.sword.orb.SWModule;
+import org.crosswire.sword.orb.SWMgr;
 
-import org.crosswire.sword.orb.*;
-
 public class StandardEntryRenderer implements ModuleEntryRenderer {
-	private String _scriptName;
-	private String _highlightKey;
-	private SWMgr _mgr;
-	private Vector _filterOptions = new Vector(); 
-	
-	public StandardEntryRenderer( String scriptName, String highlightKey, SWMgr mgr ) {
-		_scriptName = scriptName;
-		_highlightKey = highlightKey;
-		_mgr = mgr;
-	}
-	
-	public void enableFilterOption(String name) {
-		_filterOptions.add(name);
-	}
-	
-	public String render( Vector modules, String key ) {
-		StringBuffer ret = new StringBuffer();
-		ret.append("<tr>");
-		
-		Enumeration modEnum = modules.elements();
-		while (modEnum.hasMoreElements()) {		
-			SWModule mod = (SWModule)modEnum.nextElement();			
-			final boolean rtol = ("RtoL".equalsIgnoreCase(mod.getConfigEntry("Direction")));
+    protected String scriptName;
 
-			if (rtol) {				
-				ret.append("<td dir=\"rtl\">");
-			}
-			else {
-				ret.append("<td>");
-			}
-			ret.append( this.render(mod, key) );
-			ret.append("</td>");
-		}
-		
-		ret.append("</tr>");		
-		return ret.toString();
-	}
-	
-	public String render( SWModule module, String key ) {
-		StringBuffer ret = new StringBuffer();
+    protected String highlightKey;
 
-		final int verse = Integer.parseInt( key.substring(key.indexOf(":") + 1) );
-		final int highlightVerse = Integer.parseInt( _highlightKey.substring(key.indexOf(":") + 1) );
-		final boolean enableFilterOptions = (verse >= highlightVerse -1) && (verse <= highlightVerse + 1);
-		
-		Enumeration filterEnum = _filterOptions.elements();
-		while (filterEnum.hasMoreElements()) {
-				_mgr.setGlobalOption((String)filterEnum.nextElement(), enableFilterOptions ? "on" : "off");
-		}
-		
-		final String hrefURL = URLEncoder.encode(key);		
-		StringBuffer verseLink;		
-		if (key.equals(_highlightKey)) { //highlight this key, insert the #cv marker in the link
-			ret.append("<div class=\"currentverse\">");
-			verseLink = new StringBuffer("<a id=\"cv\" href=\"" + _scriptName + "?key=" + hrefURL  + "#cv\">");
-		}
-		else { //just a normal verse, no currentverse class and no cv marker
-			ret.append("<div class=\"verse\">");
-			verseLink = new StringBuffer("<a href=\"" + _scriptName + "?key=" + hrefURL  + "#cv\">");
-		}		
-		verseLink.append(verse).append("</a>"); //link end is the same for both (highlighted and plain link)
+    protected SWMgr mgr;
 
-		
-		ret.append("<span class=\"versenum\">").append(verseLink).append("</span> ");		
-		try {
-			module.setKeyText(key);
-			ret.append(new String(module.getRenderText().getBytes("iso8859-1"), "UTF-8"));  
-		}
-		catch (Exception e) {
-		}
-		
-		ret.append("</div>");
-		return ret.toString();
-	}
-} 
+    protected Vector filterOptions = new Vector();
+
+    protected boolean insertVerseLinks = true;
+
+    public StandardEntryRenderer(String scriptName, String highlightKey,
+            SWMgr mgr) {
+        this.scriptName = scriptName;
+        this.highlightKey = highlightKey;
+        this.mgr = mgr;
+    }
+
+    public void enableFilterOption(String name) {
+        filterOptions.add(name);
+    }
+
+    public String render(Vector modules, String key) {
+        StringBuffer ret = new StringBuffer();
+        SWModule mod = null;
+        Enumeration modEnum = null;
+
+        StringBuffer header = null;
+        modEnum = modules.elements();
+        while (modEnum.hasMoreElements()) {
+            mod = (SWModule) modEnum.nextElement();
+            final boolean rtol = ("RtoL".equalsIgnoreCase(mod
+                    .getConfigEntry("Direction")));
+
+            String[] heads = mod.getEntryAttribute("Heading", "Preverse", "0");
+            if (heads.length > 0) {
+                if (header == null) {
+                    header = new StringBuffer();
+                }
+
+                if (rtol) {
+                    header.append("<td dir=\"rtl\"><div dir=\"rtl\">");
+                } else {
+                    header.append("<td><div>");
+                }
+
+                header.append("<h3>");
+                try {
+                    header.append(new String(heads[0].getBytes("iso8859-1"),
+                            "UTF-8"));
+                } catch (Exception e) {
+                }
+                header.append("</h3></div></td>");
+            } else if (header != null) { // don't leave out a column if we
+                // started a new row
+                header.append("<td></td>");
+            }
+        }
+
+        if (header != null) { // we got headings
+            ret.append("<tr>").append(header).append("</tr>");
+        }
+
+        ret.append("<tr>");
+
+        modEnum = modules.elements();
+        while (modEnum.hasMoreElements()) {
+            mod = (SWModule) modEnum.nextElement();
+            final boolean rtol = ("RtoL".equalsIgnoreCase(mod
+                    .getConfigEntry("Direction")));
+
+            if (rtol) {
+                ret.append("<td dir=\"rtl\">");
+            } else {
+                ret.append("<td>");
+            }
+
+            ret.append(this.render(mod, key));
+            ret.append("</td>");
+        }
+
+        ret.append("</tr>\n");
+        return ret.toString();
+    }
+
+    public String render(SWModule module, String key) {
+        StringBuffer ret = new StringBuffer();
+
+        final int verse = Integer.parseInt(key.substring(key.indexOf(":") + 1));
+        final int highlightVerse = Integer.parseInt(highlightKey.substring(key
+                .indexOf(":") + 1));
+        final boolean enableFilterOptions = (verse >= highlightVerse - 1)
+                && (verse <= highlightVerse + 1);
+
+        Enumeration filterEnum = filterOptions.elements();
+        while (filterEnum.hasMoreElements()) {
+            mgr.setGlobalOption((String) filterEnum.nextElement(),
+                    enableFilterOptions ? "on" : "off");
+        }
+
+        String hrefURL = null;
+        try {
+            hrefURL = URLEncoder.encode(key, "UTF-8");
+        } catch (UnsupportedEncodingException e1) {
+            // TODO Auto-generated catch block
+//            e1.printStackTrace();
+        }
+
+        StringBuffer verseLink;
+        if (key.equals(highlightKey)) { // highlight this key, insert the #cv
+            // marker in the link
+            ret.append("<div class=\"currentverse\">");
+            verseLink = new StringBuffer("<a id=\"cv\" href=\"" + scriptName
+                    + "?key=" + hrefURL + "#cv\">");
+        } else { // just a normal verse, no currentverse class and no cv
+            // marker
+            ret.append("<div class=\"verse\">");
+            verseLink = new StringBuffer("<a href=\"" + scriptName + "?key="
+                    + hrefURL + "#cv\">");
+        }
+        verseLink.append(verse).append("</a>"); // link end is the same for both
+        // (highlighted and plain link)
+
+        if (insertVerseLinks) {
+            ret.append("<span class=\"versenum\">").append(verseLink).append(
+                    "</span> ");
+        }
+
+        try {
+            module.setKeyText(key);
+            ret.append(new String(module.getRenderText().getBytes("iso8859-1"),
+                    "UTF-8"));
+        } catch (Exception e) {
+        }
+
+        ret.append("</div>");
+        return ret.toString();
+    }
+}

Modified: trunk/src/org/crosswire/swordweb/VerticallyParallelTextRendering.java
===================================================================
--- trunk/src/org/crosswire/swordweb/VerticallyParallelTextRendering.java	2005-10-07 21:17:23 UTC (rev 218)
+++ trunk/src/org/crosswire/swordweb/VerticallyParallelTextRendering.java	2005-10-08 18:38:15 UTC (rev 219)
@@ -1,44 +1,36 @@
 package org.crosswire.swordweb;
 
-import java.util.Vector;
 import java.util.Enumeration;
-import java.net.URLEncoder;
-
+import java.util.Vector;
 import org.crosswire.sword.orb.SWModule;
-import org.crosswire.sword.orb.SWMgr;
 
 public class VerticallyParallelTextRendering implements ModuleTextRendering {
-	private Vector _modules;
-	private String _range;
-	
-	public String render( Vector modules, Vector entryList, ModuleEntryRenderer renderer ) {
-		StringBuffer ret = new StringBuffer();
-		ret.append("<table>");
-		ret.append("<tbody>");
-		
-		Vector swordMods = new Vector();
-		Enumeration moduleEnum = modules.elements();
-		while ( moduleEnum.hasMoreElements() ) {
-			try {
-				SWModule mod = (SWModule)moduleEnum.nextElement();
-				swordMods.add(mod);
-			}
-			catch (Exception e){
-				break;
-			}
-		}	
+    public String render(Vector modules, Vector entryList,
+            ModuleEntryRenderer renderer) {
+        StringBuffer ret = new StringBuffer();
+        ret.append("<table><tbody>");
 
-		Enumeration entryEnum = entryList.elements();
-		while ( entryEnum.hasMoreElements() ) {
-			String currentEntry = (String)entryEnum.nextElement();
-			boolean insertedVerse = false;
+        Vector swordMods = new Vector();
+        Enumeration moduleEnum = modules.elements();
+        while (moduleEnum.hasMoreElements()) {
+            try {
+                SWModule mod = (SWModule) moduleEnum.nextElement();
+                swordMods.add(mod);
+            } catch (Exception e) {
+                break;
+            }
+        }
 
-			ret.append( renderer.render(swordMods, currentEntry) );
-			ret.append("<tr><td><div style=\"height:10px;\"/><td></tr>"); //an empty line between verses
-		}
-		
-		ret.append("</tbody>").append("</table>");
-		
-		return ret.toString();
-	}
+        Enumeration entryEnum = entryList.elements();
+        while (entryEnum.hasMoreElements()) {
+            String currentEntry = (String) entryEnum.nextElement();
+            ret.append(renderer.render(swordMods, currentEntry));
+            ret.append("<tr><td><div style=\"height:10px;\"/><td></tr>"); // an
+            // empty space between verses
+        }
+
+        ret.append("</tbody></table>");
+
+        return ret.toString();
+    }
 }



More information about the sword-cvs mailing list