[jsword-svn] bibledesktop/java/main/org/crosswire/bibledesktop/desktop s

jswordcvs at crosswire.org jswordcvs at crosswire.org
Sun Mar 20 19:37:20 MST 2005


Update of /cvs/jsword/bibledesktop/java/main/org/crosswire/bibledesktop/desktop
In directory www.crosswire.org:/tmp/cvs-serv13704/java/main/org/crosswire/bibledesktop/desktop

Modified Files:
	Desktop.java 
Log Message:
Fixed BD-34. Clicking a Strong's link now switches books and selects the key.

Index: Desktop.java
===================================================================
RCS file: /cvs/jsword/bibledesktop/java/main/org/crosswire/bibledesktop/desktop/Desktop.java,v
retrieving revision 1.37
retrieving revision 1.38
diff -C2 -d -r1.37 -r1.38
*** Desktop.java	19 Mar 2005 01:57:09 -0000	1.37
--- Desktop.java	21 Mar 2005 02:37:18 -0000	1.38
***************
*** 10,14 ****
  import java.net.MalformedURLException;
  import java.net.URL;
- import java.util.ArrayList;
  import java.util.Iterator;
  import java.util.List;
--- 10,13 ----
***************
*** 59,68 ****
  import org.crosswire.common.xml.XMLUtil;
  import org.crosswire.jsword.book.Book;
- import org.crosswire.jsword.book.BookFilter;
  import org.crosswire.jsword.book.BookFilters;
  import org.crosswire.jsword.book.Books;
  import org.crosswire.jsword.book.BooksEvent;
  import org.crosswire.jsword.book.BooksListener;
! import org.crosswire.jsword.book.readings.ReadingsBookDriver;
  import org.crosswire.jsword.passage.Key;
  import org.crosswire.jsword.passage.NoSuchKeyException;
--- 58,66 ----
  import org.crosswire.common.xml.XMLUtil;
  import org.crosswire.jsword.book.Book;
  import org.crosswire.jsword.book.BookFilters;
  import org.crosswire.jsword.book.Books;
  import org.crosswire.jsword.book.BooksEvent;
  import org.crosswire.jsword.book.BooksListener;
! import org.crosswire.jsword.book.Defaults;
  import org.crosswire.jsword.passage.Key;
  import org.crosswire.jsword.passage.NoSuchKeyException;
***************
*** 505,535 ****
              else if (protocol.equals(COMMENTARY_PROTOCOL))
              {
!                 Key key = reference.getBook().getKey(data);
!                 reference.setKey(key);
              }
              else if (protocol.equals(GREEK_DEF_PROTOCOL))
              {
!                 // TODO(DM): determine the right Strong's dictionary and switch to it.
!                 reference.setWord(data);
              }
              else if (protocol.equals(HEBREW_DEF_PROTOCOL))
              {
!                 // TODO(DM): determine the right Strong's dictionary and switch to it.
!                 reference.setWord(data);
              }
              else if (protocol.equals(GREEK_MORPH_PROTOCOL))
              {
!                 // TODO(DM): determine the right Strong's dictionary and switch to it.
!                 reference.setWord(data);
              }
              else if (protocol.equals(HEBREW_MORPH_PROTOCOL))
              {
!                 // TODO(DM): determine the right Strong's dictionary and switch to it.
!                 reference.setWord(data);
              }
              else if (protocol.equals(DICTIONARY_PROTOCOL))
              {
!                 // TODO(DM): determine the right dictionary and switch to it.
!                 reference.setWord(data);
              }
              else
--- 503,533 ----
              else if (protocol.equals(COMMENTARY_PROTOCOL))
              {
!                 Book book = Defaults.getCommentary();
!                 if (book != null && Books.installed().getBook(book.getName()) != null)
!                 {
!                     reference.selectDictionary(book);
!                     Key key = reference.getBook().getKey(data);
!                     reference.setKey(key);
!                 }
              }
              else if (protocol.equals(GREEK_DEF_PROTOCOL))
              {
!                 jump(Defaults.getGreekDefinitions(), data);
              }
              else if (protocol.equals(HEBREW_DEF_PROTOCOL))
              {
!                 jump(Defaults.getHebrewDefinitions(), data);
              }
              else if (protocol.equals(GREEK_MORPH_PROTOCOL))
              {
!                 jump(Defaults.getGreekParse(), data);
              }
              else if (protocol.equals(HEBREW_MORPH_PROTOCOL))
              {
!                 jump(Defaults.getHebrewParse(), data);
              }
              else if (protocol.equals(DICTIONARY_PROTOCOL))
              {
!                 jump(Defaults.getDictionary(), data);
              }
              else
***************
*** 544,547 ****
--- 542,560 ----
      }
  
+     /**
+      * Open the requested book and go to the requested key.
+      * @param book The book to use
+      * @param data The key to find
+      */
+     private void jump(Book book, String data)
+     {
+         // TODO(DM): If it is not installed, offer to install it.
+         if (book != null && Books.installed().getBook(book.getName()) != null)
+         {
+             reference.selectDictionary(book);
+             reference.setWord(data);
+         }
+     }
+ 
      /* (non-Javadoc)
       * @see org.crosswire.bibledesktop.display.URLEventListener#enterURL(org.crosswire.bibledesktop.display.URLEvent)
***************
*** 690,696 ****
          refreshBooks();
  
-         // Create the array of readings sets
-         ChoiceFactory.getDataMap().put(READINGS_KEY, ReadingsBookDriver.getInstalledReadingsSets());
- 
          // And the array of allowed osis>html converters
          Map converters = ConverterFactory.getKnownConverters();
--- 703,706 ----
***************
*** 710,733 ****
      protected final void refreshBooks()
      {
!         // Create the array of Bibles
!         String[] bnames = getFullNameArray(BookFilters.getBibles());
!         ChoiceFactory.getDataMap().put(BIBLE_KEY, bnames);
! 
!         // Create the array of Commentaries
!         String[] cnames = getFullNameArray(BookFilters.getCommentaries());
!         ChoiceFactory.getDataMap().put(COMMENTARY_KEY, cnames);
! 
!         // Create the array of Dictionaries
!         String[] dnames = getFullNameArray(BookFilters.getDictionaries());
!         ChoiceFactory.getDataMap().put(DICTIONARY_KEY, dnames);
  
          // Has the number of reference books changed?
!         int newRefBooks = dnames.length + cnames.length;
!         if (newRefBooks != refBooks)
          {
              // This method is called during setup
              if (reference != null)
              {
!                 if (newRefBooks == 0)
                  {
                      sptBooks.setDividerLocation(8000);
--- 720,735 ----
      protected final void refreshBooks()
      {
!         Defaults.refreshBooks();
  
          // Has the number of reference books changed?
!         boolean hasDictionaries = Defaults.getDictionary() != null;
!         boolean hasCommentaries = Defaults.getCommentary() != null;
!         boolean newRefBooks = hasDictionaries || hasCommentaries;
!         if (newRefBooks != hasRefBooks)
          {
              // This method is called during setup
              if (reference != null)
              {
!                 if (!newRefBooks)
                  {
                      sptBooks.setDividerLocation(8000);
***************
*** 742,764 ****
              }
  
!             refBooks = newRefBooks;
!         }
!     }
! 
!     /**
!      * Convert a filter into an array of names of Books that pass the filter.
!      */
!     private String[] getFullNameArray(BookFilter filter)
!     {
!         List books = Books.installed().getBooks(filter);
!         List names = new ArrayList();
! 
!         for (Iterator it = books.iterator(); it.hasNext(); )
!         {
!             Book book = (Book) it.next();
!             names.add(book.getBookMetaData().getFullName());
          }
- 
-         return (String[]) names.toArray(new String[names.size()]);
      }
  
--- 744,749 ----
              }
  
!             hasRefBooks = newRefBooks;
          }
      }
  
***************
*** 771,775 ****
      }
  
!     private int refBooks;
  
      // Strings for the names of property files.
--- 756,760 ----
      }
  
!     private boolean hasRefBooks;
  
      // Strings for the names of property files.
***************
*** 791,800 ****
      private static final String CONFIG_KEY = "config"; //$NON-NLS-1$
      private static final String DESKTOP_KEY = "desktop"; //$NON-NLS-1$
-     private static final String READINGS_KEY = "readings"; //$NON-NLS-1$
      private static final String CONV_KEY = "converters"; //$NON-NLS-1$
      private static final String CSWING_KEY = "cswing-styles"; //$NON-NLS-1$
-     private static final String BIBLE_KEY = "bible-names"; //$NON-NLS-1$
-     private static final String COMMENTARY_KEY = "commentary-names"; //$NON-NLS-1$
-     private static final String DICTIONARY_KEY = "dictionary-names"; //$NON-NLS-1$
  
      /**
--- 776,781 ----



More information about the jsword-svn mailing list