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

jswordcvs at crosswire.org jswordcvs at crosswire.org
Fri Mar 18 18:57:11 MST 2005


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

Modified Files:
	IndexResolver.java SitePane.java Msg.java BookNode.java 
	TextPaneBookMetaDataDisplay.java SitePane.properties 
	Msg.properties 
Log Message:
Made Book the primary interface to a module and put BookMetaData within it. All of BookMetaData is accessible through the Book interface.

Index: SitePane.properties
===================================================================
RCS file: /cvs/jsword/bibledesktop/java/main/org/crosswire/bibledesktop/book/install/SitePane.properties,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** SitePane.properties	15 Feb 2005 02:08:59 -0000	1.1
--- SitePane.properties	19 Mar 2005 01:57:09 -0000	1.2
***************
*** 30,33 ****
--- 30,39 ----
  SelectedBookLabel.AcceleratorKey.Modifiers=
  
+ Delete.Enabled=false
+ Delete.Name=Delete
+ Delete.ShortDescription=Delete a book.
+ Delete.LongDescription=Delete the selected book
+ Delete.MnemonicKey=D
+ 
  Install.Enabled=false
  Install.Name=Install

Index: BookNode.java
===================================================================
RCS file: /cvs/jsword/bibledesktop/java/main/org/crosswire/bibledesktop/book/install/BookNode.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** BookNode.java	15 Feb 2005 02:08:59 -0000	1.1
--- BookNode.java	19 Mar 2005 01:57:09 -0000	1.2
***************
*** 6,10 ****
  import javax.swing.tree.DefaultMutableTreeNode;
  
! import org.crosswire.jsword.book.BookMetaDataSet;
  
  /**
--- 6,10 ----
  import javax.swing.tree.DefaultMutableTreeNode;
  
! import org.crosswire.jsword.book.BookSet;
  
  /**
***************
*** 36,40 ****
  {
  
!     public BookNode(Object node, BookMetaDataSet books, Object [] grouping, int level)
      {
          setUserObject(node);
--- 36,40 ----
  {
  
!     public BookNode(Object node, BookSet books, Object [] grouping, int level)
      {
          setUserObject(node);
***************
*** 47,51 ****
              {
                  String value = iter.next().toString();
!                 BookMetaDataSet subBooks = books.filter(key, value);
                  add(new BookNode(value, subBooks, grouping, level + 1));
              }
--- 47,51 ----
              {
                  String value = iter.next().toString();
!                 BookSet subBooks = books.filter(key, value);
                  add(new BookNode(value, subBooks, grouping, level + 1));
              }

Index: SitePane.java
===================================================================
RCS file: /cvs/jsword/bibledesktop/java/main/org/crosswire/bibledesktop/book/install/SitePane.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** SitePane.java	6 Mar 2005 20:21:36 -0000	1.4
--- SitePane.java	19 Mar 2005 01:57:09 -0000	1.5
***************
*** 25,31 ****
  import org.crosswire.common.util.NetUtil;
  import org.crosswire.common.util.Reporter;
  import org.crosswire.jsword.book.BookList;
  import org.crosswire.jsword.book.BookMetaData;
! import org.crosswire.jsword.book.BookMetaDataSet;
  import org.crosswire.jsword.book.Books;
  import org.crosswire.jsword.book.BooksEvent;
--- 25,34 ----
  import org.crosswire.common.util.NetUtil;
  import org.crosswire.common.util.Reporter;
+ import org.crosswire.jsword.book.Book;
+ import org.crosswire.jsword.book.BookException;
  import org.crosswire.jsword.book.BookList;
  import org.crosswire.jsword.book.BookMetaData;
! import org.crosswire.jsword.book.BookSet;
! import org.crosswire.jsword.book.BookType;
  import org.crosswire.jsword.book.Books;
  import org.crosswire.jsword.book.BooksEvent;
***************
*** 33,36 ****
--- 36,41 ----
  import org.crosswire.jsword.book.install.InstallException;
  import org.crosswire.jsword.book.install.Installer;
+ import org.crosswire.jsword.book.search.IndexManager;
+ import org.crosswire.jsword.book.search.IndexManagerFactory;
  
  /**
***************
*** 122,131 ****
          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)
              {
--- 127,136 ----
          if (installer == null)
          {
!             int bookCount = Books.installed().getBooks().size();
              desc = Msg.INSTALLED_DESC.toString(new Object[] { new Integer(bookCount) });
          }
          else
          {
!             int bookCount = installer.getBooks().size();
              if (bookCount == 0)
              {
***************
*** 225,229 ****
      {
          // return new BooksTreeModel(books);
!         BookMetaDataSet bmds = new BookMetaDataSet(books.getBookMetaDatas());
          TreeNode bookRoot = new BookNode("root", bmds, new Object[] { BookMetaData.KEY_TYPE, BookMetaData.KEY_LANGUAGE }, 0); //$NON-NLS-1$
          return new DefaultTreeModel(bookRoot);
--- 230,234 ----
      {
          // return new BooksTreeModel(books);
!         BookSet bmds = new BookSet(books.getBooks());
          TreeNode bookRoot = new BookNode("root", bmds, new Object[] { BookMetaData.KEY_TYPE, BookMetaData.KEY_LANGUAGE }, 0); //$NON-NLS-1$
          return new DefaultTreeModel(bookRoot);
***************
*** 231,235 ****
  
      // provide for backward compatibility
!     private BookMetaData getBookMetaData(Object obj)
      {
          // new way
--- 236,240 ----
  
      // provide for backward compatibility
!     private Book getBook(Object obj)
      {
          // new way
***************
*** 239,245 ****
          }
          // Old way
!         if (obj instanceof BookMetaData)
          {
!             return (BookMetaData) obj;
          }
          return null;
--- 244,250 ----
          }
          // Old way
!         if (obj instanceof Book)
          {
!             return (Book) obj;
          }
          return null;
***************
*** 258,265 ****
              panel.add(new JButton(actions.getAction(REFRESH)));
          }
! //        else
! //        {
! //            pnlActions.add(new JButton(actions.getAction(DELETE)));
! //        }
          return panel;
      }
--- 263,270 ----
              panel.add(new JButton(actions.getAction(REFRESH)));
          }
!         else
!         {
!             panel.add(new JButton(actions.getAction(DELETE)));
!         }
          return panel;
      }
***************
*** 270,273 ****
--- 275,305 ----
      public void doDelete()
      {
+         TreePath path = treAvailable.getSelectionPath();
+         if (path == null)
+         {
+             return;
+         }
+ 
+         Object last = path.getLastPathComponent();
+         Book book = getBook(last);
+ 
+         try
+         {
+             book.getBookMetaData().getDriver().delete(book);
+ 
+             IndexManager imanager = IndexManagerFactory.getIndexManager();
+             if (imanager.isIndexed(book))
+             {
+                 imanager.deleteIndex(book);
+                 
+             }
+ //            // unselect it and then remove from list.
+ //            treAvailable.removeSelectionPath(path);
+ //            ((DefaultTreeModel)treAvailable.getModel()).removeNodeFromParent((MutableTreeNode) last);
+         }
+         catch (BookException e)
+         {
+             Reporter.informUser(this, e);
+         }
      }
  
***************
*** 296,331 ****
      public void doInstall()
      {
!         if (installer != null)
          {
!             TreePath path = treAvailable.getSelectionPath();
!             if (path != null)
!             {
!                 Object last = path.getLastPathComponent();
!                 BookMetaData name = getBookMetaData(last);
  
!                 try
!                 {
!                     // 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());
!                         return;
!                     }
  
!                     float size = NetUtil.getSize(installer.toRemoteURL(name)) / 1024.0F;
!                     if (JOptionPane.showConfirmDialog(this, Msg.SIZE.toString(new Object[] {name.getName(), new Float(size)}),
!                                     Msg.CONFIRMATION_TITLE.toString(),
!                                     JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION)
!                     {
!                         installer.install(name);
!                     }
!                 }
!                 catch (InstallException ex)
!                 {
!                     Reporter.informUser(this, ex);
!                 }
              }
          }
      }
  
--- 328,367 ----
      public void doInstall()
      {
!         if (installer == null)
          {
!             return;
!         }
  
!         TreePath path = treAvailable.getSelectionPath();
!         if (path == null)
!         {
!             return;
!         }
  
!         Object last = path.getLastPathComponent();
!         Book name = getBook(last);
! 
!         try
!         {
!             // Is the book already installed? Then nothing to do.
!             Book book = Books.installed().getBook(name.getBookMetaData().getName());
!             if (book != null && !installer.isNewer(name))
!             {
!                 Reporter.informUser(this, Msg.INSTALLED, name.getBookMetaData().getName());
!                 return;
!             }
! 
!             float size = NetUtil.getSize(installer.toRemoteURL(name)) / 1024.0F;
!             if (JOptionPane.showConfirmDialog(this, Msg.SIZE.toString(new Object[] {name.getBookMetaData().getName(), new Float(size)}),
!                             Msg.CONFIRMATION_TITLE.toString(),
!                             JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION)
!             {
!                 installer.install(name);
              }
          }
+         catch (InstallException ex)
+         {
+             Reporter.informUser(this, ex);
+         }
      }
  
***************
*** 343,348 ****
              {
                  Object last = path.getLastPathComponent();
!                 BookMetaData bmd = getBookMetaData(last);
!                 IndexResolver.scheduleIndex(bmd, this);
              }
              catch (Exception ex)
--- 379,384 ----
              {
                  Object last = path.getLastPathComponent();
!                 Book book = getBook(last);
!                 IndexResolver.scheduleIndex(book, this);
              }
              catch (Exception ex)
***************
*** 361,379 ****
  
          boolean bookSelected = false;
!         BookMetaData bmd = null;
          if (path != null)
          {
              Object last = path.getLastPathComponent();
!             bmd = getBookMetaData(last);
!             if (bmd != null)
              {
                  bookSelected = true;
              }
          }
!         display.setBookMetaData(bmd);
  
!         //actions.getAction(DELETE).setEnabled(bookSelected);
          actions.getAction(INSTALL).setEnabled(bookSelected);
!         actions.getAction(INSTALL_SEARCH).setEnabled(bookSelected);
      }
  
--- 397,415 ----
  
          boolean bookSelected = false;
!         Book book = null;
          if (path != null)
          {
              Object last = path.getLastPathComponent();
!             book = getBook(last);
!             if (book != null)
              {
                  bookSelected = true;
              }
          }
!         display.setBook(book);
  
!         actions.getAction(DELETE).setEnabled(bookSelected && book.getDriver().isDeletable(book));
          actions.getAction(INSTALL).setEnabled(bookSelected);
!         actions.getAction(INSTALL_SEARCH).setEnabled(bookSelected && book.getType() == BookType.BIBLE);
      }
  
***************
*** 412,416 ****
      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$
  
      /**
--- 448,452 ----
      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$
  
      /**

Index: Msg.java
===================================================================
RCS file: /cvs/jsword/bibledesktop/java/main/org/crosswire/bibledesktop/book/install/Msg.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** Msg.java	15 Feb 2005 02:08:59 -0000	1.1
--- Msg.java	19 Mar 2005 01:57:09 -0000	1.2
***************
*** 36,39 ****
--- 36,40 ----
      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 DELETE_FAILED = new Msg("SitePane.DeleteFailed"); //$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$

Index: IndexResolver.java
===================================================================
RCS file: /cvs/jsword/bibledesktop/java/main/org/crosswire/bibledesktop/book/install/IndexResolver.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** IndexResolver.java	6 Mar 2005 20:21:36 -0000	1.2
--- IndexResolver.java	19 Mar 2005 01:57:09 -0000	1.3
***************
*** 12,16 ****
  
  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;
--- 12,16 ----
  
  import org.crosswire.common.util.Logger;
! import org.crosswire.jsword.book.Book;
  import org.crosswire.jsword.book.install.InstallManager;
  import org.crosswire.jsword.book.install.Installer;
***************
*** 66,70 ****
       *
       */
!     public static void scheduleIndex(BookMetaData bmd, Component parent)
      {
          String title = Msg.HOW_MESSAGE_TITLE.toString();
--- 66,70 ----
       *
       */
!     public static void scheduleIndex(Book book, Component parent)
      {
          String title = Msg.HOW_MESSAGE_TITLE.toString();
***************
*** 80,84 ****
                      try
                      {
!                         IndexDownloader.downloadIndex(bmd, installer);
                      }
                      catch (Exception ex)
--- 80,84 ----
                      try
                      {
!                         IndexDownloader.downloadIndex(book, installer);
                      }
                      catch (Exception ex)
***************
*** 93,97 ****
                          if (yn == JOptionPane.YES_OPTION)
                          {
!                             IndexManagerFactory.getIndexManager().scheduleIndexCreation(bmd.getBook());
                          }
                      }
--- 93,97 ----
                          if (yn == JOptionPane.YES_OPTION)
                          {
!                             IndexManagerFactory.getIndexManager().scheduleIndexCreation(book);
                          }
                      }
***************
*** 100,104 ****
  
              case 1: // generate
!                 IndexManagerFactory.getIndexManager().scheduleIndexCreation(bmd.getBook());
                  break;
  
--- 100,104 ----
  
              case 1: // generate
!                 IndexManagerFactory.getIndexManager().scheduleIndexCreation(book);
                  break;
  

Index: TextPaneBookMetaDataDisplay.java
===================================================================
RCS file: /cvs/jsword/bibledesktop/java/main/org/crosswire/bibledesktop/book/install/TextPaneBookMetaDataDisplay.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** TextPaneBookMetaDataDisplay.java	6 Mar 2005 20:21:36 -0000	1.2
--- TextPaneBookMetaDataDisplay.java	19 Mar 2005 01:57:09 -0000	1.3
***************
*** 14,18 ****
  import org.crosswire.common.xml.TransformingSAXEventProvider;
  import org.crosswire.common.xml.XMLUtil;
! import org.crosswire.jsword.book.BookMetaData;
  import org.crosswire.jsword.util.ConverterFactory;
  
--- 14,18 ----
  import org.crosswire.common.xml.TransformingSAXEventProvider;
  import org.crosswire.common.xml.XMLUtil;
! import org.crosswire.jsword.book.Book;
  import org.crosswire.jsword.util.ConverterFactory;
  
***************
*** 58,64 ****
       * @see org.crosswire.bibledesktop.display.BookDataDisplay#setBookData(org.crosswire.jsword.book.Book, org.crosswire.jsword.passage.Key)
       */
!     public void setBookMetaData(BookMetaData bmd)
      {
!         if (bmd == null)
          {
              txtView.setText(""); //$NON-NLS-1$
--- 58,64 ----
       * @see org.crosswire.bibledesktop.display.BookDataDisplay#setBookData(org.crosswire.jsword.book.Book, org.crosswire.jsword.passage.Key)
       */
!     public void setBook(Book book)
      {
!         if (book == null)
          {
              txtView.setText(""); //$NON-NLS-1$
***************
*** 69,73 ****
          {
  
!             SAXEventProvider osissep = new JDOMSAXEventProvider(bmd.toOSIS());
              TransformingSAXEventProvider htmlsep = (TransformingSAXEventProvider) converter.convert(osissep);
              String text = XMLUtil.writeToString(htmlsep);
--- 69,73 ----
          {
  
!             SAXEventProvider osissep = new JDOMSAXEventProvider(book.getBookMetaData().toOSIS());
              TransformingSAXEventProvider htmlsep = (TransformingSAXEventProvider) converter.convert(osissep);
              String text = XMLUtil.writeToString(htmlsep);

Index: Msg.properties
===================================================================
RCS file: /cvs/jsword/bibledesktop/java/main/org/crosswire/bibledesktop/book/install/Msg.properties,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** Msg.properties	15 Feb 2005 02:08:59 -0000	1.1
--- Msg.properties	19 Mar 2005 01:57:09 -0000	1.2
***************
*** 17,20 ****
--- 17,21 ----
  SitePane.Installed=Book already installed: {0}
  SitePane.InstalledDesc={0} books installed.
+ SitePane.DeleteFailed=Unable to delete: {0}
  SitePane.AvailableDesc={0} books available for download.
  SitePane.NoneAvailableDesc=<html><b>Click ''Update Available Books'' to download an up to date book list.</b>



More information about the jsword-svn mailing list