[jsword-svn]
bibledesktop/java/main/org/crosswire/bibledesktop/book 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
In directory www.crosswire.org:/tmp/cvs-serv10766/java/main/org/crosswire/bibledesktop/book
Modified Files:
DisplaySelectPane.java DictionaryPane.java CommentaryPane.java
BooksListModel.java BooksComboBoxModel.java
BookListCellRenderer.java
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: BooksListModel.java
===================================================================
RCS file: /cvs/jsword/bibledesktop/java/main/org/crosswire/bibledesktop/book/BooksListModel.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** BooksListModel.java 24 Jan 2005 23:24:19 -0000 1.7
--- BooksListModel.java 19 Mar 2005 01:57:09 -0000 1.8
***************
*** 64,71 ****
* Basic constructor
*/
! public BooksListModel(BookFilter filter, BookList books)
{
this.filter = filter;
! this.books = books;
cacheData();
--- 64,71 ----
* Basic constructor
*/
! public BooksListModel(BookFilter filter, BookList bookList)
{
this.filter = filter;
! this.bookList = bookList;
cacheData();
***************
*** 77,81 ****
public int getSize()
{
! return bmds.size();
}
--- 77,81 ----
public int getSize()
{
! return books.size();
}
***************
*** 86,96 ****
{
// PARANOIA(joe): this check shouldn't be needed
! if (index > bmds.size())
{
! log.error("trying to get book at " + index + " when there are only " + bmds.size() + " known books.", new Exception()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
return null;
}
! return bmds.get(index);
}
--- 86,96 ----
{
// PARANOIA(joe): this check shouldn't be needed
! if (index > books.size())
{
! log.error("trying to get book at " + index + " when there are only " + books.size() + " known books.", new Exception()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
return null;
}
! return books.get(index);
}
***************
*** 102,106 ****
public synchronized int getIndexOf(Object test)
{
! return bmds.indexOf(test);
}
--- 102,106 ----
public synchronized int getIndexOf(Object test)
{
! return books.indexOf(test);
}
***************
*** 123,127 ****
if (listenerList.getListenerCount() == 0)
{
! books.addBooksListener(listener);
}
--- 123,127 ----
if (listenerList.getListenerCount() == 0)
{
! bookList.addBooksListener(listener);
}
***************
*** 138,142 ****
if (listenerList.getListenerCount() == 0)
{
! books.removeBooksListener(listener);
}
}
--- 138,142 ----
if (listenerList.getListenerCount() == 0)
{
! bookList.removeBooksListener(listener);
}
}
***************
*** 147,153 ****
protected final synchronized void cacheData()
{
! bmds = new ArrayList();
! bmds.addAll(books.getBookMetaDatas(filter));
! Collections.sort(bmds);
}
--- 147,153 ----
protected final synchronized void cacheData()
{
! books = new ArrayList();
! books.addAll(bookList.getBooks(filter));
! Collections.sort(books);
}
***************
*** 189,193 ****
* The list of books in this tree
*/
! private BookList books;
/**
--- 189,193 ----
* The list of books in this tree
*/
! private BookList bookList;
/**
***************
*** 207,211 ****
* trying to create a JList based on this class.
*/
! protected List bmds;
/**
--- 207,211 ----
* trying to create a JList based on this class.
*/
! protected List books;
/**
Index: DisplaySelectPane.java
===================================================================
RCS file: /cvs/jsword/bibledesktop/java/main/org/crosswire/bibledesktop/book/DisplaySelectPane.java,v
retrieving revision 1.24
retrieving revision 1.25
diff -C2 -d -r1.24 -r1.25
*** DisplaySelectPane.java 12 Mar 2005 21:15:59 -0000 1.24
--- DisplaySelectPane.java 19 Mar 2005 01:57:09 -0000 1.25
***************
*** 38,42 ****
import org.crosswire.jsword.book.Book;
import org.crosswire.jsword.book.BookFilters;
- import org.crosswire.jsword.book.BookMetaData;
import org.crosswire.jsword.book.IndexStatus;
import org.crosswire.jsword.book.search.parse.IndexSearcher;
--- 38,41 ----
***************
*** 95,102 ****
mdlBible = new BooksComboBoxModel(BookFilters.getBibles());
JComboBox cboBible = new JComboBox(mdlBible);
! selected = mdlBible.getSelectedBookMetaData();
if (selected != null)
{
! cboBible.setToolTipText(selected.toString());
}
else
--- 94,101 ----
mdlBible = new BooksComboBoxModel(BookFilters.getBibles());
JComboBox cboBible = new JComboBox(mdlBible);
! selected = mdlBible.getSelectedBook();
if (selected != null)
{
! cboBible.setToolTipText(selected.getBookMetaData().toString());
}
else
***************
*** 205,210 ****
public Book getBook()
{
! BookMetaData bmd = mdlBible.getSelectedBookMetaData();
! return bmd != null ? bmd.getBook() : null;
}
--- 204,208 ----
public Book getBook()
{
! return mdlBible.getSelectedBook();
}
***************
*** 273,278 ****
public void doSearchAction()
{
! BookMetaData bmd = mdlBible.getSelectedBookMetaData();
! if (bmd == null)
{
noBookInstalled();
--- 271,276 ----
public void doSearchAction()
{
! Book book = mdlBible.getSelectedBook();
! if (book == null)
{
noBookInstalled();
***************
*** 283,288 ****
{
String param = txtSearch.getText();
! Book book = bmd.getBook();
!
if (chkMatch.isSelected())
{
--- 281,285 ----
{
String param = txtSearch.getText();
!
if (chkMatch.isSelected())
{
***************
*** 362,367 ****
private void updateDisplay()
{
! BookMetaData bmd = mdlBible.getSelectedBookMetaData();
! if (bmd == null)
{
noBookInstalled();
--- 359,364 ----
private void updateDisplay()
{
! Book book = mdlBible.getSelectedBook();
! if (book == null)
{
noBookInstalled();
***************
*** 371,375 ****
try
{
- Book book = bmd.getBook();
Key key = book.getKey(txtKey.getText());
--- 368,371 ----
***************
*** 421,430 ****
protected void changeVersion()
{
! BookMetaData newSelected = mdlBible.getSelectedBookMetaData();
if (selected != null && selected != newSelected)
{
! selected.removePropertyChangeListener(pcl);
! newSelected.addPropertyChangeListener(pcl);
}
--- 417,426 ----
protected void changeVersion()
{
! Book newSelected = mdlBible.getSelectedBook();
if (selected != null && selected != newSelected)
{
! selected.getBookMetaData().removePropertyChangeListener(pcl);
! newSelected.getBookMetaData().addPropertyChangeListener(pcl);
}
***************
*** 441,448 ****
try
{
! Book book = selected.getBook();
! Key key = book.getKey(txtKey.getText());
! fireVersionChanged(new DisplaySelectEvent(this, key, book));
}
catch (Exception ex)
--- 437,443 ----
try
{
! Key key = selected.getKey(txtKey.getText());
! fireVersionChanged(new DisplaySelectEvent(this, key, selected));
}
catch (Exception ex)
***************
*** 478,483 ****
{
boolean readable = selected != null;
! boolean searchable = readable && selected.getIndexStatus().equals(IndexStatus.DONE);
! boolean indexable = readable && selected.getIndexStatus().equals(IndexStatus.UNDONE);
txtSearch.setEnabled(searchable);
--- 473,478 ----
{
boolean readable = selected != null;
! boolean searchable = readable && selected.getBookMetaData().getIndexStatus().equals(IndexStatus.DONE);
! boolean indexable = readable && selected.getBookMetaData().getIndexStatus().equals(IndexStatus.UNDONE);
txtSearch.setEnabled(searchable);
***************
*** 614,618 ****
private ActionFactory actions;
! private BookMetaData selected;
/*
--- 609,613 ----
private ActionFactory actions;
! private Book selected;
/*
Index: BooksComboBoxModel.java
===================================================================
RCS file: /cvs/jsword/bibledesktop/java/main/org/crosswire/bibledesktop/book/BooksComboBoxModel.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** BooksComboBoxModel.java 15 Jan 2005 12:05:37 -0000 1.6
--- BooksComboBoxModel.java 19 Mar 2005 01:57:09 -0000 1.7
***************
*** 3,8 ****
import javax.swing.ComboBoxModel;
import org.crosswire.jsword.book.BookFilter;
- import org.crosswire.jsword.book.BookMetaData;
import org.crosswire.jsword.book.Defaults;
--- 3,8 ----
import javax.swing.ComboBoxModel;
+ import org.crosswire.jsword.book.Book;
import org.crosswire.jsword.book.BookFilter;
import org.crosswire.jsword.book.Defaults;
***************
*** 54,79 ****
{
// The default is to have the first selected
! current = (BookMetaData) getElementAt(0);
// If one of our favorite Books is in the list we ought to start
// with that selected. We put the Bible last so it will override
// the others if this is a broad list of books
! tryInitialSelection(Defaults.getCommentaryMetaData());
! tryInitialSelection(Defaults.getDictionaryMetaData());
! tryInitialSelection(Defaults.getBibleMetaData());
}
}
/**
! * @param bmd
*/
! private void tryInitialSelection(BookMetaData bmd)
{
! if (bmd != null)
{
! int i = bmds.indexOf(bmd);
if (i != -1)
{
! current = bmd;
}
}
--- 54,79 ----
{
// The default is to have the first selected
! current = (Book) getElementAt(0);
// If one of our favorite Books is in the list we ought to start
// with that selected. We put the Bible last so it will override
// the others if this is a broad list of books
! tryInitialSelection(Defaults.getCommentary());
! tryInitialSelection(Defaults.getDictionary());
! tryInitialSelection(Defaults.getBible());
}
}
/**
! * @param book
*/
! private void tryInitialSelection(Book book)
{
! if (book != null)
{
! int i = books.indexOf(book);
if (i != -1)
{
! current = book;
}
}
***************
*** 83,89 ****
* @see javax.swing.ComboBoxModel#setSelectedItem(java.lang.Object)
*/
! public void setSelectedItem(Object current)
{
! this.current = (BookMetaData) current;
fireContentsChanged(this, -1, -1);
}
--- 83,89 ----
* @see javax.swing.ComboBoxModel#setSelectedItem(java.lang.Object)
*/
! public void setSelectedItem(Object selected)
{
! this.current = (Book) selected;
fireContentsChanged(this, -1, -1);
}
***************
*** 101,105 ****
* @return A Bible
*/
! public BookMetaData getSelectedBookMetaData()
{
return current;
--- 101,105 ----
* @return A Bible
*/
! public Book getSelectedBook()
{
return current;
***************
*** 128,132 ****
if (getSize() > 0)
{
! current = (BookMetaData) getElementAt(0);
}
else
--- 128,132 ----
if (getSize() > 0)
{
! current = (Book) getElementAt(0);
}
else
***************
*** 140,144 ****
* The currently selected version
*/
! protected BookMetaData current;
/**
--- 140,144 ----
* The currently selected version
*/
! protected Book current;
/**
Index: BookListCellRenderer.java
===================================================================
RCS file: /cvs/jsword/bibledesktop/java/main/org/crosswire/bibledesktop/book/BookListCellRenderer.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** BookListCellRenderer.java 6 Mar 2005 20:21:36 -0000 1.6
--- BookListCellRenderer.java 19 Mar 2005 01:57:09 -0000 1.7
***************
*** 12,15 ****
--- 12,16 ----
import org.crosswire.common.swing.GuiUtil;
+ import org.crosswire.jsword.book.Book;
import org.crosswire.jsword.book.BookMetaData;
import org.crosswire.jsword.book.BookType;
***************
*** 103,113 ****
if (value instanceof BookMetaData)
{
! BookMetaData bmd = (BookMetaData) value;
! String displayName = bmd.toString();
setText(displayName);
setToolTipText(displayName);
! BookType type = bmd.getType();
if (type.equals(BookType.BIBLE))
{
--- 104,114 ----
if (value instanceof BookMetaData)
{
! Book book = (Book) value;
! String displayName = book.toString();
setText(displayName);
setToolTipText(displayName);
! BookType type = book.getType();
if (type.equals(BookType.BIBLE))
{
Index: CommentaryPane.java
===================================================================
RCS file: /cvs/jsword/bibledesktop/java/main/org/crosswire/bibledesktop/book/CommentaryPane.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -d -r1.11 -r1.12
*** CommentaryPane.java 6 Mar 2005 20:21:36 -0000 1.11
--- CommentaryPane.java 19 Mar 2005 01:57:09 -0000 1.12
***************
*** 19,23 ****
import org.crosswire.jsword.book.BookFilter;
import org.crosswire.jsword.book.BookFilters;
- import org.crosswire.jsword.book.BookMetaData;
import org.crosswire.jsword.passage.Key;
import org.crosswire.jsword.passage.Passage;
--- 19,22 ----
***************
*** 119,124 ****
protected void updateDisplay()
{
! BookMetaData bmd = (BookMetaData) cboComments.getSelectedItem();
! if (bmd == null)
{
return;
--- 118,123 ----
protected void updateDisplay()
{
! Book book = (Book) cboComments.getSelectedItem();
! if (book == null)
{
return;
***************
*** 128,132 ****
{
Verse verse = set.getVerse();
! display.setBookData(bmd.getBook(), verse);
}
catch (Exception ex)
--- 127,131 ----
{
Verse verse = set.getVerse();
! display.setBookData(book, verse);
}
catch (Exception ex)
***************
*** 157,167 ****
public Book getBook()
{
! BookMetaData bmd = (BookMetaData) cboComments.getSelectedItem();
! if (bmd == null)
! {
! return null;
! }
!
! return bmd.getBook();
}
--- 156,160 ----
public Book getBook()
{
! return (Book) cboComments.getSelectedItem();
}
***************
*** 171,176 ****
public void setBookData(Book book, Key key)
{
! BookMetaData bmd = book.getBookMetaData();
! cboComments.setSelectedItem(bmd);
setKey(key);
--- 164,168 ----
public void setBookData(Book book, Key key)
{
! cboComments.setSelectedItem(book);
setKey(key);
Index: DictionaryPane.java
===================================================================
RCS file: /cvs/jsword/bibledesktop/java/main/org/crosswire/bibledesktop/book/DictionaryPane.java,v
retrieving revision 1.15
retrieving revision 1.16
diff -C2 -d -r1.15 -r1.16
*** DictionaryPane.java 6 Mar 2005 04:55:44 -0000 1.15
--- DictionaryPane.java 19 Mar 2005 01:57:09 -0000 1.16
***************
*** 27,31 ****
import org.crosswire.jsword.book.BookFilter;
import org.crosswire.jsword.book.BookFilters;
- import org.crosswire.jsword.book.BookMetaData;
import org.crosswire.jsword.book.BookType;
import org.crosswire.jsword.book.Defaults;
--- 27,30 ----
***************
*** 70,74 ****
// This must come after the setViewportView() calls so scrolling works
! lstDicts.setSelectedValue(Defaults.getDictionaryMetaData(), true);
}
--- 69,73 ----
// This must come after the setViewportView() calls so scrolling works
! lstDicts.setSelectedValue(Defaults.getDictionary(), true);
}
***************
*** 276,283 ****
if (selected != null)
{
! BookMetaData dmd = (BookMetaData) selected;
! if (dmd.getType().equals(BookType.DICTIONARY))
{
! dict = dmd.getBook();
Key key = dict.getGlobalKeyList();
--- 275,282 ----
if (selected != null)
{
! Book book = (Book) selected;
! if (book.getBookMetaData().getType().equals(BookType.DICTIONARY))
{
! dict = book;
Key key = dict.getGlobalKeyList();
***************
*** 307,312 ****
protected void updateDisplay()
{
! BookMetaData bmd = (BookMetaData) lstDicts.getSelectedValue();
! if (bmd == null)
{
log.warn("no selected commentary"); //$NON-NLS-1$
--- 306,311 ----
protected void updateDisplay()
{
! Book book = (Book) lstDicts.getSelectedValue();
! if (book == null)
{
log.warn("no selected commentary"); //$NON-NLS-1$
***************
*** 317,321 ****
{
Verse verse = set.getVerse();
! display.setBookData(bmd.getBook(), verse);
}
catch (Exception ex)
--- 316,320 ----
{
Verse verse = set.getVerse();
! display.setBookData(book, verse);
}
catch (Exception ex)
More information about the jsword-svn
mailing list