[jsword-svn] r1257 - in trunk: bibledesktop/src/main/java/org/crosswire/bibledesktop/book bibledesktop/src/main/java/org/crosswire/bibledesktop/desktop jsword/src/main/java/org/crosswire/jsword/book/sword jsword/src/main/java/org/crosswire/jsword/passage jsword-limbo/src/main/java/org/crosswire/bibledesktop/book
dmsmith at www.crosswire.org
dmsmith at www.crosswire.org
Wed Mar 21 13:43:23 MST 2007
Author: dmsmith
Date: 2007-03-21 13:43:23 -0700 (Wed, 21 Mar 2007)
New Revision: 1257
Added:
trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/book/MultiBookPane.java
trunk/jsword/src/main/java/org/crosswire/jsword/passage/TreeKey.java
Removed:
trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/book/DictionaryPane.java
trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/TreeKey.java
Modified:
trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/desktop/Desktop.java
trunk/jsword-limbo/src/main/java/org/crosswire/bibledesktop/book/SidebarPane.java
trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/TreeKeyIndex.java
Log:
Refactored some classes.
Deleted: trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/book/DictionaryPane.java
===================================================================
--- trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/book/DictionaryPane.java 2007-03-21 19:24:03 UTC (rev 1256)
+++ trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/book/DictionaryPane.java 2007-03-21 20:43:23 UTC (rev 1257)
@@ -1,494 +0,0 @@
-/**
- * Distribution License:
- * BibleDesktop is free software; you can redistribute it and/or modify it under
- * the terms of the GNU General Public License, version 2 as published by
- * the Free Software Foundation. This program is distributed in the hope
- * that it will be useful, but WITHOUT ANY WARRANTY; without even the
- * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- * See the GNU General Public License for more details.
- *
- * The License is available on the internet at:
- * http://www.gnu.org/copyleft/gpl.html
- * or by writing to:
- * Free Software Foundation, Inc.
- * 59 Temple Place - Suite 330
- * Boston, MA 02111-1307, USA
- *
- * Copyright: 2005
- * The copyright to this program is held by it's authors.
- *
- * ID: $Id$
- */
-package org.crosswire.bibledesktop.book;
-
-import java.awt.Component;
-import java.awt.FlowLayout;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.io.IOException;
-import java.io.ObjectInputStream;
-
-import javax.swing.JComboBox;
-import javax.swing.JList;
-import javax.swing.JPanel;
-import javax.swing.JScrollPane;
-import javax.swing.JSplitPane;
-import javax.swing.JTree;
-import javax.swing.ListSelectionModel;
-import javax.swing.event.ListSelectionEvent;
-import javax.swing.event.ListSelectionListener;
-import javax.swing.event.TreeSelectionEvent;
-import javax.swing.event.TreeSelectionListener;
-
-import org.crosswire.bibledesktop.display.BookDataDisplay;
-import org.crosswire.bibledesktop.display.BookDataDisplayFactory;
-import org.crosswire.bibledesktop.display.URLEventListener;
-import org.crosswire.bibledesktop.passage.KeyListListModel;
-import org.crosswire.bibledesktop.passage.KeyTreeCellRenderer;
-import org.crosswire.bibledesktop.passage.KeyTreeModel;
-import org.crosswire.common.swing.FixedSplitPane;
-import org.crosswire.common.util.Logger;
-import org.crosswire.jsword.book.Book;
-import org.crosswire.jsword.book.BookCategory;
-import org.crosswire.jsword.book.BookFilter;
-import org.crosswire.jsword.book.BookFilters;
-import org.crosswire.jsword.book.Defaults;
-import org.crosswire.jsword.passage.Key;
-import org.crosswire.jsword.passage.NoSuchKeyException;
-import org.crosswire.jsword.passage.Passage;
-import org.crosswire.jsword.passage.PreferredKey;
-import org.crosswire.jsword.passage.Verse;
-
-/**
- * Builds a panel on which all the non-Bible books and their entries are visible.
- *
- * @see gnu.gpl.License for license details.
- * The copyright to this program is held by it's authors.
- * @author Joe Walker [joe at eireneh dot com]
- * @author DM Smith [dmsmith555 at yahoo dot com]
- */
-public class DictionaryPane extends JSplitPane implements BookDataDisplay
-{
- /**
- * Setup the GUI
- */
- public DictionaryPane()
- {
- init();
-
- // This must come after the setViewportView() calls so scrolling works
- bookList.setSelectedValue(Defaults.getDailyDevotional(), true);
- }
-
- /**
- * GUI initialiser
- */
- private void init()
- {
- display = BookDataDisplayFactory.createBookDataDisplay();
-
- Component bookPicker = createBookPicker();
-
- commentaryPicker = createCommentaryPicker();
-
- dictionaryKeyScroller = createDictionaryPicker();
-
- genBookKeyScroller = createGenBookPicker();
-
- JScrollPane scrDisplay = new JScrollPane(display.getComponent());
-
- sptMain = new FixedSplitPane(false);
- sptMain.setOrientation(JSplitPane.VERTICAL_SPLIT);
- // Make the top 20% of the total
- sptMain.setResizeWeight(0.2D);
- sptMain.setTopComponent(new JPanel());
- sptMain.setBottomComponent(scrDisplay);
-
-// this.setResizeWeight(0.1D);
-// this.setMinimumSize(new Dimension(0, 0));
- this.setOrientation(JSplitPane.VERTICAL_SPLIT);
- this.setTopComponent(bookPicker);
- this.setBottomComponent(sptMain);
- this.setBorder(null);
-
- Object thisUI = this.getUI();
- if (thisUI instanceof javax.swing.plaf.basic.BasicSplitPaneUI)
- {
- ((javax.swing.plaf.basic.BasicSplitPaneUI) thisUI).getDivider().setBorder(null);
- }
- }
-
- /* (non-Javadoc)
- * @see org.crosswire.bibledesktop.display.BookDataDisplay#setBookData(org.crosswire.jsword.book.Book, org.crosswire.jsword.passage.Key)
- */
- public void setBookData(Book book, Key key)
- {
- throw new UnsupportedOperationException();
- }
-
- /* (non-Javadoc)
- * @see org.crosswire.bibledesktop.display.BookDataDisplay#refresh()
- */
- public void refresh()
- {
- display.refresh();
- }
-
- /* (non-Javadoc)
- * @see org.crosswire.bibledesktop.display.FocusablePart#getComponent()
- */
- public Component getComponent()
- {
- return this;
- }
-
- /* (non-Javadoc)
- * @see org.crosswire.bibledesktop.book.FocusablePart#copy()
- */
- public void copy()
- {
- display.copy();
- }
-
- /* (non-Javadoc)
- * @see org.crosswire.bibledesktop.book.FocusablePart#getKey()
- */
- public Key getKey()
- {
- return (Key) dictionaryKeyList.getSelectedValue();
- }
-
- /* (non-Javadoc)
- * @see org.crosswire.bibledesktop.book.FocusablePart#addHyperlinkListener(javax.swing.event.HyperlinkListener)
- */
- public void addURLEventListener(URLEventListener listener)
- {
- display.addURLEventListener(listener);
- }
-
- /* (non-Javadoc)
- * @see org.crosswire.bibledesktop.book.FocusablePart#removeHyperlinkListener(javax.swing.event.HyperlinkListener)
- */
- public void removeURLEventListener(URLEventListener listener)
- {
- display.removeURLEventListener(listener);
- }
-
- /* (non-Javadoc)
- * @see org.crosswire.bibledesktop.display.FocusablePart#getBook()
- */
- public Book getBook()
- {
- 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.
- */
- public void setWord(String data)
- {
- if (book == null)
- {
- return;
- }
-
- try
- {
- Key key = book.getKey(data);
- dictionaryKeyList.setSelectedValue(key, true);
- }
- catch (NoSuchKeyException ex)
- {
- return;
- }
-
- }
-
- /**
- * Accessor for the current passage
- */
- public void setKey(Key key)
- {
- if (key instanceof Passage)
- {
- Passage ref = (Passage) key;
- if (ref.countVerses() > 0)
- {
- set.setVerse(ref.getVerseAt(0));
- }
- }
-
- updateDisplay();
- }
-
- /*
- // Code to search for a word
- for (Iterator it = Books.getBooks(filter).iterator(); it.hasNext();)
- {
- DictionaryMetaData dmd = (DictionaryMetaData) it.next();
- Dictionary tempdict = dmd.getDictionary();
- try
- {
- Key key = tempdict.getKey(data);
- bookList.setSelectedValue(tempdict, true);
- lstentries.setSelectedValue(key, true);
- return;
- }
- catch (BookException ex)
- {
- // ignore - we only wanted to see if it could be done.
- }
- }
- */
-
- public void selectBook(Book selectedBook)
- {
- bookList.setSelectedValue(selectedBook, true);
- }
-
- /**
- * Create a book picker of all non-bibles
- * @return The scrollable picker
- */
- private Component createBookPicker()
- {
- BookFilter filter = BookFilters.getNonBibles();
- BooksComboBoxModel mdlBooks = new BooksComboBoxModel(filter);
-
- bookList = new JList();
- bookList.setVisibleRowCount(6);
- bookList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
- bookList.setModel(mdlBooks);
- bookList.setCellRenderer(new BookListCellRenderer());
- bookList.setPrototypeCellValue(BookListCellRenderer.PROTOTYPE_BOOK_NAME);
- bookList.addListSelectionListener(new ListSelectionListener()
- {
- public void valueChanged(ListSelectionEvent ev)
- {
- if (ev.getValueIsAdjusting())
- {
- return;
- }
-
- newBook();
- }
- });
-
- return new JScrollPane(bookList);
- }
-
- /**
- * Build a tree for a GenBook
- */
- private Component createCommentaryPicker()
- {
- JComboBox cboBooks = new JComboBox();
- JComboBox cboChaps = new JComboBox();
- JComboBox cboVerse = new JComboBox();
- set = new BibleComboBoxModelSet(cboBooks, cboChaps, cboVerse);
-
- set.addActionListener(new ActionListener()
- {
- public void actionPerformed(ActionEvent ev)
- {
- updateDisplay();
- }
- });
-
- cboBooks.setToolTipText(Msg.SELECT_BOOK.toString());
- cboChaps.setToolTipText(Msg.SELECT_CHAPTER.toString());
- cboVerse.setToolTipText(Msg.SELECT_VERSE.toString());
-
- JPanel panel = new JPanel();
- panel.setLayout(new FlowLayout());
- panel.add(cboBooks, null);
- panel.add(cboChaps, null);
- panel.add(cboVerse, null);
- return panel;
- }
-
- /**
- * Build a tree for a GenBook
- */
- private Component createDictionaryPicker()
- {
- dictionaryKeyList = new JList();
- dictionaryKeyList.addListSelectionListener(new ListSelectionListener()
- {
- public void valueChanged(ListSelectionEvent ev)
- {
- newEntry();
- }
- });
- return new JScrollPane(dictionaryKeyList);
- }
-
- /**
- * Build a tree for a GenBook
- */
- private Component createGenBookPicker()
- {
- genBookKeyTree = new JTree();
- genBookKeyTree.setModel(new KeyTreeModel(null));
- genBookKeyTree.setShowsRootHandles(true);
- genBookKeyTree.setRootVisible(false);
- genBookKeyTree.putClientProperty("JTree.lineStyle", "Angled"); //$NON-NLS-1$//$NON-NLS-2$
- genBookKeyTree.setCellRenderer(new KeyTreeCellRenderer());
- genBookKeyTree.addTreeSelectionListener(new TreeSelectionListener()
- {
- public void valueChanged(TreeSelectionEvent ev)
- {
- // treeSelected();
- }
- });
-
- return new JScrollPane(genBookKeyTree);
- }
-
- /**
- * Called when someone selects a new Dictionary
- */
- /*private*/ final void newBook()
- {
- // First ensure that all the pickers make sense if the user
- // unselects the book
- if (book != null)
- {
- BookCategory currentCategory = book.getBookCategory();
- if (currentCategory.equals(BookCategory.DICTIONARY) || currentCategory.equals(BookCategory.GLOSSARY)
- || currentCategory.equals(BookCategory.DAILY_DEVOTIONS))
- {
- // Don't leave the scroller in the middle of the list!
- dictionaryKeyList.ensureIndexIsVisible(0);
- // Make sure that the list of keys is empty.
- dictionaryKeyList.setModel(new KeyListListModel(null));
- }
- else if (currentCategory.equals(BookCategory.GENERAL_BOOK))
- {
- // Don't leave the scroller in the middle of the list!
- genBookKeyTree.scrollRowToVisible(0);
-
- // Make sure that the list of keys is empty.
- KeyTreeModel model = new KeyTreeModel(null);
- genBookKeyTree.setModel(model);
- }
- }
- // Make sure that the display is emtpy.
- display.setBookData(null, null);
-
- Object selected = bookList.getSelectedValue();
- if (selected != null)
- {
- Book selectedBook = (Book) selected;
- BookCategory category = selectedBook.getBookCategory();
- //divider snaps back to its starting point when a new component is set
- int dividerLocation = sptMain.getDividerLocation();
- if (category.equals(BookCategory.COMMENTARY))
- {
- updateDisplay();
- sptMain.setTopComponent(commentaryPicker);
- }
- else if (category.equals(BookCategory.DICTIONARY)
- || category.equals(BookCategory.GLOSSARY)
- || category.equals(BookCategory.DAILY_DEVOTIONS))
- {
- book = selectedBook;
- Key key = book.getGlobalKeyList();
-
- KeyListListModel model = new KeyListListModel(key);
- dictionaryKeyList.setModel(model);
-
- if (book instanceof PreferredKey)
- {
- PreferredKey pref = (PreferredKey) book;
- Key prefkey = pref.getPreferred();
-
- dictionaryKeyList.setSelectedValue(prefkey, true);
- }
-
- sptMain.setTopComponent(dictionaryKeyScroller);
- }
- else // currentCategory.equals(BookCategory.GENERAL_BOOK)
- {
- book = selectedBook;
- Key key = book.getGlobalKeyList();
-
- KeyTreeModel model = new KeyTreeModel(key);
- genBookKeyTree.setModel(model);
-
- sptMain.setTopComponent(genBookKeyScroller);
- }
-
- sptMain.setDividerLocation(dividerLocation);
- }
- }
-
- /**
- *
- */
- /*protected*/ final void updateDisplay()
- {
- Book selectedBook = (Book) bookList.getSelectedValue();
- if (selectedBook == null)
- {
- log.warn("no selected book"); //$NON-NLS-1$
- return;
- }
-
- Verse verse = set.getVerse();
- display.setBookData(selectedBook, verse);
- }
-
- /**
- * Called when someone selects a new entry from the current dictionary
- */
- /*private*/ final void newEntry()
- {
- Key key = (Key) dictionaryKeyList.getSelectedValue();
- if (key != null)
- {
- display.setBookData(book, key);
- }
- }
-
- /**
- * Serialization support.
- *
- * @param is
- * @throws IOException
- * @throws ClassNotFoundException
- */
- private void readObject(ObjectInputStream is) throws IOException, ClassNotFoundException
- {
- // We don't serialize views
- display = BookDataDisplayFactory.createBookDataDisplay();
- book = null;
- set = null;
- is.defaultReadObject();
- }
-
- /**
- * The display of OSIS data
- */
- private transient BookDataDisplay display;
- private transient Book book;
- protected transient BibleComboBoxModelSet set;
- private Component commentaryPicker;
- private Component genBookKeyScroller;
- private JTree genBookKeyTree;
- private JList bookList;
- private JSplitPane sptMain;
- private Component dictionaryKeyScroller;
- private JList dictionaryKeyList;
-
- /**
- * The log stream
- */
- private static final Logger log = Logger.getLogger(DictionaryPane.class);
-
- /**
- * Serialization ID
- */
- private static final long serialVersionUID = 3616449020667442997L;
-}
Copied: trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/book/MultiBookPane.java (from rev 1256, trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/book/DictionaryPane.java)
===================================================================
--- trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/book/MultiBookPane.java (rev 0)
+++ trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/book/MultiBookPane.java 2007-03-21 20:43:23 UTC (rev 1257)
@@ -0,0 +1,494 @@
+/**
+ * Distribution License:
+ * BibleDesktop is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License, version 2 as published by
+ * the Free Software Foundation. This program is distributed in the hope
+ * that it will be useful, but WITHOUT ANY WARRANTY; without even the
+ * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details.
+ *
+ * The License is available on the internet at:
+ * http://www.gnu.org/copyleft/gpl.html
+ * or by writing to:
+ * Free Software Foundation, Inc.
+ * 59 Temple Place - Suite 330
+ * Boston, MA 02111-1307, USA
+ *
+ * Copyright: 2005
+ * The copyright to this program is held by it's authors.
+ *
+ * ID: $Id$
+ */
+package org.crosswire.bibledesktop.book;
+
+import java.awt.Component;
+import java.awt.FlowLayout;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+
+import javax.swing.JComboBox;
+import javax.swing.JList;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.JSplitPane;
+import javax.swing.JTree;
+import javax.swing.ListSelectionModel;
+import javax.swing.event.ListSelectionEvent;
+import javax.swing.event.ListSelectionListener;
+import javax.swing.event.TreeSelectionEvent;
+import javax.swing.event.TreeSelectionListener;
+
+import org.crosswire.bibledesktop.display.BookDataDisplay;
+import org.crosswire.bibledesktop.display.BookDataDisplayFactory;
+import org.crosswire.bibledesktop.display.URLEventListener;
+import org.crosswire.bibledesktop.passage.KeyListListModel;
+import org.crosswire.bibledesktop.passage.KeyTreeCellRenderer;
+import org.crosswire.bibledesktop.passage.KeyTreeModel;
+import org.crosswire.common.swing.FixedSplitPane;
+import org.crosswire.common.util.Logger;
+import org.crosswire.jsword.book.Book;
+import org.crosswire.jsword.book.BookCategory;
+import org.crosswire.jsword.book.BookFilter;
+import org.crosswire.jsword.book.BookFilters;
+import org.crosswire.jsword.book.Defaults;
+import org.crosswire.jsword.passage.Key;
+import org.crosswire.jsword.passage.NoSuchKeyException;
+import org.crosswire.jsword.passage.Passage;
+import org.crosswire.jsword.passage.PreferredKey;
+import org.crosswire.jsword.passage.Verse;
+
+/**
+ * Builds a panel on which all the non-Bible books and their entries are visible.
+ *
+ * @see gnu.gpl.License for license details.
+ * The copyright to this program is held by it's authors.
+ * @author Joe Walker [joe at eireneh dot com]
+ * @author DM Smith [dmsmith555 at yahoo dot com]
+ */
+public class MultiBookPane extends JSplitPane implements BookDataDisplay
+{
+ /**
+ * Setup the GUI
+ */
+ public MultiBookPane()
+ {
+ init();
+
+ // This must come after the setViewportView() calls so scrolling works
+ bookList.setSelectedValue(Defaults.getDailyDevotional(), true);
+ }
+
+ /**
+ * GUI initialiser
+ */
+ private void init()
+ {
+ display = BookDataDisplayFactory.createBookDataDisplay();
+
+ Component bookPicker = createBookPicker();
+
+ commentaryPicker = createCommentaryPicker();
+
+ dictionaryKeyScroller = createDictionaryPicker();
+
+ genBookKeyScroller = createGenBookPicker();
+
+ JScrollPane scrDisplay = new JScrollPane(display.getComponent());
+
+ sptMain = new FixedSplitPane(false);
+ sptMain.setOrientation(JSplitPane.VERTICAL_SPLIT);
+ // Make the top 20% of the total
+ sptMain.setResizeWeight(0.2D);
+ sptMain.setTopComponent(new JPanel());
+ sptMain.setBottomComponent(scrDisplay);
+
+// this.setResizeWeight(0.1D);
+// this.setMinimumSize(new Dimension(0, 0));
+ this.setOrientation(JSplitPane.VERTICAL_SPLIT);
+ this.setTopComponent(bookPicker);
+ this.setBottomComponent(sptMain);
+ this.setBorder(null);
+
+ Object thisUI = this.getUI();
+ if (thisUI instanceof javax.swing.plaf.basic.BasicSplitPaneUI)
+ {
+ ((javax.swing.plaf.basic.BasicSplitPaneUI) thisUI).getDivider().setBorder(null);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.crosswire.bibledesktop.display.BookDataDisplay#setBookData(org.crosswire.jsword.book.Book, org.crosswire.jsword.passage.Key)
+ */
+ public void setBookData(Book book, Key key)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ /* (non-Javadoc)
+ * @see org.crosswire.bibledesktop.display.BookDataDisplay#refresh()
+ */
+ public void refresh()
+ {
+ display.refresh();
+ }
+
+ /* (non-Javadoc)
+ * @see org.crosswire.bibledesktop.display.FocusablePart#getComponent()
+ */
+ public Component getComponent()
+ {
+ return this;
+ }
+
+ /* (non-Javadoc)
+ * @see org.crosswire.bibledesktop.book.FocusablePart#copy()
+ */
+ public void copy()
+ {
+ display.copy();
+ }
+
+ /* (non-Javadoc)
+ * @see org.crosswire.bibledesktop.book.FocusablePart#getKey()
+ */
+ public Key getKey()
+ {
+ return (Key) dictionaryKeyList.getSelectedValue();
+ }
+
+ /* (non-Javadoc)
+ * @see org.crosswire.bibledesktop.book.FocusablePart#addHyperlinkListener(javax.swing.event.HyperlinkListener)
+ */
+ public void addURLEventListener(URLEventListener listener)
+ {
+ display.addURLEventListener(listener);
+ }
+
+ /* (non-Javadoc)
+ * @see org.crosswire.bibledesktop.book.FocusablePart#removeHyperlinkListener(javax.swing.event.HyperlinkListener)
+ */
+ public void removeURLEventListener(URLEventListener listener)
+ {
+ display.removeURLEventListener(listener);
+ }
+
+ /* (non-Javadoc)
+ * @see org.crosswire.bibledesktop.display.FocusablePart#getBook()
+ */
+ public Book getBook()
+ {
+ 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.
+ */
+ public void setWord(String data)
+ {
+ if (book == null)
+ {
+ return;
+ }
+
+ try
+ {
+ Key key = book.getKey(data);
+ dictionaryKeyList.setSelectedValue(key, true);
+ }
+ catch (NoSuchKeyException ex)
+ {
+ return;
+ }
+
+ }
+
+ /**
+ * Accessor for the current passage
+ */
+ public void setKey(Key key)
+ {
+ if (key instanceof Passage)
+ {
+ Passage ref = (Passage) key;
+ if (ref.countVerses() > 0)
+ {
+ set.setVerse(ref.getVerseAt(0));
+ }
+ }
+
+ updateDisplay();
+ }
+
+ /*
+ // Code to search for a word
+ for (Iterator it = Books.getBooks(filter).iterator(); it.hasNext();)
+ {
+ DictionaryMetaData dmd = (DictionaryMetaData) it.next();
+ Dictionary tempdict = dmd.getDictionary();
+ try
+ {
+ Key key = tempdict.getKey(data);
+ bookList.setSelectedValue(tempdict, true);
+ lstentries.setSelectedValue(key, true);
+ return;
+ }
+ catch (BookException ex)
+ {
+ // ignore - we only wanted to see if it could be done.
+ }
+ }
+ */
+
+ public void selectBook(Book selectedBook)
+ {
+ bookList.setSelectedValue(selectedBook, true);
+ }
+
+ /**
+ * Create a book picker of all non-bibles
+ * @return The scrollable picker
+ */
+ private Component createBookPicker()
+ {
+ BookFilter filter = BookFilters.getNonBibles();
+ BooksComboBoxModel mdlBooks = new BooksComboBoxModel(filter);
+
+ bookList = new JList();
+ bookList.setVisibleRowCount(6);
+ bookList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
+ bookList.setModel(mdlBooks);
+ bookList.setCellRenderer(new BookListCellRenderer());
+ bookList.setPrototypeCellValue(BookListCellRenderer.PROTOTYPE_BOOK_NAME);
+ bookList.addListSelectionListener(new ListSelectionListener()
+ {
+ public void valueChanged(ListSelectionEvent ev)
+ {
+ if (ev.getValueIsAdjusting())
+ {
+ return;
+ }
+
+ newBook();
+ }
+ });
+
+ return new JScrollPane(bookList);
+ }
+
+ /**
+ * Build a tree for a GenBook
+ */
+ private Component createCommentaryPicker()
+ {
+ JComboBox cboBooks = new JComboBox();
+ JComboBox cboChaps = new JComboBox();
+ JComboBox cboVerse = new JComboBox();
+ set = new BibleComboBoxModelSet(cboBooks, cboChaps, cboVerse);
+
+ set.addActionListener(new ActionListener()
+ {
+ public void actionPerformed(ActionEvent ev)
+ {
+ updateDisplay();
+ }
+ });
+
+ cboBooks.setToolTipText(Msg.SELECT_BOOK.toString());
+ cboChaps.setToolTipText(Msg.SELECT_CHAPTER.toString());
+ cboVerse.setToolTipText(Msg.SELECT_VERSE.toString());
+
+ JPanel panel = new JPanel();
+ panel.setLayout(new FlowLayout());
+ panel.add(cboBooks, null);
+ panel.add(cboChaps, null);
+ panel.add(cboVerse, null);
+ return panel;
+ }
+
+ /**
+ * Build a tree for a GenBook
+ */
+ private Component createDictionaryPicker()
+ {
+ dictionaryKeyList = new JList();
+ dictionaryKeyList.addListSelectionListener(new ListSelectionListener()
+ {
+ public void valueChanged(ListSelectionEvent ev)
+ {
+ newEntry();
+ }
+ });
+ return new JScrollPane(dictionaryKeyList);
+ }
+
+ /**
+ * Build a tree for a GenBook
+ */
+ private Component createGenBookPicker()
+ {
+ genBookKeyTree = new JTree();
+ genBookKeyTree.setModel(new KeyTreeModel(null));
+ genBookKeyTree.setShowsRootHandles(true);
+ genBookKeyTree.setRootVisible(false);
+ genBookKeyTree.putClientProperty("JTree.lineStyle", "Angled"); //$NON-NLS-1$//$NON-NLS-2$
+ genBookKeyTree.setCellRenderer(new KeyTreeCellRenderer());
+ genBookKeyTree.addTreeSelectionListener(new TreeSelectionListener()
+ {
+ public void valueChanged(TreeSelectionEvent ev)
+ {
+ // treeSelected();
+ }
+ });
+
+ return new JScrollPane(genBookKeyTree);
+ }
+
+ /**
+ * Called when someone selects a new Dictionary
+ */
+ /*private*/ final void newBook()
+ {
+ // First ensure that all the pickers make sense if the user
+ // unselects the book
+ if (book != null)
+ {
+ BookCategory currentCategory = book.getBookCategory();
+ if (currentCategory.equals(BookCategory.DICTIONARY) || currentCategory.equals(BookCategory.GLOSSARY)
+ || currentCategory.equals(BookCategory.DAILY_DEVOTIONS))
+ {
+ // Don't leave the scroller in the middle of the list!
+ dictionaryKeyList.ensureIndexIsVisible(0);
+ // Make sure that the list of keys is empty.
+ dictionaryKeyList.setModel(new KeyListListModel(null));
+ }
+ else if (currentCategory.equals(BookCategory.GENERAL_BOOK))
+ {
+ // Don't leave the scroller in the middle of the list!
+ genBookKeyTree.scrollRowToVisible(0);
+
+ // Make sure that the list of keys is empty.
+ KeyTreeModel model = new KeyTreeModel(null);
+ genBookKeyTree.setModel(model);
+ }
+ }
+ // Make sure that the display is emtpy.
+ display.setBookData(null, null);
+
+ Object selected = bookList.getSelectedValue();
+ if (selected != null)
+ {
+ Book selectedBook = (Book) selected;
+ BookCategory category = selectedBook.getBookCategory();
+ //divider snaps back to its starting point when a new component is set
+ int dividerLocation = sptMain.getDividerLocation();
+ if (category.equals(BookCategory.COMMENTARY))
+ {
+ updateDisplay();
+ sptMain.setTopComponent(commentaryPicker);
+ }
+ else if (category.equals(BookCategory.DICTIONARY)
+ || category.equals(BookCategory.GLOSSARY)
+ || category.equals(BookCategory.DAILY_DEVOTIONS))
+ {
+ book = selectedBook;
+ Key key = book.getGlobalKeyList();
+
+ KeyListListModel model = new KeyListListModel(key);
+ dictionaryKeyList.setModel(model);
+
+ if (book instanceof PreferredKey)
+ {
+ PreferredKey pref = (PreferredKey) book;
+ Key prefkey = pref.getPreferred();
+
+ dictionaryKeyList.setSelectedValue(prefkey, true);
+ }
+
+ sptMain.setTopComponent(dictionaryKeyScroller);
+ }
+ else // currentCategory.equals(BookCategory.GENERAL_BOOK)
+ {
+ book = selectedBook;
+ Key key = book.getGlobalKeyList();
+
+ KeyTreeModel model = new KeyTreeModel(key);
+ genBookKeyTree.setModel(model);
+
+ sptMain.setTopComponent(genBookKeyScroller);
+ }
+
+ sptMain.setDividerLocation(dividerLocation);
+ }
+ }
+
+ /**
+ *
+ */
+ /*protected*/ final void updateDisplay()
+ {
+ Book selectedBook = (Book) bookList.getSelectedValue();
+ if (selectedBook == null)
+ {
+ log.warn("no selected book"); //$NON-NLS-1$
+ return;
+ }
+
+ Verse verse = set.getVerse();
+ display.setBookData(selectedBook, verse);
+ }
+
+ /**
+ * Called when someone selects a new entry from the current dictionary
+ */
+ /*private*/ final void newEntry()
+ {
+ Key key = (Key) dictionaryKeyList.getSelectedValue();
+ if (key != null)
+ {
+ display.setBookData(book, key);
+ }
+ }
+
+ /**
+ * Serialization support.
+ *
+ * @param is
+ * @throws IOException
+ * @throws ClassNotFoundException
+ */
+ private void readObject(ObjectInputStream is) throws IOException, ClassNotFoundException
+ {
+ // We don't serialize views
+ display = BookDataDisplayFactory.createBookDataDisplay();
+ book = null;
+ set = null;
+ is.defaultReadObject();
+ }
+
+ /**
+ * The display of OSIS data
+ */
+ private transient BookDataDisplay display;
+ private transient Book book;
+ protected transient BibleComboBoxModelSet set;
+ private Component commentaryPicker;
+ private Component genBookKeyScroller;
+ private JTree genBookKeyTree;
+ private JList bookList;
+ private JSplitPane sptMain;
+ private Component dictionaryKeyScroller;
+ private JList dictionaryKeyList;
+
+ /**
+ * The log stream
+ */
+ private static final Logger log = Logger.getLogger(MultiBookPane.class);
+
+ /**
+ * Serialization ID
+ */
+ private static final long serialVersionUID = 3616449020667442997L;
+}
Modified: trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/desktop/Desktop.java
===================================================================
--- trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/desktop/Desktop.java 2007-03-21 19:24:03 UTC (rev 1256)
+++ trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/desktop/Desktop.java 2007-03-21 20:43:23 UTC (rev 1257)
@@ -56,7 +56,7 @@
import javax.swing.WindowConstants;
import org.crosswire.bibledesktop.book.BibleViewPane;
-import org.crosswire.bibledesktop.book.DictionaryPane;
+import org.crosswire.bibledesktop.book.MultiBookPane;
import org.crosswire.bibledesktop.book.DisplaySelectEvent;
import org.crosswire.bibledesktop.book.DisplaySelectListener;
import org.crosswire.bibledesktop.book.DisplaySelectPane;
@@ -238,7 +238,7 @@
//barSide = new SidebarPane();
//barBook = new ReferencedPane();
- reference = new DictionaryPane();
+ reference = new MultiBookPane();
sptBooks = new FixedSplitPane(false);
sptBlog = new FixedSplitPane(false);
// blogPanel = BlogClientFrame.getInstance();
@@ -1162,7 +1162,7 @@
private JSplitPane sptBlog;
private JCheckBoxMenuItem sidebarToggle;
private StatusBar barStatus;
- private DictionaryPane reference;
+ private MultiBookPane reference;
private JSplitPane sptBooks;
private JPanel mainPanel;
private transient History history;
Deleted: trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/TreeKey.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/TreeKey.java 2007-03-21 19:24:03 UTC (rev 1256)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/TreeKey.java 2007-03-21 20:43:23 UTC (rev 1257)
@@ -1,209 +0,0 @@
-package org.crosswire.jsword.book.sword;
-/**
- * Distribution License:
- * JSword is free software; you can redistribute it and/or modify it under
- * the terms of the GNU Lesser General Public License, version 2.1 as published by
- * the Free Software Foundation. This program is distributed in the hope
- * that it will be useful, but WITHOUT ANY WARRANTY; without even the
- * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- * See the GNU Lesser General Public License for more details.
- *
- * The License is available on the internet at:
- * http://www.gnu.org/copyleft/lgpl.html
- * or by writing to:
- * Free Software Foundation, Inc.
- * 59 Temple Place - Suite 330
- * Boston, MA 02111-1307, USA
- *
- * Copyright: 2005
- * The copyright to this program is held by it's authors.
- *
- * ID: $Id: LZSSBackend.java 1143 2006-10-04 22:07:23 -0400 (Wed, 04 Oct 2006) dmsmith $
- */
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.crosswire.common.util.Logger;
-import org.crosswire.jsword.passage.AbstractKeyList;
-import org.crosswire.jsword.passage.Key;
-import org.crosswire.jsword.passage.RestrictionType;
-
-/**
- * A Key that knows where the data is in the real file.
- *
- * @see gnu.lgpl.License for license details.
- * The copyright to this program is held by it's authors.
- * @author Joe Walker [joe at eireneh dot com]
- */
-class TreeKey extends AbstractKeyList
-{
- /**
- * Setup with the key name and positions of data in the file
- */
- TreeKey(String name, Key parent)
- {
- super(name);
- this.parent = parent;
- this.children = new ArrayList();
- }
-
- /**
- * Setup with the key name. Use solely for searching.
- */
- TreeKey(String text)
- {
- this(text, null);
- }
-
- /* (non-Javadoc)
- * @see org.crosswire.jsword.passage.Key#canHaveChildren()
- */
- public boolean canHaveChildren()
- {
- return true;
- }
-
- /* (non-Javadoc)
- * @see org.crosswire.jsword.passage.Key#getChildCount()
- */
- public int getChildCount()
- {
- return children.size();
- }
-
- /* (non-Javadoc)
- * @see org.crosswire.jsword.passage.Key#getCardinality()
- */
- public int getCardinality()
- {
- int cardinality = 1; // count this node
- Iterator iter = children.iterator();
- while (iter.hasNext())
- {
- Key child = (Key) iter.next();
- cardinality += child.getCardinality();
- }
-
- return cardinality;
- }
-
- /* (non-Javadoc)
- * @see org.crosswire.jsword.passage.Key#isEmpty()
- */
- /* @Override */
- public boolean isEmpty()
- {
- return children.isEmpty();
- }
-
- /* (non-Javadoc)
- * @see org.crosswire.jsword.passage.Key#contains(org.crosswire.jsword.passage.Key)
- */
- /* @Override */
- public boolean contains(Key key)
- {
- if (children.contains(key))
- {
- return true;
- }
-
- Iterator iter = children.iterator();
- while (iter.hasNext())
- {
- Key child = (Key) iter.next();
- if (child.contains(key))
- {
- return true;
- }
- }
-
- return false;
- }
-
- /* (non-Javadoc)
- * @see org.crosswire.jsword.passage.Key#iterator()
- */
- public Iterator iterator()
- {
- return children.iterator();
- }
-
- /* (non-Javadoc)
- * @see org.crosswire.jsword.passage.Key#add(org.crosswire.jsword.passage.Key)
- */
- public void addAll(Key key)
- {
- children.add(key);
- }
-
- /* (non-Javadoc)
- * @see org.crosswire.jsword.passage.Key#remove(org.crosswire.jsword.passage.Key)
- */
- public void removeAll(Key key)
- {
- children.remove(key);
- }
-
- /* (non-Javadoc)
- * @see org.crosswire.jsword.passage.Key#clear()
- */
- public void clear()
- {
- children.clear();
- }
-
- /* (non-Javadoc)
- * @see org.crosswire.jsword.passage.Key#get(int)
- */
- public Key get(int index)
- {
- return (Key) children.get(index);
- }
-
- /* (non-Javadoc)
- * @see org.crosswire.jsword.passage.Key#indexOf(org.crosswire.jsword.passage.Key)
- */
- public int indexOf(Key that)
- {
- return children.indexOf(that);
- }
-
- /* (non-Javadoc)
- * @see org.crosswire.jsword.passage.Key#getParent()
- */
- public Key getParent()
- {
- return parent;
- }
-
- /* (non-Javadoc)
- * @see org.crosswire.jsword.passage.Key#blur(int)
- */
- public void blur(int by, RestrictionType restrict)
- {
- log.warn("attempt to blur a non-blur-able list"); //$NON-NLS-1$
- }
-
- /* (non-Javadoc)
- * @see java.lang.Object#clone()
- */
- public Object clone()
- {
- return super.clone();
- }
-
- private Key parent;
-
- private List children;
-
- /**
- * Serialization ID
- */
- private static final long serialVersionUID = -6560408145705717977L;
-
- /**
- * The log stream
- */
- private static final Logger log = Logger.getLogger(TreeKey.class);
-}
Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/TreeKeyIndex.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/TreeKeyIndex.java 2007-03-21 19:24:03 UTC (rev 1256)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/TreeKeyIndex.java 2007-03-21 20:43:23 UTC (rev 1257)
@@ -162,7 +162,8 @@
}
Key key = new DefaultKeyList(null, bmd.getName());
- node.setName(SwordUtil.decode(key, buffer, size, bmd.getBookCharset()));
+ // Some of the keys have extraneous whitespace, so remove it.
+ node.setName(SwordUtil.decode(key, buffer, size, bmd.getBookCharset()).trim());
buffer = SwordUtil.readNextRAF(datRaf, 2);
int userDataSize = SwordUtil.decodeLittleEndian16(buffer, 0);
Copied: trunk/jsword/src/main/java/org/crosswire/jsword/passage/TreeKey.java (from rev 1256, trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/TreeKey.java)
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/passage/TreeKey.java (rev 0)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/passage/TreeKey.java 2007-03-21 20:43:23 UTC (rev 1257)
@@ -0,0 +1,206 @@
+package org.crosswire.jsword.passage;
+/**
+ * Distribution License:
+ * JSword is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License, version 2.1 as published by
+ * the Free Software Foundation. This program is distributed in the hope
+ * that it will be useful, but WITHOUT ANY WARRANTY; without even the
+ * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU Lesser General Public License for more details.
+ *
+ * The License is available on the internet at:
+ * http://www.gnu.org/copyleft/lgpl.html
+ * or by writing to:
+ * Free Software Foundation, Inc.
+ * 59 Temple Place - Suite 330
+ * Boston, MA 02111-1307, USA
+ *
+ * Copyright: 2005
+ * The copyright to this program is held by it's authors.
+ *
+ * ID: $Id: LZSSBackend.java 1143 2006-10-04 22:07:23 -0400 (Wed, 04 Oct 2006) dmsmith $
+ */
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.crosswire.common.util.Logger;
+
+/**
+ * A Key that knows where the data is in the real file.
+ *
+ * @see gnu.lgpl.License for license details.
+ * The copyright to this program is held by it's authors.
+ * @author Joe Walker [joe at eireneh dot com]
+ */
+class TreeKey extends AbstractKeyList
+{
+ /**
+ * Setup with the key name and positions of data in the file
+ */
+ TreeKey(String name, Key parent)
+ {
+ super(name);
+ this.parent = parent;
+ this.children = new ArrayList();
+ }
+
+ /**
+ * Setup with the key name. Use solely for searching.
+ */
+ TreeKey(String text)
+ {
+ this(text, null);
+ }
+
+ /* (non-Javadoc)
+ * @see org.crosswire.jsword.passage.Key#canHaveChildren()
+ */
+ public boolean canHaveChildren()
+ {
+ return true;
+ }
+
+ /* (non-Javadoc)
+ * @see org.crosswire.jsword.passage.Key#getChildCount()
+ */
+ public int getChildCount()
+ {
+ return children.size();
+ }
+
+ /* (non-Javadoc)
+ * @see org.crosswire.jsword.passage.Key#getCardinality()
+ */
+ public int getCardinality()
+ {
+ int cardinality = 1; // count this node
+ Iterator iter = children.iterator();
+ while (iter.hasNext())
+ {
+ Key child = (Key) iter.next();
+ cardinality += child.getCardinality();
+ }
+
+ return cardinality;
+ }
+
+ /* (non-Javadoc)
+ * @see org.crosswire.jsword.passage.Key#isEmpty()
+ */
+ /* @Override */
+ public boolean isEmpty()
+ {
+ return children.isEmpty();
+ }
+
+ /* (non-Javadoc)
+ * @see org.crosswire.jsword.passage.Key#contains(org.crosswire.jsword.passage.Key)
+ */
+ /* @Override */
+ public boolean contains(Key key)
+ {
+ if (children.contains(key))
+ {
+ return true;
+ }
+
+ Iterator iter = children.iterator();
+ while (iter.hasNext())
+ {
+ Key child = (Key) iter.next();
+ if (child.contains(key))
+ {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see org.crosswire.jsword.passage.Key#iterator()
+ */
+ public Iterator iterator()
+ {
+ return children.iterator();
+ }
+
+ /* (non-Javadoc)
+ * @see org.crosswire.jsword.passage.Key#add(org.crosswire.jsword.passage.Key)
+ */
+ public void addAll(Key key)
+ {
+ children.add(key);
+ }
+
+ /* (non-Javadoc)
+ * @see org.crosswire.jsword.passage.Key#remove(org.crosswire.jsword.passage.Key)
+ */
+ public void removeAll(Key key)
+ {
+ children.remove(key);
+ }
+
+ /* (non-Javadoc)
+ * @see org.crosswire.jsword.passage.Key#clear()
+ */
+ public void clear()
+ {
+ children.clear();
+ }
+
+ /* (non-Javadoc)
+ * @see org.crosswire.jsword.passage.Key#get(int)
+ */
+ public Key get(int index)
+ {
+ return (Key) children.get(index);
+ }
+
+ /* (non-Javadoc)
+ * @see org.crosswire.jsword.passage.Key#indexOf(org.crosswire.jsword.passage.Key)
+ */
+ public int indexOf(Key that)
+ {
+ return children.indexOf(that);
+ }
+
+ /* (non-Javadoc)
+ * @see org.crosswire.jsword.passage.Key#getParent()
+ */
+ public Key getParent()
+ {
+ return parent;
+ }
+
+ /* (non-Javadoc)
+ * @see org.crosswire.jsword.passage.Key#blur(int)
+ */
+ public void blur(int by, RestrictionType restrict)
+ {
+ log.warn("attempt to blur a non-blur-able list"); //$NON-NLS-1$
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#clone()
+ */
+ public Object clone()
+ {
+ return super.clone();
+ }
+
+ private Key parent;
+
+ private List children;
+
+ /**
+ * Serialization ID
+ */
+ private static final long serialVersionUID = -6560408145705717977L;
+
+ /**
+ * The log stream
+ */
+ private static final Logger log = Logger.getLogger(TreeKey.class);
+}
Modified: trunk/jsword-limbo/src/main/java/org/crosswire/bibledesktop/book/SidebarPane.java
===================================================================
--- trunk/jsword-limbo/src/main/java/org/crosswire/bibledesktop/book/SidebarPane.java 2007-03-21 19:24:03 UTC (rev 1256)
+++ trunk/jsword-limbo/src/main/java/org/crosswire/bibledesktop/book/SidebarPane.java 2007-03-21 20:43:23 UTC (rev 1257)
@@ -58,7 +58,7 @@
// Make resizing affect the right only
split.setResizeWeight(0.0);
split.setTopComponent(comments);
- split.setBottomComponent(dicts);
+ split.setBottomComponent(multiBooks);
this.setLayout(new BorderLayout());
this.add(split, BorderLayout.CENTER);
@@ -69,7 +69,7 @@
*/
public void addURLEventListener(URLEventListener li)
{
- dicts.addURLEventListener(li);
+ multiBooks.addURLEventListener(li);
comments.addURLEventListener(li);
}
@@ -78,7 +78,7 @@
*/
public void removeURLEventListener(URLEventListener li)
{
- dicts.removeURLEventListener(li);
+ multiBooks.removeURLEventListener(li);
comments.removeURLEventListener(li);
}
@@ -91,16 +91,16 @@
}
/**
- * Accessor for the DictionaryPane
+ * Accessor for the MultiBookPane
*/
- public DictionaryPane getDictionaryPane()
+ public MultiBookPane getMultiBookPane()
{
- return dicts;
+ return multiBooks;
}
private CommentaryPane comments = new CommentaryPane();
private JSplitPane split = new FixedSplitPane();
- private DictionaryPane dicts = new DictionaryPane();
+ private MultiBookPane multiBooks = new MultiBookPane();
/**
* Serialization ID
More information about the jsword-svn
mailing list