[jsword-devel] [PATCH] Fix ClassCastException when changing bibles in the bible combo box

Joe Walker jsword-devel@crosswire.org
Fri, 29 Nov 2002 23:52:44 +0000


That's fantastic thanks.
One of the good things about unit test is it gives you confidence to 
refactor things, but one of the bad things is that the areas that are 
hard to unit test (typically user interfaces) get left out, and the 
refactorer gets lulled into a false sense of security ...

I'm sure it must be possible to use an eclipse variable of some sort to 
make those launchers work, but I've not had any joy - I tried 
${project_loc:/....} but it didn't expand properly.

Joe.


Eric Galluzzo wrote:

>Folks,
>
>I'm new to this list, and to JSword in general, but I just wanted to
>say: Wow! :)  I'm extremely impressed by the quality of the code and the
>design (with a couple of small exceptions that can easily be fixed); and
>with the significant number of unit tests.  I was just reading a passage
>of C.S. Lewis about "good works and good work," and this is definitely
>good work!  I definitely hope to contribute whatever I can to this
>project in the future.
>
>So anyway, I just checked out the latest JSword, got it to run by
>changing the jsword.bible.dir property in the Eclipse launcher, and
>noticed that a ClassCastException occurred whenever one attempted to
>change Bibles via the Bible dropdown.  The attached patch should fix
>that problem.  The patch is relative to the
>/jsword/java/jsword/org/crosswire/jsword/view/swing/book directory.  You
>should be able to apply it by selecting that directory and then Compare
>With > Patch... in Eclipse.
>
>    In Christ,
>
>    Eric
>  
>
>------------------------------------------------------------------------
>
>Index: BibleListCellRenderer.java
>===================================================================
>RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/view/swing/book/BibleListCellRenderer.java,v
>retrieving revision 1.2
>diff -u -r1.2 BibleListCellRenderer.java
>--- BibleListCellRenderer.java	6 Sep 2002 18:36:20 -0000	1.2
>+++ BibleListCellRenderer.java	29 Nov 2002 18:56:44 -0000
>@@ -12,6 +12,7 @@
> import javax.swing.border.Border;
> 
> import org.crosswire.common.swing.GuiUtil;
>+import org.crosswire.jsword.book.BibleMetaData;
> 
> /**
>  * A custom list view that paints icons alongside the words. This is a
>@@ -73,8 +74,9 @@
>             setBackground(list.getBackground());
>             setForeground(list.getForeground());
>         }
>-
>-        setText((value == null) ? "" : value.toString());
>+        
>+        BibleMetaData bmd = (BibleMetaData) value;
>+        setText((bmd == null) ? "" : bmd.getFullName());
>         setIcon(small_icon);
> 
>         setEnabled(list.isEnabled());
>Index: BiblesListModel.java
>===================================================================
>RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/view/swing/book/BiblesListModel.java,v
>retrieving revision 1.5
>diff -u -r1.5 BiblesListModel.java
>--- BiblesListModel.java	28 Nov 2002 23:10:04 -0000	1.5
>+++ BiblesListModel.java	29 Nov 2002 18:56:44 -0000
>@@ -81,7 +81,7 @@
>         if (index >= bmds.length)
>             return null;
> 
>-        return bmds[index].getFullName();
>+        return bmds[index];
>     }
> 
>     /**
>  
>