[jsword-svn] r1154 - in trunk/bibledesktop: etc/eclipse src/main/java/org/crosswire/bibledesktop/book src/main/java/org/crosswire/bibledesktop/book/install src/main/java/org/crosswire/bibledesktop/desktop src/main/java/org/crosswire/bibledesktop/display src/main/java/org/crosswire/bibledesktop/display/scrolled src/main/java/org/crosswire/bibledesktop/display/tab src/main/java/org/crosswire/bibledesktop/display/textpane src/main/java/org/crosswire/bibledesktop/passage
dmsmith at www.crosswire.org
dmsmith at www.crosswire.org
Tue Oct 10 16:34:13 MST 2006
Author: dmsmith
Date: 2006-10-10 16:33:39 -0700 (Tue, 10 Oct 2006)
New Revision: 1154
Modified:
trunk/bibledesktop/etc/eclipse/bibledesktop-app-desktop.launch
trunk/bibledesktop/etc/eclipse/bibledesktop-junit-jsword.launch
trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/book/BibleComboBoxModelSet.java
trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/book/DictionaryPane.java
trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/book/DisplaySelectPane.java
trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/book/install/IndexResolver.java
trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/book/install/SitePane.java
trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/book/install/SwordSiteEditor.java
trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/book/install/TextPaneBookMetaDataDisplay.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/desktop/ViewSourcePane.java
trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/display/BookDataDisplayFactory.java
trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/display/scrolled/ScrolledBookDataDisplay.java
trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/display/tab/TabbedBookDataDisplay.java
trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/display/textpane/TextPaneBookDataDisplay.java
trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/passage/KeyListListModel.java
trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/passage/KeySidebar.java
trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/passage/WholeBibleTreeNode.java
Log:
Fixing bugs reported by findbugs.
Modified: trunk/bibledesktop/etc/eclipse/bibledesktop-app-desktop.launch
===================================================================
--- trunk/bibledesktop/etc/eclipse/bibledesktop-app-desktop.launch 2006-10-10 23:32:58 UTC (rev 1153)
+++ trunk/bibledesktop/etc/eclipse/bibledesktop-app-desktop.launch 2006-10-10 23:33:39 UTC (rev 1154)
@@ -1,6 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<launchConfiguration type="org.eclipse.jdt.launching.localJavaApplication">
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.crosswire.bibledesktop.desktop.Desktop"/>
+<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
+<listEntry value="4"/>
+</listAttribute>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="bibledesktop"/>
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Xmx512m -ea"/>
<listAttribute key="org.eclipse.debug.ui.favoriteGroups">
@@ -8,6 +11,9 @@
<listEntry value="org.eclipse.debug.ui.launchGroup.debug"/>
</listAttribute>
<stringAttribute key="org.eclipse.debug.ui.target_debug_perspective" value="perspective_default"/>
+<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
+<listEntry value="/bibledesktop"/>
+</listAttribute>
<booleanAttribute key="org.eclipse.debug.core.appendEnvironmentVariables" value="true"/>
<stringAttribute key="org.eclipse.debug.ui.target_run_perspective" value="perspective_default"/>
</launchConfiguration>
Modified: trunk/bibledesktop/etc/eclipse/bibledesktop-junit-jsword.launch
===================================================================
--- trunk/bibledesktop/etc/eclipse/bibledesktop-junit-jsword.launch 2006-10-10 23:32:58 UTC (rev 1153)
+++ trunk/bibledesktop/etc/eclipse/bibledesktop-junit-jsword.launch 2006-10-10 23:33:39 UTC (rev 1154)
@@ -2,6 +2,7 @@
<launchConfiguration type="org.eclipse.jdt.junit.launchconfig">
<booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR" value="false"/>
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="JSwordAllTests"/>
+<stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value=""/>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="jsword"/>
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Xmx128m -ea"/>
<listAttribute key="org.eclipse.debug.ui.favoriteGroups">
@@ -11,6 +12,6 @@
<stringAttribute key="org.eclipse.debug.ui.target_debug_perspective" value="perspective_default"/>
<stringAttribute key="org.eclipse.jdt.junit.CONTAINER" value=""/>
<booleanAttribute key="org.eclipse.debug.core.appendEnvironmentVariables" value="true"/>
-<stringAttribute key="org.eclipse.debug.core.source_locator_id" value="org.eclipse.jdt.debug.ui.javaSourceLocator"/>
+<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit3"/>
<stringAttribute key="org.eclipse.debug.ui.target_run_perspective" value="perspective_none"/>
</launchConfiguration>
Modified: trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/book/BibleComboBoxModelSet.java
===================================================================
--- trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/book/BibleComboBoxModelSet.java 2006-10-10 23:32:58 UTC (rev 1153)
+++ trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/book/BibleComboBoxModelSet.java 2006-10-10 23:33:39 UTC (rev 1154)
@@ -42,6 +42,13 @@
*/
public class BibleComboBoxModelSet
{
+ public BibleComboBoxModelSet(JComboBox books, JComboBox chapters, JComboBox verses)
+ {
+ setBookComboBox(books);
+ setChapterComboBox(chapters);
+ setVerseComboBox(verses);
+ }
+
/**
* The book combo box
*/
Modified: trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/book/DictionaryPane.java
===================================================================
--- trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/book/DictionaryPane.java 2006-10-10 23:32:58 UTC (rev 1153)
+++ trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/book/DictionaryPane.java 2006-10-10 23:33:39 UTC (rev 1154)
@@ -41,7 +41,6 @@
import org.crosswire.bibledesktop.passage.KeyListListModel;
import org.crosswire.common.swing.FixedSplitPane;
import org.crosswire.common.util.Logger;
-import org.crosswire.common.util.Reporter;
import org.crosswire.jsword.book.Book;
import org.crosswire.jsword.book.BookCategory;
import org.crosswire.jsword.book.BookFilter;
@@ -111,13 +110,11 @@
JScrollPane scrDicts = new JScrollPane();
scrDicts.setViewportView(lstDicts);
- set = new BibleComboBoxModelSet();
JComboBox cboBooks = new JComboBox();
JComboBox cboChaps = new JComboBox();
JComboBox cboVerse = new JComboBox();
- set.setBookComboBox(cboBooks);
- set.setChapterComboBox(cboChaps);
- set.setVerseComboBox(cboVerse);
+ set = new BibleComboBoxModelSet(cboBooks, cboChaps, cboVerse);
+
set.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent ev)
@@ -360,15 +357,8 @@
return;
}
- try
- {
- Verse verse = set.getVerse();
- display.setBookData(book, verse);
- }
- catch (Exception ex)
- {
- Reporter.informUser(this, ex);
- }
+ Verse verse = set.getVerse();
+ display.setBookData(book, verse);
}
/**
@@ -376,18 +366,11 @@
*/
protected void newEntry()
{
- try
+ Key key = (Key) lstEntries.getSelectedValue();
+ if (key != null)
{
- Key key = (Key) lstEntries.getSelectedValue();
- if (key != null)
- {
- display.setBookData(dict, key);
- }
+ display.setBookData(dict, key);
}
- catch (Exception ex)
- {
- Reporter.informUser(this, ex);
- }
}
/**
Modified: trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/book/DisplaySelectPane.java
===================================================================
--- trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/book/DisplaySelectPane.java 2006-10-10 23:32:58 UTC (rev 1153)
+++ trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/book/DisplaySelectPane.java 2006-10-10 23:33:39 UTC (rev 1154)
@@ -53,6 +53,7 @@
import org.crosswire.common.swing.desktop.event.TitleChangedListener;
import org.crosswire.common.util.Reporter;
import org.crosswire.jsword.book.Book;
+import org.crosswire.jsword.book.BookException;
import org.crosswire.jsword.book.BookFilters;
import org.crosswire.jsword.index.IndexStatus;
import org.crosswire.jsword.index.IndexStatusEvent;
@@ -319,7 +320,7 @@
setKey(results);
}
}
- catch (Exception ex)
+ catch (BookException ex)
{
Reporter.informUser(this, ex);
}
Modified: trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/book/install/IndexResolver.java
===================================================================
--- trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/book/install/IndexResolver.java 2006-10-10 23:32:58 UTC (rev 1153)
+++ trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/book/install/IndexResolver.java 2006-10-10 23:33:39 UTC (rev 1154)
@@ -23,6 +23,7 @@
import java.awt.BorderLayout;
import java.awt.Component;
+import java.io.IOException;
import java.util.Iterator;
import java.util.Map;
@@ -33,6 +34,8 @@
import org.crosswire.common.util.Logger;
import org.crosswire.jsword.book.Book;
+import org.crosswire.jsword.book.BookException;
+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.index.IndexManagerFactory;
@@ -84,12 +87,27 @@
Installer installer = selectInstaller(parent);
if (installer != null)
{
+ Exception ex = null;
try
{
IndexDownloader.downloadIndex(book, installer);
}
- catch (Exception ex)
+ catch (InstallException e)
{
+ ex = e;
+
+ }
+ catch (BookException e)
+ {
+ ex = e;
+ }
+ catch (IOException e)
+ {
+ ex = e;
+ }
+
+ if (ex != null)
+ {
log.error("index download failed: ", ex); //$NON-NLS-1$
//Reporter.informUser(parent, ex);
Modified: trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/book/install/SitePane.java
===================================================================
--- trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/book/install/SitePane.java 2006-10-10 23:32:58 UTC (rev 1153)
+++ trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/book/install/SitePane.java 2006-10-10 23:33:39 UTC (rev 1154)
@@ -459,16 +459,9 @@
TreePath path = treAvailable.getSelectionPath();
if (path != null)
{
- try
- {
- Object last = path.getLastPathComponent();
- Book book = getBook(last);
- IndexResolver.scheduleIndex(book, this);
- }
- catch (Exception ex)
- {
- Reporter.informUser(this, ex);
- }
+ Object last = path.getLastPathComponent();
+ Book book = getBook(last);
+ IndexResolver.scheduleIndex(book, this);
}
}
Modified: trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/book/install/SwordSiteEditor.java
===================================================================
--- trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/book/install/SwordSiteEditor.java 2006-10-10 23:32:58 UTC (rev 1153)
+++ trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/book/install/SwordSiteEditor.java 2006-10-10 23:33:39 UTC (rev 1154)
@@ -41,6 +41,10 @@
*/
public class SwordSiteEditor extends JPanel implements SiteEditor
{
+ public SwordSiteEditor()
+ {
+ }
+
public void initialize()
{
host = new JTextField();
@@ -73,6 +77,11 @@
*/
public void save()
{
+ if (installer == null)
+ {
+ return;
+ }
+
installer.setHost(host.getText());
installer.setDirectory(directory.getText());
installer.setProxyHost(proxyHost.getText());
Modified: trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/book/install/TextPaneBookMetaDataDisplay.java
===================================================================
--- trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/book/install/TextPaneBookMetaDataDisplay.java 2006-10-10 23:32:58 UTC (rev 1153)
+++ trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/book/install/TextPaneBookMetaDataDisplay.java 2006-10-10 23:33:39 UTC (rev 1154)
@@ -25,6 +25,7 @@
import javax.swing.JTextPane;
import javax.swing.text.html.HTMLEditorKit;
+import javax.xml.transform.TransformerException;
import org.crosswire.common.swing.AntiAliasedTextPane;
import org.crosswire.common.util.Logger;
@@ -36,6 +37,7 @@
import org.crosswire.common.xml.XMLUtil;
import org.crosswire.jsword.book.Book;
import org.crosswire.jsword.util.ConverterFactory;
+import org.xml.sax.SAXException;
/**
* A JDK JTextPane implementation of an OSIS displayer.
@@ -79,10 +81,14 @@
txtView.setText(text);
txtView.select(0, 0);
}
- catch (Exception ex)
+ catch (SAXException e)
{
- Reporter.informUser(this, ex);
+ Reporter.informUser(this, e);
}
+ catch (TransformerException e)
+ {
+ Reporter.informUser(this, e);
+ }
}
/**
Modified: trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/desktop/Desktop.java
===================================================================
--- trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/desktop/Desktop.java 2006-10-10 23:32:58 UTC (rev 1153)
+++ trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/desktop/Desktop.java 2006-10-10 23:33:39 UTC (rev 1154)
@@ -23,6 +23,7 @@
import java.awt.BorderLayout;
import java.awt.Component;
+import java.awt.Container;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.WindowAdapter;
@@ -41,7 +42,6 @@
import javax.swing.ButtonGroup;
import javax.swing.ImageIcon;
import javax.swing.JCheckBoxMenuItem;
-import javax.swing.JComponent;
import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
@@ -96,6 +96,7 @@
import org.crosswire.jsword.util.ConverterFactory;
import org.crosswire.jsword.util.Project;
import org.jdom.Document;
+import org.jdom.JDOMException;
/**
* The Desktop is the user's view of BibleDesktop.
@@ -117,40 +118,7 @@
try
{
ThreadGroup group = new CatchingThreadGroup("BibleDesktopUIGroup"); //$NON-NLS-1$
- Thread t = new Thread(group, "BibleDesktopUIThread") //$NON-NLS-1$
- {
- /* (non-Javadoc)
- * @see java.lang.Runnable#run()
- */
- /* @Override */
- public void run()
- {
-// new BusStart();
- ExceptionPane.setHelpDeskListener(true);
- LookAndFeelUtil.initialize();
-
- final Splash splash = new Splash();
-
- final Desktop desktop = new Desktop();
-
- // change the size and location before showing the application.
- GuiUtil.setSize(desktop, getDefaultSize());
- GuiUtil.centerWindow(desktop);
-
- // Now bring up the app and offer to install books if the user has none.
- SwingUtilities.invokeLater(new Runnable()
- {
- public void run()
- {
- splash.close();
- desktop.setVisible(true);
- desktop.establishPreferredSize();
- desktop.pack();
- desktop.checkForBooks();
- }
- });
- }
- };
+ Thread t = new DesktopThread(group);
t.start();
}
catch (Exception ex)
@@ -295,7 +263,7 @@
// The toolbar needs to be in the outermost container, on the border
// And the only other item in that container can be CENTER
- JComponent contentPane = (JComponent) getContentPane();
+ Container contentPane = getContentPane();
contentPane.setLayout(new BorderLayout());
ToolBar toolbar = createToolBar();
contentPane.add(toolbar, BorderLayout.NORTH);
@@ -435,7 +403,6 @@
{
JMenu menuView = new JMenu(actions.getAction(DesktopActions.VIEW));
JCheckBoxMenuItem toggle = new JCheckBoxMenuItem(actions.getAction(XSLTProperty.TINY_VERSE_NUMBERS.getName()));
- toggle = new JCheckBoxMenuItem(actions.getAction(XSLTProperty.TINY_VERSE_NUMBERS.getName()));
toggle.setSelected(XSLTProperty.TINY_VERSE_NUMBERS.getDefault());
menuView.add(toggle).addMouseListener(barStatus);
toggle = new JCheckBoxMenuItem(actions.getAction(XSLTProperty.START_VERSE_ON_NEWLINE.getName()));
@@ -529,9 +496,8 @@
*/
public void establishPreferredSize()
{
- JComponent contentPane = (JComponent) getContentPane();
+ Container contentPane = getContentPane();
contentPane.setPreferredSize(contentPane.getSize());
-
log.warn("The size of the contentpane is: " + contentPane.getSize()); //$NON-NLS-1$
}
@@ -804,13 +770,18 @@
{
xmlconfig = XMLUtil.getDocument(CONFIG_KEY);
}
- catch (Exception ex)
+ // Something went wrong before we've managed to get on our feet.
+ // so we want the best possible shot at working out what failed.
+ catch (IOException e)
{
- // Something went wrong before we've managed to get on our feet.
- // so we want the best possible shot at working out what failed.
- ex.printStackTrace();
- ExceptionPane.showExceptionDialog(null, ex);
+ e.printStackTrace();
+ ExceptionPane.showExceptionDialog(null, e);
}
+ catch (JDOMException e)
+ {
+ e.printStackTrace();
+ ExceptionPane.showExceptionDialog(null, e);
+ }
Locale defaultLocale = Locale.getDefault();
ResourceBundle configResources = ResourceBundle.getBundle(CONFIG_KEY, defaultLocale, new CWClassLoader(Desktop.class));
@@ -821,7 +792,7 @@
{
config.setProperties(ResourceUtil.getProperties(DESKTOP_KEY));
}
- catch (Exception ex)
+ catch (IOException ex)
{
ex.printStackTrace();
ExceptionPane.showExceptionDialog(null, ex);
@@ -1012,6 +983,70 @@
return config;
}
+ /**
+ * Helper class to run the application in a thread group and capture errors.
+ */
+ private static final class DesktopThread extends Thread
+ {
+ DesktopThread(ThreadGroup group)
+ {
+ super(group, "BibleDesktopUIThread"); //$NON-NLS-1$
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Runnable#run()
+ */
+ /* @Override */
+ public void run()
+ {
+// new BusStart();
+ ExceptionPane.setHelpDeskListener(true);
+ LookAndFeelUtil.initialize();
+
+ Splash splash = new Splash();
+
+ Desktop desktop = new Desktop();
+
+ // change the size and location before showing the application.
+ GuiUtil.setSize(desktop, getDefaultSize());
+ GuiUtil.centerWindow(desktop);
+
+ // Now bring up the app and offer to install books if the user has none.
+ SwingUtilities.invokeLater(new DesktopRunner(desktop, splash));
+ }
+ }
+
+ /**
+ * Helper class to actually display the application at the right time.
+ */
+ private static class DesktopRunner implements Runnable
+ {
+ /**
+ * @param aDesktop
+ * @param aSplash
+ */
+ public DesktopRunner(Desktop aDesktop, Splash aSplash)
+ {
+ desktop = aDesktop;
+ splash = aSplash;
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Runnable#run()
+ */
+ public void run()
+ {
+ splash.close();
+ desktop.setVisible(true);
+ desktop.establishPreferredSize();
+ desktop.pack();
+ desktop.checkForBooks();
+ }
+
+ private Desktop desktop;
+ private Splash splash;
+ }
+
private boolean hasRefBooks;
// Strings for the names of property files.
Modified: trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/desktop/DesktopActions.java
===================================================================
--- trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/desktop/DesktopActions.java 2006-10-10 23:32:58 UTC (rev 1153)
+++ trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/desktop/DesktopActions.java 2006-10-10 23:33:39 UTC (rev 1154)
@@ -43,6 +43,7 @@
import org.crosswire.common.util.Reporter;
import org.crosswire.jsword.book.Book;
import org.crosswire.jsword.passage.Key;
+import org.crosswire.jsword.passage.NoSuchVerseException;
import org.crosswire.jsword.util.Project;
/**
@@ -110,10 +111,14 @@
BibleViewPane view = (BibleViewPane) getDesktop().getViews().getSelected();
view.open();
}
- catch (Exception ex)
+ catch (NoSuchVerseException e)
{
- Reporter.informUser(getDesktop(), ex);
+ Reporter.informUser(getDesktop(), e);
}
+ catch (IOException e)
+ {
+ Reporter.informUser(getDesktop(), e);
+ }
}
/**
@@ -349,34 +354,27 @@
*/
public void doViewSource()
{
- try
+ // Limit view source to the current tab.
+ BibleViewPane view = (BibleViewPane) getDesktop().getViews().getSelected();
+ SplitBookDataDisplay da = view.getPassagePane();
+ BookDataDisplay bdd = da.getBookDataDisplay();
+ if (bdd instanceof TabbedBookDataDisplay)
{
- // Limit view source to the current tab.
- BibleViewPane view = (BibleViewPane) getDesktop().getViews().getSelected();
- SplitBookDataDisplay da = view.getPassagePane();
- BookDataDisplay bdd = da.getBookDataDisplay();
- if (bdd instanceof TabbedBookDataDisplay)
- {
- bdd = ((TabbedBookDataDisplay) bdd).getInnerDisplayPane();
- }
+ bdd = ((TabbedBookDataDisplay) bdd).getInnerDisplayPane();
+ }
- Key key = bdd.getKey();
+ Key key = bdd.getKey();
- if (key == null)
- {
- Reporter.informUser(getDesktop(), Msg.SOURCE_MISSING);
- return;
- }
-
- Book book = da.getBook();
-
- ViewSourcePane viewer = new ViewSourcePane(book, key);
- viewer.showInFrame(getDesktop());
- }
- catch (Exception ex)
+ if (key == null)
{
- Reporter.informUser(getDesktop(), ex);
+ Reporter.informUser(getDesktop(), Msg.SOURCE_MISSING);
+ return;
}
+
+ Book book = da.getBook();
+
+ ViewSourcePane viewer = new ViewSourcePane(book, key);
+ viewer.showInFrame(getDesktop());
}
/**
@@ -392,15 +390,8 @@
*/
public void doOptions()
{
- try
- {
- URL configUrl = Project.instance().getWritablePropertiesURL("desktop"); //$NON-NLS-1$
- ConfigEditorFactory.showDialog(desktop.getConfig(), desktop, configUrl);
- }
- catch (Exception ex)
- {
- Reporter.informUser(desktop, ex);
- }
+ URL configUrl = Project.instance().getWritablePropertiesURL("desktop"); //$NON-NLS-1$
+ ConfigEditorFactory.showDialog(desktop.getConfig(), desktop, configUrl);
}
/**
@@ -479,9 +470,12 @@
*/
public void visitView(Component component)
{
- BibleViewPane view = (BibleViewPane) component;
- SplitBookDataDisplay sbDisplay = view.getPassagePane();
- sbDisplay.showSidebar(show);
+ if (component instanceof BibleViewPane)
+ {
+ BibleViewPane view = (BibleViewPane) component;
+ SplitBookDataDisplay sbDisplay = view.getPassagePane();
+ sbDisplay.showSidebar(show);
+ }
}
private boolean show;
Modified: trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/desktop/ViewSourcePane.java
===================================================================
--- trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/desktop/ViewSourcePane.java 2006-10-10 23:32:58 UTC (rev 1153)
+++ trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/desktop/ViewSourcePane.java 2006-10-10 23:33:39 UTC (rev 1154)
@@ -38,6 +38,7 @@
import javax.swing.JTextArea;
import javax.swing.WindowConstants;
import javax.swing.text.JTextComponent;
+import javax.xml.transform.TransformerException;
import org.crosswire.bibledesktop.util.ConfigurableSwingConverter;
import org.crosswire.common.swing.ActionFactory;
@@ -51,10 +52,12 @@
import org.crosswire.jsword.book.Book;
import org.crosswire.jsword.book.BookCategory;
import org.crosswire.jsword.book.BookData;
+import org.crosswire.jsword.book.BookException;
import org.crosswire.jsword.book.BookMetaData;
import org.crosswire.jsword.passage.Key;
import org.crosswire.jsword.util.ConverterFactory;
import org.xml.sax.ContentHandler;
+import org.xml.sax.SAXException;
/**
* ViewSourcePane allow viewing of some text in its own standalone frame.
@@ -99,10 +102,18 @@
init(orig, osis.toString(), html.toString());
}
- catch (Exception ex)
+ catch (SAXException e)
{
- Reporter.informUser(null, ex);
+ Reporter.informUser(null, e);
}
+ catch (TransformerException e)
+ {
+ Reporter.informUser(null, e);
+ }
+ catch (BookException e)
+ {
+ Reporter.informUser(null, e);
+ }
}
/**
Modified: trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/display/BookDataDisplayFactory.java
===================================================================
--- trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/display/BookDataDisplayFactory.java 2006-10-10 23:32:58 UTC (rev 1153)
+++ trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/display/BookDataDisplayFactory.java 2006-10-10 23:33:39 UTC (rev 1154)
@@ -21,6 +21,8 @@
*/
package org.crosswire.bibledesktop.display;
+import java.io.IOException;
+
import org.crosswire.common.util.ClassUtil;
/**
@@ -44,14 +46,33 @@
*/
public static BookDataDisplay createBookDataDisplay()
{
+ Exception ex = null;
try
{
return (BookDataDisplay) ClassUtil.getImplementation(BookDataDisplay.class);
}
- catch (Exception ex)
+ catch (ClassCastException e)
{
- assert false : ex;
- return null;
+ ex = e;
}
+ catch (IOException e)
+ {
+ ex = e;
+ }
+ catch (ClassNotFoundException e)
+ {
+ ex = e;
+ }
+ catch (InstantiationException e)
+ {
+ ex = e;
+ }
+ catch (IllegalAccessException e)
+ {
+ ex = e;
+ }
+
+ assert false : ex;
+ return null;
}
}
Modified: trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/display/scrolled/ScrolledBookDataDisplay.java
===================================================================
--- trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/display/scrolled/ScrolledBookDataDisplay.java 2006-10-10 23:32:58 UTC (rev 1153)
+++ trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/display/scrolled/ScrolledBookDataDisplay.java 2006-10-10 23:33:39 UTC (rev 1154)
@@ -36,7 +36,7 @@
* The copyright to this program is held by it's authors.
* @author Joe Walker [joe at eireneh dot com]
*/
-public class ScrolledBookDataDisplay extends ProxyBookDataDisplay implements BookDataDisplay
+public class ScrolledBookDataDisplay extends ProxyBookDataDisplay
{
/**
* Simple Constructor
Modified: trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/display/tab/TabbedBookDataDisplay.java
===================================================================
--- trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/display/tab/TabbedBookDataDisplay.java 2006-10-10 23:32:58 UTC (rev 1153)
+++ trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/display/tab/TabbedBookDataDisplay.java 2006-10-10 23:33:39 UTC (rev 1154)
@@ -41,7 +41,6 @@
import org.crosswire.bibledesktop.display.URLEventListener;
import org.crosswire.bibledesktop.display.scrolled.ScrolledBookDataDisplay;
import org.crosswire.common.swing.GuiUtil;
-import org.crosswire.common.util.Reporter;
import org.crosswire.jsword.book.Book;
import org.crosswire.jsword.passage.Key;
import org.crosswire.jsword.passage.KeyUtil;
@@ -283,43 +282,36 @@
*/
protected void tabChanged()
{
- try
+ // This is someone clicking on more isnt it?
+ if (tabMain.getSelectedComponent() != pnlMore)
{
- // This is someone clicking on more isnt it?
- if (tabMain.getSelectedComponent() != pnlMore)
- {
- return;
- }
+ return;
+ }
- // First remove the old more ... tab that the user has just selected
- tabMain.remove(pnlMore);
+ // First remove the old more ... tab that the user has just selected
+ tabMain.remove(pnlMore);
- // What do we display next
- Passage next = waiting;
- waiting = next.trimVerses(pageSize);
+ // What do we display next
+ Passage next = waiting;
+ waiting = next.trimVerses(pageSize);
- // Create a new tab
- BookDataDisplay pnlNew = createInnerDisplayPane();
- pnlNew.setBookData(book, next);
+ // Create a new tab
+ BookDataDisplay pnlNew = createInnerDisplayPane();
+ pnlNew.setBookData(book, next);
- Component display = pnlNew.getComponent();
- views.put(display, pnlNew);
+ Component display = pnlNew.getComponent();
+ views.put(display, pnlNew);
- tabMain.add(getTabName(next), display);
+ tabMain.add(getTabName(next), display);
- // Do we need a new more tab
- if (waiting != null)
- {
- tabMain.add(Msg.MORE.toString(), pnlMore);
- }
-
- // Select the real new tab in place of any more tabs
- tabMain.setSelectedComponent(display);
- }
- catch (Exception ex)
+ // Do we need a new more tab
+ if (waiting != null)
{
- Reporter.informUser(this, ex);
+ tabMain.add(Msg.MORE.toString(), pnlMore);
}
+
+ // Select the real new tab in place of any more tabs
+ tabMain.setSelectedComponent(display);
}
/**
Modified: trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/display/textpane/TextPaneBookDataDisplay.java
===================================================================
--- trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/display/textpane/TextPaneBookDataDisplay.java 2006-10-10 23:32:58 UTC (rev 1153)
+++ trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/display/textpane/TextPaneBookDataDisplay.java 2006-10-10 23:33:39 UTC (rev 1154)
@@ -36,6 +36,7 @@
import javax.swing.text.StyleConstants;
import javax.swing.text.StyledDocument;
import javax.swing.text.html.HTMLEditorKit;
+import javax.xml.transform.TransformerException;
import org.crosswire.bibledesktop.desktop.XSLTProperty;
import org.crosswire.bibledesktop.display.BookDataDisplay;
@@ -51,9 +52,11 @@
import org.crosswire.jsword.book.Book;
import org.crosswire.jsword.book.BookCategory;
import org.crosswire.jsword.book.BookData;
+import org.crosswire.jsword.book.BookException;
import org.crosswire.jsword.book.BookMetaData;
import org.crosswire.jsword.passage.Key;
import org.crosswire.jsword.util.ConverterFactory;
+import org.xml.sax.SAXException;
/**
* A JDK JTextPane implementation of an OSIS displayer.
@@ -142,10 +145,18 @@
txtView.setText(text);
txtView.select(0, 0);
}
- catch (Exception ex)
+ catch (SAXException e)
{
- Reporter.informUser(this, ex);
+ Reporter.informUser(this, e);
}
+ catch (BookException e)
+ {
+ Reporter.informUser(this, e);
+ }
+ catch (TransformerException e)
+ {
+ Reporter.informUser(this, e);
+ }
}
/* (non-Javadoc)
Modified: trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/passage/KeyListListModel.java
===================================================================
--- trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/passage/KeyListListModel.java 2006-10-10 23:32:58 UTC (rev 1153)
+++ trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/passage/KeyListListModel.java 2006-10-10 23:33:39 UTC (rev 1154)
@@ -22,7 +22,6 @@
package org.crosswire.bibledesktop.passage;
import javax.swing.AbstractListModel;
-import javax.swing.ListModel;
import org.crosswire.jsword.passage.Key;
@@ -33,7 +32,7 @@
* The copyright to this program is held by it's authors.
* @author Joe Walker [joe at eireneh dot com]
*/
-public class KeyListListModel extends AbstractListModel implements ListModel
+public class KeyListListModel extends AbstractListModel
{
/**
* Constructor for ListListModel.
Modified: trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/passage/KeySidebar.java
===================================================================
--- trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/passage/KeySidebar.java 2006-10-10 23:32:58 UTC (rev 1153)
+++ trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/passage/KeySidebar.java 2006-10-10 23:33:39 UTC (rev 1154)
@@ -41,7 +41,6 @@
import org.crosswire.bibledesktop.book.DisplaySelectListener;
import org.crosswire.common.swing.ActionFactory;
import org.crosswire.common.swing.GuiUtil;
-import org.crosswire.common.util.Reporter;
import org.crosswire.jsword.book.Book;
import org.crosswire.jsword.passage.Key;
import org.crosswire.jsword.passage.Passage;
@@ -262,33 +261,26 @@
*/
protected void selection()
{
- try
+ Object[] selected = list.getSelectedValues();
+
+ if (selected.length > 0)
{
- Object[] selected = list.getSelectedValues();
+ partial = book.createEmptyKeyList();
- if (selected.length > 0)
+ for (int i = 0; i < selected.length; i++)
{
- partial = book.createEmptyKeyList();
-
- for (int i = 0; i < selected.length; i++)
- {
- partial.addAll((Key) selected[i]);
- }
-
- fireKeyChanged(new KeyChangeEvent(this, partial));
+ partial.addAll((Key) selected[i]);
}
- else
- {
- // Nothing selected so use the whole passage
- fireKeyChanged(new KeyChangeEvent(this, key));
- }
- setActive();
+ fireKeyChanged(new KeyChangeEvent(this, partial));
}
- catch (Exception ex)
+ else
{
- Reporter.informUser(this, ex);
+ // Nothing selected so use the whole passage
+ fireKeyChanged(new KeyChangeEvent(this, key));
}
+
+ setActive();
}
/**
Modified: trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/passage/WholeBibleTreeNode.java
===================================================================
--- trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/passage/WholeBibleTreeNode.java 2006-10-10 23:32:58 UTC (rev 1153)
+++ trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/passage/WholeBibleTreeNode.java 2006-10-10 23:33:39 UTC (rev 1154)
@@ -194,8 +194,6 @@
return WholeBibleTreeNode.getNode(this, range.getStart().getBook(), range.getStart().getChapter(), i + 1);
case LEVEL_VERSE:
- return null;
-
default:
return null;
}
@@ -221,8 +219,6 @@
return BibleInfo.versesInChapter(range.getStart().getBook(), range.getStart().getChapter());
case LEVEL_VERSE:
- return 0;
-
default:
return 0;
}
@@ -259,8 +255,6 @@
return vnode.getVerseRange().getStart().getVerse() - 1;
case LEVEL_VERSE:
- return -1;
-
default:
return -1;
}
@@ -293,13 +287,13 @@
private int count;
}
- protected static final int LEVEL_BIBLE = 0;
- protected static final int LEVEL_BOOK = 1;
- protected static final int LEVEL_CHAPTER = 2;
- protected static final int LEVEL_VERSE = 3;
+ private static final int LEVEL_BIBLE = 0;
+ private static final int LEVEL_BOOK = 1;
+ private static final int LEVEL_CHAPTER = 2;
+ private static final int LEVEL_VERSE = 3;
/** The range that this node refers to */
- protected VerseRange range;
+ private VerseRange range;
/** Our parent tree node */
private TreeNode parent;
More information about the jsword-svn
mailing list