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

Eric Galluzzo jsword-devel@crosswire.org
29 Nov 2002 13:45:40 -0500


--=-WV687XnxMHMMQHKw29H5
Content-Type: text/plain
Content-Transfer-Encoding: 7bit

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

--=-WV687XnxMHMMQHKw29H5
Content-Disposition: attachment; filename=jsword.patch
Content-Transfer-Encoding: quoted-printable
Content-Type: text/x-patch; name=jsword.patch; charset=ISO-8859-1

Index: BibleListCellRenderer.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/view/swing/bo=
ok/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;
=20
 import org.crosswire.common.swing.GuiUtil;
+import org.crosswire.jsword.book.BibleMetaData;
=20
 /**
  * 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 =3D=3D null) ? "" : value.toString());
+       =20
+        BibleMetaData bmd =3D (BibleMetaData) value;
+        setText((bmd =3D=3D null) ? "" : bmd.getFullName());
         setIcon(small_icon);
=20
         setEnabled(list.isEnabled());
Index: BiblesListModel.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/view/swing/bo=
ok/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 >=3D bmds.length)
             return null;
=20
-        return bmds[index].getFullName();
+        return bmds[index];
     }
=20
     /**

--=-WV687XnxMHMMQHKw29H5--