[jsword-svn] r1349 - in trunk: bibledesktop/src/main/java/org/crosswire/bibledesktop/book jsword/src/main/java/org/crosswire/jsword/book/basic

dmsmith at www.crosswire.org dmsmith at www.crosswire.org
Thu May 24 14:01:53 MST 2007


Author: dmsmith
Date: 2007-05-24 14:01:53 -0700 (Thu, 24 May 2007)
New Revision: 1349

Modified:
   trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/book/BookListCellRenderer.java
   trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/book/DisplaySelectPane.java
   trunk/jsword/src/main/java/org/crosswire/jsword/book/basic/AbstractBookMetaData.java
Log:
prep work for parallel bible picker.

Modified: trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/book/BookListCellRenderer.java
===================================================================
--- trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/book/BookListCellRenderer.java	2007-05-24 19:10:01 UTC (rev 1348)
+++ trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/book/BookListCellRenderer.java	2007-05-24 21:01:53 UTC (rev 1349)
@@ -45,15 +45,44 @@
 public class BookListCellRenderer extends JLabel implements ListCellRenderer
 {
     /**
-     * Constructs a default renderer object for an item in a list.
+     * Constructs a default renderer object for an item in a list,
+     * using full names.
      */
     public BookListCellRenderer()
     {
+        this(false);
+    }
+
+    /**
+     * Constructs a renderer object for an item in a list,
+     * using abbreviated names if desired.
+     * 
+     * @param abbreviated use the initials in the list.
+     */
+    public BookListCellRenderer(boolean abbreviated)
+    {
+        this.abbreviated = abbreviated;
         setOpaque(true);
         setBorder(noFocus);
     }
 
     /**
+     * @return the abbreviated
+     */
+    public boolean isAbbreviated()
+    {
+        return abbreviated;
+    }
+
+    /**
+     * @param newAbbreviated the abbreviated to set
+     */
+    public void setAbbreviated(boolean newAbbreviated)
+    {
+        this.abbreviated = newAbbreviated;
+    }
+
+    /**
      * This is the only method defined by ListCellRenderer.  We just
      * reconfigure the Jlabel each time we're called.
      * @param list The JLists that we are part of
@@ -101,9 +130,17 @@
         {
             Book book = (Book) value;
 
-            String displayName = book.toString();
-            setText(displayName);
-            setToolTipText(displayName);
+            if (abbreviated)
+            {
+                setText(book.getInitials());
+                setToolTipText(book.getName());
+            }
+            else
+            {
+                String displayName = book.toString();
+                setText(displayName);
+                setToolTipText(displayName);
+            }
 
             setIcon(BookIcon.getIcon(book));
             setEnabled(list.isEnabled());
@@ -115,6 +152,11 @@
     }
 
     /**
+     * If true then the initials of a book are shown, otherwise the full name.
+     */
+    private boolean abbreviated;
+
+    /**
      * border if we do not have focus
      */
     private static Border noFocus = BorderFactory.createEmptyBorder(1, 1, 1, 1);

Modified: trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/book/DisplaySelectPane.java
===================================================================
--- trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/book/DisplaySelectPane.java	2007-05-24 19:10:01 UTC (rev 1348)
+++ trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/book/DisplaySelectPane.java	2007-05-24 21:01:53 UTC (rev 1349)
@@ -123,7 +123,7 @@
             // But here we don't have a book yet.
             key = new RocketPassage();
         }
-        cboBible.setRenderer(new BookListCellRenderer());
+        cboBible.setRenderer(new BookListCellRenderer(true));
         cboBible.addItemListener(new ItemListener()
         {
             /* (non-Javadoc)

Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/basic/AbstractBookMetaData.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/basic/AbstractBookMetaData.java	2007-05-24 19:10:01 UTC (rev 1348)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/basic/AbstractBookMetaData.java	2007-05-24 21:01:53 UTC (rev 1349)
@@ -96,14 +96,15 @@
      */
     private String computeFullName()
     {
-        StringBuffer buf = new StringBuffer(getName());
-
-        if (getDriver() != null)
-        {
-            buf.append(" (").append(getDriverName()).append(')'); //$NON-NLS-1$
-        }
-
-        return buf.toString();
+//        StringBuffer buf = new StringBuffer(getName());
+//
+//        if (getDriver() != null)
+//        {
+//            buf.append(" (").append(getDriverName()).append(')'); //$NON-NLS-1$
+//        }
+//
+//        return buf.toString();
+        return getName();
     }
 
     /* (non-Javadoc)
@@ -328,7 +329,7 @@
         int result = this.getBookCategory().compareTo(((BookMetaData) obj).getBookCategory());
         if (result == 0)
         {
-            result = this.getInitials().compareTo(((BookMetaData) obj).getInitials());
+            result = this.getName().compareTo(((BookMetaData) obj).getName());
         }
         return result;
     }




More information about the jsword-svn mailing list