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

jswordcvs at crosswire.org jswordcvs at crosswire.org
Fri Oct 15 16:28:24 MST 2004


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

Modified Files:
	Msg.properties Msg.java SitesPane.java SitePane.properties 
	SitePane.java IndexResolver.java SitesPane.properties 
Log Message:
progress on downloading index

Index: SitePane.properties
===================================================================
RCS file: /cvs/jsword/bibledesktop/java/main/org/crosswire/bibledesktop/book/SitePane.properties,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** SitePane.properties	27 Aug 2004 11:41:33 -0000	1.2
--- SitePane.properties	15 Oct 2004 23:28:22 -0000	1.3
***************
*** 34,45 ****
  Install.ShortDescription=Install a book.
  Install.LongDescription=Install the selected book
- Install.SmallIcon=
- Install.LargeIcon=
  Install.MnemonicKey=I
! Install.AcceleratorKey=
! Install.AcceleratorKey.Modifiers=
  
  Refresh.Enabled=true
! Refresh.Name=Update Index
  Refresh.ShortDescription=Refresh the list of books.
  Refresh.LongDescription=Download a current listing of books.
--- 34,47 ----
  Install.ShortDescription=Install a book.
  Install.LongDescription=Install the selected book
  Install.MnemonicKey=I
! 
! InstallSearch.Enabled=false
! InstallSearch.Name=Install with Search
! InstallSearch.ShortDescription=Download a book and search index.
! InstallSearch.LongDescription=Install the selected book along with a search index.
! InstallSearch.MnemonicKey=S
  
  Refresh.Enabled=true
! Refresh.Name=Update Available Books
  Refresh.ShortDescription=Refresh the list of books.
  Refresh.LongDescription=Download a current listing of books.

Index: SitePane.java
===================================================================
RCS file: /cvs/jsword/bibledesktop/java/main/org/crosswire/bibledesktop/book/SitePane.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -d -r1.12 -r1.13
*** SitePane.java	10 Oct 2004 22:12:11 -0000	1.12
--- SitePane.java	15 Oct 2004 23:28:22 -0000	1.13
***************
*** 29,32 ****
--- 29,33 ----
  import org.crosswire.jsword.book.install.InstallException;
  import org.crosswire.jsword.book.install.Installer;
+ import org.crosswire.jsword.util.IndexDownloader;
  
  /**
***************
*** 73,76 ****
--- 74,80 ----
      }
  
+     /**
+      * Internal ctor
+      */
      private SitePane(Installer bookListInstaller, String labelAcronymn)
      {
***************
*** 80,84 ****
  
          BookList bl = installer;
!         if (installer == null)
          {
              bl = Books.installed();
--- 84,88 ----
  
          BookList bl = installer;
!         if (bl == null)
          {
              bl = Books.installed();
***************
*** 93,100 ****
--- 97,144 ----
      private void initialize(String labelAcronymn, BookList books)
      {
+         lblDesc = new JLabel();
+         lblDesc.setBorder(BorderFactory.createEmptyBorder(5, 5, 0, 0));
+ 
          Component left = createAvailablePanel(labelAcronymn, books);
          Component right = createSelectedPanel();
          this.setLayout(new BorderLayout());
+         this.add(lblDesc, BorderLayout.NORTH);
          this.add(createSplitPane(left, right), BorderLayout.CENTER);
+ 
+         updateDescription();
+     }
+ 
+     /**
+      * 
+      */
+     private void updateDescription()
+     {
+         String desc = "#ERROR#"; //$NON-NLS-1$
+ 
+         if (installer == null)
+         {
+             int bookCount = Books.installed().getBookMetaDatas().size();
+             desc = Msg.INSTALLED_DESC.toString(new Object[]
+             {
+                 new Integer(bookCount)
+             });
+         }
+         else
+         {
+             int bookCount = installer.getBookMetaDatas().size();
+             if (bookCount == 0)
+             {
+                 desc = Msg.NONE_AVAILABLE_DESC.toString();
+             }
+             else
+             {
+                 desc = Msg.AVAILABLE_DESC.toString(new Object[]
+                 {
+                     new Integer(bookCount)
+                 });
+             }
+         }
+ 
+         lblDesc.setText(desc);
      }
  
***************
*** 187,190 ****
--- 231,235 ----
          {
              panel.add(new JButton(actions.getAction(INSTALL)));
+             panel.add(new JButton(actions.getAction(INSTALL_SEARCH)));
              panel.add(new JButton(actions.getAction(REFRESH)));
          }
***************
*** 240,244 ****
                      // Is the book already installed? Then nothing to do.
                      BookMetaData bmd = Books.installed().getBookMetaData(name.getName());
!                     if (bmd != null && ! installer.isNewer(bmd))
                      {
                          Reporter.informUser(this, Msg.INSTALLED, name.getName());
--- 285,289 ----
                      // Is the book already installed? Then nothing to do.
                      BookMetaData bmd = Books.installed().getBookMetaData(name.getName());
!                     if (bmd != null && !installer.isNewer(bmd))
                      {
                          Reporter.informUser(this, Msg.INSTALLED, name.getName());
***************
*** 253,257 ****
                          installer.install(name);
                      }
- 
                  }
                  catch (InstallException ex)
--- 298,301 ----
***************
*** 264,267 ****
--- 308,333 ----
  
      /**
+      * Kick off the installer
+      */
+     public void doInstallSearch()
+     {
+         doInstall();
+ 
+         TreePath path = treAvailable.getSelectionPath();
+         if (path != null)
+         {
+             try
+             {
+                 BookMetaData bmd = (BookMetaData) path.getLastPathComponent();
+                 IndexDownloader.downloadIndex(bmd, installer);
+             }
+             catch (Exception ex)
+             {
+                 Reporter.informUser(this, ex);
+             }
+         }
+     }
+ 
+     /**
       * Something has been (un)selected in the tree
       */
***************
*** 286,289 ****
--- 352,356 ----
          //actions.getAction(DELETE).setEnabled(bookSelected);
          actions.getAction(INSTALL).setEnabled(bookSelected);
+         actions.getAction(INSTALL_SEARCH).setEnabled(bookSelected);
      }
  
***************
*** 293,296 ****
--- 360,364 ----
      private static final String REFRESH = "Refresh"; //$NON-NLS-1$
      private static final String INSTALL = "Install"; //$NON-NLS-1$
+     private static final String INSTALL_SEARCH = "InstallSearch"; //$NON-NLS-1$
      //private static final String DELETE = "Delete"; //$NON-NLS-1$
  
***************
*** 308,314 ****
       * GUI Components
       */
!     private JTree treAvailable;
!     private JTable tblSelected;
!     private MapTableModel emptyTableModel;
  
      /**
--- 376,383 ----
       * GUI Components
       */
!     private JTree treAvailable = null;
!     private JTable tblSelected = null;
!     private MapTableModel emptyTableModel = null;
!     private JLabel lblDesc = null;
  
      /**
***************
*** 316,318 ****
       */
      private static final long serialVersionUID = 1L;
! }
--- 385,387 ----
       */
      private static final long serialVersionUID = 1L;
! }
\ No newline at end of file

Index: Msg.java
===================================================================
RCS file: /cvs/jsword/bibledesktop/java/main/org/crosswire/bibledesktop/book/Msg.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -d -r1.12 -r1.13
*** Msg.java	10 Oct 2004 22:12:11 -0000	1.12
--- Msg.java	15 Oct 2004 23:28:22 -0000	1.13
***************
*** 58,61 ****
--- 58,64 ----
      static final Msg CONFIRMATION_TITLE = new Msg("SitePane.ConfirmationTitle"); //$NON-NLS-1$
      static final Msg INSTALLED = new Msg("SitePane.Installed"); //$NON-NLS-1$
+     static final Msg INSTALLED_DESC = new Msg("SitePane.InstalledDesc"); //$NON-NLS-1$
+     static final Msg AVAILABLE_DESC = new Msg("SitePane.AvailableDesc"); //$NON-NLS-1$
+     static final Msg NONE_AVAILABLE_DESC = new Msg("SitePane.NoneAvailableDesc"); //$NON-NLS-1$
  
      static final Msg EDIT_SITE_TITLE = new Msg("EditSitePane.EditSitesTitle"); //$NON-NLS-1$

Index: IndexResolver.java
===================================================================
RCS file: /cvs/jsword/bibledesktop/java/main/org/crosswire/bibledesktop/book/IndexResolver.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** IndexResolver.java	10 Oct 2004 22:12:11 -0000	1.1
--- IndexResolver.java	15 Oct 2004 23:28:22 -0000	1.2
***************
*** 3,8 ****
  import java.awt.BorderLayout;
  import java.awt.Component;
- import java.io.IOException;
- import java.net.URL;
  import java.util.Iterator;
  import java.util.Map;
--- 3,6 ----
***************
*** 14,25 ****
  
  import org.crosswire.common.util.Logger;
- import org.crosswire.common.util.NetUtil;
- import org.crosswire.jsword.book.BookException;
  import org.crosswire.jsword.book.BookMetaData;
- import org.crosswire.jsword.book.install.InstallException;
  import org.crosswire.jsword.book.install.InstallManager;
  import org.crosswire.jsword.book.install.Installer;
- import org.crosswire.jsword.book.search.IndexManager;
  import org.crosswire.jsword.book.search.IndexManagerFactory;
  
  /**
--- 12,20 ----
  
  import org.crosswire.common.util.Logger;
  import org.crosswire.jsword.book.BookMetaData;
  import org.crosswire.jsword.book.install.InstallManager;
  import org.crosswire.jsword.book.install.Installer;
  import org.crosswire.jsword.book.search.IndexManagerFactory;
+ import org.crosswire.jsword.util.IndexDownloader;
  
  /**
***************
*** 85,89 ****
                      try
                      {
!                         downloadIndex(bmd, installer);
                      }
                      catch (Exception ex)
--- 80,84 ----
                      try
                      {
!                         IndexDownloader.downloadIndex(bmd, installer);
                      }
                      catch (Exception ex)
***************
*** 114,145 ****
      
      /**
-      * Download and install a search index
-      * @param bmd The book to get an index for
-      */
-     private static void downloadIndex(BookMetaData bmd, Installer installer) throws IOException, InstallException, BookException
-     {
-         // Get a temp home
-         URL tempDownload = NetUtil.getTemporaryURL(TEMP_PREFIX, TEMP_SUFFIX);
- 
-         try
-         {
-             // Now we know what installer to use, download to the temp file
-             installer.downloadSearchIndex(bmd, tempDownload);
- 
-             // And install from that file.
-             IndexManager idxman = IndexManagerFactory.getIndexManager();
-             idxman.installDownloadedIndex(bmd.getBook(), tempDownload);
-         }
-         finally
-         {
-             // tidy up after ourselves
-             if (tempDownload != null)
-             {
-                 NetUtil.delete(tempDownload);
-             }
-         }
-     }
- 
-     /**
       * Pick an installer
       * @param parent A component to tie dialogs to
--- 109,112 ----
***************
*** 182,187 ****
       */
      private static final Logger log = Logger.getLogger(IndexResolver.class);
- 
-     private static final String TEMP_SUFFIX = "dat"; //$NON-NLS-1$
-     private static final String TEMP_PREFIX = "jsword-index"; //$NON-NLS-1$
  }
--- 149,151 ----

Index: Msg.properties
===================================================================
RCS file: /cvs/jsword/bibledesktop/java/main/org/crosswire/bibledesktop/book/Msg.properties,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -d -r1.10 -r1.11
*** Msg.properties	10 Oct 2004 22:12:11 -0000	1.10
--- Msg.properties	15 Oct 2004 23:28:22 -0000	1.11
***************
*** 42,45 ****
--- 42,48 ----
  SitePane.ConfirmationTitle=Download Book
  SitePane.Installed=Book already installed: {0}
+ SitePane.InstalledDesc={0} books installed.
+ SitePane.AvailableDesc={0} books available for download.
+ SitePane.NoneAvailableDesc=<html><b>Click ''Update Available Books'' to download an up to date book list.</b>
  
  EditSitePane.EditSitesTitle=Edit Update Sites

Index: SitesPane.properties
===================================================================
RCS file: /cvs/jsword/bibledesktop/java/main/org/crosswire/bibledesktop/book/SitesPane.properties,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** SitesPane.properties	27 Aug 2004 11:41:33 -0000	1.2
--- SitesPane.properties	15 Oct 2004 23:28:22 -0000	1.3
***************
*** 2,20 ****
  SitesClose.Enabled=true
  SitesClose.Name=OK
- SitesClose.ShortDescription=Close the window.
- SitesClose.LongDescription=Close the window.
- SitesClose.SmallIcon=
- SitesClose.LargeIcon=
  SitesClose.MnemonicKey=O
- SitesClose.AcceleratorKey=
- SitesClose.AcceleratorKey.Modifiers=
  
  ManageSites.Enabled=true
  ManageSites.Name=Edit Sites ...
- ManageSites.ShortDescription=Edit the site.
- ManageSites.LongDescription=Edit the site.
- ManageSites.SmallIcon=
- ManageSites.LargeIcon=
  ManageSites.MnemonicKey=S
- ManageSites.AcceleratorKey=
- ManageSites.AcceleratorKey.Modifiers=
--- 2,8 ----

Index: SitesPane.java
===================================================================
RCS file: /cvs/jsword/bibledesktop/java/main/org/crosswire/bibledesktop/book/SitesPane.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** SitesPane.java	2 Oct 2004 14:01:38 -0000	1.8
--- SitesPane.java	15 Oct 2004 23:28:22 -0000	1.9
***************
*** 118,124 ****
      protected void addAllInstallers()
      {
-         // Add the panel for the locally installed books
-         tabMain.add(Msg.LOCAL_BOOKS.toString(), new SitePane());
- 
          // Now add panels for book installation sites
          for (Iterator it = installers.keySet().iterator(); it.hasNext(); )
--- 118,121 ----
***************
*** 130,133 ****
--- 127,133 ----
              tabMain.add(name, site);
          }
+ 
+         // Add the panel for the locally installed books
+         tabMain.add(Msg.LOCAL_BOOKS.toString(), new SitePane());
      }
  



More information about the jsword-svn mailing list