[jsword-svn] r1389 - in trunk: bibledesktop/src/main/java/org/crosswire/bibledesktop/book bibledesktop/src/main/java/org/crosswire/bibledesktop/desktop bibledesktop/src/main/java/org/crosswire/bibledesktop/display bibledesktop/src/main/java/org/crosswire/bibledesktop/display/basic jsword/src/main/java/org/crosswire/jsword/book jsword-limbo/src/main/java/org/crosswire/bibledesktop/book jsword-limbo/src/main/java/org/crosswire/bibledesktop/display/jdtb jsword-limbo/src/main/java/org/crosswire/bibledesktop/reference
dmsmith at www.crosswire.org
dmsmith at www.crosswire.org
Thu Jun 7 06:55:26 MST 2007
Author: dmsmith
Date: 2007-06-07 06:55:25 -0700 (Thu, 07 Jun 2007)
New Revision: 1389
Modified:
trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/book/BookSelectEvent.java
trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/book/DisplaySelectPane.java
trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/book/MultiBookPane.java
trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/desktop/Desktop.java
trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/desktop/DesktopActions.java
trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/display/BookDataDisplay.java
trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/display/ProxyBookDataDisplay.java
trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/display/basic/SplitBookDataDisplay.java
trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/display/basic/TabbedBookDataDisplay.java
trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/display/basic/TextPaneBookDataDisplay.java
trunk/jsword-limbo/src/main/java/org/crosswire/bibledesktop/book/CommentaryPane.java
trunk/jsword-limbo/src/main/java/org/crosswire/bibledesktop/display/jdtb/JDTBBookDataDisplay.java
trunk/jsword-limbo/src/main/java/org/crosswire/bibledesktop/reference/ReferencedPane.java
trunk/jsword/src/main/java/org/crosswire/jsword/book/BookData.java
Log:
Added getFirstBook for classes that held Books.
Modified: trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/book/BookSelectEvent.java
===================================================================
--- trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/book/BookSelectEvent.java 2007-06-06 20:49:06 UTC (rev 1388)
+++ trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/book/BookSelectEvent.java 2007-06-07 13:55:25 UTC (rev 1389)
@@ -46,8 +46,8 @@
}
/**
- * Get the type of command
- * @return The type of command
+ * Get all the books.
+ * @return the books
*/
public Book[] getBooks()
{
@@ -55,6 +55,15 @@
}
/**
+ * Get the first book.
+ * @return the first book
+ */
+ public Book getFirstBook()
+ {
+ return books != null && books.length > 0 ? books[0] : null;
+ }
+
+ /**
* The new list of Books
*/
private transient Book[] books;
Modified: trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/book/DisplaySelectPane.java
===================================================================
--- trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/book/DisplaySelectPane.java 2007-06-06 20:49:06 UTC (rev 1388)
+++ trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/book/DisplaySelectPane.java 2007-06-07 13:55:25 UTC (rev 1389)
@@ -182,6 +182,14 @@
}
/**
+ * What is the first currently selected book?
+ */
+ public Book getFirstBook()
+ {
+ return selected != null && selected.length > 0 ? selected[0] : null;
+ }
+
+ /**
*
*/
public void clear()
@@ -557,7 +565,7 @@
Book[] books = ev.getBooks();
assert books.length > 0;
- Book newSelected = books[0];
+ Book newSelected = ev.getFirstBook();
if (selected.length > 0 && selected[0] != newSelected)
{
Modified: trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/book/MultiBookPane.java
===================================================================
--- trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/book/MultiBookPane.java 2007-06-06 20:49:06 UTC (rev 1388)
+++ trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/book/MultiBookPane.java 2007-06-07 13:55:25 UTC (rev 1389)
@@ -193,6 +193,14 @@
return new Book[] {book};
}
+ /* (non-Javadoc)
+ * @see org.crosswire.bibledesktop.display.BookDataDisplay#getFirstBook()
+ */
+ public Book getFirstBook()
+ {
+ return book;
+ }
+
/**
* See if the current dictionary has a mention of the word in question.
* LATER(joe): add a background task to highlight other dictionaries that have the word.
Modified: trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/desktop/Desktop.java
===================================================================
--- trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/desktop/Desktop.java 2007-06-06 20:49:06 UTC (rev 1388)
+++ trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/desktop/Desktop.java 2007-06-07 13:55:25 UTC (rev 1389)
@@ -628,10 +628,10 @@
clearView = view;
continue;
}
- Book[] books = view.getSelectPane().getBooks();
- if (books.length > 0)
+ Book book = view.getSelectPane().getFirstBook();
+ if (book != null)
{
- Key key = books[0].getKey(data);
+ Key key = book.getKey(data);
String dataPassage = key.getName();
if (view.getTitle().equals(dataPassage))
{
@@ -656,11 +656,11 @@
// Do we have an empty view we can use?
if (clearView != null)
{
- Book[] books = clearView.getSelectPane().getBooks();
- if (books.length > 0)
+ Book book = clearView.getSelectPane().getFirstBook();
+ if (book != null)
{
- Key key = books[0].getKey(data);
- clearView.setKey(books[0].createEmptyKeyList()); // force it to be a clear view, if it is not really.
+ Key key = book.getKey(data);
+ clearView.setKey(book.createEmptyKeyList()); // force it to be a clear view, if it is not really.
clearView.setKey(key);
views.select(clearView);
}
@@ -671,10 +671,10 @@
// and load it up.
BibleViewPane view = (BibleViewPane) views.addView();
- Book[] books = view.getSelectPane().getBooks();
- if (books.length > 0)
+ Book book = view.getSelectPane().getFirstBook();
+ if (book != null)
{
- Key key = books[0].getKey(data);
+ Key key = book.getKey(data);
view.setKey(key);
}
}
Modified: trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/desktop/DesktopActions.java
===================================================================
--- trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/desktop/DesktopActions.java 2007-06-06 20:49:06 UTC (rev 1388)
+++ trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/desktop/DesktopActions.java 2007-06-07 13:55:25 UTC (rev 1389)
@@ -394,9 +394,9 @@
return;
}
- Book[] books = da.getBooks();
+ Book book = da.getFirstBook();
- ViewSourcePane viewer = new ViewSourcePane(books[0], key);
+ ViewSourcePane viewer = new ViewSourcePane(book, key);
viewer.showInFrame(getDesktop());
}
Modified: trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/display/BookDataDisplay.java
===================================================================
--- trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/display/BookDataDisplay.java 2007-06-06 20:49:06 UTC (rev 1388)
+++ trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/display/BookDataDisplay.java 2007-06-07 13:55:25 UTC (rev 1389)
@@ -91,4 +91,11 @@
* @return The current books
*/
Book[] getBooks();
+
+ /**
+ * Accessor for the first Book used in the current display, or null if we are not
+ * displaying anything.
+ * @return The current books
+ */
+ Book getFirstBook();
}
Modified: trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/display/ProxyBookDataDisplay.java
===================================================================
--- trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/display/ProxyBookDataDisplay.java 2007-06-06 20:49:06 UTC (rev 1388)
+++ trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/display/ProxyBookDataDisplay.java 2007-06-07 13:55:25 UTC (rev 1389)
@@ -136,6 +136,14 @@
return getProxy().getBooks();
}
+ /* (non-Javadoc)
+ * @see org.crosswire.bibledesktop.display.BookDataDisplay#getFirstBook()
+ */
+ public Book getFirstBook()
+ {
+ return getProxy().getFirstBook();
+ }
+
/**
* The component to which we proxy
*/
Modified: trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/display/basic/SplitBookDataDisplay.java
===================================================================
--- trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/display/basic/SplitBookDataDisplay.java 2007-06-06 20:49:06 UTC (rev 1388)
+++ trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/display/basic/SplitBookDataDisplay.java 2007-06-07 13:55:25 UTC (rev 1389)
@@ -162,6 +162,14 @@
}
/**
+ * Get the first book being displayed
+ */
+ public Book getFirstBook()
+ {
+ return books != null && books.length > 0 ? books[0] : null;
+ }
+
+ /**
* copy the child
*/
public void copy()
Modified: trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/display/basic/TabbedBookDataDisplay.java
===================================================================
--- trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/display/basic/TabbedBookDataDisplay.java 2007-06-06 20:49:06 UTC (rev 1388)
+++ trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/display/basic/TabbedBookDataDisplay.java 2007-06-07 13:55:25 UTC (rev 1389)
@@ -200,6 +200,14 @@
}
/* (non-Javadoc)
+ * @see org.crosswire.bibledesktop.display.BookDataDisplay#getFirstBook()
+ */
+ public Book getFirstBook()
+ {
+ return books != null && books.length > 0 ? books[0] : null;
+ }
+
+ /* (non-Javadoc)
* @see org.crosswire.bibledesktop.display.BookDataDisplay#copy()
*/
public void copy()
Modified: trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/display/basic/TextPaneBookDataDisplay.java
===================================================================
--- trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/display/basic/TextPaneBookDataDisplay.java 2007-06-06 20:49:06 UTC (rev 1388)
+++ trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/display/basic/TextPaneBookDataDisplay.java 2007-06-07 13:55:25 UTC (rev 1389)
@@ -115,7 +115,7 @@
}
// Make sure Hebrew displays from Right to Left
- BookMetaData bmd = books[0].getBookMetaData();
+ BookMetaData bmd = getFirstBook().getBookMetaData();
if (bmd == null)
{
txtView.setText(""); //$NON-NLS-1$
@@ -154,7 +154,7 @@
* It appears that it is a line too long issue.
*/
/* Apply the fix if the text is too long and we are not Java 1.5 or greater */
- if (text.length() > 32768 && BookCategory.GENERAL_BOOK.equals(books[0].getBookCategory()))
+ if (text.length() > 32768 && BookCategory.GENERAL_BOOK.equals(getFirstBook().getBookCategory()))
{
String javaVersion = System.getProperty("java.specification.version"); //$NON-NLS-1$
if (javaVersion == null || "1.5".compareTo(javaVersion) > 0) //$NON-NLS-1$
@@ -408,6 +408,14 @@
return books;
}
+ /* (non-Javadoc)
+ * @see org.crosswire.bibledesktop.display.BookDataDisplay#getFirstBook()
+ */
+ public Book getFirstBook()
+ {
+ return books != null && books.length > 0 ? books[0] : null;
+ }
+
// Strings for hyperlinks
private static final String HYPERLINK_STYLE = "Hyperlink"; //$NON-NLS-1$
private static final String DOUBLE_SLASH = "//"; //$NON-NLS-1$
Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/BookData.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/BookData.java 2007-06-06 20:49:06 UTC (rev 1388)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/BookData.java 2007-06-07 13:55:25 UTC (rev 1389)
@@ -83,7 +83,7 @@
if (osis == null)
{
// TODO(DMS): Determine the proper representation of the OSISWork name for multiple books.
- osis = OSISUtil.createOsisFramework(books[0].getBookMetaData());
+ osis = OSISUtil.createOsisFramework(getFirstBook().getBookMetaData());
Element text = osis.getChild(OSISUtil.OSIS_ELEMENT_OSISTEXT);
Element div = getOsisContent();
text.addContent(div);
@@ -116,12 +116,20 @@
* Who created this data.
* @return Returns the book.
*/
- public Book getBook()
+ public Book[] getBooks()
{
- return books[0];
+ return books;
}
/**
+ * Get the first book.
+ */
+ public Book getFirstBook()
+ {
+ return books != null && books.length > 0 ? books[0] : null;
+ }
+
+ /**
* The key used to obtain data from one or more books.
* @return Returns the key.
*/
Modified: trunk/jsword-limbo/src/main/java/org/crosswire/bibledesktop/book/CommentaryPane.java
===================================================================
--- trunk/jsword-limbo/src/main/java/org/crosswire/bibledesktop/book/CommentaryPane.java 2007-06-06 20:49:06 UTC (rev 1388)
+++ trunk/jsword-limbo/src/main/java/org/crosswire/bibledesktop/book/CommentaryPane.java 2007-06-07 13:55:25 UTC (rev 1389)
@@ -163,6 +163,14 @@
}
/* (non-Javadoc)
+ * @see org.crosswire.bibledesktop.display.BookDataDisplay#getFirstBook()
+ */
+ public Book getFirstBook()
+ {
+ return (Book) cboComments.getSelectedItem();
+ }
+
+ /* (non-Javadoc)
* @see org.crosswire.bibledesktop.display.BookDataDisplay#clearBookData()
*/
public void clearBookData()
Modified: trunk/jsword-limbo/src/main/java/org/crosswire/bibledesktop/display/jdtb/JDTBBookDataDisplay.java
===================================================================
--- trunk/jsword-limbo/src/main/java/org/crosswire/bibledesktop/display/jdtb/JDTBBookDataDisplay.java 2007-06-06 20:49:06 UTC (rev 1388)
+++ trunk/jsword-limbo/src/main/java/org/crosswire/bibledesktop/display/jdtb/JDTBBookDataDisplay.java 2007-06-07 13:55:25 UTC (rev 1389)
@@ -168,6 +168,14 @@
return new Book[] {book};
}
+ /* (non-Javadoc)
+ * @see org.crosswire.bibledesktop.display.BookDataDisplay#getFirstBook()
+ */
+ public Book getFirstBook()
+ {
+ return book;
+ }
+
/**
* The current book
*/
Modified: trunk/jsword-limbo/src/main/java/org/crosswire/bibledesktop/reference/ReferencedPane.java
===================================================================
--- trunk/jsword-limbo/src/main/java/org/crosswire/bibledesktop/reference/ReferencedPane.java 2007-06-06 20:49:06 UTC (rev 1388)
+++ trunk/jsword-limbo/src/main/java/org/crosswire/bibledesktop/reference/ReferencedPane.java 2007-06-07 13:55:25 UTC (rev 1389)
@@ -194,6 +194,14 @@
}
/* (non-Javadoc)
+ * @see org.crosswire.bibledesktop.display.BookDataDisplay#getFirstBook()
+ */
+ public Book getFirstBook()
+ {
+ return book;
+ }
+
+ /* (non-Javadoc)
* @see org.crosswire.bibledesktop.display.BookDataDisplay#addURIEventListener(org.crosswire.bibledesktop.display.URIEventListener)
*/
public void addURIEventListener(URIEventListener listener)
More information about the jsword-svn
mailing list