From jswordcvs at crosswire.org Fri Oct 1 15:49:33 2004
From: jswordcvs at crosswire.org (jswordcvs@crosswire.org)
Date: Fri Oct 1 15:49:35 2004
Subject: [jsword-svn] common/java/swing/org/crosswire/common/swing s
Message-ID: <200410012249.i91MnXMQ009567@www.crosswire.org>
Update of /cvs/jsword/common/java/swing/org/crosswire/common/swing
In directory www.crosswire.org:/tmp/cvs-serv9561/java/swing/org/crosswire/common/swing
Added Files:
QuickHelpDialog.properties QuickHelpDialog.java
Log Message:
Help for search
--- NEW FILE: QuickHelpDialog.properties ---
# for the Passage Lookup text entry field
OK.Enabled=true
OK.Name=OK
OK.MnemonicKey=O
--- NEW FILE: QuickHelpDialog.java ---
package org.crosswire.common.swing;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.FlowLayout;
import java.awt.Frame;
import java.awt.Insets;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JEditorPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.text.html.HTMLEditorKit;
/**
* .
*
*
Index: config.properties
===================================================================
RCS file: /cvs/jsword/bibledesktop/resource/config.properties,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** config.properties 2 Sep 2004 17:44:47 -0000 1.3
--- config.properties 2 Oct 2004 23:51:06 -0000 1.4
***************
*** 17,20 ****
--- 17,22 ----
BibleDisplay.ConfigurableFont.path=Bible Display.Configurable Font
BibleDisplay.ConfigurableFont.help=The font to be used to display books.
+ BibleDisplay.AntiAliasDisplay.path=Bible Display.Anti Alias Text
+ BibleDisplay.AntiAliasDisplay.help=Do we anti-alias the viewed work. Anti-aliasing can be slow, but makes the text look smoother.
SwordModule.ModuleSearchPath.path=Sword Module.Module Search Path
SwordModule.ModuleSearchPath.help=Where should we look for SWORD Project modules.
From jswordcvs at crosswire.org Sat Oct 2 16:51:08 2004
From: jswordcvs at crosswire.org (jswordcvs@crosswire.org)
Date: Sat Oct 2 16:51:11 2004
Subject: [jsword-svn]
bibledesktop/java/main/org/crosswire/bibledesktop/book s
Message-ID: <200410022351.i92Np8E5019676@www.crosswire.org>
Update of /cvs/jsword/bibledesktop/java/main/org/crosswire/bibledesktop/book
In directory www.crosswire.org:/tmp/cvs-serv19652/java/main/org/crosswire/bibledesktop/book
Modified Files:
DisplaySelectPane.java PassageSelectionPane.java
Msg.properties Msg.java PassageSelectionPane.properties
DisplaySelectPane.properties
Log Message:
advanced search and a-a option.
Index: DisplaySelectPane.properties
===================================================================
RCS file: /cvs/jsword/bibledesktop/java/main/org/crosswire/bibledesktop/book/DisplaySelectPane.properties,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** DisplaySelectPane.properties 1 Oct 2004 22:49:37 -0000 1.6
--- DisplaySelectPane.properties 2 Oct 2004 23:51:06 -0000 1.7
***************
*** 1,57 ****
# for the Passage label
- ViewLabel.Enabled=true
ViewLabel.Name=Show Passage:
- ViewLabel.ShortDescription=
- ViewLabel.LongDescription=
- ViewLabel.SmallIcon=
- ViewLabel.LargeIcon=
ViewLabel.MnemonicKey=W
- ViewLabel.AcceleratorKey=
- ViewLabel.AcceleratorKey.Modifiers=
# for the Passage Lookup text entry field
- PassageAction.Enabled=true
PassageAction.Name=Passage
PassageAction.ShortDescription=Enter a passage to display. Press CTRL+ENTER or press the ... button for a Passage selection window.
PassageAction.LongDescription=Enter a passage to display. Press CTRL+ENTER or press the ... button for a Passage selection window.
- PassageAction.SmallIcon=
- PassageAction.LargeIcon=
- PassageAction.MnemonicKey=
- PassageAction.AcceleratorKey=
- PassageAction.AcceleratorKey.Modifiers=
# for the ... button that brings up a passage picker dialog
- More.Enabled=true
More.Name=Select
More.ShortDescription=Pick a passage to display
More.LongDescription=Open the Passage selection window.
- More.SmallIcon=
- More.LargeIcon=
- More.MnemonicKey=
- More.AcceleratorKey=
- More.AcceleratorKey.Modifiers=
# for the Passage Lookup go button
- GoPassage.Enabled=true
GoPassage.Name=Go
GoPassage.ShortDescription=Display the passage
GoPassage.LongDescription=Display the passage.
- GoPassage.SmallIcon=
- GoPassage.LargeIcon=
GoPassage.MnemonicKey=G
- GoPassage.AcceleratorKey=
- GoPassage.AcceleratorKey.Modifiers=
# for the Search label
- SearchLabel.Enabled=true
SearchLabel.Name=Search:
- SearchLabel.ShortDescription=
- SearchLabel.LongDescription=
- SearchLabel.SmallIcon=
- SearchLabel.LargeIcon=
SearchLabel.MnemonicKey=S
- SearchLabel.AcceleratorKey=
- SearchLabel.AcceleratorKey.Modifiers=
# for the Search text entry field
--- 1,35 ----
+ # Format of this file:
+ # Blah.Name=Blah
+ # Blah.ShortDescription=Short description of Blah
+ # Blah.LongDescription=A longer and more verbose description of Blah
+ # Blah.SmallIcon=some16by16graphic.gif
+ # Blah.LargeIcon=some32by32graphic.gif
+ # Blah.MnemonicKey=B
+ # Blah.AcceleratorKey=B
+ # Blah.AcceleratorKey.Modifiers=CRTL
# for the Passage label
ViewLabel.Name=Show Passage:
ViewLabel.MnemonicKey=W
# for the Passage Lookup text entry field
PassageAction.Name=Passage
PassageAction.ShortDescription=Enter a passage to display. Press CTRL+ENTER or press the ... button for a Passage selection window.
PassageAction.LongDescription=Enter a passage to display. Press CTRL+ENTER or press the ... button for a Passage selection window.
# for the ... button that brings up a passage picker dialog
More.Name=Select
More.ShortDescription=Pick a passage to display
More.LongDescription=Open the Passage selection window.
# for the Passage Lookup go button
GoPassage.Name=Go
GoPassage.ShortDescription=Display the passage
GoPassage.LongDescription=Display the passage.
GoPassage.MnemonicKey=G
# for the Search label
SearchLabel.Name=Search:
SearchLabel.MnemonicKey=S
# for the Search text entry field
***************
*** 60,96 ****
# for the Search go button
- GoSearch.Enabled=true
GoSearch.Name=Go
GoSearch.ShortDescription=Search for a passage
- GoSearch.LongDescription=
- GoSearch.SmallIcon=
- GoSearch.LargeIcon=
GoSearch.MnemonicKey=G
- GoSearch.AcceleratorKey=
- GoSearch.AcceleratorKey.Modifiers=
# for the Help button
- HelpAction.Enabled=true
HelpAction.Name=
HelpAction.ShortDescription=Quick Search Help
HelpAction.LongDescription=Show some quick help on how to search
HelpAction.SmallIcon=toolbarButtonGraphics/general/ContextualHelp16.gif
! HelpAction.LargeIcon=toolbarButtonGraphics/general/ContextualHelp32.gif
! HelpAction.MnemonicKey=
! HelpAction.AcceleratorKey=
! HelpAction.AcceleratorKey.Modifiers=
! # for the Blah label
! BlahLabel.Name=Find Verses Like:
! BlahLabel.MnemonicKey=V
! # for the Blah text entry field
! BlahAction.Enabled=true
! BlahAction.Name=Blah
! BlahAction.ShortDescription=Find passages like
! BlahAction.LongDescription=Find passages like
! BlahAction.SmallIcon=
! BlahAction.LargeIcon=
! BlahAction.MnemonicKey=
! BlahAction.AcceleratorKey=
! BlahAction.AcceleratorKey.Modifiers=
--- 38,65 ----
# for the Search go button
GoSearch.Name=Go
GoSearch.ShortDescription=Search for a passage
GoSearch.MnemonicKey=G
# for the Help button
HelpAction.Name=
HelpAction.ShortDescription=Quick Search Help
HelpAction.LongDescription=Show some quick help on how to search
HelpAction.SmallIcon=toolbarButtonGraphics/general/ContextualHelp16.gif
! HelpAction.LargeIcon=toolbarButtonGraphics/general/ContextualHelp24.gif
! # for the Bible combo box
! Bible.Name=Bible:\
! Bible.MnemonicKey=B
! # for the best match toggle button
! Match.Name=Match
! Match.MnemonicKey=M
!
! # for the advanced search button
! Advanced.Name=Advanced
! Advanced.ShortDescription=Advanced Search
! Advanced.LongDescription=Show an advanced search dialog
! Advanced.SmallIcon=toolbarButtonGraphics/general/Find16.gif
! Advanced.LargeIcon=toolbarButtonGraphics/general/Find24.gif
! Advanced.MnemonicKey=V
Index: Msg.java
===================================================================
RCS file: /cvs/jsword/bibledesktop/java/main/org/crosswire/bibledesktop/book/Msg.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** Msg.java 1 Oct 2004 22:49:37 -0000 1.9
--- Msg.java 2 Oct 2004 23:51:06 -0000 1.10
***************
*** 48,54 ****
static final Msg CLEAR = new Msg("DisplaySelectPane.Clear"); //$NON-NLS-1$
static final Msg UNTITLED = new Msg("DisplaySelectPane.Untitled"); //$NON-NLS-1$
! static final Msg SELECT_BIBLE = new Msg("DisplaySelectPane.Bible"); //$NON-NLS-1$
! static final Msg SELECT_ADVANCED = new Msg("DisplaySelectPane.Advanced"); //$NON-NLS-1$
! static final Msg SELECT_MATCH = new Msg("DisplaySelectPane.Match"); //$NON-NLS-1$
static final Msg AVAILABLE_BOOKS = new Msg("SitesPane.AvailableBooks"); //$NON-NLS-1$
--- 48,54 ----
static final Msg CLEAR = new Msg("DisplaySelectPane.Clear"); //$NON-NLS-1$
static final Msg UNTITLED = new Msg("DisplaySelectPane.Untitled"); //$NON-NLS-1$
! static final Msg ADVANCED_TITLE = new Msg("DisplaySelectPane.AdvancedTitle"); //$NON-NLS-1$
! static final Msg HELP_TEXT = new Msg("DisplaySelectPane.HelpText"); //$NON-NLS-1$
! static final Msg HELP_TITLE = new Msg("DisplaySelectPane.HelpTitle"); //$NON-NLS-1$
static final Msg AVAILABLE_BOOKS = new Msg("SitesPane.AvailableBooks"); //$NON-NLS-1$
***************
*** 70,84 ****
static final Msg SUMMARY = new Msg("PassageSelectionPane.Summary"); //$NON-NLS-1$
- static final Msg SEARCH_PHRASE = new Msg("AdvancedSearchPane.Phrase"); //$NON-NLS-1$
- static final Msg SEARCH_GO = new Msg("AdvancedSearchPane.Go"); //$NON-NLS-1$
- static final Msg SEARCH_SELECT = new Msg("AdvancedSearchPane.Select"); //$NON-NLS-1$
- static final Msg SEARCH_RESTRICT = new Msg("AdvancedSearchPane.Restrict"); //$NON-NLS-1$
- static final Msg SEARCH_HEADING = new Msg("AdvancedSearchPane.Heading"); //$NON-NLS-1$
- static final Msg SEARCH_EXCLUDES = new Msg("AdvancedSearchPane.Excludes"); //$NON-NLS-1$
- static final Msg SEARCH_INCLUDES = new Msg("AdvancedSearchPane.Includes"); //$NON-NLS-1$
-
- static final Msg HELP_TEXT = new Msg("DisplaySelectPane.HelpText"); //$NON-NLS-1$
- static final Msg HELP_TITLE = new Msg("DisplaySelectPane.HelpTitle"); //$NON-NLS-1$
-
/**
* Passthrough ctor
--- 70,73 ----
Index: DisplaySelectPane.java
===================================================================
RCS file: /cvs/jsword/bibledesktop/java/main/org/crosswire/bibledesktop/book/DisplaySelectPane.java,v
retrieving revision 1.14
retrieving revision 1.15
diff -C2 -d -r1.14 -r1.15
*** DisplaySelectPane.java 1 Oct 2004 22:49:37 -0000 1.14
--- DisplaySelectPane.java 2 Oct 2004 23:51:06 -0000 1.15
***************
*** 25,28 ****
--- 25,29 ----
import javax.swing.JTextField;
+ import org.crosswire.bibledesktop.book.parse.AdvancedSearchPane;
import org.crosswire.bibledesktop.passage.KeyChangeEvent;
import org.crosswire.bibledesktop.passage.KeyChangeListener;
***************
*** 104,109 ****
}
});
! JLabel lblBible = new JLabel();
! lblBible.setText(Msg.SELECT_BIBLE.toString());
lblBible.setLabelFor(cboBible);
--- 105,109 ----
}
});
! JLabel lblBible = actions.createJLabel(BIBLE);
lblBible.setLabelFor(cboBible);
***************
*** 148,160 ****
dlgHelp = new QuickHelpDialog(GuiUtil.getFrame(this), Msg.HELP_TITLE.toString(), Msg.HELP_TEXT.toString());
! JButton btnAdvanced = new JButton();
! btnAdvanced.setText(Msg.SELECT_ADVANCED.toString());
! btnAdvanced.setMnemonic(KeyEvent.VK_V);
! btnAdvanced.setBorderPainted(true);
! btnAdvanced.setIcon(ICON_SEARCH);
btnAdvanced.setBorderPainted(false);
! chkMatch = new JCheckBox();
! chkMatch.setText(Msg.SELECT_MATCH.toString());
this.setLayout(new GridBagLayout());
--- 148,155 ----
dlgHelp = new QuickHelpDialog(GuiUtil.getFrame(this), Msg.HELP_TITLE.toString(), Msg.HELP_TEXT.toString());
! JButton btnAdvanced = new JButton(actions.getAction(ADVANCED));
btnAdvanced.setBorderPainted(false);
! chkMatch = new JCheckBox(actions.getAction(MATCH));
this.setLayout(new GridBagLayout());
***************
*** 284,287 ****
--- 279,304 ----
/**
+ * Someone has clicked on the advanced search button
+ */
+ public void doAdvanced()
+ {
+ String reply = advanced.showInDialog(this, Msg.ADVANCED_TITLE.toString(), true, txtSearch.getText());
+ if (reply != null)
+ {
+ txtSearch.setText(reply);
+ }
+ }
+
+ /**
+ * Match is an action, but we don't need to do anything because match is
+ * only used when search is clicked. But ActionFactory will complain if we
+ * leave it out.
+ */
+ public void doMatch()
+ {
+ // Do nothing
+ }
+
+ /**
* Someone clicked help
*/
***************
*** 400,406 ****
dlgSelect = new PassageSelectionPane();
}
String passg = dlgSelect.showInDialog(this, Msg.SELECT_PASSAGE_TITLE.toString(), true, txtKey.getText());
! txtKey.setText(passg);
! doPassageAction();
}
--- 417,427 ----
dlgSelect = new PassageSelectionPane();
}
+
String passg = dlgSelect.showInDialog(this, Msg.SELECT_PASSAGE_TITLE.toString(), true, txtKey.getText());
! if (passg != null)
! {
! txtKey.setText(passg);
! doPassageAction();
! }
}
***************
*** 487,492 ****
private static final String GO_SEARCH = "GoSearch"; //$NON-NLS-1$
private static final String SEARCH_FIELD = "SearchAction"; //$NON-NLS-1$
!
! private static final ImageIcon ICON_SEARCH = GuiUtil.getIcon("toolbarButtonGraphics/general/Find16.gif"); //$NON-NLS-1$
private static final ImageIcon ICON_SELECT = GuiUtil.getIcon("toolbarButtonGraphics/general/Edit16.gif"); //$NON-NLS-1$
--- 508,514 ----
private static final String GO_SEARCH = "GoSearch"; //$NON-NLS-1$
private static final String SEARCH_FIELD = "SearchAction"; //$NON-NLS-1$
! private static final String ADVANCED = "Advanced"; //$NON-NLS-1$
! private static final String MATCH = "Match"; //$NON-NLS-1$
! private static final String BIBLE = "Bible"; //$NON-NLS-1$
private static final ImageIcon ICON_SELECT = GuiUtil.getIcon("toolbarButtonGraphics/general/Edit16.gif"); //$NON-NLS-1$
***************
*** 514,517 ****
--- 536,541 ----
private JCheckBox chkMatch = null;
+ private AdvancedSearchPane advanced = new AdvancedSearchPane();
+
/**
* SERIALUID(dms): A placeholder for the ultimate version id.
Index: Msg.properties
===================================================================
RCS file: /cvs/jsword/bibledesktop/java/main/org/crosswire/bibledesktop/book/Msg.properties,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** Msg.properties 1 Oct 2004 22:49:37 -0000 1.7
--- Msg.properties 2 Oct 2004 23:51:06 -0000 1.8
***************
*** 34,37 ****
--- 34,38 ----
DisplaySelectPane.Advanced=Advanced
DisplaySelectPane.Bible=Bible:
+ DisplaySelectPane.AdvancedTitle=Advanced Search
SitesPane.AvailableBooks=Available Books
***************
*** 52,61 ****
PassageSelectionPane.Error=Error: {0}
PassageSelectionPane.Summary=Summary: {0}
-
- AdvancedSearchPane.Phrase=Includes this phrase:
- AdvancedSearchPane.Go=Go
- AdvancedSearchPane.Select=Select
- AdvancedSearchPane.Restrict=Restrict search to these verses:
- AdvancedSearchPane.Heading=Search for verses with the following details
- AdvancedSearchPane.Excludes=Excludes these words:
- AdvancedSearchPane.Includes=Includes all these words:
--- 53,54 ----
Index: PassageSelectionPane.properties
===================================================================
RCS file: /cvs/jsword/bibledesktop/java/main/org/crosswire/bibledesktop/book/PassageSelectionPane.properties,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** PassageSelectionPane.properties 14 Jun 2004 05:27:26 -0000 1.1
--- PassageSelectionPane.properties 2 Oct 2004 23:51:06 -0000 1.2
***************
*** 26,30 ****
Done.SmallIcon=
Done.LargeIcon=
! Done.MnemonicKey=R
Done.AcceleratorKey=
Done.AcceleratorKey.Modifiers=
--- 26,30 ----
Done.SmallIcon=
Done.LargeIcon=
! Done.MnemonicKey=O
Done.AcceleratorKey=
Done.AcceleratorKey.Modifiers=
Index: PassageSelectionPane.java
===================================================================
RCS file: /cvs/jsword/bibledesktop/java/main/org/crosswire/bibledesktop/book/PassageSelectionPane.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -d -r1.11 -r1.12
*** PassageSelectionPane.java 8 Sep 2004 19:57:58 -0000 1.11
--- PassageSelectionPane.java 2 Oct 2004 23:51:06 -0000 1.12
***************
*** 283,295 ****
dlgMain = new JDialog(JOptionPane.getFrameForComponent(parent));
! JPanel pnl_action = new JPanel();
KeyStroke esc = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0);
bailout = true;
! JButton btn_go = new JButton(actions.getAction(DONE));
! pnl_action.setLayout(new BorderLayout());
! pnl_action.setBorder(BorderFactory.createEmptyBorder(5, 5, 15, 20));
! pnl_action.add(btn_go, BorderLayout.EAST);
ActionListener closer = new ActionListener()
--- 283,295 ----
dlgMain = new JDialog(JOptionPane.getFrameForComponent(parent));
! JPanel pnlAction = new JPanel();
KeyStroke esc = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0);
bailout = true;
! JButton btnGo = new JButton(actions.getAction(DONE));
! pnlAction.setLayout(new BorderLayout());
! pnlAction.setBorder(BorderFactory.createEmptyBorder(5, 5, 15, 20));
! pnlAction.add(btnGo, BorderLayout.EAST);
ActionListener closer = new ActionListener()
***************
*** 303,308 ****
dlgMain.getContentPane().setLayout(new BorderLayout());
dlgMain.getContentPane().add(this, BorderLayout.CENTER);
! dlgMain.getContentPane().add(pnl_action, BorderLayout.SOUTH);
! dlgMain.getRootPane().setDefaultButton(btn_go);
dlgMain.getRootPane().registerKeyboardAction(closer, esc, JComponent.WHEN_IN_FOCUSED_WINDOW);
dlgMain.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
--- 303,308 ----
dlgMain.getContentPane().setLayout(new BorderLayout());
dlgMain.getContentPane().add(this, BorderLayout.CENTER);
! dlgMain.getContentPane().add(pnlAction, BorderLayout.SOUTH);
! dlgMain.getRootPane().setDefaultButton(btnGo);
dlgMain.getRootPane().registerKeyboardAction(closer, esc, JComponent.WHEN_IN_FOCUSED_WINDOW);
dlgMain.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
***************
*** 357,360 ****
--- 357,363 ----
}
+ /**
+ * Someone clicked on OK
+ */
public void doDone()
{
***************
*** 408,414 ****
private Passage ref;
! /*
! * The ActionFactory holding the actions used by this
! * EditSite.
*/
private ActionFactory actions;
--- 411,416 ----
private Passage ref;
! /**
! * The ActionFactory holding the actions used by this Component.
*/
private ActionFactory actions;
From jswordcvs at crosswire.org Sat Oct 2 16:51:08 2004
From: jswordcvs at crosswire.org (jswordcvs@crosswire.org)
Date: Sat Oct 2 16:51:11 2004
Subject: [jsword-svn]
bibledesktop/java/main/org/crosswire/bibledesktop/display/textpane s
Message-ID: <200410022351.i92Np8hB019694@www.crosswire.org>
Update of /cvs/jsword/bibledesktop/java/main/org/crosswire/bibledesktop/display/textpane
In directory www.crosswire.org:/tmp/cvs-serv19652/java/main/org/crosswire/bibledesktop/display/textpane
Modified Files:
TextPaneBookDataDisplay.java
Log Message:
advanced search and a-a option.
Index: TextPaneBookDataDisplay.java
===================================================================
RCS file: /cvs/jsword/bibledesktop/java/main/org/crosswire/bibledesktop/display/textpane/TextPaneBookDataDisplay.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -d -r1.10 -r1.11
*** TextPaneBookDataDisplay.java 3 Sep 2004 21:38:17 -0000 1.10
--- TextPaneBookDataDisplay.java 2 Oct 2004 23:51:06 -0000 1.11
***************
*** 3,9 ****
import java.awt.Component;
import java.awt.ComponentOrientation;
- import java.awt.Graphics;
- import java.awt.Graphics2D;
- import java.awt.RenderingHints;
import java.awt.event.MouseListener;
import java.net.MalformedURLException;
--- 3,6 ----
***************
*** 22,25 ****
--- 19,23 ----
import org.crosswire.bibledesktop.display.URLEvent;
import org.crosswire.bibledesktop.display.URLEventListener;
+ import org.crosswire.common.swing.AntiAliasedTextPane;
import org.crosswire.common.util.Logger;
import org.crosswire.common.util.Reporter;
***************
*** 411,430 ****
*/
private EventListenerList listenerList = new EventListenerList();
-
- /**
- *
- */
- public class AntiAliasedTextPane extends JTextPane
- {
- /* (non-Javadoc)
- * @see javax.swing.JComponent#paintComponent(java.awt.Graphics)
- */
- public void paintComponent(Graphics g)
- {
- Graphics2D g2 = (Graphics2D) g;
- g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
- g2.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
- super.paintComponent(g2);
- }
- }
}
--- 409,411 ----
From jswordcvs at crosswire.org Sat Oct 2 16:51:08 2004
From: jswordcvs at crosswire.org (jswordcvs@crosswire.org)
Date: Sat Oct 2 16:51:12 2004
Subject: [jsword-svn]
bibledesktop/java/main/org/crosswire/bibledesktop/book/parse s
Message-ID: <200410022351.i92Np8d3019696@www.crosswire.org>
Update of /cvs/jsword/bibledesktop/java/main/org/crosswire/bibledesktop/book/parse
In directory www.crosswire.org:/tmp/cvs-serv19652/java/main/org/crosswire/bibledesktop/book/parse
Added Files:
Msg.java AdvancedSearchPane.properties Msg.properties
AdvancedSearchPane.java package.html
Log Message:
advanced search and a-a option.
--- NEW FILE: package.html ---
This package contains Swing MVC models to help implementing a Swing GUI
using JSword classes.
--- NEW FILE: Msg.properties ---
# The naming convention for the keys in the file is ClassName.MessageName
# Where ClassName is the name of the class using the property.
# When the resource is used by more than one class it should be the one
# that the resource is most closely associated.
# The MessageName should be mixed case, with a leading capital.
# It should have no spaces or other punctuation (e.g. _, -, ', ...)
AdvancedSearchPane.Presets=The Whole Bible|\
All Prophecy (Deu 28, Isa-Mal, Rev)|\
Old Testament (Gen-Mal)|\
New Testament (Mat-Rev)|\
The Penteteuch (Gen-Deu)|\
History (Josh-Est)|\
Poetry (Job-Song)|\
Major Prophets (Isa-Dan)|\
Minor Prophets (Hos-Mal)|\
Gospels and Acts (Mat-Act)|\
Letters to People (Rom-Heb)|\
Letters from People (Jam-Jude)|\
Custom
AdvancedSearchPane.SelectPassageTitle=Select Passages to Restrict Search to
--- NEW FILE: AdvancedSearchPane.properties ---
HeadBase.Name:Search for verses with the following details
Phrase.Name=Includes this phrase:
Includes.Name=Includes these words:
Excludes.Name=Excludes all these words:
HeadRestrict.Name:Restrict search to parts of the Bible
Restrict.Name:Include these verses:
RestrictSelect.Name=Select
RestrictSelect.MnemonicKey=T
Presets.Name=Preset Ranges:
HeadSummary.Name:Show quick search syntax
Summary.Name:Quick search syntax:
HeadOriginal.Name:Contains Strongs Hebrew and Greek
HebrewInclude.Name:Includes Hebrew Nos:
HebrewExclude.Name:Excludes Hebrew Nos:
GreekInclude.Name:Includes Greek Nos:
GreekExclude.Name:Excludes Greek Nos:
HeadTime.Name:Narrow search by time peroid
After.Name:Restrict to verses written after:
Before.Name:Restrict to verses written before:
Done.Name=Search
Done.MnemonicKey=S
--- NEW FILE: AdvancedSearchPane.java ---
package org.crosswire.bibledesktop.book.parse;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Font;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.SystemColor;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.util.Map;
import javax.swing.BorderFactory;
import javax.swing.ComboBoxModel;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JComponent;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.KeyStroke;
import javax.swing.WindowConstants;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import org.crosswire.bibledesktop.book.PassageSelectionPane;
import org.crosswire.common.swing.ActionFactory;
import org.crosswire.common.swing.GuiUtil;
import org.crosswire.common.swing.LookAndFeelUtil;
import org.crosswire.common.util.Logger;
import org.crosswire.common.util.StringUtil;
import org.crosswire.jsword.book.search.parse.IndexSearcher;
import org.crosswire.jsword.book.search.parse.PassageLeftParamWord;
import org.crosswire.jsword.book.search.parse.PassageRightParamWord;
import org.crosswire.jsword.book.search.parse.PhraseParamWord;
import org.crosswire.jsword.book.search.parse.RemoveCommandWord;
import org.crosswire.jsword.book.search.parse.RetainCommandWord;
/**
* An advanced search dialog.
*
*
*
*
* Distribution Licence:
* JSword 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
* here , or by writing to:
* Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
* MA 02111-1307, USA
* The copyright to this program is held by it's authors.
*
* @see gnu.gpl.Licence
* @author Joe Walker [joe at eireneh dot com]
* @version $Id: AdvancedSearchPane.java,v 1.1 2004/10/02 23:51:06 joe Exp $
*/
public class AdvancedSearchPane extends JPanel implements DocumentListener
{
/**
* This is the default constructor
*/
public AdvancedSearchPane()
{
commands = IndexSearcher.getPreferredMap();
presets = Msg.PRESETS.toString().split("\\|"); //$NON-NLS-1$
initialize();
}
/**
* This method initializes this GUI
*/
private void initialize()
{
actions = new ActionFactory(AdvancedSearchPane.class, this);
// SystemColor.controlShadow
JLabel temp = new JLabel();
Color headBG = SystemColor.control.darker();
Color headFG = Color.BLACK;
Font headFont = temp.getFont().deriveFont(Font.BOLD);
lblHeading = actions.createJLabel(HEAD_BASE);
lblHeading.setBorder(BorderFactory.createLineBorder(headBG, 3));
lblHeading.setBackground(headBG);
lblHeading.setForeground(headFG);
lblHeading.setFont(headFont);
lblHeading.setOpaque(true);
lblPhrase = actions.createJLabel(PHRASE);
txtPhrase = new JTextField();
txtPhrase.getDocument().addDocumentListener(this);
txtIncludes = new JTextField();
txtIncludes.getDocument().addDocumentListener(this);
lblIncludes = actions.createJLabel(INCLUDES);
lblIncludes.setLabelFor(txtIncludes);
txtExcludes = new JTextField();
txtExcludes.getDocument().addDocumentListener(this);
lblExcludes = actions.createJLabel(EXCLUDES);
lblExcludes.setLabelFor(txtExcludes);
chkRestrict = new JCheckBox(actions.getAction(HEAD_RESTRICT));
chkRestrict.setBackground(headBG);
chkRestrict.setForeground(headFG);
chkRestrict.setFont(headFont);
lblPresets = actions.createJLabel(PRESETS);
lblPresets.setVisible(false);
cboPresets = new JComboBox(presets);
cboPresets.setVisible(false);
cboPresets.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent ev)
{
updatePreset();
}
});
lblRestrict = actions.createJLabel(RESTRICT);
lblRestrict.setVisible(false);
txtRestrict = new JTextField();
txtRestrict.setVisible(false);
txtRestrict.getDocument().addDocumentListener(this);
btnRestrict = new JButton(actions.getAction(RESTRICT_SELECT));
btnRestrict.setVisible(false);
chkSummary = new JCheckBox(actions.getAction(HEAD_SUMMARY));
chkSummary.setBackground(headBG);
chkSummary.setForeground(headFG);
chkSummary.setFont(headFont);
lblSummary = actions.createJLabel(SUMMARY);
lblSummary.setVisible(false);
txtSummary = new JTextArea();
txtSummary.setBackground(SystemColor.control);
txtSummary.setLineWrap(true);
txtSummary.setEditable(false);
txtSummary.setRows(2);
scrSummary = new JScrollPane(txtSummary);
scrSummary.setVisible(false);
// chkHebGrk = new JCheckBox(actions.getAction(HEAD_ORIGINAL));
// chkHebGrk.setBackground(headBG);
// chkHebGrk.setForeground(headFG);
// chkHebGrk.setFont(headFont);
// lblHebInc = actions.createJLabel(HEBREW_INCLUDE);
// lblHebInc.setVisible(false);
// txtHebInc = new JTextField();
// txtHebInc.setVisible(false);
// txtHebInc.getDocument().addDocumentListener(this);
// lblHebExc = actions.createJLabel(HEBREW_EXCLUDE);
// lblHebExc.setVisible(false);
// txtHebExc = new JTextField();
// txtHebExc.setVisible(false);
// txtHebExc.getDocument().addDocumentListener(this);
// lblGrkInc = actions.createJLabel(GREEK_INCLUDE);
// lblGrkInc.setVisible(false);
// txtGrkInc = new JTextField();
// txtGrkInc.setVisible(false);
// txtGrkInc.getDocument().addDocumentListener(this);
// lblGrkExc = actions.createJLabel(GREEK_EXCLUDE);
// lblGrkExc.setVisible(false);
// txtGrkExc = new JTextField();
// txtGrkExc.setVisible(false);
// txtGrkExc.getDocument().addDocumentListener(this);
//
// chkTime = new JCheckBox(actions.getAction(HEAD_TIME));
// chkTime.setBackground(headBG);
// chkTime.setForeground(headFG);
// chkTime.setFont(headFont);
// lblAfter = actions.createJLabel(AFTER);
// lblAfter.setVisible(false);
// txtAfter = new JTextField();
// txtAfter.setVisible(false);
// txtAfter.getDocument().addDocumentListener(this);
// lblBefore = actions.createJLabel(BEFORE);
// lblBefore.setVisible(false);
// txtBefore = new JTextField();
// txtBefore.setVisible(false);
// txtBefore.getDocument().addDocumentListener(this);
btnGo = new JButton(actions.getAction(DONE));
this.setBorder(BorderFactory.createLineBorder(SystemColor.control, 5));
this.setLayout(new GridBagLayout());
this.add(lblHeading, new GridBagConstraints(0, 1, 3, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(2, 2, 2, 2), 0, 0));
this.add(lblPhrase, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
this.add(txtPhrase, new GridBagConstraints(1, 2, 2, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(2, 5, 2, 5), 0, 0));
this.add(lblIncludes, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
this.add(txtIncludes, new GridBagConstraints(1, 3, 2, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(2, 5, 2, 5), 0, 0));
this.add(lblExcludes, new GridBagConstraints(0, 4, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
this.add(txtExcludes, new GridBagConstraints(1, 4, 2, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(2, 5, 2, 5), 0, 0));
this.add(chkRestrict, new GridBagConstraints(0, 5, 3, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(2, 2, 2, 2), 0, 0));
this.add(lblPresets, new GridBagConstraints(0, 6, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
this.add(cboPresets, new GridBagConstraints(1, 6, 2, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(2, 5, 2, 5), 0, 0));
this.add(lblRestrict, new GridBagConstraints(0, 7, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
this.add(txtRestrict, new GridBagConstraints(1, 7, 1, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(2, 5, 2, 5), 0, 0));
this.add(btnRestrict, new GridBagConstraints(2, 7, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 5), 0, 0));
// this.add(chkHebGrk, new GridBagConstraints(0, 8, 3, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(2, 2, 2, 2), 0, 0));
// this.add(lblHebInc, new GridBagConstraints(0, 9, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
// this.add(txtHebInc, new GridBagConstraints(1, 9, 2, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(2, 5, 2, 5), 0, 0));
// this.add(lblHebExc, new GridBagConstraints(0, 10, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
// this.add(txtHebExc, new GridBagConstraints(1, 10, 2, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(2, 5, 2, 5), 0, 0));
// this.add(lblGrkInc, new GridBagConstraints(0, 11, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
// this.add(txtGrkInc, new GridBagConstraints(1, 11, 2, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(2, 5, 2, 5), 0, 0));
// this.add(lblGrkExc, new GridBagConstraints(0, 12, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
// this.add(txtGrkExc, new GridBagConstraints(1, 12, 2, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(2, 5, 2, 5), 0, 0));
// this.add(chkTime, new GridBagConstraints(0, 13, 3, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(2, 2, 2, 2), 0, 0));
// this.add(lblAfter, new GridBagConstraints(0, 14, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
// this.add(txtAfter, new GridBagConstraints(1, 14, 2, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(2, 5, 2, 5), 0, 0));
// this.add(lblBefore, new GridBagConstraints(0, 15, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
// this.add(txtBefore, new GridBagConstraints(1, 15, 2, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(2, 5, 2, 5), 0, 0));
this.add(chkSummary, new GridBagConstraints(0, 16, 3, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(2, 2, 2, 2), 0, 0));
this.add(lblSummary, new GridBagConstraints(0, 17, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
this.add(scrSummary, new GridBagConstraints(1, 17, 2, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(2, 5, 2, 5), 0, 0));
this.add(btnGo, new GridBagConstraints(2, 18, 1, 1, 0.0, 0.0, GridBagConstraints.SOUTH, GridBagConstraints.NONE, new Insets(10, 0, 5, 5), 0, 0));
}
/**
* Open us in a new (optionally modal) dialog window
* @param parent The component to which to attach the new dialog
* @param title The title for the new dialog
*/
public String showInDialog(Component parent, String title, boolean modal, String search)
{
txtSummary.setText(search);
dlgMain = new JDialog(JOptionPane.getFrameForComponent(parent));
KeyStroke esc = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0);
bailout = true;
ActionListener closer = new ActionListener()
{
public void actionPerformed(ActionEvent ev)
{
dlgMain.dispose();
}
};
dlgMain.getContentPane().setLayout(new BorderLayout());
dlgMain.getContentPane().add(this, BorderLayout.CENTER);
dlgMain.getRootPane().setDefaultButton(btnGo);
dlgMain.getRootPane().registerKeyboardAction(closer, esc, JComponent.WHEN_IN_FOCUSED_WINDOW);
dlgMain.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
dlgMain.setTitle(title);
dlgMain.setModal(modal);
GuiUtil.restrainedPack(dlgMain, 0.5f, 0.75f);
GuiUtil.centerWindow(dlgMain);
dlgMain.setVisible(true);
if (bailout)
{
return null;
}
else
{
return txtSummary.getText();
}
}
/**
* Someone clicked the restrict toggle button
*/
public void doHeadRestrict()
{
boolean visible = chkRestrict.isSelected();
lblPresets.setVisible(visible);
cboPresets.setVisible(visible);
lblRestrict.setVisible(visible);
txtRestrict.setVisible(visible);
btnRestrict.setVisible(visible);
if (dlgMain != null)
{
dlgMain.pack();
}
}
/**
* Someone clicked the restrict toggle button
*/
public void doHeadSummary()
{
boolean visible = chkSummary.isSelected();
lblSummary.setVisible(visible);
scrSummary.setVisible(visible);
if (dlgMain != null)
{
dlgMain.pack();
}
}
/**
* Someone clicked the original strongs toggle button
*/
public void doHeadOriginal()
{
// boolean visible = chkHebGrk.isSelected();
//
// lblHebInc.setVisible(visible);
// txtHebInc.setVisible(visible);
// lblHebExc.setVisible(visible);
// txtHebExc.setVisible(visible);
// lblGrkInc.setVisible(visible);
// txtGrkInc.setVisible(visible);
// lblGrkExc.setVisible(visible);
// txtGrkExc.setVisible(visible);
//
// if (dlgMain != null)
// {
// dlgMain.pack();
// }
}
/**
* Someone clicked the original strongs toggle button
*/
public void doHeadTime()
{
// boolean visible = chkTime.isSelected();
//
// lblBefore.setVisible(visible);
// txtBefore.setVisible(visible);
// lblAfter.setVisible(visible);
// txtAfter.setVisible(visible);
//
// if (dlgMain != null)
// {
// dlgMain.pack();
// }
}
/**
*
*/
public void doRestrictSelect()
{
if (dlgSelect == null)
{
dlgSelect = new PassageSelectionPane();
}
String passg = dlgSelect.showInDialog(this, Msg.SELECT_PASSAGE_TITLE.toString(), true, txtRestrict.getText());
if (passg != null)
{
cboPresets.setSelectedItem(presets[presets.length - 1]);
txtRestrict.setText(passg);
}
}
/**
* Someone clicked on OK
*/
public void doDone()
{
bailout = false;
dlgMain.dispose();
}
/**
*
*/
public void updatePreset()
{
if (editingRestrict)
{
return;
}
String include = ""; //$NON-NLS-1$
String preset = (String) cboPresets.getSelectedItem();
if (preset != null)
{
int open = preset.indexOf(PRESET_START);
int close = preset.indexOf(PRESET_END);
if (open != -1 && close != -1)
{
include = preset.substring(open + 1, close);
}
}
txtRestrict.setText(include);
}
/**
* Regenerate the search string from the input boxes
*/
private void updateSearchString()
{
String quote = (String) commands.get(PhraseParamWord.class);
String plus = (String) commands.get(RetainCommandWord.class);
String minus = (String) commands.get(RemoveCommandWord.class);
String open = (String) commands.get(PassageLeftParamWord.class);
String close = (String) commands.get(PassageRightParamWord.class);
StringBuffer search = new StringBuffer();
String phrase = txtPhrase.getText();
if (phrase != null && phrase.trim().length() > 0)
{
search.append(quote);
search.append(phrase);
search.append(quote);
}
String includes = txtIncludes.getText();
if (includes != null && includes.trim().length() > 0)
{
if (search.length() != 0)
{
search.append(SPACE);
}
String[] words = includes.split(SPACE);
search.append(plus);
search.append(StringUtil.join(words, SPACE + plus));
}
String excludes = txtExcludes.getText();
if (excludes != null && excludes.trim().length() > 0)
{
if (search.length() != 0)
{
search.append(SPACE);
}
String[] words = excludes.split(SPACE);
search.append(minus);
search.append(StringUtil.join(words, SPACE + minus));
}
String restrict = txtRestrict.getText();
if (restrict != null && restrict.trim().length() > 0)
{
if (search.length() != 0)
{
search.append(SPACE);
}
search.append(plus);
search.append(open);
search.append(restrict);
search.append(close);
}
txtSummary.setText(search.toString());
// Check that the presets match the combo
editingRestrict = true;
boolean match = false;
ComboBoxModel model = cboPresets.getModel();
String find = PRESET_START + restrict + PRESET_END;
for (int i = 0; !match && i < model.getSize(); i++)
{
String element = (String) model.getElementAt(i);
if (element.indexOf(find) != -1)
{
cboPresets.setSelectedIndex(i);
match = true;
}
}
if (!match)
{
cboPresets.setSelectedItem(presets[presets.length - 1]);
}
editingRestrict = false;
}
/* (non-Javadoc)
* @see javax.swing.event.DocumentListener#changedUpdate(javax.swing.event.DocumentEvent)
*/
public void changedUpdate(DocumentEvent ev)
{
updateSearchString();
}
/* (non-Javadoc)
* @see javax.swing.event.DocumentListener#insertUpdate(javax.swing.event.DocumentEvent)
*/
public void insertUpdate(DocumentEvent ev)
{
updateSearchString();
}
/* (non-Javadoc)
* @see javax.swing.event.DocumentListener#removeUpdate(javax.swing.event.DocumentEvent)
*/
public void removeUpdate(DocumentEvent ev)
{
updateSearchString();
}
/**
* Quick test method
*/
public static void main(String[] args)
{
LookAndFeelUtil.initialize();
AdvancedSearchPane adv = new AdvancedSearchPane();
String reply = adv.showInDialog(null, "Advanced Search", true, "test"); //$NON-NLS-1$ //$NON-NLS-2$
log.debug(reply);
System.exit(0);
}
/*
* Action constants
*/
private static final String DONE = "Done"; //$NON-NLS-1$
private static final String PHRASE = "Phrase"; //$NON-NLS-1$
private static final String RESTRICT = "Restrict"; //$NON-NLS-1$
private static final String HEAD_RESTRICT = "HeadRestrict"; //$NON-NLS-1$
private static final String HEAD_BASE = "HeadBase"; //$NON-NLS-1$
private static final String INCLUDES = "Includes"; //$NON-NLS-1$
private static final String EXCLUDES = "Excludes"; //$NON-NLS-1$
private static final String PRESETS = "Presets"; //$NON-NLS-1$
private static final String RESTRICT_SELECT = "RestrictSelect"; //$NON-NLS-1$
private static final String HEAD_SUMMARY = "HeadSummary"; //$NON-NLS-1$
private static final String SUMMARY = "Summary"; //$NON-NLS-1$
// private static final String HEAD_ORIGINAL = "HeadOriginal"; //$NON-NLS-1$
// private static final String HEBREW_INCLUDE = "HebrewInclude"; //$NON-NLS-1$
// private static final String HEBREW_EXCLUDE = "HebrewExclude"; //$NON-NLS-1$
// private static final String GREEK_INCLUDE = "GreekInclude"; //$NON-NLS-1$
// private static final String GREEK_EXCLUDE = "GreekExclude"; //$NON-NLS-1$
// private static final String HEAD_TIME = "HeadTime"; //$NON-NLS-1$
// private static final String AFTER = "After"; //$NON-NLS-1$
// private static final String BEFORE = "Before"; //$NON-NLS-1$
/**
* In our parsing we use space quite a lot and this ensures there is only
* one and that we don't have lots of NON-NLS comments everywhere
*/
private static final String SPACE = " "; //$NON-NLS-1$
private static final String PRESET_END = ")"; //$NON-NLS-1$
private static final String PRESET_START = "("; //$NON-NLS-1$
/**
* If escape was pressed we don't want to update the parent
*/
protected boolean bailout;
/**
* The ActionFactory holding the actions used by this Component.
*/
private ActionFactory actions;
/**
* The symbols that have been configured
*/
private Map commands = null;
/**
* The entries in the restrictions preset
*/
private String[] presets = null;
/**
* If we are editing the restrict text box, ignore preset updates
*/
private boolean editingRestrict = false;
/*
* GUI Components
*/
private PassageSelectionPane dlgSelect;
private JLabel lblPhrase = null;
private JLabel lblIncludes = null;
private JTextField txtIncludes = null;
private JTextField txtPhrase = null;
private JLabel lblExcludes = null;
private JTextField txtExcludes = null;
private JLabel lblHeading = null;
private JCheckBox chkRestrict = null;
private JLabel lblRestrict = null;
private JTextField txtRestrict = null;
private JButton btnRestrict = null;
private JButton btnGo = null;
private JLabel lblPresets = null;
private JComboBox cboPresets = null;
protected JDialog dlgMain = null;
// private JCheckBox chkHebGrk = null;
// private JLabel lblHebInc = null;
// private JTextField txtHebInc = null;
// private JLabel lblHebExc = null;
// private JTextField txtHebExc = null;
// private JLabel lblGrkInc = null;
// private JTextField txtGrkInc = null;
// private JLabel lblGrkExc = null;
// private JTextField txtGrkExc = null;
// private JCheckBox chkTime = null;
// private JLabel lblBefore = null;
// private JTextField txtBefore = null;
// private JLabel lblAfter = null;
// private JTextField txtAfter = null;
private JLabel lblSummary = null;
private JCheckBox chkSummary = null;
private JTextArea txtSummary = null;
private JScrollPane scrSummary = null;
/**
* The log stream
*/
private static final Logger log = Logger.getLogger(AdvancedSearchPane.class);
}
--- NEW FILE: Msg.java ---
package org.crosswire.bibledesktop.book.parse;
import org.crosswire.common.util.MsgBase;
/**
* Compile safe Msg resource settings.
*
*
*
*
* Distribution Licence:
* JSword 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
* here , or by writing to:
* Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
* MA 02111-1307, USA
* The copyright to this program is held by it's authors.
*
* @see gnu.gpl.Licence
* @author Joe Walker [joe at eireneh dot com]
* @version $Id: Msg.java,v 1.1 2004/10/02 23:51:06 joe Exp $
*/
class Msg extends MsgBase
{
static final Msg PRESETS = new Msg("AdvancedSearchPane.Presets"); //$NON-NLS-1$
static final Msg SELECT_PASSAGE_TITLE = new Msg("AdvancedSearchPane.SelectPassageTitle"); //$NON-NLS-1$
/**
* Passthrough ctor
*/
private Msg(String name)
{
super(name);
}
}
From jswordcvs at crosswire.org Sat Oct 2 16:51:14 2004
From: jswordcvs at crosswire.org (jswordcvs@crosswire.org)
Date: Sat Oct 2 16:51:15 2004
Subject: [jsword-svn]
jsword/java/jsword/org/crosswire/jsword/book/search/parse s
Message-ID: <200410022351.i92NpE1e019740@www.crosswire.org>
Update of /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/search/parse
In directory www.crosswire.org:/tmp/cvs-serv19722/java/jsword/org/crosswire/jsword/book/search/parse
Modified Files:
IndexSearcher.java Word.properties
Added Files:
PhraseParamWord.java
Log Message:
advanced search and a-a option.
Index: Word.properties
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/search/parse/Word.properties,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** Word.properties 14 Jun 2004 05:27:22 -0000 1.1
--- Word.properties 2 Oct 2004 23:51:12 -0000 1.2
***************
*** 1,3 ****
--- 1,4 ----
+ # Mappings to turn command symbols into classes to execute them
/: org.crosswire.jsword.book.search.parse.AddCommandWord
|: org.crosswire.jsword.book.search.parse.AddCommandWord
***************
*** 15,16 ****
--- 16,32 ----
gr: org.crosswire.jsword.book.search.parse.GrammarParamWord
grammar: org.crosswire.jsword.book.search.parse.GrammarParamWord
+ \": org.crosswire.jsword.book.search.parse.PhraseParamWord
+ \': org.crosswire.jsword.book.search.parse.PhraseParamWord
+
+ # Mappings of preferred symbols for each command
+ org.crosswire.jsword.book.search.parse.AddCommandWord: /
+ org.crosswire.jsword.book.search.parse.RetainCommandWord: +
+ org.crosswire.jsword.book.search.parse.RemoveCommandWord: -
+ org.crosswire.jsword.book.search.parse.BlurCommandWord: ~
+ org.crosswire.jsword.book.search.parse.SubLeftParamWord: (
+ org.crosswire.jsword.book.search.parse.SubRightParamWord: )
+ org.crosswire.jsword.book.search.parse.PassageLeftParamWord: [
+ org.crosswire.jsword.book.search.parse.PassageRightParamWord: ]
+ org.crosswire.jsword.book.search.parse.StartsParamWord: sw
+ org.crosswire.jsword.book.search.parse.GrammarParamWord: gr
+ org.crosswire.jsword.book.search.parse.PhraseParamWord: "
Index: IndexSearcher.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/search/parse/IndexSearcher.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** IndexSearcher.java 29 Sep 2004 22:21:23 -0000 1.1
--- IndexSearcher.java 2 Oct 2004 23:51:12 -0000 1.2
***************
*** 1,11 ****
package org.crosswire.jsword.book.search.parse;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
- import org.crosswire.common.util.ClassUtil;
import org.crosswire.common.util.Logger;
import org.crosswire.jsword.book.BookException;
import org.crosswire.jsword.book.Search;
--- 1,13 ----
package org.crosswire.jsword.book.search.parse;
+ import java.io.IOException;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
+ import java.util.Properties;
import org.crosswire.common.util.Logger;
+ import org.crosswire.common.util.ResourceUtil;
import org.crosswire.jsword.book.BookException;
import org.crosswire.jsword.book.Search;
***************
*** 238,258 ****
if (wordMap == null)
{
! Map classes = ClassUtil.getImplementorsMap(Word.class);
! wordMap = new HashMap();
!
! for (Iterator it = classes.keySet().iterator(); it.hasNext(); )
{
! String key = (String) it.next();
! Class clazz = (Class) classes.get(key);
! try
! {
! wordMap.put(key, clazz.newInstance());
! }
! catch (Exception ex)
{
! log.error("can't add CommandWord: key=" + key + " Class=" + clazz.getName(), ex); //$NON-NLS-1$ //$NON-NLS-2$
}
}
}
--- 240,285 ----
if (wordMap == null)
{
! try
{
! Properties prop = ResourceUtil.getProperties(Word.class);
! wordMap = new HashMap();
! preferredMap = new HashMap();
!
! for (Iterator it = prop.keySet().iterator(); it.hasNext(); )
{
! String key = (String) it.next();
! String value = prop.getProperty(key);
!
! if (key.startsWith(PACKAGE_NAME))
! {
! try
! {
! Class clazz = Class.forName(key);
! preferredMap.put(clazz, value);
! }
! catch (Exception ex)
! {
! log.error("can't add CommandWord: key=" + key + " Class=" + value, ex); //$NON-NLS-1$ //$NON-NLS-2$
! }
! }
! else
! {
! try
! {
! Class clazz = Class.forName(value);
! wordMap.put(key, clazz.newInstance());
! }
! catch (Exception ex)
! {
! log.error("can't add CommandWord: key=" + key + " Class=" + value, ex); //$NON-NLS-1$ //$NON-NLS-2$
! }
! }
}
}
+ catch (IOException ex)
+ {
+ log.fatal("Missing search words", ex); //$NON-NLS-1$
+ }
}
***************
*** 261,264 ****
--- 288,306 ----
/**
+ * Accessor for the cached list of known special lookup words
+ */
+ public static Map getPreferredMap()
+ {
+ // Check the maps have been created
+ getWordMap();
+ return preferredMap;
+ }
+
+ /**
+ * To distinguish command mappings from preferred mappings in Word.properties
+ */
+ private static final String PACKAGE_NAME = "org.crosswire.jsword.book.search.parse"; //$NON-NLS-1$
+
+ /**
* The log stream
*/
***************
*** 271,274 ****
--- 313,321 ----
/**
+ * The cache of preferred symbols for the words
+ */
+ private static Map preferredMap = null;
+
+ /**
* The parsed version of the current string
*/
--- NEW FILE: PhraseParamWord.java ---
package org.crosswire.jsword.book.search.parse;
import java.util.Iterator;
import org.crosswire.jsword.book.BookException;
import org.crosswire.jsword.book.search.Index;
import org.crosswire.jsword.passage.Key;
import org.crosswire.jsword.passage.NoSuchKeyException;
/**
* The Search Word for a Word to search for. The default
* if no other SearchWords match.
*
*
*
*
* Distribution Licence:
* JSword 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
* here , or by writing to:
* Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
* MA 02111-1307, USA
* The copyright to this program is held by it's authors.
*
* @see gnu.gpl.Licence
* @author Joe Walker [joe at eireneh dot com]
* @version $Id: PhraseParamWord.java,v 1.1 2004/10/02 23:51:12 joe Exp $
*/
public class PhraseParamWord implements ParamWord
{
/* (non-Javadoc)
* @see org.crosswire.jsword.book.search.parse.ParamWord#getWord(org.crosswire.jsword.book.search.parse.Searcher)
*/
public String getWord(IndexSearcher engine) throws BookException
{
throw new BookException(Msg.LEFT_PARAM);
}
/* (non-Javadoc)
* @see org.crosswire.jsword.book.search.parse.ParamWord#Key(org.crosswire.jsword.book.search.parse.Searcher)
*/
public Key getKeyList(IndexSearcher engine) throws BookException
{
Iterator it = engine.iterator();
StringBuffer buff = new StringBuffer();
int paren_level = 1;
while (true)
{
if (!it.hasNext())
{
throw new BookException(Msg.LEFT_BRACKETS);
}
Word word = (Word) it.next();
if (word instanceof PhraseParamWord)
{
paren_level++;
}
if (word instanceof PassageRightParamWord)
{
paren_level--;
}
if (paren_level == 0)
{
break;
}
buff.append(word);
buff.append(" "); //$NON-NLS-1$
}
try
{
Index index = engine.getIndex();
return index.getKey(buff.toString());
}
catch (NoSuchKeyException ex)
{
throw new BookException(Msg.ILLEGAL_PASSAGE, ex, new Object[] { buff.toString() });
}
}
}
From jswordcvs at crosswire.org Sun Oct 3 07:04:08 2004
From: jswordcvs at crosswire.org (jswordcvs@crosswire.org)
Date: Sun Oct 3 07:04:10 2004
Subject: [jsword-svn] common/java/core/org/crosswire/common/util s
Message-ID: <200410031404.i93E48Kp005645@www.crosswire.org>
Update of /cvs/jsword/common/java/core/org/crosswire/common/util
In directory www.crosswire.org:/tmp/cvs-serv5641/java/core/org/crosswire/common/util
Added Files:
Histogram.java
Log Message:
Simple histogram implementation to do statistical analysis.
--- NEW FILE: Histogram.java ---
package org.crosswire.common.util;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
/**
* A simple implementation of a histogram. It would be nice to enhance
* it to order on frequency.
*
*
*
*
* Distribution Licence:
* JSword 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
* here , or by writing to:
* Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
* MA 02111-1307, USA
* The copyright to this program is held by it's authors.
*
* @see gnu.gpl.Licence
* @author DM Smith [ dmsmith555 at yahoo dot com]
* @version $Id: Histogram.java,v 1.1 2004/10/03 14:04:06 dmsmith Exp $
*/
public class Histogram
{
/**
* Create an empty histogram
*/
public Histogram()
{
hist = new HashMap();
}
/**
* note that this key has been seen one time more than before.
* @param key
*/
public void increment(String key)
{
Counter counter = (Counter) hist.get(key);
if (counter == null)
{
counter = new Counter();
hist.put(key, counter);
}
counter.increment();
}
/**
* The format of the histogram is an unordered list
* of string and the counts of the number of times it has been seen.
* @return the resultant histogram
* @see java.lang.Object#toString()
*/
public String toString()
{
StringBuffer buf = new StringBuffer();
Iterator iter = hist.entrySet().iterator();
while (iter.hasNext())
{
Map.Entry entry = (Map.Entry) iter.next();
buf.append(entry.getKey().toString());
buf.append('\t');
buf.append(entry.getValue().toString());
buf.append('\n');
}
return buf.toString();
}
/**
* Trivial mutable counting integer class.
*/
private static class Counter
{
public Counter()
{
}
public void increment()
{
counter++;
}
public String toString()
{
return Integer.toString(counter);
}
private int counter;
}
private Map hist;
}
From jswordcvs at crosswire.org Tue Oct 5 15:03:11 2004
From: jswordcvs at crosswire.org (jswordcvs@crosswire.org)
Date: Tue Oct 5 15:03:13 2004
Subject: [jsword-svn] jsword/java/limbo/org/crosswire/jsword/book/stub s
Message-ID: <200410052203.i95M3BmQ009950@www.crosswire.org>
Update of /cvs/jsword/jsword/java/limbo/org/crosswire/jsword/book/stub
In directory www.crosswire.org:/tmp/cvs-serv9907/java/limbo/org/crosswire/jsword/book/stub
Modified Files:
StubDictionary.java StubBookDriver.java StubBook.java
Log Message:
Improvments on reading SwordBookMetaData
Index: StubBook.java
===================================================================
RCS file: /cvs/jsword/jsword/java/limbo/org/crosswire/jsword/book/stub/StubBook.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** StubBook.java 29 Sep 2004 22:21:23 -0000 1.3
--- StubBook.java 5 Oct 2004 22:03:09 -0000 1.4
***************
*** 41,47 ****
* Basic constructor for a StubBook
*/
! public StubBook(StubBookDriver driver, String name, BookType type, int speed)
{
! BookMetaData bmd = new DefaultBookMetaData(driver, this, name, type, speed);
setBookMetaData(bmd);
}
--- 41,47 ----
* Basic constructor for a StubBook
*/
! public StubBook(StubBookDriver driver, String name, BookType type)
{
! BookMetaData bmd = new DefaultBookMetaData(driver, this, name, type);
setBookMetaData(bmd);
}
Index: StubDictionary.java
===================================================================
RCS file: /cvs/jsword/jsword/java/limbo/org/crosswire/jsword/book/stub/StubDictionary.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** StubDictionary.java 29 Sep 2004 22:21:23 -0000 1.6
--- StubDictionary.java 5 Oct 2004 22:03:09 -0000 1.7
***************
*** 46,52 ****
* Basic constructor for a StubBook
*/
! public StubDictionary(StubBookDriver driver, String name, BookType type, int speed)
{
! BookMetaData bmd = new DefaultBookMetaData(driver, this, name, type, speed);
setBookMetaData(bmd);
}
--- 46,52 ----
* Basic constructor for a StubBook
*/
! public StubDictionary(StubBookDriver driver, String name, BookType type)
{
! BookMetaData bmd = new DefaultBookMetaData(driver, this, name, type);
setBookMetaData(bmd);
}
Index: StubBookDriver.java
===================================================================
RCS file: /cvs/jsword/jsword/java/limbo/org/crosswire/jsword/book/stub/StubBookDriver.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** StubBookDriver.java 27 Jul 2004 21:42:34 -0000 1.2
--- StubBookDriver.java 5 Oct 2004 22:03:09 -0000 1.3
***************
*** 41,48 ****
Book[] books = new Book[]
{
! new StubBook(this, "Stub Version", BookType.BIBLE, BookMetaData.SPEED_INACCURATE), //$NON-NLS-1$
! new StubBook(this, "New Stub Version", BookType.BIBLE, BookMetaData.SPEED_INACCURATE), //$NON-NLS-1$
! new StubBook(this, "Stub Comments", BookType.COMMENTARY, BookMetaData.SPEED_INACCURATE), //$NON-NLS-1$
! new StubDictionary(this, "Stub Dict", BookType.DICTIONARY, BookMetaData.SPEED_INACCURATE), //$NON-NLS-1$
};
--- 41,48 ----
Book[] books = new Book[]
{
! new StubBook(this, "Stub Version", BookType.BIBLE), //$NON-NLS-1$
! new StubBook(this, "New Stub Version", BookType.BIBLE), //$NON-NLS-1$
! new StubBook(this, "Stub Comments", BookType.COMMENTARY), //$NON-NLS-1$
! new StubDictionary(this, "Stub Dict", BookType.DICTIONARY), //$NON-NLS-1$
};
From jswordcvs at crosswire.org Tue Oct 5 15:03:11 2004
From: jswordcvs at crosswire.org (jswordcvs@crosswire.org)
Date: Tue Oct 5 15:03:13 2004
Subject: [jsword-svn] jsword/java/limbo/org/crosswire/jsword/book/remote s
Message-ID: <200410052203.i95M3BBR009933@www.crosswire.org>
Update of /cvs/jsword/jsword/java/limbo/org/crosswire/jsword/book/remote
In directory www.crosswire.org:/tmp/cvs-serv9907/java/limbo/org/crosswire/jsword/book/remote
Modified Files:
RemoteBookDriver.java HttpRemoter.java LocalRemoter.java
ConverterTest.java FixtureRemoter.java Converter.java
RemoteBook.java LocalRemoterTest.java Remoter.java
Log Message:
Improvments on reading SwordBookMetaData
Index: LocalRemoter.java
===================================================================
RCS file: /cvs/jsword/jsword/java/limbo/org/crosswire/jsword/book/remote/LocalRemoter.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** LocalRemoter.java 27 Jul 2004 21:42:34 -0000 1.3
--- LocalRemoter.java 5 Oct 2004 22:03:09 -0000 1.4
***************
*** 115,126 ****
}
- /* (non-Javadoc)
- * @see org.crosswire.jsword.book.remote.Remoter#getSpeed()
- */
- public int getSpeed()
- {
- return BookMetaData.SPEED_REMOTE_FASTEST;
- }
-
/**
* Lookup a BibleMetaData using the UID that we assigned to it earlier
*/
--- 115,118 ----
***************
*** 168,172 ****
* The filter to select the bibles we are exporting
*/
! private static final BookFilter FILTER = BookFilters.getFaster(BookMetaData.SPEED_SLOWEST);
/**
--- 160,164 ----
* The filter to select the bibles we are exporting
*/
! private static final BookFilter FILTER = BookFilters.getAll();
/**
Index: HttpRemoter.java
===================================================================
RCS file: /cvs/jsword/jsword/java/limbo/org/crosswire/jsword/book/remote/HttpRemoter.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** HttpRemoter.java 21 Sep 2004 17:46:23 -0000 1.2
--- HttpRemoter.java 5 Oct 2004 22:03:09 -0000 1.3
***************
*** 8,12 ****
import org.crosswire.common.util.Logger;
- import org.crosswire.jsword.book.BookMetaData;
import org.jdom.Document;
import org.jdom.input.SAXBuilder;
--- 8,11 ----
***************
*** 84,95 ****
/**
- * How fast are we?
- */
- public int getSpeed()
- {
- return BookMetaData.SPEED_REMOTE_SLOW;
- }
-
- /**
* Convert a RemoteMethod to a String which we can append to a base url
* to get a complete URL which will get us the required XML document.
*/
--- 83,86 ----
Index: Converter.java
===================================================================
RCS file: /cvs/jsword/jsword/java/limbo/org/crosswire/jsword/book/remote/Converter.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** Converter.java 21 Sep 2004 17:46:23 -0000 1.4
--- Converter.java 5 Oct 2004 22:03:09 -0000 1.5
***************
*** 3,8 ****
import java.io.PrintWriter;
import java.io.StringWriter;
- import java.net.MalformedURLException;
- import java.text.ParseException;
import java.util.ArrayList;
import java.util.Iterator;
--- 3,6 ----
***************
*** 12,17 ****
import org.crosswire.jsword.book.BookMetaData;
import org.crosswire.jsword.book.BookType;
- import org.crosswire.jsword.book.Openness;
- import org.crosswire.jsword.book.basic.DefaultBookMetaData;
import org.crosswire.jsword.passage.DefaultKeyList;
import org.crosswire.jsword.passage.Key;
--- 10,13 ----
***************
*** 53,60 ****
private static final String ELEMENT_ROOT = "root"; //$NON-NLS-1$
private static final String ELEMENT_TYPE = "type"; //$NON-NLS-1$
- private static final String ELEMENT_LICENCE = "licence"; //$NON-NLS-1$
- private static final String ELEMENT_OPENNESS = "openness"; //$NON-NLS-1$
- private static final String ELEMENT_PUB = "pub"; //$NON-NLS-1$
- private static final String ELEMENT_EDITION = "edition"; //$NON-NLS-1$
private static final String ELEMENT_NAME = "name"; //$NON-NLS-1$
private static final String ATTRIBUTE_ID = "id"; //$NON-NLS-1$
--- 49,52 ----
***************
*** 75,83 ****
* [metadata id="uid"]
* [name]King James Version[/name]
! * [edition][/edition]
! * [initials]KJV[/initials]
! * [pub]1900[/pub]
! * [openness]PD[/openness]
! * [/metadata]
* [/root]
*
--- 67,71 ----
* [metadata id="uid"]
* [name]King James Version[/name]
! \ * [/metadata]
* [/root]
*
***************
*** 85,135 ****
* @return BibleMetaData[]
*/
! public static BookMetaData[] convertDocumentToBookMetaDatas(RemoteBookDriver driver, Document doc, Remoter remoter, int speed) throws ConverterException
{
! try
! {
! Element root = doc.getRootElement();
! List bmds = root.getChildren(ELEMENT_METADATA);
! BookMetaData[] rbmds = new BookMetaData[bmds.size()];
! int i = 0;
!
! for (Iterator it = bmds.iterator(); it.hasNext();)
! {
! Element bmdele = (Element) it.next();
! String id = bmdele.getAttributeValue(ATTRIBUTE_ID);
! String name = bmdele.getChildTextTrim(ELEMENT_NAME);
! String edition = bmdele.getChildTextTrim(ELEMENT_EDITION);
! String pubstr = bmdele.getChildTextTrim(ELEMENT_PUB);
! String openstr = bmdele.getChildTextTrim(ELEMENT_OPENNESS);
! String licencestr = bmdele.getChildTextTrim(ELEMENT_LICENCE);
! String typestr = bmdele.getChildTextTrim(ELEMENT_TYPE);
! BookType type = BookType.fromString(typestr);
! Book book = new RemoteBook(remoter, driver, name, type, edition, pubstr, openstr, licencestr, speed);
! BookMetaData bmd = book.getBookMetaData();
! driver.registerID(id, bmd);
! rbmds[i++] = bmd;
! }
! return rbmds;
! }
! catch (MalformedURLException ex)
! {
! throw new ConverterException(Msg.CONVERT_BMD, ex);
! }
! catch (ParseException ex)
! {
! throw new ConverterException(Msg.CONVERT_BMD, ex);
}
}
/**
* Reverse of convertDocumentToBibleMetaDatas().
! * @see Converter#convertDocumentToBookMetaDatas(RemoteBookDriver, Document, Remoter, int)
*/
public static Document convertBookMetaDatasToDocument(BookMetaData[] bmds, String[] ids)
--- 73,108 ----
* @return BibleMetaData[]
*/
! public static BookMetaData[] convertDocumentToBookMetaDatas(RemoteBookDriver driver, Document doc, Remoter remoter)
{
! Element root = doc.getRootElement();
! List bmds = root.getChildren(ELEMENT_METADATA);
! BookMetaData[] rbmds = new BookMetaData[bmds.size()];
! int i = 0;
! for (Iterator it = bmds.iterator(); it.hasNext();)
! {
! Element bmdele = (Element) it.next();
! String id = bmdele.getAttributeValue(ATTRIBUTE_ID);
! String name = bmdele.getChildTextTrim(ELEMENT_NAME);
! String typestr = bmdele.getChildTextTrim(ELEMENT_TYPE);
! BookType type = BookType.fromString(typestr);
! Book book = new RemoteBook(remoter, driver, name, type);
! BookMetaData bmd = book.getBookMetaData();
! driver.registerID(id, bmd);
! rbmds[i++] = bmd;
}
+
+ return rbmds;
}
/**
* Reverse of convertDocumentToBibleMetaDatas().
! * @see Converter#convertDocumentToBookMetaDatas(RemoteBookDriver, Document, Remoter)
*/
public static Document convertBookMetaDatasToDocument(BookMetaData[] bmds, String[] ids)
***************
*** 150,180 ****
bmdele.addContent(temp);
- temp = new Element(ELEMENT_EDITION);
- temp.addContent(bmd.getEdition());
- bmdele.addContent(temp);
-
- String pubstr = DefaultBookMetaData.formatPublishedDate(bmd.getFirstPublished());
- if (pubstr != null)
- {
- temp = new Element(ELEMENT_PUB);
- temp.addContent(pubstr);
- bmdele.addContent(temp);
- }
-
- Openness open = bmd.getOpenness();
- if (open != null)
- {
- temp = new Element(ELEMENT_OPENNESS);
- temp.addContent(open.toString());
- bmdele.addContent(temp);
- }
-
- if (bmd.getLicence() != null)
- {
- temp = new Element(ELEMENT_LICENCE);
- temp.addContent(bmd.getLicence().toExternalForm());
- bmdele.addContent(temp);
- }
-
root.addContent(bmdele);
}
--- 123,126 ----
Index: RemoteBookDriver.java
===================================================================
RCS file: /cvs/jsword/jsword/java/limbo/org/crosswire/jsword/book/remote/RemoteBookDriver.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** RemoteBookDriver.java 25 Jun 2004 11:15:16 -0000 1.1
--- RemoteBookDriver.java 5 Oct 2004 22:03:09 -0000 1.2
***************
*** 82,86 ****
Document doc = remoter.execute(method);
! rbmd = Converter.convertDocumentToBookMetaDatas(this, doc, remoter, remoter.getSpeed());
}
catch (Exception ex)
--- 82,86 ----
Document doc = remoter.execute(method);
! rbmd = Converter.convertDocumentToBookMetaDatas(this, doc, remoter);
}
catch (Exception ex)
Index: Remoter.java
===================================================================
RCS file: /cvs/jsword/jsword/java/limbo/org/crosswire/jsword/book/remote/Remoter.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** Remoter.java 25 Jun 2004 11:15:16 -0000 1.1
--- Remoter.java 5 Oct 2004 22:03:09 -0000 1.2
***************
*** 39,45 ****
public String getRemoterName();
- /**
- * The speed of the Remoter
- */
- public int getSpeed();
}
--- 39,41 ----
Index: FixtureRemoter.java
===================================================================
RCS file: /cvs/jsword/jsword/java/limbo/org/crosswire/jsword/book/remote/FixtureRemoter.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** FixtureRemoter.java 8 Aug 2004 12:26:34 -0000 1.1
--- FixtureRemoter.java 5 Oct 2004 22:03:09 -0000 1.2
***************
*** 1,5 ****
package org.crosswire.jsword.book.remote;
- import org.crosswire.jsword.book.BookMetaData;
import org.jdom.Document;
--- 1,4 ----
***************
*** 46,55 ****
}
- /**
- * How fast are we?
- */
- public int getSpeed()
- {
- return BookMetaData.SPEED_INACCURATE;
- }
}
--- 45,47 ----
Index: RemoteBook.java
===================================================================
RCS file: /cvs/jsword/jsword/java/limbo/org/crosswire/jsword/book/remote/RemoteBook.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** RemoteBook.java 21 Sep 2004 17:46:23 -0000 1.6
--- RemoteBook.java 5 Oct 2004 22:03:09 -0000 1.7
***************
*** 1,7 ****
package org.crosswire.jsword.book.remote;
- import java.net.MalformedURLException;
- import java.text.ParseException;
-
import org.crosswire.common.util.Logger;
import org.crosswire.common.xml.JDOMSAXEventProvider;
--- 1,4 ----
***************
*** 55,61 ****
* Basic constructor for a SerBook
*/
! public RemoteBook(Remoter remoter, RemoteBookDriver driver, String name, BookType type, String edition, String pubstr, String openstr, String licencestr, int speed) throws MalformedURLException, ParseException
{
! BookMetaData bmd = new DefaultBookMetaData(driver, this, name, type, speed, edition, openstr, licencestr, pubstr);
setBookMetaData(bmd);
--- 52,58 ----
* Basic constructor for a SerBook
*/
! public RemoteBook(Remoter remoter, RemoteBookDriver driver, String name, BookType type)
{
! BookMetaData bmd = new DefaultBookMetaData(driver, this, name, type);
setBookMetaData(bmd);
Index: ConverterTest.java
===================================================================
RCS file: /cvs/jsword/jsword/java/limbo/org/crosswire/jsword/book/remote/ConverterTest.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** ConverterTest.java 8 Aug 2004 12:26:34 -0000 1.1
--- ConverterTest.java 5 Oct 2004 22:03:09 -0000 1.2
***************
*** 57,65 ****
t1 = new BookMetaData[]
{
! new DefaultBookMetaData(rbd, null, "v1", BookType.BIBLE, BookMetaData.SPEED_MEDIUM), //$NON-NLS-1$
! new DefaultBookMetaData(rbd, null, "v2", BookType.BIBLE, BookMetaData.SPEED_MEDIUM), //$NON-NLS-1$
! new DefaultBookMetaData(rbd, null, "v3", BookType.BIBLE, BookMetaData.SPEED_MEDIUM), //$NON-NLS-1$
! new DefaultBookMetaData(rbd, null, "test version", BookType.BIBLE, BookMetaData.SPEED_MEDIUM, "tv", "PD", "http://nowhere.com/test", "1900-10-20"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
! new DefaultBookMetaData(rbd, null, "test version", BookType.BIBLE, BookMetaData.SPEED_MEDIUM, null, (String) null, null, null), //$NON-NLS-1$
};
uid1 = new String[]
--- 57,65 ----
t1 = new BookMetaData[]
{
! new DefaultBookMetaData(rbd, null, "v1", BookType.BIBLE), //$NON-NLS-1$
! new DefaultBookMetaData(rbd, null, "v2", BookType.BIBLE), //$NON-NLS-1$
! new DefaultBookMetaData(rbd, null, "v3", BookType.BIBLE), //$NON-NLS-1$
! new DefaultBookMetaData(rbd, null, "test version", BookType.BIBLE), //$NON-NLS-1$
! new DefaultBookMetaData(rbd, null, "test version", BookType.BIBLE), //$NON-NLS-1$
};
uid1 = new String[]
***************
*** 73,77 ****
doc = Converter.convertBookMetaDatasToDocument(t1, uid1);
! t2 = Converter.convertDocumentToBookMetaDatas(rbd, doc, new FixtureRemoter(), BookMetaData.SPEED_INACCURATE);
assertEquals(t1.length, 5);
assertEquals(t2.length, 5);
--- 73,77 ----
doc = Converter.convertBookMetaDatasToDocument(t1, uid1);
! t2 = Converter.convertDocumentToBookMetaDatas(rbd, doc, new FixtureRemoter());
assertEquals(t1.length, 5);
assertEquals(t2.length, 5);
***************
*** 82,91 ****
//assertEquals(uid1[i], driver.getID(t2[i]));
assertEquals(t1[i].getName(), t2[i].getName());
- assertEquals(t1[i].getEdition(), t2[i].getEdition());
// We scrapped this test because exact times were getting confused
- //assertEquals(t1[i].getFirstPublished(), t2[i].getFirstPublished());
assertEquals(t1[i].getInitials(), t2[i].getInitials());
- assertEquals(t1[i].getLicence(), t2[i].getLicence());
- assertEquals(t1[i].getOpenness(), t2[i].getOpenness());
// this did check for not equals - surely this was wrong???
assertTrue(t1[i].equals(t2[i]));
--- 82,87 ----
***************
*** 94,98 ****
t1 = new BookMetaData[] { };
doc = Converter.convertBookMetaDatasToDocument(t1, new String[] { });
! t2 = Converter.convertDocumentToBookMetaDatas(null, doc, null, BookMetaData.SPEED_INACCURATE);
assertEquals(t1.length, 0);
assertEquals(t2.length, 0);
--- 90,94 ----
t1 = new BookMetaData[] { };
doc = Converter.convertBookMetaDatasToDocument(t1, new String[] { });
! t2 = Converter.convertDocumentToBookMetaDatas(null, doc, null);
assertEquals(t1.length, 0);
assertEquals(t2.length, 0);
Index: LocalRemoterTest.java
===================================================================
RCS file: /cvs/jsword/jsword/java/limbo/org/crosswire/jsword/book/remote/LocalRemoterTest.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** LocalRemoterTest.java 8 Aug 2004 12:26:34 -0000 1.1
--- LocalRemoterTest.java 5 Oct 2004 22:03:09 -0000 1.2
***************
*** 50,54 ****
public void testGetBibles() throws Exception
{
! BookFilter filter = BookFilters.both(BookFilters.getFaster(BookMetaData.SPEED_SLOWEST), BookFilters.getBibles());
List lbmds = Books.installed().getBookMetaDatas(filter);
BookMetaData[] names1 = (BookMetaData[]) lbmds.toArray(new BookMetaData[lbmds.size()]);
--- 50,54 ----
public void testGetBibles() throws Exception
{
! BookFilter filter = BookFilters.getBibles();
List lbmds = Books.installed().getBookMetaDatas(filter);
BookMetaData[] names1 = (BookMetaData[]) lbmds.toArray(new BookMetaData[lbmds.size()]);
***************
*** 57,61 ****
RemoteMethod method = new RemoteMethod(MethodName.GETBIBLES);
Document doc = remote.execute(method);
! BookMetaData[] names2 = Converter.convertDocumentToBookMetaDatas(rbd, doc, new FixtureRemoter(), BookMetaData.SPEED_INACCURATE);
assertEquals(names1.length, names2.length);
--- 57,61 ----
RemoteMethod method = new RemoteMethod(MethodName.GETBIBLES);
Document doc = remote.execute(method);
! BookMetaData[] names2 = Converter.convertDocumentToBookMetaDatas(rbd, doc, new FixtureRemoter());
assertEquals(names1.length, names2.length);
From jswordcvs at crosswire.org Tue Oct 5 15:03:11 2004
From: jswordcvs at crosswire.org (jswordcvs@crosswire.org)
Date: Tue Oct 5 15:03:13 2004
Subject: [jsword-svn]
jsword/java/jsword/org/crosswire/jsword/book/install/sword s
Message-ID: <200410052203.i95M3BmJ009962@www.crosswire.org>
Update of /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/install/sword
In directory www.crosswire.org:/tmp/cvs-serv9907/java/jsword/org/crosswire/jsword/book/install/sword
Modified Files:
HttpSwordInstaller.java FtpSwordInstaller.java
Log Message:
Improvments on reading SwordBookMetaData
Index: HttpSwordInstaller.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/install/sword/HttpSwordInstaller.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** HttpSwordInstaller.java 2 Oct 2004 14:01:42 -0000 1.9
--- HttpSwordInstaller.java 5 Oct 2004 22:03:09 -0000 1.10
***************
*** 286,290 ****
File confdir = new File(dldir, SwordConstants.DIR_CONF);
confdir.mkdirs();
! File conf = new File(confdir, sbmd.getInternalName() + SwordConstants.EXTENSION_CONF);
URL configurl = new URL(NetUtil.PROTOCOL_FILE, null, conf.getAbsolutePath());
sbmd.save(configurl);
--- 286,290 ----
File confdir = new File(dldir, SwordConstants.DIR_CONF);
confdir.mkdirs();
! File conf = new File(confdir, sbmd.getDiskName() + SwordConstants.EXTENSION_CONF);
URL configurl = new URL(NetUtil.PROTOCOL_FILE, null, conf.getAbsolutePath());
sbmd.save(configurl);
***************
*** 356,360 ****
URL local = toLocalURL(bmd);
SwordBookMetaData sbmd = (SwordBookMetaData) bmd;
! local = NetUtil.lengthenURL(local, sbmd.getInternalName() + SwordConstants.EXTENSION_CONF);
URL remote = toRemoteURL(bmd);
return NetUtil.isNewer(remote, local);
--- 356,360 ----
URL local = toLocalURL(bmd);
SwordBookMetaData sbmd = (SwordBookMetaData) bmd;
! local = NetUtil.lengthenURL(local, sbmd.getDiskName() + SwordConstants.EXTENSION_CONF);
URL remote = toRemoteURL(bmd);
return NetUtil.isNewer(remote, local);
***************
*** 376,380 ****
ModuleType type = sbmd.getModuleType();
String modpath = type.getInstallDirectory();
! String destname = modpath + '/' + sbmd.getInternalName();
File dldir = SwordBookDriver.getDownloadDir();
--- 376,380 ----
ModuleType type = sbmd.getModuleType();
String modpath = type.getInstallDirectory();
! String destname = modpath + '/' + sbmd.getDiskName();
File dldir = SwordBookDriver.getDownloadDir();
Index: FtpSwordInstaller.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/install/sword/FtpSwordInstaller.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** FtpSwordInstaller.java 2 Oct 2004 14:01:42 -0000 1.6
--- FtpSwordInstaller.java 5 Oct 2004 22:03:09 -0000 1.7
***************
*** 127,131 ****
ModuleType type = sbmd.getModuleType();
String modpath = type.getInstallDirectory();
! String destname = modpath + '/' + sbmd.getInternalName();
File dldir = SwordBookDriver.getDownloadDir();
--- 127,131 ----
ModuleType type = sbmd.getModuleType();
String modpath = type.getInstallDirectory();
! String destname = modpath + '/' + sbmd.getDiskName();
File dldir = SwordBookDriver.getDownloadDir();
***************
*** 193,197 ****
ModuleType type = sbmd.getModuleType();
String modpath = type.getInstallDirectory();
! String destname = modpath + '/' + sbmd.getInternalName();
downloadAll(job, host, USERNAME, PASSWORD, directory + '/' + SwordConstants.DIR_DATA + '/' + destname, desturl);
--- 193,197 ----
ModuleType type = sbmd.getModuleType();
String modpath = type.getInstallDirectory();
! String destname = modpath + '/' + sbmd.getDiskName();
downloadAll(job, host, USERNAME, PASSWORD, directory + '/' + SwordConstants.DIR_DATA + '/' + destname, desturl);
***************
*** 200,204 ****
File confdir = new File(dldir, SwordConstants.DIR_CONF);
confdir.mkdirs();
! File conf = new File(confdir, sbmd.getInternalName() + SwordConstants.EXTENSION_CONF);
URL configurl = new URL(NetUtil.PROTOCOL_FILE, null, conf.getAbsolutePath());
sbmd.save(configurl);
--- 200,204 ----
File confdir = new File(dldir, SwordConstants.DIR_CONF);
confdir.mkdirs();
! File conf = new File(confdir, sbmd.getDiskName() + SwordConstants.EXTENSION_CONF);
URL configurl = new URL(NetUtil.PROTOCOL_FILE, null, conf.getAbsolutePath());
sbmd.save(configurl);
From jswordcvs at crosswire.org Tue Oct 5 15:03:11 2004
From: jswordcvs at crosswire.org (jswordcvs@crosswire.org)
Date: Tue Oct 5 15:03:13 2004
Subject: [jsword-svn] jsword/java/jsword/org/crosswire/jsword/book/basic s
Message-ID: <200410052203.i95M3BLj009967@www.crosswire.org>
Update of /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/basic
In directory www.crosswire.org:/tmp/cvs-serv9907/java/jsword/org/crosswire/jsword/book/basic
Modified Files:
DefaultBookMetaData.java
Log Message:
Improvments on reading SwordBookMetaData
Index: DefaultBookMetaData.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/basic/DefaultBookMetaData.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -d -r1.12 -r1.13
*** DefaultBookMetaData.java 21 Sep 2004 17:46:23 -0000 1.12
--- DefaultBookMetaData.java 5 Oct 2004 22:03:09 -0000 1.13
***************
*** 1,8 ****
package org.crosswire.jsword.book.basic;
- import java.net.MalformedURLException;
- import java.net.URL;
- import java.text.ParseException;
- import java.util.Date;
import java.util.LinkedHashMap;
import java.util.Map;
--- 1,4 ----
***************
*** 14,18 ****
import org.crosswire.jsword.book.BookMetaData;
import org.crosswire.jsword.book.BookType;
- import org.crosswire.jsword.book.Openness;
/**
--- 10,13 ----
***************
*** 50,54 ****
* A call to setBook() is still required after this ctor is called
*/
! public DefaultBookMetaData(BookDriver driver, Book book, Properties prop) throws MalformedURLException, ParseException
{
this.driver = driver;
--- 45,49 ----
* A call to setBook() is still required after this ctor is called
*/
! public DefaultBookMetaData(BookDriver driver, Book book, Properties prop)
{
this.driver = driver;
***************
*** 59,69 ****
setName(prop.getProperty(BookMetaData.KEY_NAME));
setType(prop.getProperty(BookMetaData.KEY_TYPE));
- setSpeed(Integer.parseInt(prop.getProperty(BookMetaData.KEY_SPEED)));
setLanguage(prop.getProperty(BookMetaData.KEY_LANGUAGE));
- setEdition(prop.getProperty(BookMetaData.KEY_EDITION));
- setOpenness(prop.getProperty(BookMetaData.KEY_OPENNESS));
- setLicence(prop.getProperty(BookMetaData.KEY_LICENCE));
- setFirstPublished(prop.getProperty(BookMetaData.KEY_FIRSTPUB));
}
--- 54,59 ----
***************
*** 72,109 ****
* A call to setBook() is still required after this ctor is called
*/
! public DefaultBookMetaData(BookDriver driver, Book book, String name, BookType type, int speed)
! {
! this.driver = driver;
! this.book = book;
!
! setName(name);
! setType(type);
! setSpeed(speed);
! }
!
! /**
! * Ctor with all important values.
! * A call to setBook() is still required after this ctor is called
! */
! public DefaultBookMetaData(BookDriver driver, Book book, String name, BookType type, int speed, String edition, Openness openness, URL licence, Date firstPublished)
! {
! this.driver = driver;
! this.book = book;
!
! setName(name);
! setType(type);
! setSpeed(speed);
!
! setEdition(edition);
! setOpenness(openness);
! setLicence(licence);
! setFirstPublished(firstPublished);
! }
!
! /**
! * Ctor with all important values.
! * A call to setBook() is still required after this ctor is called
! */
! public DefaultBookMetaData(BookDriver driver, Book book, String name, BookType type, int speed, String edition, String openstr, String licencestr, String pubstr) throws MalformedURLException, ParseException, NumberFormatException
{
this.driver = driver;
--- 62,66 ----
* A call to setBook() is still required after this ctor is called
*/
! public DefaultBookMetaData(BookDriver driver, Book book, String name, BookType type)
{
this.driver = driver;
***************
*** 112,121 ****
setName(name);
setType(type);
- setSpeed(speed);
-
- setEdition(edition);
- setOpenness(openstr);
- setLicence(licencestr);
- setFirstPublished(pubstr);
}
--- 69,72 ----
***************
*** 161,172 ****
/* (non-Javadoc)
- * @see org.crosswire.jsword.book.BookMetaData#getEdition()
- */
- public String getEdition()
- {
- return edition;
- }
-
- /* (non-Javadoc)
* @see org.crosswire.jsword.book.BookMetaData#getInitials()
*/
--- 112,115 ----
***************
*** 177,212 ****
/* (non-Javadoc)
- * @see org.crosswire.jsword.book.BookMetaData#getSpeed()
- */
- public int getSpeed()
- {
- return speed;
- }
-
- /* (non-Javadoc)
- * @see org.crosswire.jsword.book.BookMetaData#getFirstPublished()
- */
- public Date getFirstPublished()
- {
- return firstPublished;
- }
-
- /* (non-Javadoc)
- * @see org.crosswire.jsword.book.BookMetaData#getOpenness()
- */
- public Openness getOpenness()
- {
- return openness;
- }
-
- /* (non-Javadoc)
- * @see org.crosswire.jsword.book.BookMetaData#getLicence()
- */
- public URL getLicence()
- {
- return licence;
- }
-
- /* (non-Javadoc)
* @see org.crosswire.jsword.book.BookMetaData#getProperties()
*/
--- 120,123 ----
***************
*** 222,231 ****
{
StringBuffer buf = new StringBuffer(getName());
- String ed = getEdition();
-
- if (!ed.equals("")) //$NON-NLS-1$
- {
- buf.append(", ").append(ed); //$NON-NLS-1$
- }
if (driver != null)
--- 133,136 ----
***************
*** 246,257 ****
/* (non-Javadoc)
- * @see org.crosswire.jsword.book.BookMetaData#isSameFamily(org.crosswire.jsword.book.BookMetaData)
- */
- public boolean isSameFamily(BookMetaData version)
- {
- return getName().equals(version.getName());
- }
-
- /* (non-Javadoc)
* @see org.crosswire.jsword.book.BookMetaData#getDriverName()
*/
--- 151,154 ----
***************
*** 304,351 ****
/**
- * @param edition The edition to set.
- */
- public void setEdition(String edition)
- {
- if (edition == null)
- {
- this.edition = ""; //$NON-NLS-1$
- }
- else
- {
- this.edition = edition;
- }
-
- map.put(KEY_EDITION, this.edition);
- }
-
- /**
- * @param firstPublished The firstPublished to set.
- */
- public void setFirstPublished(Date firstPublished)
- {
- if (firstPublished == null)
- {
- firstPublished = FIRSTPUB_DEFAULT;
- }
- this.firstPublished = firstPublished;
-
- map.put(KEY_FIRSTPUB, this.firstPublished.toString());
- }
-
- /**
- * Internal setter for the first published date
- */
- public void setFirstPublished(String pubstr) throws ParseException
- {
- Date newPublished = null;
- if (pubstr != null && pubstr.trim().length() > 0)
- {
- newPublished = FIRSTPUB_FORMAT.parse(pubstr);
- }
- setFirstPublished(newPublished);
- }
-
- /**
* See note on setName() for side effect on setInitials(). If a value of
* null is used then the initials are defaulted using the name
--- 201,204 ----
***************
*** 375,402 ****
/**
- * @param licence The licence to set.
- */
- public void setLicence(URL licence)
- {
- this.licence = licence;
-
- map.put(KEY_LICENCE, licence == null ? "" : this.licence.toString()); //$NON-NLS-1$
- }
-
- /**
- * Internal setter for the license
- */
- public void setLicence(String licencestr) throws MalformedURLException
- {
- URL newLicence = null;
- if (licencestr != null)
- {
- newLicence = new URL(licencestr);
- }
-
- setLicence(newLicence);
- }
-
- /**
* Setting the name also sets some default initials, so if you wish to set
* some specific initials then it should be done after setting the name.
--- 228,231 ----
***************
*** 414,463 ****
/**
- * @param openness The openness to set.
- */
- public void setOpenness(Openness openness)
- {
- if (openness == null)
- {
- openness = Openness.UNKNOWN;
- }
- this.openness = openness;
-
- map.put(KEY_OPENNESS, this.openness.toString());
- }
-
- /**
- * @param openstr The string version of the openness to set.
- */
- public void setOpenness(String openstr)
- {
- Openness newOpenness = null;
- if (openstr != null)
- {
- newOpenness = Openness.fromString(openstr);
- }
-
- setOpenness(newOpenness);
- }
-
- /**
- * @param speed The speed to set.
- */
- public void setSpeed(int speed)
- {
- this.speed = speed;
-
- map.put(KEY_SPEED, Integer.toString(this.speed));
- }
-
- /**
- * @param speedstr The speed to set.
- */
- public void setSpeed(String speedstr) throws NumberFormatException
- {
- setSpeed(Integer.parseInt(speedstr));
- }
-
- /**
* @param type The type to set.
*/
--- 243,246 ----
***************
*** 508,528 ****
}
- // If super does equals ...
- /* Commented out because super.equals() always equals false
- if (!super.equals(obj))
- {
- return false;
- }
- */
-
// The real bit ...
BookMetaData that = (BookMetaData) obj;
! if (!getName().equals(that.getName()))
! {
! return false;
! }
!
! return getEdition().equals(that.getEdition());
}
--- 291,298 ----
}
// The real bit ...
BookMetaData that = (BookMetaData) obj;
! return getName().equals(that.getName());
}
***************
*** 532,536 ****
public int hashCode()
{
! return (getName() + getEdition()).hashCode();
}
--- 302,306 ----
public int hashCode()
{
! return getName().hashCode();
}
***************
*** 553,564 ****
/**
- * Convert a published Date into the standard (String) format
- */
- public static String formatPublishedDate(Date pub)
- {
- return FIRSTPUB_FORMAT.format(pub);
- }
-
- /**
*
*/
--- 323,326 ----
***************
*** 570,578 ****
private String name = ""; //$NON-NLS-1$
private String language = ""; //$NON-NLS-1$
- private String edition = ""; //$NON-NLS-1$
private String initials = ""; //$NON-NLS-1$
- private int speed = BookMetaData.SPEED_SLOWEST;
- private Date firstPublished = FIRSTPUB_DEFAULT;
- private Openness openness = Openness.UNKNOWN;
- private URL licence;
}
--- 332,335 ----
From jswordcvs at crosswire.org Tue Oct 5 15:03:11 2004
From: jswordcvs at crosswire.org (jswordcvs@crosswire.org)
Date: Tue Oct 5 15:03:15 2004
Subject: [jsword-svn] jsword/java/jswordtest/org/crosswire/jsword/book s
Message-ID: <200410052203.i95M3BNx009993@www.crosswire.org>
Update of /cvs/jsword/jsword/java/jswordtest/org/crosswire/jsword/book
In directory www.crosswire.org:/tmp/cvs-serv9907/java/jswordtest/org/crosswire/jsword/book
Modified Files:
BooksTest.java
Log Message:
Improvments on reading SwordBookMetaData
Index: BooksTest.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jswordtest/org/crosswire/jsword/book/BooksTest.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** BooksTest.java 8 Aug 2004 11:40:12 -0000 1.8
--- BooksTest.java 5 Oct 2004 22:03:09 -0000 1.9
***************
*** 1,5 ****
package org.crosswire.jsword.book;
- import java.util.Date;
import java.util.Iterator;
import java.util.List;
--- 1,4 ----
***************
*** 100,113 ****
BookMetaData bmd = bmds[i];
- assertTrue(bmd.getEdition() != null);
- assertTrue(!bmd.getEdition().endsWith("Edition")); //$NON-NLS-1$
-
- Date pub = bmd.getFirstPublished();
- if (pub != null)
- {
- // the date must be in the past
- assertTrue(pub.before(new Date()));
- }
-
assertTrue(bmd.getFullName() != null);
assertTrue(bmd.getFullName().length() > 0);
--- 99,102 ----
***************
*** 118,122 ****
assertTrue(bmd.getFullName().length() > bmd.getName().length());
assertTrue(bmd.getName().length() > bmd.getInitials().length());
- assertTrue(bmd.getOpenness() != null);
}
}
--- 107,110 ----
From jswordcvs at crosswire.org Tue Oct 5 15:03:11 2004
From: jswordcvs at crosswire.org (jswordcvs@crosswire.org)
Date: Tue Oct 5 15:03:15 2004
Subject: [jsword-svn] jsword/java/limbo/org/crosswire/jsword/book/raw s
Message-ID: <200410052203.i95M3BLK009974@www.crosswire.org>
Update of /cvs/jsword/jsword/java/limbo/org/crosswire/jsword/book/raw
In directory www.crosswire.org:/tmp/cvs-serv9907/java/limbo/org/crosswire/jsword/book/raw
Modified Files:
RawBook.java
Log Message:
Improvments on reading SwordBookMetaData
Index: RawBook.java
===================================================================
RCS file: /cvs/jsword/jsword/java/limbo/org/crosswire/jsword/book/raw/RawBook.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** RawBook.java 29 Sep 2004 22:21:23 -0000 1.7
--- RawBook.java 5 Oct 2004 22:03:09 -0000 1.8
***************
*** 2,8 ****
import java.io.IOException;
- import java.net.MalformedURLException;
import java.net.URL;
- import java.text.ParseException;
import java.util.Collection;
import java.util.Iterator;
--- 2,6 ----
***************
*** 212,216 ****
* Simple ctor
*/
! public RawBook(BookDriver driver, Properties prop, URL url) throws MalformedURLException, ParseException
{
BookMetaData bmd = new DefaultBookMetaData(driver, this, prop);
--- 210,214 ----
* Simple ctor
*/
! public RawBook(BookDriver driver, Properties prop, URL url)
{
BookMetaData bmd = new DefaultBookMetaData(driver, this, prop);
From jswordcvs at crosswire.org Tue Oct 5 15:03:11 2004
From: jswordcvs at crosswire.org (jswordcvs@crosswire.org)
Date: Tue Oct 5 15:03:15 2004
Subject: [jsword-svn] jsword/java/limbo/org/crosswire/jsword/book/ser s
Message-ID: <200410052203.i95M3Bhn009980@www.crosswire.org>
Update of /cvs/jsword/jsword/java/limbo/org/crosswire/jsword/book/ser
In directory www.crosswire.org:/tmp/cvs-serv9907/java/limbo/org/crosswire/jsword/book/ser
Modified Files:
SerBook.java
Log Message:
Improvments on reading SwordBookMetaData
Index: SerBook.java
===================================================================
RCS file: /cvs/jsword/jsword/java/limbo/org/crosswire/jsword/book/ser/SerBook.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** SerBook.java 29 Sep 2004 22:21:23 -0000 1.4
--- SerBook.java 5 Oct 2004 22:03:09 -0000 1.5
***************
*** 1,7 ****
package org.crosswire.jsword.book.ser;
- import java.net.MalformedURLException;
import java.net.URL;
- import java.text.ParseException;
import java.util.Properties;
--- 1,5 ----
***************
*** 147,151 ****
* Simple ctor
*/
! public SerBook(BookDriver driver, Properties prop, URL url) throws MalformedURLException, ParseException, BookException
{
BookMetaData bmd = new DefaultBookMetaData(driver, this, prop);
--- 145,149 ----
* Simple ctor
*/
! public SerBook(BookDriver driver, Properties prop, URL url) throws BookException
{
BookMetaData bmd = new DefaultBookMetaData(driver, this, prop);
From jswordcvs at crosswire.org Tue Oct 5 15:03:11 2004
From: jswordcvs at crosswire.org (jswordcvs@crosswire.org)
Date: Tue Oct 5 15:03:15 2004
Subject: [jsword-svn] jsword/java/jsword/org/crosswire/jsword/book/readings s
Message-ID: <200410052203.i95M3BD6009944@www.crosswire.org>
Update of /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/readings
In directory www.crosswire.org:/tmp/cvs-serv9907/java/jsword/org/crosswire/jsword/book/readings
Modified Files:
ReadingsBookDriver.java ReadingsBook.java
Log Message:
Improvments on reading SwordBookMetaData
Index: ReadingsBook.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/readings/ReadingsBook.java,v
retrieving revision 1.21
retrieving revision 1.22
diff -C2 -d -r1.21 -r1.22
*** ReadingsBook.java 29 Sep 2004 22:21:23 -0000 1.21
--- ReadingsBook.java 5 Oct 2004 22:03:09 -0000 1.22
***************
*** 62,68 ****
* Constructor for ReadingsBook.
*/
! public ReadingsBook(ReadingsBookDriver driver, String name, BookType type, int speed)
{
! BookMetaData bmd = new DefaultBookMetaData(driver, this, name, type, speed);
setBookMetaData(bmd);
--- 62,68 ----
* Constructor for ReadingsBook.
*/
! public ReadingsBook(ReadingsBookDriver driver, String name, BookType type)
{
! BookMetaData bmd = new DefaultBookMetaData(driver, this, name, type);
setBookMetaData(bmd);
Index: ReadingsBookDriver.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/readings/ReadingsBookDriver.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -d -r1.11 -r1.12
*** ReadingsBookDriver.java 8 Sep 2004 19:55:07 -0000 1.11
--- ReadingsBookDriver.java 5 Oct 2004 22:03:09 -0000 1.12
***************
*** 45,49 ****
Book[] books = new Book[]
{
! new ReadingsBook(this, Msg.TITLE.toString(), BookType.DICTIONARY, BookMetaData.SPEED_MEDIUM),
};
--- 45,49 ----
Book[] books = new Book[]
{
! new ReadingsBook(this, Msg.TITLE.toString(), BookType.DICTIONARY),
};
From jswordcvs at crosswire.org Tue Oct 5 15:03:12 2004
From: jswordcvs at crosswire.org (jswordcvs@crosswire.org)
Date: Tue Oct 5 15:03:15 2004
Subject: [jsword-svn] jsword/java/jsword/org/crosswire/jsword/examples s
Message-ID: <200410052203.i95M3C3m010009@www.crosswire.org>
Update of /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/examples
In directory www.crosswire.org:/tmp/cvs-serv9907/java/jsword/org/crosswire/jsword/examples
Modified Files:
APIExamples.java
Log Message:
Improvments on reading SwordBookMetaData
Index: APIExamples.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/examples/APIExamples.java,v
retrieving revision 1.17
retrieving revision 1.18
diff -C2 -d -r1.17 -r1.18
*** APIExamples.java 30 Aug 2004 09:27:08 -0000 1.17
--- APIExamples.java 5 Oct 2004 22:03:09 -0000 1.18
***************
*** 160,164 ****
// And you can get back to the MetaData object to find out more too:
bmd = book.getBookMetaData();
! System.out.println(bmd.getEdition());
// If you want a greater selection of Books:
--- 160,164 ----
// And you can get back to the MetaData object to find out more too:
bmd = book.getBookMetaData();
! System.out.println(bmd.getLanguage());
// If you want a greater selection of Books:
From jswordcvs at crosswire.org Tue Oct 5 15:03:11 2004
From: jswordcvs at crosswire.org (jswordcvs@crosswire.org)
Date: Tue Oct 5 15:03:16 2004
Subject: [jsword-svn] jsword/java/limbo/org/crosswire/jsword/book/jdbc s
Message-ID: <200410052203.i95M3BXN009999@www.crosswire.org>
Update of /cvs/jsword/jsword/java/limbo/org/crosswire/jsword/book/jdbc
In directory www.crosswire.org:/tmp/cvs-serv9907/java/limbo/org/crosswire/jsword/book/jdbc
Modified Files:
JDBCBook.java
Log Message:
Improvments on reading SwordBookMetaData
Index: JDBCBook.java
===================================================================
RCS file: /cvs/jsword/jsword/java/limbo/org/crosswire/jsword/book/jdbc/JDBCBook.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** JDBCBook.java 29 Sep 2004 22:21:24 -0000 1.6
--- JDBCBook.java 5 Oct 2004 22:03:09 -0000 1.7
***************
*** 1,5 ****
package org.crosswire.jsword.book.jdbc;
- import java.net.MalformedURLException;
import java.sql.Connection;
import java.sql.DriverManager;
--- 1,4 ----
***************
*** 8,12 ****
import java.sql.SQLException;
import java.sql.Statement;
- import java.text.ParseException;
import java.util.ArrayList;
import java.util.Collection;
--- 7,10 ----
***************
*** 58,62 ****
* Simple ctor
*/
! public JDBCBook(BookDriver driver, Properties prop) throws MalformedURLException, ParseException, BookException
{
BookMetaData bmd = new DefaultBookMetaData(driver, this, prop);
--- 56,60 ----
* Simple ctor
*/
! public JDBCBook(BookDriver driver, Properties prop) throws BookException
{
BookMetaData bmd = new DefaultBookMetaData(driver, this, prop);
From jswordcvs at crosswire.org Tue Oct 5 15:03:11 2004
From: jswordcvs at crosswire.org (jswordcvs@crosswire.org)
Date: Tue Oct 5 15:03:16 2004
Subject: [jsword-svn] jsword/java/jsword/org/crosswire/jsword/book s
Message-ID: <200410052203.i95M3Brc009988@www.crosswire.org>
Update of /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book
In directory www.crosswire.org:/tmp/cvs-serv9907/java/jsword/org/crosswire/jsword/book
Modified Files:
BookFilters.java BookMetaData.java Defaults.java
Log Message:
Improvments on reading SwordBookMetaData
Index: Defaults.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/Defaults.java,v
retrieving revision 1.22
retrieving revision 1.23
diff -C2 -d -r1.22 -r1.23
*** Defaults.java 8 Sep 2004 19:55:07 -0000 1.22
--- Defaults.java 5 Oct 2004 22:03:09 -0000 1.23
***************
*** 48,57 ****
/**
- * Has the default Bible been manually set or are we picking the fastest
- * as the default?
- */
- private static boolean autobdeft = true;
-
- /**
* The default Bible
*/
--- 48,51 ----
***************
*** 59,68 ****
/**
- * Has the default Commentary been manually set or are we picking the fastest
- * as the default?
- */
- private static boolean autocdeft = true;
-
- /**
* The default Commentary
*/
--- 53,56 ----
***************
*** 70,79 ****
/**
- * Has the default Dictionary been manually set or are we picking the fastest
- * as the default?
- */
- private static boolean autoddeft = true;
-
- /**
* The default Dictionary
*/
--- 58,61 ----
***************
*** 88,92 ****
public static void setBibleMetaData(BookMetaData bmd)
{
- autobdeft = false;
bdeft = bmd;
}
--- 70,73 ----
***************
*** 97,101 ****
protected static void unsetBibleMetaData()
{
- autobdeft = true;
bdeft = null;
--- 78,81 ----
***************
*** 170,174 ****
public static void setCommentaryMetaData(BookMetaData cmd)
{
- autocdeft = false;
cdeft = cmd;
}
--- 150,153 ----
***************
*** 179,183 ****
protected static void unsetCommentaryMetaData()
{
- autocdeft = true;
cdeft = null;
--- 158,161 ----
***************
*** 254,258 ****
public static void setDictionaryMetaData(BookMetaData dmd)
{
- autoddeft = false;
ddeft = dmd;
}
--- 232,235 ----
***************
*** 263,267 ****
protected static void unsetDictionaryMetaData()
{
- autoddeft = true;
ddeft = null;
--- 240,243 ----
***************
*** 345,349 ****
/**
! * Should this Bible become the default?
*/
protected static void checkPreferable(BookMetaData bmd)
--- 321,326 ----
/**
! * Should this Book become the default?
! * Only if there is not one.
*/
protected static void checkPreferable(BookMetaData bmd)
***************
*** 351,395 ****
assert bmd != null;
! if (bmd.getType().equals(BookType.BIBLE))
{
! // Do we even think about replacing the default Bible?
! if (autobdeft || bdeft == null)
! {
! // If there is no default or this is faster
! if (bdeft == null || bmd.getSpeed() > bdeft.getSpeed())
! {
! bdeft = bmd;
! autobdeft = true;
! log.debug("setting as default bible since speed=" + bdeft.getSpeed()); //$NON-NLS-1$
! }
! }
}
! else if (bmd.getType().equals(BookType.COMMENTARY))
{
! // Do we even think about replacing the default Bible?
! if (autocdeft || cdeft == null)
! {
! // If there is no default or this is faster
! if (cdeft == null || bmd.getSpeed() > cdeft.getSpeed())
! {
! cdeft = bmd;
! autocdeft = true;
! log.debug("setting as default commentary since speed=" + cdeft.getSpeed()); //$NON-NLS-1$
! }
! }
}
! else if (bmd.getType().equals(BookType.DICTIONARY))
{
! // Do we even think about replacing the default Bible?
! if (autoddeft || ddeft == null)
! {
! // If there is no default or this is faster
! if (ddeft == null || bmd.getSpeed() > ddeft.getSpeed())
! {
! ddeft = bmd;
! autoddeft = true;
! log.debug("setting as default dictionary since speed=" + ddeft.getSpeed()); //$NON-NLS-1$
! }
! }
}
}
--- 328,342 ----
assert bmd != null;
! if (bmd.getType().equals(BookType.BIBLE) && bdeft == null)
{
! bdeft = bmd;
}
! else if (bmd.getType().equals(BookType.COMMENTARY) && cdeft == null)
{
! cdeft = bmd;
}
! else if (bmd.getType().equals(BookType.DICTIONARY) && ddeft == null)
{
! ddeft = bmd;
}
}
Index: BookFilters.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/BookFilters.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** BookFilters.java 19 Nov 2003 22:48:15 -0000 1.6
--- BookFilters.java 5 Oct 2004 22:03:09 -0000 1.7
***************
*** 132,150 ****
/**
! * A filter that accepts everything faster that a set minimum.
! */
! public static BookFilter getFaster(final int slowest)
! {
! return new BookFilter()
! {
! public boolean test(BookMetaData bmd)
! {
! return bmd.getSpeed() > slowest;
! }
! };
! }
!
! /**
! * A filter that accepts everything faster that a set minimum.
*/
public static BookFilter both(final BookFilter b1, final BookFilter b2)
--- 132,136 ----
/**
! * A filter that accepts Books that match two criteria.
*/
public static BookFilter both(final BookFilter b1, final BookFilter b2)
***************
*** 160,164 ****
/**
! * A filter that accepts everything faster that a set minimum.
*/
public static BookFilter either(final BookFilter b1, final BookFilter b2)
--- 146,150 ----
/**
! * A filter that accepts Books that match either of two criteria.
*/
public static BookFilter either(final BookFilter b1, final BookFilter b2)
Index: BookMetaData.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/BookMetaData.java,v
retrieving revision 1.20
retrieving revision 1.21
diff -C2 -d -r1.20 -r1.21
*** BookMetaData.java 10 Sep 2004 14:14:15 -0000 1.20
--- BookMetaData.java 5 Oct 2004 22:03:09 -0000 1.21
***************
*** 1,8 ****
package org.crosswire.jsword.book;
- import java.net.URL;
- import java.text.DateFormat;
- import java.text.SimpleDateFormat;
- import java.util.Date;
import java.util.Map;
--- 1,4 ----
***************
*** 86,100 ****
/**
- * The edition of this book, for example "Anglicised" (NIV),
- * "Stephanus" (Greek).
- * For 2 books to be equal both the name and the edition must be equal.
- * In general the text returned by this method should not include the word
- * "Edition". It is valid for an edition to be a blank string but not for it
- * to be null.
- * @return The name of the edition
- */
- public String getEdition();
-
- /**
* The initials of this book - how people familiar with this book will know
* it, for example "NIV", "KJV".
--- 82,85 ----
***************
*** 104,146 ****
/**
- * The expected speed at which this implementation gets correct answers.
- * This value is used by Books to decide the fastest implementation for a
- * given job.
- * The valid values are defined in the Books class.
- * @see Books
- * @return a speed value between -1 and 10
- */
- public int getSpeed();
-
- /**
- * The date of first publishing.
- * This does not need to be accurate and 2 books can be considered equal
- * even if they have different first publishing dates for that reason.
- * In general "1 Jan 1970" means published in 1970, and so on.
- * A null return from this method is entirely valid if the date of
- * first publishing is not known.
- * If the date is required in string form it should be in the format
- * YYYY-MM-DD so save US/UK confusion over MM/DD and DD/MM.
- * @return The date of first publishing
- */
- public Date getFirstPublished();
-
- /**
- * Is this book sold for commercial profit like the NIV, or kept
- * open like the NET book.
- * @return A STATUS_* constant
- */
- public Openness getOpenness();
-
- /**
- * Not sure about this one - Do we need a way of getting at the dist.
- * licence? Are we going to be able to tie it down to a single book
- * policy like this? A null return is valid if the licence URL is not
- * known.
- * @return String detailing the users right to distribute this book
- */
- public URL getLicence();
-
- /**
* Calculated field: Get an OSIS identifier for the OsisText.setOsisIDWork()
* and the Work.setOsisWork() methods.
--- 89,92 ----
***************
*** 151,157 ****
/**
! * Calculated field: The full name including edition of the book, for example
! * "New International Version, Anglicised (Ser)".
! * The format is "name, edition (Driver)"
* @return The full name of this book
*/
--- 97,102 ----
/**
! * Calculated field: The full name of the book, for example
! * The format is "name, (Driver)"
* @return The full name of this book
*/
***************
*** 159,169 ****
/**
- * Calculated method: Do the 2 books have matching names.
- * @param book The book to compare to
- * @return true if the names match
- */
- public boolean isSameFamily(BookMetaData book);
-
- /**
* Calculated field: The name of the name, which could be helpful to
* distinguish similar Books available through 2 BookDrivers.
--- 104,107 ----
***************
*** 191,260 ****
/**
- * The SPEED_* constants specify how fast a Book implementation is.
- *
- * Important values include 5, were the remoting system will not remote
- * Books where getSpeed() >= 5 (to save re-remoting already remote Books).
- * 10 is also special - values > 10 indicate the data returned is likely to
- * be wrong (i.e. test data) So we should probably not ship systems with
- * BibleDrivers that return > 10.
- */
- public static final int SPEED_FASTEST = 10;
-
- /**
- * @see BookMetaData#SPEED_FASTEST
- */
- public static final int SPEED_FAST = 9;
-
- /**
- * @see BookMetaData#SPEED_FASTEST
- */
- public static final int SPEED_MEDIUM = 8;
-
- /**
- * @see BookMetaData#SPEED_FASTEST
- */
- public static final int SPEED_SLOW = 7;
-
- /**
- * @see BookMetaData#SPEED_FASTEST
- */
- public static final int SPEED_SLOWEST = 6;
-
- /**
- * @see BookMetaData#SPEED_FASTEST
- */
- public static final int SPEED_REMOTE_FASTEST = 5;
-
- /**
- * @see BookMetaData#SPEED_FASTEST
- */
- public static final int SPEED_REMOTE_FAST = 4;
-
- /**
- * @see BookMetaData#SPEED_FASTEST
- */
- public static final int SPEED_REMOTE_MEDIUM = 3;
-
- /**
- * @see BookMetaData#SPEED_FASTEST
- */
- public static final int SPEED_REMOTE_SLOW = 2;
-
- /**
- * @see BookMetaData#SPEED_FASTEST
- */
- public static final int SPEED_REMOTE_SLOWEST = 1;
-
- /**
- * @see BookMetaData#SPEED_FASTEST
- */
- public static final int SPEED_IGNORE = 0;
-
- /**
- * @see BookMetaData#SPEED_FASTEST
- */
- public static final int SPEED_INACCURATE = -1;
-
- /**
* The key for the type in the properties map
*/
--- 129,132 ----
***************
*** 274,278 ****
* The key for the name in the properties map
*/
! public static final String KEY_NAME = "Name"; //$NON-NLS-1$
/**
--- 146,150 ----
* The key for the name in the properties map
*/
! public static final String KEY_NAME = "Description"; //$NON-NLS-1$
/**
***************
*** 282,325 ****
/**
- * The key for the edition in the properties map
- */
- public static final String KEY_EDITION = "Edition"; //$NON-NLS-1$
-
- /**
* The key for the initials in the properties map
*/
public static final String KEY_INITIALS = "Initials"; //$NON-NLS-1$
- /**
- * The key for the speed in the properties map
- */
- public static final String KEY_SPEED = "Speed"; //$NON-NLS-1$
-
- /**
- * The key for the first pub in the properties map
- */
- public static final String KEY_FIRSTPUB = "FirstPublished"; //$NON-NLS-1$
-
- /**
- * The key for the openness in the properties map
- */
- public static final String KEY_OPENNESS = "Openness"; //$NON-NLS-1$
-
- /**
- * The key for the licence in the properties map
- */
- public static final String KEY_LICENCE = "Licence"; //$NON-NLS-1$
-
- /**
- * The default creation date.
- * Using new Date(0) is the same as FIRSTPUB_FORMAT.parse("1970-01-01")
- * but does not throw
- */
- public static final Date FIRSTPUB_DEFAULT = new Date(0L);
-
- /**
- * The default way for format published dates when converting to and from
- * strings
- */
- public static final DateFormat FIRSTPUB_FORMAT = new SimpleDateFormat("yyyy-MM-dd"); //$NON-NLS-1$
}
--- 154,160 ----
From jswordcvs at crosswire.org Tue Oct 5 15:03:11 2004
From: jswordcvs at crosswire.org (jswordcvs@crosswire.org)
Date: Tue Oct 5 15:03:16 2004
Subject: [jsword-svn] jsword/java/jsword/org/crosswire/jsword/book/sword s
Message-ID: <200410052203.i95M3BFc009983@www.crosswire.org>
Update of /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/sword
In directory www.crosswire.org:/tmp/cvs-serv9907/java/jsword/org/crosswire/jsword/book/sword
Modified Files:
CompressionType.java SwordConstants.java
SwordBookMetaData.java ModuleType.java
Log Message:
Improvments on reading SwordBookMetaData
Index: SwordBookMetaData.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/sword/SwordBookMetaData.java,v
retrieving revision 1.31
retrieving revision 1.32
diff -C2 -d -r1.31 -r1.32
*** SwordBookMetaData.java 21 Sep 2004 17:46:23 -0000 1.31
--- SwordBookMetaData.java 5 Oct 2004 22:03:09 -0000 1.32
***************
*** 10,15 ****
import java.net.URL;
import java.util.ArrayList;
! import java.util.Collections;
! import java.util.Date;
import java.util.Iterator;
import java.util.LinkedHashMap;
--- 10,14 ----
import java.net.URL;
import java.util.ArrayList;
! import java.util.HashSet;
[...1104 lines suppressed...]
! private Openness openness = Openness.UNKNOWN;
! private URL licence;
! private boolean leftToRight = true;
private StringBuffer data = new StringBuffer();
private String readahead;
! }
--- 1058,1069 ----
private Book book;
private BookDriver driver;
private String fullName;
private String displayName;
private String initials = ""; //$NON-NLS-1$
! private boolean supported;
private StringBuffer data = new StringBuffer();
private String readahead;
! private static Histogram histogram = new Histogram();
! private List warnings = new ArrayList();
!
! }
\ No newline at end of file
Index: CompressionType.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/sword/CompressionType.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** CompressionType.java 8 Sep 2004 19:55:07 -0000 1.2
--- CompressionType.java 5 Oct 2004 22:03:09 -0000 1.3
***************
*** 43,47 ****
protected Backend getBackend(SwordBookMetaData sbmd, String path) throws BookException
{
! BlockType blockType = BlockType.fromString(sbmd.getFirstValue(ConfigEntry.BLOCK_TYPE));
return new GZIPBackend(path, blockType);
}
--- 43,47 ----
protected Backend getBackend(SwordBookMetaData sbmd, String path) throws BookException
{
! BlockType blockType = BlockType.fromString(sbmd.getProperty(ConfigEntry.BLOCK_TYPE));
return new GZIPBackend(path, blockType);
}
Index: SwordConstants.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/sword/SwordConstants.java,v
retrieving revision 1.26
retrieving revision 1.27
diff -C2 -d -r1.26 -r1.27
*** SwordConstants.java 30 Aug 2004 09:27:07 -0000 1.26
--- SwordConstants.java 5 Oct 2004 22:03:09 -0000 1.27
***************
*** 226,230 ****
"Glossary", //$NON-NLS-1$
};
!
/**
* public domain
--- 226,230 ----
"Glossary", //$NON-NLS-1$
};
!
/**
* public domain
Index: ModuleType.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/sword/ModuleType.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** ModuleType.java 8 Sep 2004 19:55:07 -0000 1.9
--- ModuleType.java 5 Oct 2004 22:03:09 -0000 1.10
***************
*** 277,281 ****
public Book createBook(SwordBookMetaData sbmd, File progdir) throws BookException
{
! String dataPath = sbmd.getFirstValue(ConfigEntry.DATA_PATH);
File baseurl = new File(progdir, dataPath);
String path = baseurl.getAbsolutePath();
--- 277,281 ----
public Book createBook(SwordBookMetaData sbmd, File progdir) throws BookException
{
! String dataPath = sbmd.getProperty(ConfigEntry.DATA_PATH);
File baseurl = new File(progdir, dataPath);
String path = baseurl.getAbsolutePath();
***************
*** 301,305 ****
protected static Backend getCompressedBackend(SwordBookMetaData sbmd, String path) throws BookException
{
! String cStr = sbmd.getFirstValue(ConfigEntry.COMPRESS_TYPE);
if (cStr != null)
{
--- 301,305 ----
protected static Backend getCompressedBackend(SwordBookMetaData sbmd, String path) throws BookException
{
! String cStr = sbmd.getProperty(ConfigEntry.COMPRESS_TYPE);
if (cStr != null)
{
***************
*** 314,318 ****
protected static boolean isCompressedBackendSupported(SwordBookMetaData sbmd)
{
! String cStr = sbmd.getFirstValue(ConfigEntry.COMPRESS_TYPE);
if (cStr != null)
{
--- 314,318 ----
protected static boolean isCompressedBackendSupported(SwordBookMetaData sbmd)
{
! String cStr = sbmd.getProperty(ConfigEntry.COMPRESS_TYPE);
if (cStr != null)
{
From jswordcvs at crosswire.org Wed Oct 6 15:52:25 2004
From: jswordcvs at crosswire.org (jswordcvs@crosswire.org)
Date: Wed Oct 6 15:52:26 2004
Subject: [jsword-svn] jsword/java/jsword/org/crosswire/jsword/book/sword s
Message-ID: <200410062252.i96MqPme026979@www.crosswire.org>
Update of /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/sword
In directory www.crosswire.org:/tmp/cvs-serv26973/java/jsword/org/crosswire/jsword/book/sword
Modified Files:
SwordBookDriver.java
Log Message:
[BD-2] and linked issues
Index: SwordBookDriver.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/sword/SwordBookDriver.java,v
retrieving revision 1.33
retrieving revision 1.34
diff -C2 -d -r1.33 -r1.34
*** SwordBookDriver.java 2 Oct 2004 14:01:42 -0000 1.33
--- SwordBookDriver.java 6 Oct 2004 22:52:22 -0000 1.34
***************
*** 180,190 ****
/**
* Accessor for the Sword directory
! * @param dirs The new Sword directory
* @throws BookException
*/
! public static void setSwordPath(File[] dirs) throws BookException
{
! dirs = validateSwordPath(dirs);
! if (dirs == null)
{
return;
--- 180,190 ----
/**
* Accessor for the Sword directory
! * @param newDirs The new Sword directory
* @throws BookException
*/
! public static void setSwordPath(File[] newDirs) throws BookException
{
! newDirs = validateSwordPath(newDirs);
! if (newDirs == null)
{
return;
***************
*** 198,202 ****
}
! SwordBookDriver.dirs = dirs;
// Now we need to register ourselves
--- 198,202 ----
}
! SwordBookDriver.dirs = newDirs;
// Now we need to register ourselves
***************
*** 252,256 ****
if (pos == -1)
{
! File[] temp = new File[dirs.length + 1];
temp[0] = downloadDir;
for (int i = 0; i < files.length; i++)
--- 252,256 ----
if (pos == -1)
{
! File[] temp = new File[files.length + 1];
temp[0] = downloadDir;
for (int i = 0; i < files.length; i++)
From jswordcvs at crosswire.org Wed Oct 6 15:52:25 2004
From: jswordcvs at crosswire.org (jswordcvs@crosswire.org)
Date: Wed Oct 6 15:52:26 2004
Subject: [jsword-svn] jsword/java/jsword/org/crosswire/jsword/book s
Message-ID: <200410062252.i96MqPWO026986@www.crosswire.org>
Update of /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book
In directory www.crosswire.org:/tmp/cvs-serv26973/java/jsword/org/crosswire/jsword/book
Modified Files:
BookDriver.properties
Log Message:
[BD-2] and linked issues
Index: BookDriver.properties
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/BookDriver.properties,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** BookDriver.properties 14 Jun 2004 05:27:22 -0000 1.1
--- BookDriver.properties 6 Oct 2004 22:52:23 -0000 1.2
***************
*** 1,4 ****
sword=org.crosswire.jsword.book.sword.SwordBookDriver
! readings=org.crosswire.jsword.book.readings.ReadingsBookDriver
#ser=org.crosswire.jsword.book.ser.SerBookDriver
--- 1,4 ----
sword=org.crosswire.jsword.book.sword.SwordBookDriver
! #readings=org.crosswire.jsword.book.readings.ReadingsBookDriver
#ser=org.crosswire.jsword.book.ser.SerBookDriver
From jswordcvs at crosswire.org Wed Oct 6 15:52:31 2004
From: jswordcvs at crosswire.org (jswordcvs@crosswire.org)
Date: Wed Oct 6 15:52:32 2004
Subject: [jsword-svn]
bibledesktop/java/main/org/crosswire/bibledesktop/desktop s
Message-ID: <200410062252.i96MqVEj027016@www.crosswire.org>
Update of /cvs/jsword/bibledesktop/java/main/org/crosswire/bibledesktop/desktop
In directory www.crosswire.org:/tmp/cvs-serv26997/java/main/org/crosswire/bibledesktop/desktop
Modified Files:
Desktop.java
Log Message:
[BD-2] and linked issues
Index: Desktop.java
===================================================================
RCS file: /cvs/jsword/bibledesktop/java/main/org/crosswire/bibledesktop/desktop/Desktop.java,v
retrieving revision 1.30
retrieving revision 1.31
diff -C2 -d -r1.30 -r1.31
*** Desktop.java 18 Sep 2004 12:40:45 -0000 1.30
--- Desktop.java 6 Oct 2004 22:52:29 -0000 1.31
***************
*** 184,187 ****
--- 184,191 ----
init();
+ // This is technically overkill, but it does hide the reference pane if
+ // there are no reference works
+ refreshBooks();
+
// Configuration
startJob.setProgress(Msg.STARTUP_GENERAL_CONFIG.toString());
***************
*** 670,673 ****
--- 674,700 ----
String[] dnames = getFullNameArray(BookFilters.getDictionaries());
ChoiceFactory.getDataMap().put(DICTIONARY_KEY, dnames);
+
+ // Has the number of reference books changed?
+ int newRefBooks = dnames.length + cnames.length;
+ if (newRefBooks != refBooks)
+ {
+ // This method is called during setup
+ if (reference != null)
+ {
+ if (newRefBooks == 0)
+ {
+ sptBooks.setDividerLocation(8000);
+ }
+ else
+ {
+ int norm = (int) (sptBooks.getMaximumDividerLocation() * 0.8);
+ sptBooks.setDividerLocation(norm);
+ }
+ //reference.setVisible(newRefBooks != 0);
+ //sptBooks.setDividerLocation(0.8D);
+ }
+
+ refBooks = newRefBooks;
+ }
}
***************
*** 697,700 ****
--- 724,729 ----
}
+ private int refBooks = 0;
+
// Strings for the names of property files.
private static final String SPLASH_PROPS = "splash"; //$NON-NLS-1$
From jswordcvs at crosswire.org Wed Oct 6 15:52:36 2004
From: jswordcvs at crosswire.org (jswordcvs@crosswire.org)
Date: Wed Oct 6 15:52:37 2004
Subject: [jsword-svn] common/java/config/org/crosswire/common/config/swing s
Message-ID: <200410062252.i96MqaiI027046@www.crosswire.org>
Update of /cvs/jsword/common/java/config/org/crosswire/common/config/swing
In directory www.crosswire.org:/tmp/cvs-serv27031/java/config/org/crosswire/common/config/swing
Modified Files:
DirectoryField.java
Log Message:
[BD-2] and linked issues
Index: DirectoryField.java
===================================================================
RCS file: /cvs/jsword/common/java/config/org/crosswire/common/config/swing/DirectoryField.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** DirectoryField.java 28 Apr 2004 22:35:38 -0000 1.1
--- DirectoryField.java 6 Oct 2004 22:52:34 -0000 1.2
***************
*** 30,36 ****
{
/* (non-Javadoc)
! * @see org.crosswire.common.config.swing.FileField#browse()
*/
! protected void browse()
{
JFileChooser chooser = new JFileChooser(text.getText());
--- 30,36 ----
{
/* (non-Javadoc)
! * @see org.crosswire.common.config.swing.FileField#doBrowse()
*/
! public void doBrowse()
{
JFileChooser chooser = new JFileChooser(text.getText());
From jswordcvs at crosswire.org Wed Oct 6 15:52:36 2004
From: jswordcvs at crosswire.org (jswordcvs@crosswire.org)
Date: Wed Oct 6 15:52:37 2004
Subject: [jsword-svn] common/java/config/org/crosswire/common/config s
Message-ID: <200410062252.i96Mqa8b027039@www.crosswire.org>
Update of /cvs/jsword/common/java/config/org/crosswire/common/config
In directory www.crosswire.org:/tmp/cvs-serv27031/java/config/org/crosswire/common/config
Modified Files:
Msg.properties Msg.java Config.java
Added Files:
ConfigException.java
Log Message:
[BD-2] and linked issues
Index: Msg.properties
===================================================================
RCS file: /cvs/jsword/common/java/config/org/crosswire/common/config/Msg.properties,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** Msg.properties 14 Jun 2004 05:27:31 -0000 1.1
--- Msg.properties 6 Oct 2004 22:52:34 -0000 1.2
***************
*** 14,15 ****
--- 14,16 ----
StringOptionsChoice.ConfigNoMap=Missing element.
IntOptionsChoice.Ignore=Ignoring invalid option: {0}
+ Config.SetFail=Failed to set option: {0}
Index: Config.java
===================================================================
RCS file: /cvs/jsword/common/java/config/org/crosswire/common/config/Config.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** Config.java 16 Aug 2004 22:07:35 -0000 1.5
--- Config.java 6 Oct 2004 22:52:34 -0000 1.6
***************
*** 73,77 ****
{
/**
! * Ensure that we can not be instansiated
* @param title The name for dialog boxes and properties files
*/
--- 73,77 ----
{
/**
! * Config ctor
* @param title The name for dialog boxes and properties files
*/
***************
*** 265,269 ****
public void localToApplication(boolean force)
{
! int highest_change = Choice.PRIORITY_LOWEST;
if (force)
--- 265,269 ----
public void localToApplication(boolean force)
{
! int highestChange = Choice.PRIORITY_LOWEST;
if (force)
***************
*** 280,296 ****
{
String key = (String) it.next();
! Choice model = getChoice(key);
! if (model.getPriority() == priority)
{
! String old_value = model.getString();
! String new_value = local.getProperty(key);
// The new value shouldn't really be blank - obviously this
// choice has just been added, substitute the default.
! if (new_value == null)
{
! local.put(key, old_value);
! new_value = old_value;
}
--- 280,296 ----
{
String key = (String) it.next();
! Choice choice = getChoice(key);
! if (choice.getPriority() == priority)
{
! String oldValue = choice.getString();
! String newValue = local.getProperty(key);
// The new value shouldn't really be blank - obviously this
// choice has just been added, substitute the default.
! if (newValue == null)
{
! local.put(key, oldValue);
! newValue = oldValue;
}
***************
*** 301,317 ****
// changed.
if (force
! || priority < highest_change
! || !new_value.equals(old_value))
{
! log.info("Setting " + key + "=" + new_value + " (was " + old_value + ")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
! model.setString(new_value);
! if (priority > highest_change)
{
! highest_change = priority;
if (!force)
{
! log.info("Change at level " + highest_change + ", all changes will propogate regardless"); //$NON-NLS-1$ //$NON-NLS-2$
}
}
--- 301,317 ----
// changed.
if (force
! || priority < highestChange
! || !newValue.equals(oldValue))
{
! log.info("Setting " + key + "=" + newValue + " (was " + oldValue + ")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
! choice.setString(newValue);
! if (priority > highestChange)
{
! highestChange = priority;
if (!force)
{
! log.info("Change at level " + highestChange + ", all changes will propogate regardless"); //$NON-NLS-1$ //$NON-NLS-2$
}
}
***************
*** 320,325 ****
catch (Exception ex)
{
! log.warn("Failure with " + key + "=" + new_value, ex); //$NON-NLS-1$ //$NON-NLS-2$
! Reporter.informUser(this, ex);
}
}
--- 320,325 ----
catch (Exception ex)
{
! log.warn("Failure setting " + key + "=" + newValue, ex); //$NON-NLS-1$ //$NON-NLS-2$
! Reporter.informUser(this, new ConfigException(Msg.CONFIG_SETFAIL, ex, new Object[] { choice.getFullPath() } ));
}
}
***************
*** 413,423 ****
public static String getPath(String key)
{
! int last_dot = key.lastIndexOf('.');
! if (last_dot == -1)
{
throw new IllegalArgumentException("key=" + key + " does not contain a dot."); //$NON-NLS-1$ //$NON-NLS-2$
}
! return key.substring(0, last_dot);
}
--- 413,423 ----
public static String getPath(String key)
{
! int lastDot = key.lastIndexOf('.');
! if (lastDot == -1)
{
throw new IllegalArgumentException("key=" + key + " does not contain a dot."); //$NON-NLS-1$ //$NON-NLS-2$
}
! return key.substring(0, lastDot);
}
***************
*** 427,437 ****
public static String getLeaf(String key)
{
! int last_dot = key.lastIndexOf('.');
! if (last_dot == -1)
{
throw new IllegalArgumentException("key=" + key + " does not contain a dot."); //$NON-NLS-1$ //$NON-NLS-2$
}
! return key.substring(last_dot + 1);
}
--- 427,437 ----
public static String getLeaf(String key)
{
! int lastDot = key.lastIndexOf('.');
! if (lastDot == -1)
{
throw new IllegalArgumentException("key=" + key + " does not contain a dot."); //$NON-NLS-1$ //$NON-NLS-2$
}
! return key.substring(lastDot + 1);
}
***************
*** 442,446 ****
public void addConfigListener(ConfigListener li)
{
! listener_list.add(ConfigListener.class, li);
}
--- 442,446 ----
public void addConfigListener(ConfigListener li)
{
! listenerList.add(ConfigListener.class, li);
}
***************
*** 451,455 ****
public void removeConfigListener(ConfigListener li)
{
! listener_list.remove(ConfigListener.class, li);
}
--- 451,455 ----
public void removeConfigListener(ConfigListener li)
{
! listenerList.remove(ConfigListener.class, li);
}
***************
*** 460,464 ****
{
// Guaranteed to return a non-null array
! Object[] listeners = listener_list.getListenerList();
// Process the listeners last to first, notifying
--- 460,464 ----
{
// Guaranteed to return a non-null array
! Object[] listeners = listenerList.getListenerList();
// Process the listeners last to first, notifying
***************
*** 485,489 ****
{
// Guaranteed to return a non-null array
! Object[] listeners = listener_list.getListenerList();
// Process the listeners last to first, notifying
--- 485,489 ----
{
// Guaranteed to return a non-null array
! Object[] listeners = listenerList.getListenerList();
// Process the listeners last to first, notifying
***************
*** 532,535 ****
* The list of listeners
*/
! protected EventListenerList listener_list = new EventListenerList();
}
--- 532,535 ----
* The list of listeners
*/
! protected EventListenerList listenerList = new EventListenerList();
}
--- NEW FILE: ConfigException.java ---
package org.crosswire.common.config;
import org.crosswire.common.util.LucidException;
import org.crosswire.common.util.MsgBase;
/**
* Something went wrong while setting config options.
*
*
*
*
* Distribution Licence:
* JSword 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
* here , or by writing to:
* Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
* MA 02111-1307, USA
* The copyright to this program is held by it's authors.
*
* @see gnu.gpl.Licence
* @author Joe Walker [joe at eireneh dot com]
* @version $Id: ConfigException.java,v 1.1 2004/10/06 22:52:34 joe Exp $
*/
public class ConfigException extends LucidException
{
/**
* Construct the Exception with a message
* @param msg The resource id to read
*/
public ConfigException(MsgBase msg)
{
super(msg);
}
/**
* Construct the Exception with a message and a nested Exception
* @param msg The resource id to read
* @param ex The nested Exception
*/
public ConfigException(MsgBase msg, Throwable ex)
{
super(msg, ex);
}
/**
* Construct the Exception with a message and some Msg params
* @param msg The resource id to read
* @param params An array of parameters
*/
public ConfigException(MsgBase msg, Object[] params)
{
super(msg, params);
}
/**
* Construct the Exception with a message, a nested Exception and some Msg params
* @param msg The resource id to read
* @param ex The nested Exception
* @param params An array of parameters
*/
public ConfigException(MsgBase msg, Throwable ex, Object[] params)
{
super(msg, ex, params);
}
}
Index: Msg.java
===================================================================
RCS file: /cvs/jsword/common/java/config/org/crosswire/common/config/Msg.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** Msg.java 28 Apr 2004 22:35:38 -0000 1.1
--- Msg.java 6 Oct 2004 22:52:34 -0000 1.2
***************
*** 37,40 ****
--- 37,41 ----
static final Msg NO_HELP = new Msg("AbstractReflectedChoice.NoHelp"); //$NON-NLS-1$
static final Msg IGNORE = new Msg("IntOptionsChoice.Ignore"); //$NON-NLS-1$
+ static final Msg CONFIG_SETFAIL = new Msg("Config.SetFail"); //$NON-NLS-1$
/**
From jswordcvs at crosswire.org Wed Oct 6 15:53:52 2004
From: jswordcvs at crosswire.org (jswordcvs@crosswire.org)
Date: Wed Oct 6 15:53:54 2004
Subject: [jsword-svn] jsword/java/jsword/org/crosswire/jsword/book s
Message-ID: <200410062253.i96MrqmL027084@www.crosswire.org>
Update of /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book
In directory www.crosswire.org:/tmp/cvs-serv27080/java/jsword/org/crosswire/jsword/book
Modified Files:
BookDriver.properties
Log Message:
[BD-2] and linked issues - oops forgot to remove debug
Index: BookDriver.properties
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/BookDriver.properties,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** BookDriver.properties 6 Oct 2004 22:52:23 -0000 1.2
--- BookDriver.properties 6 Oct 2004 22:53:50 -0000 1.3
***************
*** 1,4 ****
sword=org.crosswire.jsword.book.sword.SwordBookDriver
! #readings=org.crosswire.jsword.book.readings.ReadingsBookDriver
#ser=org.crosswire.jsword.book.ser.SerBookDriver
--- 1,4 ----
sword=org.crosswire.jsword.book.sword.SwordBookDriver
! readings=org.crosswire.jsword.book.readings.ReadingsBookDriver
#ser=org.crosswire.jsword.book.ser.SerBookDriver
From jswordcvs at crosswire.org Sat Oct 9 14:44:35 2004
From: jswordcvs at crosswire.org (jswordcvs@crosswire.org)
Date: Sat Oct 9 14:44:37 2004
Subject: [jsword-svn] jsword/java/limbo/org/crosswire/jsword/book/search -
New directorys
Message-ID: <200410092144.i99LiZMa029989@www.crosswire.org>
Update of /cvs/jsword/jsword/java/limbo/org/crosswire/jsword/book/search
In directory www.crosswire.org:/tmp/cvs-serv29983/java/limbo/org/crosswire/jsword/book/search
Log Message:
Directory /cvs/jsword/jsword/java/limbo/org/crosswire/jsword/book/search added to the repository
From jswordcvs at crosswire.org Sat Oct 9 14:44:35 2004
From: jswordcvs at crosswire.org (jswordcvs@crosswire.org)
Date: Sat Oct 9 14:44:37 2004
Subject: [jsword-svn]
jsword/java/limbo/org/crosswire/jsword/book/search/ser - New
directorys
Message-ID: <200410092144.i99LiZfB029993@www.crosswire.org>
Update of /cvs/jsword/jsword/java/limbo/org/crosswire/jsword/book/search/ser
In directory www.crosswire.org:/tmp/cvs-serv29983/java/limbo/org/crosswire/jsword/book/search/ser
Log Message:
Directory /cvs/jsword/jsword/java/limbo/org/crosswire/jsword/book/search/ser added to the repository
From jswordcvs at crosswire.org Sat Oct 9 14:44:44 2004
From: jswordcvs at crosswire.org (jswordcvs@crosswire.org)
Date: Sat Oct 9 14:44:45 2004
Subject: [jsword-svn] biblemapper/java/main/org/crosswire/biblemapper/model s
Message-ID: <200410092144.i99LiilZ030029@www.crosswire.org>
Update of /cvs/jsword/biblemapper/java/main/org/crosswire/biblemapper/model
In directory www.crosswire.org:/tmp/cvs-serv30023/java/main/org/crosswire/biblemapper/model
Modified Files:
LinkArray.java
Log Message:
indexing updates
Index: LinkArray.java
===================================================================
RCS file: /cvs/jsword/biblemapper/java/main/org/crosswire/biblemapper/model/LinkArray.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** LinkArray.java 8 Aug 2004 11:39:38 -0000 1.4
--- LinkArray.java 9 Oct 2004 21:44:42 -0000 1.5
***************
*** 12,16 ****
import org.crosswire.jsword.book.Book;
import org.crosswire.jsword.book.BookData;
- import org.crosswire.jsword.book.Search;
import org.crosswire.jsword.passage.BibleInfo;
import org.crosswire.jsword.passage.NoSuchVerseException;
--- 12,15 ----
***************
*** 228,232 ****
BookData bdata = book.getData(find);
String text = bdata.getPlainText();
! PassageTally temp = (PassageTally) book.find(new Search(text, false));
temp.setOrdering(PassageTally.ORDER_TALLY);
total.addAll(temp);
--- 227,231 ----
BookData bdata = book.getData(find);
String text = bdata.getPlainText();
! PassageTally temp = (PassageTally) book.find(text);
temp.setOrdering(PassageTally.ORDER_TALLY);
total.addAll(temp);
From jswordcvs at crosswire.org Sat Oct 9 14:44:44 2004
From: jswordcvs at crosswire.org (jswordcvs@crosswire.org)
Date: Sat Oct 9 14:44:45 2004
Subject: [jsword-svn] biblemapper/java/main/org/crosswire/biblemapper/swing s
Message-ID: <200410092144.i99LiiJu030035@www.crosswire.org>
Update of /cvs/jsword/biblemapper/java/main/org/crosswire/biblemapper/swing
In directory www.crosswire.org:/tmp/cvs-serv30023/java/main/org/crosswire/biblemapper/swing
Modified Files:
CliMapper.java
Log Message:
indexing updates
Index: CliMapper.java
===================================================================
RCS file: /cvs/jsword/biblemapper/java/main/org/crosswire/biblemapper/swing/CliMapper.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** CliMapper.java 8 Aug 2004 11:39:38 -0000 1.4
--- CliMapper.java 9 Oct 2004 21:44:42 -0000 1.5
***************
*** 11,15 ****
import org.crosswire.jsword.book.BookMetaData;
import org.crosswire.jsword.book.Books;
! import org.crosswire.jsword.book.Search;
import org.crosswire.jsword.passage.BibleInfo;
import org.crosswire.jsword.passage.NoSuchVerseException;
--- 11,16 ----
import org.crosswire.jsword.book.BookMetaData;
import org.crosswire.jsword.book.Books;
! import org.crosswire.jsword.book.search.parse.IndexSearcher;
! import org.crosswire.jsword.book.search.parse.PhraseParamWord;
import org.crosswire.jsword.passage.BibleInfo;
import org.crosswire.jsword.passage.NoSuchVerseException;
***************
*** 100,104 ****
BookData bdata = book.getData(find);
String text = bdata.getPlainText();
! PassageTally temp = (PassageTally) book.find(new Search(text, true));
temp.setOrdering(PassageTally.ORDER_TALLY);
total.addAll(temp);
--- 101,107 ----
BookData bdata = book.getData(find);
String text = bdata.getPlainText();
! String quote = IndexSearcher.getPreferredSyntax(PhraseParamWord.class);
! text = quote + text + quote;
! PassageTally temp = (PassageTally) book.find(text);
temp.setOrdering(PassageTally.ORDER_TALLY);
total.addAll(temp);
From jswordcvs at crosswire.org Sat Oct 9 14:45:06 2004
From: jswordcvs at crosswire.org (jswordcvs@crosswire.org)
Date: Sat Oct 9 14:45:09 2004
Subject: [jsword-svn] jsword/java/jswordtest/org/crosswire/jsword/book/test s
Message-ID: <200410092145.i99Lj6Ts030107@www.crosswire.org>
Update of /cvs/jsword/jsword/java/jswordtest/org/crosswire/jsword/book/test
In directory www.crosswire.org:/tmp/cvs-serv30045/java/jswordtest/org/crosswire/jsword/book/test
Modified Files:
Speed.java
Log Message:
indexing updates
Index: Speed.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jswordtest/org/crosswire/jsword/book/test/Speed.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** Speed.java 27 Jul 2004 21:42:38 -0000 1.7
--- Speed.java 9 Oct 2004 21:45:04 -0000 1.8
***************
*** 3,7 ****
import org.crosswire.common.util.Reporter;
import org.crosswire.jsword.book.Book;
- import org.crosswire.jsword.book.Search;
import org.crosswire.jsword.passage.Key;
import org.crosswire.jsword.passage.KeyUtil;
--- 3,6 ----
***************
*** 74,78 ****
// Part 1, a best match, and doc generate
! tally = (PassageTally) book.find(new Search("In the beginning god created the heavens and the earth", true)); //$NON-NLS-1$
tally.trimVerses(35);
dummyDisplay(tally);
--- 73,77 ----
// Part 1, a best match, and doc generate
! tally = (PassageTally) book.find("\"In the beginning god created the heavens and the earth\""); //$NON-NLS-1$
tally.trimVerses(35);
dummyDisplay(tally);
***************
*** 80,84 ****
// Part 2, another best match, and doc generate
! tally = (PassageTally) book.find(new Search("for god so loves the world that he gave his only begotten son", true)); //$NON-NLS-1$
tally.trimVerses(35);
dummyDisplay(tally);
--- 79,83 ----
// Part 2, another best match, and doc generate
! tally = (PassageTally) book.find("\"for god so loves the world that he gave his only begotten son\""); //$NON-NLS-1$
tally.trimVerses(35);
dummyDisplay(tally);
***************
*** 86,90 ****
// Part 3, a power match, and doc generate
! String nextInput = book.find(new Search("aaron & manna", false)).getName(); //$NON-NLS-1$
Key key = book.getKey(nextInput);
Passage ref = KeyUtil.getPassage(key);
--- 85,89 ----
// Part 3, a power match, and doc generate
! String nextInput = book.find("aaron & manna").getName(); //$NON-NLS-1$
Key key = book.getKey(nextInput);
Passage ref = KeyUtil.getPassage(key);
From jswordcvs at crosswire.org Sat Oct 9 14:45:07 2004
From: jswordcvs at crosswire.org (jswordcvs@crosswire.org)
Date: Sat Oct 9 14:45:09 2004
Subject: [jsword-svn] jsword/java/jsword/org/crosswire/jsword/book/sword s
Message-ID: <200410092145.i99Lj7Ul030119@www.crosswire.org>
Update of /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/sword
In directory www.crosswire.org:/tmp/cvs-serv30045/java/jsword/org/crosswire/jsword/book/sword
Modified Files:
SwordBookDriver.java SwordBookMetaData.java
Log Message:
indexing updates
Index: SwordBookDriver.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/sword/SwordBookDriver.java,v
retrieving revision 1.34
retrieving revision 1.35
diff -C2 -d -r1.34 -r1.35
*** SwordBookDriver.java 6 Oct 2004 22:52:22 -0000 1.34
--- SwordBookDriver.java 9 Oct 2004 21:45:05 -0000 1.35
***************
*** 16,20 ****
--- 16,23 ----
import org.crosswire.jsword.book.BookMetaData;
import org.crosswire.jsword.book.Books;
+ import org.crosswire.jsword.book.IndexStatus;
import org.crosswire.jsword.book.basic.AbstractBookDriver;
+ import org.crosswire.jsword.book.search.IndexManager;
+ import org.crosswire.jsword.book.search.IndexManagerFactory;
import org.crosswire.jsword.util.Project;
***************
*** 89,92 ****
--- 92,105 ----
Book book = createBook(sbmd, dirs[j]);
valid.add(book.getBookMetaData());
+
+ IndexManager imanager = IndexManagerFactory.getIndexManager();
+ if (imanager.isIndexed(book))
+ {
+ sbmd.setIndexStatus(IndexStatus.DONE);
+ }
+ else
+ {
+ sbmd.setIndexStatus(IndexStatus.UNDONE);
+ }
}
else
Index: SwordBookMetaData.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/sword/SwordBookMetaData.java,v
retrieving revision 1.32
retrieving revision 1.33
diff -C2 -d -r1.32 -r1.33
*** SwordBookMetaData.java 5 Oct 2004 22:03:09 -0000 1.32
--- SwordBookMetaData.java 9 Oct 2004 21:45:05 -0000 1.33
***************
*** 30,33 ****
--- 30,35 ----
import org.crosswire.jsword.book.BookMetaData;
import org.crosswire.jsword.book.BookType;
+ import org.crosswire.jsword.book.IndexStatus;
+ import org.crosswire.jsword.book.basic.AbstractBookMetaData;
import org.crosswire.jsword.book.filter.Filter;
import org.crosswire.jsword.book.filter.FilterFactory;
***************
*** 67,71 ****
* @version $Id$
*/
! public class SwordBookMetaData implements BookMetaData
{
/**
--- 69,73 ----
* @version $Id$
*/
! public class SwordBookMetaData extends AbstractBookMetaData
{
/**
***************
*** 152,158 ****
// set the key property file entries
prop.put(KEY_INITIALS, initials);
!
validate();
!
if (!isSupported())
{
--- 154,160 ----
// set the key property file entries
prop.put(KEY_INITIALS, initials);
!
validate();
!
if (!isSupported())
{
***************
*** 323,327 ****
prop = orderedMap;
}
!
private void organize(Map result, Object[] category)
{
--- 325,332 ----
prop = orderedMap;
}
!
! /**
! *
! */
private void organize(Map result, Object[] category)
{
***************
*** 337,340 ****
--- 342,348 ----
}
+ /**
+ *
+ */
public void validate()
{
***************
*** 391,397 ****
log.debug("Book not supported: " + internal + " because ModuleType (" + modTypeName + ") is not supported."); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
supported = false;
! return;
}
!
// report on unknown config entries
for (Iterator kit = getKeys(); kit.hasNext();)
--- 399,405 ----
log.debug("Book not supported: " + internal + " because ModuleType (" + modTypeName + ") is not supported."); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
supported = false;
! return;
}
!
// report on unknown config entries
for (Iterator kit = getKeys(); kit.hasNext();)
***************
*** 403,413 ****
}
}
!
// output collected warnings
! for (Iterator kit = warnings.iterator(); kit.hasNext(); )
{
log.warn((String) kit.next());
}
-
}
--- 411,420 ----
}
}
!
// output collected warnings
! for (Iterator kit = warnings.iterator(); kit.hasNext();)
{
log.warn((String) kit.next());
}
}
***************
*** 516,520 ****
// strip { and } which are found in {\i text }
copy = copy.replaceAll("[{}]", ""); //$NON-NLS-1$ //$NON-NLS-2$
!
if (!allowsRTF.contains(key))
{
--- 523,527 ----
// strip { and } which are found in {\i text }
copy = copy.replaceAll("[{}]", ""); //$NON-NLS-1$ //$NON-NLS-2$
!
if (!allowsRTF.contains(key))
{
***************
*** 739,742 ****
--- 746,768 ----
}
+ /* (non-Javadoc)
+ * @see org.crosswire.jsword.book.BookMetaData#getIndexStatus()
+ */
+ public IndexStatus getIndexStatus()
+ {
+ return indexStatus;
+ }
+
+ /* (non-Javadoc)
+ * @see org.crosswire.jsword.book.BookMetaData#setIndexStatus(java.lang.String)
+ */
+ public void setIndexStatus(IndexStatus newValue)
+ {
+ IndexStatus oldValue = this.indexStatus;
+ this.indexStatus = newValue;
+ prop.put(KEY_INDEXSTATUS, newValue);
+ firePropertyChange(KEY_INDEXSTATUS, oldValue, newValue);
+ }
+
/**
* Get the string value for the property or null if it is not defined.
***************
*** 783,786 ****
--- 809,815 ----
}
+ /**
+ *
+ */
private String computeFullName()
{
***************
*** 862,866 ****
}
-
// The real bit ...
BookMetaData that = (BookMetaData) obj;
--- 891,894 ----
***************
*** 930,1004 ****
private static final Object[] BASIC_INFO =
{
! KEY_INITIALS,
! ConfigEntry.DESCRIPTION,
! KEY_TYPE,
! ConfigEntry.LCSH,
! ConfigEntry.CATEGORY,
! ConfigEntry.VERSION,
! ConfigEntry.SWORD_VERSION_DATE,
};
private static final Object[] LANG_INFO =
{
! KEY_LANGUAGE,
! ConfigEntry.LANG,
! ConfigEntry.GLOSSARY_FROM,
! ConfigEntry.GLOSSARY_TO,
! ConfigEntry.LEXICON_FROM,
! ConfigEntry.LEXICON_TO,
};
private static final Object[] HISTORY_INFO =
{
! ConfigEntry.HISTORY_2_5,
! ConfigEntry.HISTORY_2_2,
! ConfigEntry.HISTORY_2_1,
! ConfigEntry.HISTORY_2_0,
! ConfigEntry.HISTORY_1_9,
! ConfigEntry.HISTORY_1_8,
! ConfigEntry.HISTORY_1_7,
! ConfigEntry.HISTORY_1_6,
! ConfigEntry.HISTORY_1_5,
! ConfigEntry.HISTORY_1_4,
! ConfigEntry.HISTORY_1_3,
! ConfigEntry.HISTORY_1_2,
! ConfigEntry.HISTORY_1_1,
! ConfigEntry.HISTORY_1_0,
! ConfigEntry.HISTORY_0_92,
! ConfigEntry.HISTORY_0_91,
! ConfigEntry.HISTORY_0_9,
! ConfigEntry.HISTORY_0_3,
! ConfigEntry.HISTORY_0_2,
! ConfigEntry.HISTORY_0_1
};
private static final Object[] SYSTEM_INFO =
{
! ConfigEntry.DATA_PATH,
! ConfigEntry.MOD_DRV,
! ConfigEntry.SOURCE_TYPE,
! ConfigEntry.BLOCK_TYPE,
! ConfigEntry.COMPRESS_TYPE,
! ConfigEntry.ENCODING,
! ConfigEntry.MINIMUM_VERSION,
! ConfigEntry.MINIMUM_SWORD_VERSION,
! ConfigEntry.DIRECTION
};
private static final Object[] COPYRIGHT_INFO =
{
! ConfigEntry.ABOUT,
! ConfigEntry.DISTRIBUTION,
! ConfigEntry.DISTRIBUTION_LICENSE,
! ConfigEntry.DISTRIBUTION_NOTES,
! ConfigEntry.DISTRIBUTION_SOURCE,
! ConfigEntry.COPYRIGHT,
! ConfigEntry.COPYRIGHT_DATE,
! ConfigEntry.COPYRIGHT_HOLDER,
! ConfigEntry.COPYRIGHT_CONTACT_NAME,
! ConfigEntry.COPYRIGHT_CONTACT_ADDRESS,
! ConfigEntry.COPYRIGHT_CONTACT_EMAIL,
! ConfigEntry.COPYRIGHT_NOTES,
! ConfigEntry.TEXT_SOURCE,
};
--- 958,1032 ----
private static final Object[] BASIC_INFO =
{
! KEY_INITIALS,
! ConfigEntry.DESCRIPTION,
! KEY_TYPE,
! ConfigEntry.LCSH,
! ConfigEntry.CATEGORY,
! ConfigEntry.VERSION,
! ConfigEntry.SWORD_VERSION_DATE,
};
private static final Object[] LANG_INFO =
{
! KEY_LANGUAGE,
! ConfigEntry.LANG,
! ConfigEntry.GLOSSARY_FROM,
! ConfigEntry.GLOSSARY_TO,
! ConfigEntry.LEXICON_FROM,
! ConfigEntry.LEXICON_TO,
};
private static final Object[] HISTORY_INFO =
{
! ConfigEntry.HISTORY_2_5,
! ConfigEntry.HISTORY_2_2,
! ConfigEntry.HISTORY_2_1,
! ConfigEntry.HISTORY_2_0,
! ConfigEntry.HISTORY_1_9,
! ConfigEntry.HISTORY_1_8,
! ConfigEntry.HISTORY_1_7,
! ConfigEntry.HISTORY_1_6,
! ConfigEntry.HISTORY_1_5,
! ConfigEntry.HISTORY_1_4,
! ConfigEntry.HISTORY_1_3,
! ConfigEntry.HISTORY_1_2,
! ConfigEntry.HISTORY_1_1,
! ConfigEntry.HISTORY_1_0,
! ConfigEntry.HISTORY_0_92,
! ConfigEntry.HISTORY_0_91,
! ConfigEntry.HISTORY_0_9,
! ConfigEntry.HISTORY_0_3,
! ConfigEntry.HISTORY_0_2,
! ConfigEntry.HISTORY_0_1
};
private static final Object[] SYSTEM_INFO =
{
! ConfigEntry.DATA_PATH,
! ConfigEntry.MOD_DRV,
! ConfigEntry.SOURCE_TYPE,
! ConfigEntry.BLOCK_TYPE,
! ConfigEntry.COMPRESS_TYPE,
! ConfigEntry.ENCODING,
! ConfigEntry.MINIMUM_VERSION,
! ConfigEntry.MINIMUM_SWORD_VERSION,
! ConfigEntry.DIRECTION
};
private static final Object[] COPYRIGHT_INFO =
{
! ConfigEntry.ABOUT,
! ConfigEntry.DISTRIBUTION,
! ConfigEntry.DISTRIBUTION_LICENSE,
! ConfigEntry.DISTRIBUTION_NOTES,
! ConfigEntry.DISTRIBUTION_SOURCE,
! ConfigEntry.COPYRIGHT,
! ConfigEntry.COPYRIGHT_DATE,
! ConfigEntry.COPYRIGHT_HOLDER,
! ConfigEntry.COPYRIGHT_CONTACT_NAME,
! ConfigEntry.COPYRIGHT_CONTACT_ADDRESS,
! ConfigEntry.COPYRIGHT_CONTACT_EMAIL,
! ConfigEntry.COPYRIGHT_NOTES,
! ConfigEntry.TEXT_SOURCE,
};
***************
*** 1038,1042 ****
}
-
/**
* A map of lists of known keys. Keys are presented in insertion order
--- 1066,1069 ----
***************
*** 1066,1069 ****
private static Histogram histogram = new Histogram();
private List warnings = new ArrayList();
!
! }
\ No newline at end of file
--- 1093,1096 ----
private static Histogram histogram = new Histogram();
private List warnings = new ArrayList();
! private IndexStatus indexStatus = IndexStatus.UNDONE;
! }
From jswordcvs at crosswire.org Sat Oct 9 14:45:07 2004
From: jswordcvs at crosswire.org (jswordcvs@crosswire.org)
Date: Sat Oct 9 14:45:10 2004
Subject: [jsword-svn]
jsword/java/jsword/org/crosswire/jsword/book/search/ser s
Message-ID: <200410092145.i99Lj72t030128@www.crosswire.org>
Update of /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/search/ser
In directory www.crosswire.org:/tmp/cvs-serv30045/java/jsword/org/crosswire/jsword/book/search/ser
Removed Files:
Msg.java Msg.properties package.html SerIndex.java
Log Message:
indexing updates
--- package.html DELETED ---
--- Msg.properties DELETED ---
--- SerIndex.java DELETED ---
--- Msg.java DELETED ---
From jswordcvs at crosswire.org Sat Oct 9 14:45:06 2004
From: jswordcvs at crosswire.org (jswordcvs@crosswire.org)
Date: Sat Oct 9 14:45:10 2004
Subject: [jsword-svn] jsword/java/jsword/org/crosswire/jsword/book/search s
Message-ID: <200410092145.i99Lj6Sl030089@www.crosswire.org>
Update of /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/search
In directory www.crosswire.org:/tmp/cvs-serv30045/java/jsword/org/crosswire/jsword/book/search
Modified Files:
Index.java Msg.java IndexManager.java Searcher.java
Msg.properties SearcherFactory.java
Added Files:
IndexManagerFactory.java IndexManager.properties
Removed Files:
Matcher.java IndexFactory.java Matcher.properties
MatcherFactory.java Index.properties
Log Message:
indexing updates
--- Matcher.java DELETED ---
--- NEW FILE: IndexManagerFactory.java ---
package org.crosswire.jsword.book.search;
import org.crosswire.common.util.ClassUtil;
import org.crosswire.common.util.Logger;
/**
* A Factory class for IndexManagers.
*
*
*
*
* Distribution Licence:
* JSword 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
* here , or by writing to:
* Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
* MA 02111-1307, USA
* The copyright to this program is held by it's authors.
*
* @see gnu.gpl.Licence
* @author Joe Walker [joe at eireneh dot com]
* @version $Id: IndexManagerFactory.java,v 1.1 2004/10/09 21:45:04 joe Exp $
*/
public class IndexManagerFactory
{
/**
* Prevent Instansiation
*/
private IndexManagerFactory()
{
}
/**
* Create a new IndexManager.
*/
public static IndexManager getIndexManager()
{
return instance;
}
/**
* The singleton
*/
private static IndexManager instance = null;
/**
* The log stream
*/
private static final Logger log = Logger.getLogger(IndexManagerFactory.class);
/**
* Setup the instance
*/
static
{
try
{
Class impl = ClassUtil.getImplementor(IndexManager.class);
instance = (IndexManager) impl.newInstance();
}
catch (Exception ex)
{
log.error("createIndexManager failed", ex); //$NON-NLS-1$
}
}
}
Index: SearcherFactory.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/search/SearcherFactory.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** SearcherFactory.java 29 Sep 2004 22:21:23 -0000 1.1
--- SearcherFactory.java 9 Oct 2004 21:45:04 -0000 1.2
***************
*** 3,6 ****
--- 3,7 ----
import org.crosswire.common.util.ClassUtil;
import org.crosswire.common.util.Logger;
+ import org.crosswire.jsword.book.Book;
/**
***************
*** 40,47 ****
* Create a new Searcher.
*/
! public static Searcher createSearcher(Index index) throws InstantiationException
{
try
{
Class impl = ClassUtil.getImplementor(Searcher.class);
Searcher parser = (Searcher) impl.newInstance();
--- 41,51 ----
* Create a new Searcher.
*/
! public static Searcher createSearcher(Book book) throws InstantiationException
{
try
{
+ IndexManager imanager = IndexManagerFactory.getIndexManager();
+ Index index = imanager.getIndex(book);
+
Class impl = ClassUtil.getImplementor(Searcher.class);
Searcher parser = (Searcher) impl.newInstance();
Index: Msg.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/search/Msg.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** Msg.java 29 Sep 2004 22:21:23 -0000 1.9
--- Msg.java 9 Oct 2004 21:45:04 -0000 1.10
***************
*** 29,34 ****
class Msg extends MsgBase
{
! static final Msg TYPE_INDEXGEN = new Msg("IndexManager.TypeIndexGen"); //$NON-NLS-1$
! static final Msg INDEXING = new Msg("IndexManager.Indexing"); //$NON-NLS-1$
/**
--- 29,33 ----
class Msg extends MsgBase
{
! static final Msg Example = new Msg("Example.Example"); //$NON-NLS-1$
/**
Index: Searcher.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/search/Searcher.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** Searcher.java 29 Sep 2004 22:21:23 -0000 1.5
--- Searcher.java 9 Oct 2004 21:45:04 -0000 1.6
***************
*** 39,46 ****
* Take a search string and decipher it into a Passage.
* @param search The string to be searched for
- * @param restriction What verses are we interested in looking in?
- * @see org.crosswire.jsword.book.Search#UNRESTRICTED
* @return The matching verses
*/
! public Key search(String search, Key restriction) throws BookException;
}
--- 39,44 ----
* Take a search string and decipher it into a Passage.
* @param search The string to be searched for
* @return The matching verses
*/
! public Key search(String search) throws BookException;
}
--- MatcherFactory.java DELETED ---
Index: IndexManager.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/search/IndexManager.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** IndexManager.java 29 Sep 2004 22:21:23 -0000 1.1
--- IndexManager.java 9 Oct 2004 21:45:04 -0000 1.2
***************
*** 1,11 ****
package org.crosswire.jsword.book.search;
! import java.util.HashSet;
! import java.util.Iterator;
! import java.util.Set;
!
! import org.crosswire.common.progress.Job;
! import org.crosswire.common.progress.JobManager;
! import org.crosswire.common.util.Reporter;
/**
--- 1,6 ----
package org.crosswire.jsword.book.search;
! import org.crosswire.jsword.book.Book;
! import org.crosswire.jsword.book.BookException;
/**
***************
*** 33,114 ****
* @version $Id$
*/
! public class IndexManager
{
/**
! *
! */
! public static IndexManager instance()
! {
! return instance;
! }
!
! /**
! *
! */
! public void createIndex(Index index)
! {
! Reporter.informUser(this, Msg.TYPE_INDEXGEN);
!
! todo.add(index);
!
! Thread work = new Thread(runner);
! work.start();
! }
!
! /**
! * The index creation thread
! */
! private class IndexerRunnable implements Runnable
! {
! /* (non-Javadoc)
! * @see java.lang.Runnable#run()
! */
! public void run()
! {
! running = true;
!
! Iterator it = todo.iterator();
! while (it.hasNext())
! {
! Index index = (Index) it.next();
! Job job = JobManager.createJob(Msg.INDEXING.toString(), Thread.currentThread(), false);
!
! try
! {
! index.generateSearchIndex(job);
! }
! catch (Exception ex)
! {
! Reporter.informUser(IndexManager.class, ex);
! job.ignoreTimings();
! }
! finally
! {
! job.done();
! }
! }
!
! running = false;
! }
! }
!
! /**
! *
*/
! private static IndexManager instance = new IndexManager();
/**
! * The thread worker that creates the indexes.
*/
! private Runnable runner = new IndexerRunnable();
/**
! * The books to be indexed
*/
! protected Set todo = new HashSet();
/**
! * Is there an index generation in progress?
*/
! protected boolean running = false;
}
--- 28,53 ----
* @version $Id$
*/
! public interface IndexManager
{
/**
! * Detects if index data has been stored for this Bible already
*/
! public boolean isIndexed(Book book);
/**
! * Create a new Searcher.
*/
! public Index getIndex(Book book) throws BookException;
/**
! * Read from the given source version to generate ourselves. On completion
! * of this method the index should be usable.
*/
! public void scheduleIndexCreation(Book book);
/**
! * Tidy up after yourself and remove all the files that make up any indexes
! * you created.
*/
! public void deleteIndex(Book book) throws BookException;
}
--- NEW FILE: IndexManager.properties ---
default=org.crosswire.jsword.book.search.lucene.LuceneIndexManager
Index: Msg.properties
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/search/Msg.properties,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** Msg.properties 29 Sep 2004 22:21:23 -0000 1.2
--- Msg.properties 9 Oct 2004 21:45:04 -0000 1.3
***************
*** 6,9 ****
# It should have no spaces or other punctuation (e.g. _, -, ', ...)
! IndexManager.TypeIndexGen=Generating index for this work. Search results will be more accurate when index is complete.
! IndexManager.Indexing=Indexing Bible Data
--- 6,8 ----
# It should have no spaces or other punctuation (e.g. _, -, ', ...)
! Example.Example=Example
Index: Index.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/search/Index.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** Index.java 29 Sep 2004 22:21:23 -0000 1.8
--- Index.java 9 Oct 2004 21:45:04 -0000 1.9
***************
*** 1,8 ****
package org.crosswire.jsword.book.search;
- import java.io.IOException;
-
- import org.crosswire.common.progress.Job;
- import org.crosswire.jsword.book.Book;
import org.crosswire.jsword.book.BookException;
import org.crosswire.jsword.passage.Key;
--- 1,4 ----
***************
*** 36,47 ****
{
/**
- * An initializer type method so we can configure the Search engine at
- * runtime. This method is run first of all, before anything else and should
- * do everything it can to ensure that future method calls will be error
- * free without consuming significant system resources.
- */
- public void init(Book book) throws BookException;
-
- /**
* For a given word find a list of references to it.
* If the word
being searched for is null then an empty Key
--- 32,35 ----
***************
*** 60,85 ****
* @return A new Key representing the given string, if possible
* @throws NoSuchKeyException If the string can not be turned into a Key
*/
public Key getKey(String name) throws NoSuchKeyException;
-
- /**
- * Tidy up after yourself and remove all the files that make up any indexes
- * you created.
- */
- public void delete() throws BookException;
-
- /**
- * Detects if index data has been stored for this Bible already
- */
- public boolean isIndexed();
-
- /**
- * Read from the given source version to generate ourselves. On completion
- * of this method the index should be usable. If this is not the natural
- * way this emthod finishes then it should be possible to call loadIndexes()
- * @param ajob The place to report progress
- * @throws IOException if the load fails to read from disk
- * @throws BookException if there is a problem reading from the Bible
- */
- public void generateSearchIndex(Job ajob) throws IOException, BookException, NoSuchKeyException;
}
--- 48,53 ----
* @return A new Key representing the given string, if possible
* @throws NoSuchKeyException If the string can not be turned into a Key
+ * @see org.crosswire.jsword.passage.KeyFactory#getKey(String)
*/
public Key getKey(String name) throws NoSuchKeyException;
}
--- Matcher.properties DELETED ---
--- Index.properties DELETED ---
--- IndexFactory.java DELETED ---
From jswordcvs at crosswire.org Sat Oct 9 14:45:06 2004
From: jswordcvs at crosswire.org (jswordcvs@crosswire.org)
Date: Sat Oct 9 14:45:10 2004
Subject: [jsword-svn]
jsword/java/limbo/org/crosswire/jsword/book/search/ser s
Message-ID: <200410092145.i99Lj6PX030099@www.crosswire.org>
Update of /cvs/jsword/jsword/java/limbo/org/crosswire/jsword/book/search/ser
In directory www.crosswire.org:/tmp/cvs-serv30045/java/limbo/org/crosswire/jsword/book/search/ser
Added Files:
Msg.properties Msg.java package.html SerIndexManager.java
SerIndex.java
Log Message:
indexing updates
--- NEW FILE: package.html ---
An implementation of SearchEngine that uses simple serialized files.
--- NEW FILE: Msg.properties ---
# The naming convention for the keys in the file is ClassName.MessageName
# Where ClassName is the name of the class using the property.
# When the resource is used by more than one class it should be the one
# that the resource is most closely associated.
# The MessageName should be mixed case, with a leading capital.
# It should have no spaces or other punctuation (e.g. _, -, ', ...)
SerIndex.Indexing=Creating index. Processing {0}
SerIndex.Init=Failed to initialise Lucene search engine.
SerIndex.DeleteFailed=Failed to delete search index
SerIndex.WriteError=Write Error.
SerIndex.FindingWords=Finding Words ({0})
SerIndex.WritingWords=Writing Words ({0})
SerIndex.Saving=Saving Index
--- NEW FILE: Msg.java ---
package org.crosswire.jsword.book.search.ser;
import org.crosswire.common.util.MsgBase;
/**
* Compile safe Msg resource settings.
*
*
*
*
* Distribution Licence:
* JSword 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
* here , or by writing to:
* Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
* MA 02111-1307, USA
* The copyright to this program is held by it's authors.
*
* @see gnu.gpl.Licence
* @author Joe Walker [joe at eireneh dot com]
* @version $Id: Msg.java,v 1.1 2004/10/09 21:45:04 joe Exp $
*/
class Msg extends MsgBase
{
static final Msg INDEX_START = new Msg("SerIndex.Indexing"); //$NON-NLS-1$
static final Msg SER_INIT = new Msg("SerIndex.Init"); //$NON-NLS-1$
static final Msg DELETE_FAILED = new Msg("SerIndex.DeleteFailed"); //$NON-NLS-1$
static final Msg WRITE_ERROR = new Msg("SerIndex.WriteError"); //$NON-NLS-1$
static final Msg FINDING_WORDS = new Msg("SerIndex.FindingWords"); //$NON-NLS-1$
static final Msg WRITING_WORDS = new Msg("SerIndex.WritingWords"); //$NON-NLS-1$
static final Msg SAVING = new Msg("SerIndex.Saving"); //$NON-NLS-1$
/**
* Passthrough ctor
*/
private Msg(String name)
{
super(name);
}
}
--- NEW FILE: SerIndex.java ---
package org.crosswire.jsword.book.search.ser;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.RandomAccessFile;
import java.net.URL;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.SortedMap;
import java.util.TreeMap;
import org.crosswire.common.activate.Activatable;
import org.crosswire.common.activate.Activator;
import org.crosswire.common.activate.Lock;
import org.crosswire.common.progress.Job;
import org.crosswire.common.progress.JobManager;
import org.crosswire.common.util.FileUtil;
import org.crosswire.common.util.Logger;
import org.crosswire.common.util.NetUtil;
import org.crosswire.common.util.Reporter;
import org.crosswire.jsword.book.Book;
import org.crosswire.jsword.book.BookData;
import org.crosswire.jsword.book.BookException;
import org.crosswire.jsword.book.SentanceUtil;
import org.crosswire.jsword.book.search.Grammar;
import org.crosswire.jsword.book.search.Index;
import org.crosswire.jsword.book.search.Thesaurus;
import org.crosswire.jsword.passage.BibleInfo;
import org.crosswire.jsword.passage.Key;
import org.crosswire.jsword.passage.KeyUtil;
import org.crosswire.jsword.passage.NoSuchKeyException;
import org.crosswire.jsword.passage.Passage;
import org.crosswire.jsword.passage.PassageKeyFactory;
import org.crosswire.jsword.passage.Verse;
/**
* A search engine - This is a stepping stone on the way to allowing use of
* Lucene in place of our search engine.
*
*
*
*
* Distribution Licence:
* JSword 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
* here , or by writing to:
* Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
* MA 02111-1307, USA
* The copyright to this program is held by it's authors.
*
* @see gnu.gpl.Licence
* @author Joe Walker [joe at eireneh dot com]
* @version $Id: SerIndex.java,v 1.1 2004/10/09 21:45:04 joe Exp $
*/
public class SerIndex implements Index, Activatable, Thesaurus
{
/**
* Default ctor
*/
public SerIndex(Book newbook, URL storage)
{
this.book = newbook;
this.url = storage;
}
/**
* Generate an index to use, telling the job about progress as you go.
* @throws BookException If we fail to read the index files
*/
public SerIndex(Book book, URL storage, boolean create) throws BookException
{
assert create;
this.book = book;
this.url = storage;
Job job = JobManager.createJob(Msg.INDEX_START.toString(), Thread.currentThread(), false);
try
{
synchronized (creating)
{
generateSearchIndex(job);
}
}
catch (Exception ex)
{
job.ignoreTimings();
throw new BookException(Msg.SER_INIT, ex);
}
finally
{
job.done();
}
}
/* (non-Javadoc)
* @see org.crosswire.jsword.book.search.Index#getKey(java.lang.String)
*/
public Key getKey(String name) throws NoSuchKeyException
{
return book.getKey(name);
}
/* (non-Javadoc)
* @see org.crosswire.jsword.book.search.parse.Index#getStartsWith(java.lang.String)
*/
public Collection getSynonyms(String word)
{
checkActive();
// log.fine("considering="+words[i]);
String root = Grammar.getRoot(word);
// Check that the root is still a word. If not then we
// use the full version. This catches misses like se is
// the root of seed, and matches sea and so on ...
Key ref = findWord(root);
if (ref.isEmpty())
{
root = word;
}
word = word.toLowerCase();
SortedMap submap = datamap.subMap(word, word + "\u9999"); //$NON-NLS-1$
return submap.keySet();
}
/* (non-Javadoc)
* @see org.crosswire.jsword.book.search.parse.Index#findWord(java.lang.String)
*/
public Key findWord(String word)
{
checkActive();
if (word == null)
{
return book.createEmptyKeyList();
}
Section section = (Section) datamap.get(word.toLowerCase());
if (section == null)
{
return book.createEmptyKeyList();
}
try
{
// Read blob
byte[] blob = new byte[section.length];
dataRaf.seek(section.offset);
int read = dataRaf.read(blob);
// Probably a bit harsh, but it would be wrong to just drop it.
if (read != blob.length)
{
throw new IOException();
}
// De-serialize
return PassageKeyFactory.fromBinaryRepresentation(blob);
}
catch (Exception ex)
{
log.warn("Search failed on:"); //$NON-NLS-1$
log.warn(" word=" + word); //$NON-NLS-1$
log.warn(" offset=" + section.offset); //$NON-NLS-1$
log.warn(" length=" + section.length); //$NON-NLS-1$
Reporter.informUser(this, ex);
return book.createEmptyKeyList();
}
}
/* (non-Javadoc)
* @see org.crosswire.jsword.book.search.AbstractIndex#generateSearchIndex(org.crosswire.common.progress.Job)
*/
public void generateSearchIndex(Job job) throws BookException
{
// create a word/passage hashmap
Map matchmap = new HashMap();
generateSearchIndexImpl(job, book.getGlobalKeyList(), matchmap);
// For the progress listener
int count = 0;
int words = matchmap.size();
// Now we need to write the words into our index
try
{
NetUtil.makeDirectory(url);
URL dataUrl = NetUtil.lengthenURL(url, FILE_DATA);
dataRaf = new RandomAccessFile(NetUtil.getAsFile(dataUrl), FileUtil.MODE_WRITE);
}
catch (IOException ex)
{
throw new BookException(Msg.WRITE_ERROR, ex);
}
for (Iterator it = matchmap.keySet().iterator(); it.hasNext(); )
{
String word = (String) it.next();
Key match = (Key) matchmap.get(word);
recordFoundPassage(word, match);
// Fire a progress event?
int percent = PERCENT_READ + (PERCENT_WRITE * count++ / words) / BibleInfo.versesInBible();
job.setProgress(percent, Msg.WRITING_WORDS.toString(word));
// This could take a long time ...
Thread.yield();
if (Thread.currentThread().isInterrupted())
{
break;
}
}
// Store the indexes on disk
try
{
job.setProgress(PERCENT_READ + PERCENT_WRITE, Msg.SAVING.toString());
// Save the ascii Passage index
URL indexurl = NetUtil.lengthenURL(url, FILE_INDEX);
PrintWriter indexout = new PrintWriter(NetUtil.getOutputStream(indexurl));
Iterator it = datamap.keySet().iterator();
while (it.hasNext())
{
String word = (String) it.next();
Section section = (Section) datamap.get(word);
indexout.println(word + ":" + section.offset + ":" + section.length); //$NON-NLS-1$ //$NON-NLS-2$
}
indexout.close();
}
catch (IOException ex)
{
throw new BookException(Msg.WRITE_ERROR, ex);
}
}
/**
* Dig down into a Key indexing as we go.
*/
private void generateSearchIndexImpl(Job job, Key key, Map matchmap) throws BookException
{
// loop through all the verses
int percent = 0;
for (Iterator it = key.iterator(); it.hasNext(); )
{
Key sublist = (Key) it.next();
if (sublist.canHaveChildren())
{
generateSearchIndexImpl(job, sublist, matchmap);
}
else
{
BookData data = book.getData(sublist);
String text = data.getPlainText();
String[] words = SentanceUtil.getWords(text);
for (int i = 0; i < words.length; i++)
{
// ensure there is a Passage for this word in the word/passage hashmap
Key matches = (Key) matchmap.get(words[i]);
if (matches == null)
{
matches = book.createEmptyKeyList();
matchmap.put(words[i], matches);
}
// add this verse to this words passage
matches.addAll(sublist);
}
// report progress
if (sublist instanceof Passage)
{
Verse verse = KeyUtil.getVerse(sublist);
percent = PERCENT_READ * verse.getOrdinal() / BibleInfo.versesInBible();
}
job.setProgress(percent, Msg.FINDING_WORDS.toString(sublist.getName()));
// This could take a long time ...
Thread.yield();
if (Thread.currentThread().isInterrupted())
{
break;
}
}
}
}
/**
* Add to the main index data the references against this word
* @param word The word to write
* @param key The references to the word
*/
private void recordFoundPassage(String word, Key key) throws BookException
{
if (word == null)
{
return;
}
try
{
Passage ref = KeyUtil.getPassage(key);
byte[] buffer = PassageKeyFactory.toBinaryRepresentation(ref);
Section section = new Section(dataRaf.getFilePointer(), buffer.length);
dataRaf.write(buffer);
datamap.put(word.toLowerCase(), section);
}
catch (Exception ex)
{
throw new BookException(Msg.WRITE_ERROR, ex);
}
}
/* (non-Javadoc)
* @see org.crosswire.jsword.book.search.SearchEngine#activate()
*/
public final void activate(Lock lock)
{
try
{
URL dataUrl = NetUtil.lengthenURL(url, FILE_DATA);
dataRaf = new RandomAccessFile(NetUtil.getAsFile(dataUrl), FileUtil.MODE_READ);
URL indexUrl = NetUtil.lengthenURL(url, FILE_INDEX);
BufferedReader indexIn = new BufferedReader(new InputStreamReader(indexUrl.openStream()));
while (true)
{
String line = indexIn.readLine();
if (line == null)
{
break;
}
try
{
int colon1 = line.indexOf(":"); //$NON-NLS-1$
int colon2 = line.lastIndexOf(":"); //$NON-NLS-1$
String word = line.substring(0, colon1);
long offset = Long.parseLong(line.substring(colon1 + 1, colon2));
int length = Integer.parseInt(line.substring(colon2 + 1));
Section section = new Section(offset, length);
datamap.put(word, section);
}
catch (NumberFormatException ex)
{
log.error("NumberFormatException reading line: " + line, ex); //$NON-NLS-1$
}
}
}
catch (IOException ex)
{
log.error("Read failed on indexin", ex); //$NON-NLS-1$
}
active = true;
}
/* (non-Javadoc)
* @see org.crosswire.jsword.book.search.SearchEngine#deactivate()
*/
public final void deactivate(Lock lock)
{
datamap.clear();
dataRaf = null;
active = false;
}
/**
* Helper method so we can quickly activate ourselves on access
*/
private final void checkActive()
{
if (!active)
{
Activator.activate(this);
}
}
/**
* A synchronization lock point to prevent us from doing 2 index runs at a time.
*/
private static final Object creating = new Object();
/**
* Are we active
*/
private boolean active = false;
/**
* The name of the data file
*/
private static final String FILE_DATA = "ref.data"; //$NON-NLS-1$
/**
* The name of the index file
*/
protected static final String FILE_INDEX = "ref.index"; //$NON-NLS-1$
/**
* The Bible we are indexing
*/
protected Book book;
/**
* The directory to which to write the index
*/
private URL url;
/**
* The passages random access file
*/
private RandomAccessFile dataRaf;
/**
* The hash of indexes into the passages file
*/
private SortedMap datamap = new TreeMap();
/**
* The log stream
*/
private static final Logger log = Logger.getLogger(SerIndex.class);
/**
* The percentages taken but by different parts
*/
private static final int PERCENT_READ = 60;
private static final int PERCENT_WRITE = 39;
// private static final int PERCENT_INDEX = 1;
/**
* A simple class to hold an offset and length into the passages random
* access file
*/
public static class Section
{
protected Section(long offset, int length)
{
this.offset = offset;
this.length = length;
}
protected long offset;
protected int length;
}
}
--- NEW FILE: SerIndexManager.java ---
package org.crosswire.jsword.book.search.ser;
import java.io.IOException;
import java.net.URL;
import java.util.HashMap;
import java.util.Map;
import org.crosswire.common.util.Logger;
import org.crosswire.common.util.NetUtil;
import org.crosswire.common.util.Reporter;
import org.crosswire.jsword.book.Book;
import org.crosswire.jsword.book.BookException;
import org.crosswire.jsword.book.search.Index;
import org.crosswire.jsword.book.search.IndexManager;
import org.crosswire.jsword.util.Project;
/**
* .
*
*
*
*
* Distribution Licence:
* JSword 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
* here , or by writing to:
* Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
* MA 02111-1307, USA
* The copyright to this program is held by it's authors.
*
* @see gnu.gpl.Licence
* @author Joe Walker [joe at eireneh dot com]
* @version $Id: SerIndexManager.java,v 1.1 2004/10/09 21:45:04 joe Exp $
*/
public class SerIndexManager implements IndexManager
{
/* (non-Javadoc)
* @see org.crosswire.jsword.book.search.AbstractIndex#isIndexed()
*/
public boolean isIndexed(Book book)
{
try
{
URL storage = getStorageArea(book);
URL longer = NetUtil.lengthenURL(storage, SerIndex.FILE_INDEX);
return NetUtil.isFile(longer);
}
catch (IOException ex)
{
log.error("Failed to find lucene index storage area.", ex); //$NON-NLS-1$
return false;
}
}
/* (non-Javadoc)
* @see org.crosswire.jsword.book.search.IndexManager#getIndex(org.crosswire.jsword.book.Book)
*/
public Index getIndex(Book book) throws BookException
{
try
{
Index reply = (Index) indexes.get(book);
if (reply == null)
{
URL storage = getStorageArea(book);
reply = new SerIndex(book, storage);
indexes.put(book, reply);
}
return reply;
}
catch (IOException ex)
{
throw new BookException(Msg.SER_INIT, ex);
}
}
/* (non-Javadoc)
* @see org.crosswire.jsword.book.search.AbstractIndex#generateSearchIndex(org.crosswire.common.progress.Job)
*/
public void scheduleIndexCreation(final Book book)
{
Thread work = new Thread(new Runnable()
{
public void run()
{
try
{
URL storage = getStorageArea(book);
Index index = new SerIndex(book, storage, true);
indexes.put(book, index);
}
catch (Exception ex)
{
Reporter.informUser(SerIndexManager.this, ex);
}
}
});
work.start();
}
/* (non-Javadoc)
* @see org.crosswire.jsword.book.search.IndexManager#deleteIndex(org.crosswire.jsword.book.Book)
*/
public void deleteIndex(Book book) throws BookException
{
try
{
// TODO(joe): This needs some checks that it isn't being used
URL storage = getStorageArea(book);
NetUtil.delete(storage);
}
catch (IOException ex)
{
throw new BookException(Msg.DELETE_FAILED, ex);
}
}
/**
* Determine where an index should be stored
* @param book The book to be indexed
* @return A URL to store stuff in
* @throws IOException If there is a problem in finding where to store stuff
*/
protected URL getStorageArea(Book book) throws IOException
{
String driverName = book.getBookMetaData().getDriverName();
String bookName = book.getBookMetaData().getInitials();
assert driverName != null;
assert bookName != null;
URL base = Project.instance().getTempScratchSpace(DIR_SER, false);
URL driver = NetUtil.lengthenURL(base, driverName);
return NetUtil.lengthenURL(driver, bookName);
}
/**
* The created indexes
*/
protected static final Map indexes = new HashMap();
/**
* The ser search index directory
*/
private static final String DIR_SER = "ser"; //$NON-NLS-1$
/**
* The log stream
*/
private static final Logger log = Logger.getLogger(SerIndexManager.class);
}
From jswordcvs at crosswire.org Sat Oct 9 14:45:07 2004
From: jswordcvs at crosswire.org (jswordcvs@crosswire.org)
Date: Sat Oct 9 14:45:11 2004
Subject: [jsword-svn] jsword/java/jsword/org/crosswire/jsword/examples s
Message-ID: <200410092145.i99Lj7dC030145@www.crosswire.org>
Update of /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/examples
In directory www.crosswire.org:/tmp/cvs-serv30045/java/jsword/org/crosswire/jsword/examples
Modified Files:
APIExamples.java
Log Message:
indexing updates
Index: APIExamples.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/examples/APIExamples.java,v
retrieving revision 1.18
retrieving revision 1.19
diff -C2 -d -r1.18 -r1.19
*** APIExamples.java 5 Oct 2004 22:03:09 -0000 1.18
--- APIExamples.java 9 Oct 2004 21:45:05 -0000 1.19
***************
*** 17,21 ****
import org.crosswire.jsword.book.BooksEvent;
import org.crosswire.jsword.book.BooksListener;
- import org.crosswire.jsword.book.Search;
import org.crosswire.jsword.passage.Key;
import org.crosswire.jsword.passage.NoSuchKeyException;
--- 17,20 ----
***************
*** 124,128 ****
/**
* An example of how to search for various bits of data.
- * @see Search
*/
public void search() throws BookException
--- 123,126 ----
***************
*** 132,143 ****
// This does a standard operator search. See the search documentation
// for more examples of how to search
! Search search = new Search("moses + aaron", false); //$NON-NLS-1$
! Key key = bible.find(search);
System.out.println("The following verses contain both moses and aaron: " + key.getName()); //$NON-NLS-1$
! // Or you can do a best match search ...
! search = new Search("for god so loves the world", true); //$NON-NLS-1$
! key = bible.find(search);
System.out.println("Trying to find verses like John 3:16: " + key.getName()); //$NON-NLS-1$
--- 130,139 ----
// This does a standard operator search. See the search documentation
// for more examples of how to search
! Key key = bible.find("moses + aaron"); //$NON-NLS-1$
System.out.println("The following verses contain both moses and aaron: " + key.getName()); //$NON-NLS-1$
! // Or you can do a best match search, by enclosing the string in quotes ...
! key = bible.find("\"for god so loves the world\""); //$NON-NLS-1$
System.out.println("Trying to find verses like John 3:16: " + key.getName()); //$NON-NLS-1$
From jswordcvs at crosswire.org Sat Oct 9 14:45:07 2004
From: jswordcvs at crosswire.org (jswordcvs@crosswire.org)
Date: Sat Oct 9 14:45:11 2004
Subject: [jsword-svn]
jsword/java/jsword/org/crosswire/jsword/book/search/index s
Message-ID: <200410092145.i99Lj7wk030165@www.crosswire.org>
Update of /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/search/index
In directory www.crosswire.org:/tmp/cvs-serv30045/java/jsword/org/crosswire/jsword/book/search/index
Removed Files:
IndexMatcher.java
Log Message:
indexing updates
--- IndexMatcher.java DELETED ---
From jswordcvs at crosswire.org Sat Oct 9 14:45:07 2004
From: jswordcvs at crosswire.org (jswordcvs@crosswire.org)
Date: Sat Oct 9 14:45:11 2004
Subject: [jsword-svn]
jsword/java/jswordtest/org/crosswire/jsword/book/search/parse s
Message-ID: <200410092145.i99Lj78O030132@www.crosswire.org>
Update of /cvs/jsword/jsword/java/jswordtest/org/crosswire/jsword/book/search/parse
In directory www.crosswire.org:/tmp/cvs-serv30045/java/jswordtest/org/crosswire/jsword/book/search/parse
Modified Files:
WordsTest.java ParserTest.java
Log Message:
indexing updates
Index: WordsTest.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jswordtest/org/crosswire/jsword/book/search/parse/WordsTest.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** WordsTest.java 29 Sep 2004 22:21:23 -0000 1.3
--- WordsTest.java 9 Oct 2004 21:45:05 -0000 1.4
***************
*** 5,10 ****
import junit.framework.TestCase;
- import org.crosswire.jsword.book.Search;
-
/**
* JUnit Test.
--- 5,8 ----
***************
*** 62,115 ****
public void testAddCommandWord() throws Exception
{
! assertEquals(engine.search("t1", Search.UNRESTRICTED).getName(), "Rut 2"); //$NON-NLS-1$ //$NON-NLS-2$
! assertEquals(engine.search("t2", Search.UNRESTRICTED).getName(), "Deu 28:1-1Sa 1:1"); //$NON-NLS-1$ //$NON-NLS-2$
! assertEquals(engine.search("/t1", Search.UNRESTRICTED).getName(), "Rut 2"); //$NON-NLS-1$ //$NON-NLS-2$
! assertEquals(engine.search("/t2", Search.UNRESTRICTED).getName(), "Deu 28:1-1Sa 1:1"); //$NON-NLS-1$ //$NON-NLS-2$
! assertEquals(engine.search("|t1", Search.UNRESTRICTED).getName(), "Rut 2"); //$NON-NLS-1$ //$NON-NLS-2$
! assertEquals(engine.search("|t2", Search.UNRESTRICTED).getName(), "Deu 28:1-1Sa 1:1"); //$NON-NLS-1$ //$NON-NLS-2$
}
public void testRetainCommandWord() throws Exception
{
! assertEquals(engine.search("t2&t1", Search.UNRESTRICTED).getName(), "Rut 2"); //$NON-NLS-1$ //$NON-NLS-2$
! assertEquals(engine.search("t1&t2", Search.UNRESTRICTED).getName(), "Rut 2"); //$NON-NLS-1$ //$NON-NLS-2$
! assertEquals(engine.search("t2+t1", Search.UNRESTRICTED).getName(), "Rut 2"); //$NON-NLS-1$ //$NON-NLS-2$
! assertEquals(engine.search("t1+t2", Search.UNRESTRICTED).getName(), "Rut 2"); //$NON-NLS-1$ //$NON-NLS-2$
! assertEquals(engine.search("t2,t1", Search.UNRESTRICTED).getName(), "Rut 2"); //$NON-NLS-1$ //$NON-NLS-2$
! assertEquals(engine.search("t1,t2", Search.UNRESTRICTED).getName(), "Rut 2"); //$NON-NLS-1$ //$NON-NLS-2$
}
public void testRemoveCommandWord() throws Exception
{
! assertEquals(engine.search("t2-t1", Search.UNRESTRICTED).getName(), "Deu 28-Rut 1, Rut 3:1-1Sa 1:1"); //$NON-NLS-1$ //$NON-NLS-2$
! assertEquals(engine.search("t1-t2", Search.UNRESTRICTED).getName(), ""); //$NON-NLS-1$ //$NON-NLS-2$
}
public void testBlurCommandWord() throws Exception
{
! assertEquals(engine.search("t3 ~1", Search.UNRESTRICTED).getName(), "Mar 2:2-4"); //$NON-NLS-1$ //$NON-NLS-2$
! assertEquals(engine.search("t3 ~2", Search.UNRESTRICTED).getName(), "Mar 2:1-5"); //$NON-NLS-1$ //$NON-NLS-2$
! assertEquals(engine.search("t3 ~3", Search.UNRESTRICTED).getName(), "Mar 2:1-6"); //$NON-NLS-1$ //$NON-NLS-2$
! assertEquals(engine.search("t3 ~4", Search.UNRESTRICTED).getName(), "Mar 2:1-7"); //$NON-NLS-1$ //$NON-NLS-2$
! assertEquals(engine.search("t3 ~5", Search.UNRESTRICTED).getName(), "Mar 2:1-8"); //$NON-NLS-1$ //$NON-NLS-2$
}
public void testStartsParamWord() throws Exception
{
! //assertEquals(engine.search("startswith joshu", Search.UNRESTRICTED), engine.search("joshua", Search.UNRESTRICTED));
! //assertEquals(engine.search("sw joshu", Search.UNRESTRICTED), engine.search("joshua", Search.UNRESTRICTED));
}
public void testSubXParamWord() throws Exception
{
! assertEquals(engine.search("t3 / ( t2 )", Search.UNRESTRICTED).getName(), "Deu 28:1-1Sa 1:1, Mar 2:3"); //$NON-NLS-1$ //$NON-NLS-2$
! assertEquals(engine.search("t3/(t2)", Search.UNRESTRICTED).getName(), "Deu 28:1-1Sa 1:1, Mar 2:3"); //$NON-NLS-1$ //$NON-NLS-2$
! assertEquals(engine.search("t1 & t2 | t3", Search.UNRESTRICTED).getName(), "Rut 2, Mar 2:3"); //$NON-NLS-1$ //$NON-NLS-2$
! assertEquals(engine.search("t1 & t2 - t3", Search.UNRESTRICTED).getName(), "Rut 2"); //$NON-NLS-1$ //$NON-NLS-2$
! assertEquals(engine.search("( t1 & t2 ) | t3", Search.UNRESTRICTED).getName(), "Rut 2, Mar 2:3"); //$NON-NLS-1$ //$NON-NLS-2$
! assertEquals(engine.search("t1 & ( t2 | t3 )", Search.UNRESTRICTED).getName(), "Rut 2"); //$NON-NLS-1$ //$NON-NLS-2$
! assertEquals(engine.search("t1 & ( t2 | t3 ) & ( t3 | t2 )", Search.UNRESTRICTED).getName(), "Rut 2"); //$NON-NLS-1$ //$NON-NLS-2$
! assertEquals(engine.search("t1&(t2|t3)&(t3|t2)", Search.UNRESTRICTED).getName(), "Rut 2"); //$NON-NLS-1$ //$NON-NLS-2$
! assertEquals(engine.search("t1&(t2|(t3))&(t3|t2)", Search.UNRESTRICTED).getName(), "Rut 2"); //$NON-NLS-1$ //$NON-NLS-2$
}
--- 60,113 ----
public void testAddCommandWord() throws Exception
{
! assertEquals(engine.search("t1").getName(), "Rut 2"); //$NON-NLS-1$ //$NON-NLS-2$
! assertEquals(engine.search("t2").getName(), "Deu 28:1-1Sa 1:1"); //$NON-NLS-1$ //$NON-NLS-2$
! assertEquals(engine.search("/t1").getName(), "Rut 2"); //$NON-NLS-1$ //$NON-NLS-2$
! assertEquals(engine.search("/t2").getName(), "Deu 28:1-1Sa 1:1"); //$NON-NLS-1$ //$NON-NLS-2$
! assertEquals(engine.search("|t1").getName(), "Rut 2"); //$NON-NLS-1$ //$NON-NLS-2$
! assertEquals(engine.search("|t2").getName(), "Deu 28:1-1Sa 1:1"); //$NON-NLS-1$ //$NON-NLS-2$
}
public void testRetainCommandWord() throws Exception
{
! assertEquals(engine.search("t2&t1").getName(), "Rut 2"); //$NON-NLS-1$ //$NON-NLS-2$
! assertEquals(engine.search("t1&t2").getName(), "Rut 2"); //$NON-NLS-1$ //$NON-NLS-2$
! assertEquals(engine.search("t2+t1").getName(), "Rut 2"); //$NON-NLS-1$ //$NON-NLS-2$
! assertEquals(engine.search("t1+t2").getName(), "Rut 2"); //$NON-NLS-1$ //$NON-NLS-2$
! assertEquals(engine.search("t2,t1").getName(), "Rut 2"); //$NON-NLS-1$ //$NON-NLS-2$
! assertEquals(engine.search("t1,t2").getName(), "Rut 2"); //$NON-NLS-1$ //$NON-NLS-2$
}
public void testRemoveCommandWord() throws Exception
{
! assertEquals(engine.search("t2-t1").getName(), "Deu 28-Rut 1, Rut 3:1-1Sa 1:1"); //$NON-NLS-1$ //$NON-NLS-2$
! assertEquals(engine.search("t1-t2").getName(), ""); //$NON-NLS-1$ //$NON-NLS-2$
}
public void testBlurCommandWord() throws Exception
{
! assertEquals(engine.search("t3 ~1").getName(), "Mar 2:2-4"); //$NON-NLS-1$ //$NON-NLS-2$
! assertEquals(engine.search("t3 ~2").getName(), "Mar 2:1-5"); //$NON-NLS-1$ //$NON-NLS-2$
! assertEquals(engine.search("t3 ~3").getName(), "Mar 2:1-6"); //$NON-NLS-1$ //$NON-NLS-2$
! assertEquals(engine.search("t3 ~4").getName(), "Mar 2:1-7"); //$NON-NLS-1$ //$NON-NLS-2$
! assertEquals(engine.search("t3 ~5").getName(), "Mar 2:1-8"); //$NON-NLS-1$ //$NON-NLS-2$
}
public void testStartsParamWord() throws Exception
{
! //assertEquals(engine.search("startswith joshu"), engine.search("joshua"));
! //assertEquals(engine.search("sw joshu"), engine.search("joshua"));
}
public void testSubXParamWord() throws Exception
{
! assertEquals(engine.search("t3 / ( t2 )").getName(), "Deu 28:1-1Sa 1:1, Mar 2:3"); //$NON-NLS-1$ //$NON-NLS-2$
! assertEquals(engine.search("t3/(t2)").getName(), "Deu 28:1-1Sa 1:1, Mar 2:3"); //$NON-NLS-1$ //$NON-NLS-2$
! assertEquals(engine.search("t1 & t2 | t3").getName(), "Rut 2, Mar 2:3"); //$NON-NLS-1$ //$NON-NLS-2$
! assertEquals(engine.search("t1 & t2 - t3").getName(), "Rut 2"); //$NON-NLS-1$ //$NON-NLS-2$
! assertEquals(engine.search("( t1 & t2 ) | t3").getName(), "Rut 2, Mar 2:3"); //$NON-NLS-1$ //$NON-NLS-2$
! assertEquals(engine.search("t1 & ( t2 | t3 )").getName(), "Rut 2"); //$NON-NLS-1$ //$NON-NLS-2$
! assertEquals(engine.search("t1 & ( t2 | t3 ) & ( t3 | t2 )").getName(), "Rut 2"); //$NON-NLS-1$ //$NON-NLS-2$
! assertEquals(engine.search("t1&(t2|t3)&(t3|t2)").getName(), "Rut 2"); //$NON-NLS-1$ //$NON-NLS-2$
! assertEquals(engine.search("t1&(t2|(t3))&(t3|t2)").getName(), "Rut 2"); //$NON-NLS-1$ //$NON-NLS-2$
}
***************
*** 131,136 ****
public void testUpdatePassage() throws Exception
{
! //assertEquals(engine.search("grammar joseph", Search.UNRESTRICTED), engine.search("joseph / joseph's", Search.UNRESTRICTED));
! //assertEquals(engine.search("gr joseph", Search.UNRESTRICTED), engine.search("joseph / joseph's", Search.UNRESTRICTED));
}
}
\ No newline at end of file
--- 129,134 ----
public void testUpdatePassage() throws Exception
{
! //assertEquals(engine.search("grammar joseph"), engine.search("joseph / joseph's"));
! //assertEquals(engine.search("gr joseph"), engine.search("joseph / joseph's"));
}
}
\ No newline at end of file
Index: ParserTest.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jswordtest/org/crosswire/jsword/book/search/parse/ParserTest.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** ParserTest.java 29 Sep 2004 22:21:23 -0000 1.7
--- ParserTest.java 9 Oct 2004 21:45:05 -0000 1.8
***************
*** 4,8 ****
import org.crosswire.jsword.book.BookException;
- import org.crosswire.jsword.book.Search;
/**
--- 4,7 ----
***************
*** 54,74 ****
//try { engine.search(new Search("moses aaron", false)); fail(); } catch (BookException ex) { }
! try { engine.search("(", Search.UNRESTRICTED); fail(); } catch (BookException ex) { } //$NON-NLS-1$
! try { engine.search("~", Search.UNRESTRICTED); fail(); } catch (BookException ex) { } //$NON-NLS-1$
! try { engine.search(")", Search.UNRESTRICTED); fail(); } catch (BookException ex) { } //$NON-NLS-1$
! try { engine.search("&", Search.UNRESTRICTED); fail(); } catch (BookException ex) { } //$NON-NLS-1$
! try { engine.search(",", Search.UNRESTRICTED); fail(); } catch (BookException ex) { } //$NON-NLS-1$
! try { engine.search("+", Search.UNRESTRICTED); fail(); } catch (BookException ex) { } //$NON-NLS-1$
! try { engine.search("-", Search.UNRESTRICTED); fail(); } catch (BookException ex) { } //$NON-NLS-1$
! try { engine.search("/", Search.UNRESTRICTED); fail(); } catch (BookException ex) { } //$NON-NLS-1$
! try { engine.search("|", Search.UNRESTRICTED); fail(); } catch (BookException ex) { } //$NON-NLS-1$
! try { engine.search("sw", Search.UNRESTRICTED); fail(); } catch (BookException ex) { } //$NON-NLS-1$
! try { engine.search("startswith", Search.UNRESTRICTED); fail(); } catch (BookException ex) { } //$NON-NLS-1$
! try { engine.search("gr", Search.UNRESTRICTED); fail(); } catch (BookException ex) { } //$NON-NLS-1$
! try { engine.search("grammar", Search.UNRESTRICTED); fail(); } catch (BookException ex) { } //$NON-NLS-1$
! //try { engine.search("moses ( aaron )", Search.UNRESTRICTED); fail(); } catch (BookException ex) { }
! //try { engine.search("moses & ( aaron", Search.UNRESTRICTED); fail(); } catch (BookException ex) { }
! //try { engine.search("moses & ( aaron", Search.UNRESTRICTED); fail(); } catch (BookException ex) { }
! //try { engine.search("( moses ( aaron ) )", Search.UNRESTRICTED); fail(); } catch (BookException ex) { }
}
--- 53,73 ----
//try { engine.search(new Search("moses aaron", false)); fail(); } catch (BookException ex) { }
! try { engine.search("("); fail(); } catch (BookException ex) { } //$NON-NLS-1$
! try { engine.search("~"); fail(); } catch (BookException ex) { } //$NON-NLS-1$
! try { engine.search(")"); fail(); } catch (BookException ex) { } //$NON-NLS-1$
! try { engine.search("&"); fail(); } catch (BookException ex) { } //$NON-NLS-1$
! try { engine.search(","); fail(); } catch (BookException ex) { } //$NON-NLS-1$
! try { engine.search("+"); fail(); } catch (BookException ex) { } //$NON-NLS-1$
! try { engine.search("-"); fail(); } catch (BookException ex) { } //$NON-NLS-1$
! try { engine.search("/"); fail(); } catch (BookException ex) { } //$NON-NLS-1$
! try { engine.search("|"); fail(); } catch (BookException ex) { } //$NON-NLS-1$
! try { engine.search("sw"); fail(); } catch (BookException ex) { } //$NON-NLS-1$
! try { engine.search("startswith"); fail(); } catch (BookException ex) { } //$NON-NLS-1$
! try { engine.search("gr"); fail(); } catch (BookException ex) { } //$NON-NLS-1$
! try { engine.search("grammar"); fail(); } catch (BookException ex) { } //$NON-NLS-1$
! //try { engine.search("moses ( aaron )"); fail(); } catch (BookException ex) { }
! //try { engine.search("moses & ( aaron"); fail(); } catch (BookException ex) { }
! //try { engine.search("moses & ( aaron"); fail(); } catch (BookException ex) { }
! //try { engine.search("( moses ( aaron ) )"); fail(); } catch (BookException ex) { }
}
From jswordcvs at crosswire.org Sat Oct 9 14:45:07 2004
From: jswordcvs at crosswire.org (jswordcvs@crosswire.org)
Date: Sat Oct 9 14:45:11 2004
Subject: [jsword-svn]
jsword/java/jsword/org/crosswire/jsword/book/search/lucene s
Message-ID: <200410092145.i99Lj7Re030148@www.crosswire.org>
Update of /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/search/lucene
In directory www.crosswire.org:/tmp/cvs-serv30045/java/jsword/org/crosswire/jsword/book/search/lucene
Modified Files:
Msg.java LuceneIndex.java Msg.properties
Added Files:
LuceneIndexManager.java
Log Message:
indexing updates
Index: LuceneIndex.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/search/lucene/LuceneIndex.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** LuceneIndex.java 29 Sep 2004 22:21:24 -0000 1.1
--- LuceneIndex.java 9 Oct 2004 21:45:05 -0000 1.2
***************
*** 21,24 ****
--- 21,25 ----
import org.crosswire.common.activate.Lock;
import org.crosswire.common.progress.Job;
+ import org.crosswire.common.progress.JobManager;
import org.crosswire.common.util.Logger;
import org.crosswire.common.util.NetUtil;
***************
*** 27,32 ****
import org.crosswire.jsword.book.BookData;
import org.crosswire.jsword.book.BookException;
import org.crosswire.jsword.book.search.Index;
- import org.crosswire.jsword.book.search.IndexManager;
import org.crosswire.jsword.passage.BibleInfo;
import org.crosswire.jsword.passage.Key;
--- 28,33 ----
import org.crosswire.jsword.book.BookData;
import org.crosswire.jsword.book.BookException;
+ import org.crosswire.jsword.book.IndexStatus;
import org.crosswire.jsword.book.search.Index;
import org.crosswire.jsword.passage.BibleInfo;
import org.crosswire.jsword.passage.Key;
***************
*** 37,41 ****
import org.crosswire.jsword.passage.Verse;
import org.crosswire.jsword.passage.VerseFactory;
- import org.crosswire.jsword.util.Project;
/**
--- 38,41 ----
***************
*** 65,99 ****
public class LuceneIndex implements Index, Activatable
{
! /* (non-Javadoc)
! * @see org.crosswire.jsword.book.search.SearchEngine#init(org.crosswire.jsword.book.Bible, java.net.URL)
*/
! public void init(Book newBook) throws BookException
{
try
{
! book = newBook;
! String driverName = book.getBookMetaData().getDriverName();
! String bookName = book.getBookMetaData().getInitials();
! assert driverName != null;
! assert bookName != null;
! URL base = Project.instance().getTempScratchSpace(DIR_LUCENE, false);
! URL driver = NetUtil.lengthenURL(base, driverName);
! url = NetUtil.lengthenURL(driver, bookName);
! if (isIndexed())
{
! // Opening Lucene indexes is quite quick I think, so we can try
! // it to see if it works to report errors that we want to drop
! // later
! searcher = new IndexSearcher(NetUtil.getAsFile(url).getCanonicalPath());
}
}
! catch (IOException ex)
{
throw new BookException(Msg.LUCENE_INIT, ex);
}
}
--- 65,134 ----
public class LuceneIndex implements Index, Activatable
{
! /**
! * Read an existing index and use it.
! * @throws BookException If we fail to read the index files
*/
! public LuceneIndex(Book book, URL storage) throws BookException
{
+ this.book = book;
+ this.storage = storage;
+
try
{
! // Opening Lucene indexes is quite quick I think, so we can try
! // it to see if it works to report errors that we want to drop
! // later
! searcher = new IndexSearcher(NetUtil.getAsFile(storage).getCanonicalPath());
! }
! catch (IOException ex)
! {
! throw new BookException(Msg.LUCENE_INIT, ex);
! }
! }
! /**
! * Generate an index to use, telling the job about progress as you go.
! * @throws BookException If we fail to read the index files
! */
! public LuceneIndex(Book book, URL storage, boolean create) throws BookException
! {
! assert create;
! this.book = book;
! this.storage = storage;
! Job job = JobManager.createJob(Msg.INDEX_START.toString(), Thread.currentThread(), false);
! try
! {
! synchronized (creating)
{
! book.getBookMetaData().setIndexStatus(IndexStatus.CREATING);
!
! // An index is created by opening an IndexWriter with the
! // create argument set to true.
! IndexWriter writer = new IndexWriter(NetUtil.getAsFile(storage).getCanonicalPath(), new StandardAnalyzer(), true);
!
! generateSearchIndexImpl(job, writer, book.getGlobalKeyList());
!
! job.setProgress(95, Msg.OPTIMIZING.toString());
!
! writer.optimize();
! writer.close();
!
! searcher = new IndexSearcher(NetUtil.getAsFile(storage).getCanonicalPath());
!
! book.getBookMetaData().setIndexStatus(IndexStatus.DONE);
}
}
! catch (Exception ex)
{
+ job.ignoreTimings();
throw new BookException(Msg.LUCENE_INIT, ex);
}
+ finally
+ {
+ job.done();
+ }
}
***************
*** 147,197 ****
/* (non-Javadoc)
! * @see org.crosswire.jsword.book.search.SearchEngine#delete()
*/
! public void delete() throws BookException
{
- checkActive();
-
try
{
! NetUtil.delete(url);
}
catch (IOException ex)
{
! throw new BookException(Msg.DELETE_FAILED, ex);
}
}
/* (non-Javadoc)
! * @see org.crosswire.jsword.book.search.AbstractIndex#isIndexed()
*/
! public boolean isIndexed()
{
! if (generating)
{
! return false;
}
! URL longer = NetUtil.lengthenURL(url, DIR_SEGMENTS);
! return NetUtil.isFile(longer);
}
! /* (non-Javadoc)
! * @see org.crosswire.jsword.book.search.AbstractIndex#generateSearchIndex(org.crosswire.common.progress.Job)
*/
! public void generateSearchIndex(Job job) throws IOException, BookException
{
! // An index is created by opening an IndexWriter with the
! // create argument set to true.
! IndexWriter writer = new IndexWriter(NetUtil.getAsFile(url), new StandardAnalyzer(), true);
!
! generateSearchIndexImpl(job, writer, book.getGlobalKeyList());
!
! job.setProgress(95, Msg.OPTIMIZING.toString());
!
! writer.optimize();
! writer.close();
!
! searcher = new IndexSearcher(NetUtil.getAsFile(url).getCanonicalPath());
}
--- 182,228 ----
/* (non-Javadoc)
! * @see org.crosswire.jsword.book.search.SearchEngine#activate()
*/
! public final void activate(Lock lock)
{
try
{
! searcher = new IndexSearcher(NetUtil.getAsFile(storage).getCanonicalPath());
}
catch (IOException ex)
{
! log.warn("second load failure", ex); //$NON-NLS-1$
}
+
+ active = true;
}
/* (non-Javadoc)
! * @see org.crosswire.jsword.book.search.SearchEngine#deactivate()
*/
! public final void deactivate(Lock lock)
{
! try
{
! searcher.close();
! searcher = null;
! }
! catch (IOException ex)
! {
! Reporter.informUser(this, ex);
}
! active = false;
}
! /**
! * Helper method so we can quickly activate ourselves on access
*/
! protected final void checkActive()
{
! if (!active)
! {
! Activator.activate(this);
! }
}
***************
*** 248,304 ****
}
- /* (non-Javadoc)
- * @see org.crosswire.jsword.book.search.SearchEngine#activate()
- */
- public final void activate(Lock lock)
- {
- // Load the ascii Passage index
- if (isIndexed())
- {
- try
- {
- searcher = new IndexSearcher(NetUtil.getAsFile(url).getCanonicalPath());
- }
- catch (IOException ex)
- {
- log.warn("second load failure", ex); //$NON-NLS-1$
- }
- }
- else
- {
- IndexManager.instance().createIndex(this);
- }
-
- active = true;
- }
-
- /* (non-Javadoc)
- * @see org.crosswire.jsword.book.search.SearchEngine#deactivate()
- */
- public final void deactivate(Lock lock)
- {
- try
- {
- searcher.close();
- searcher = null;
- }
- catch (IOException ex)
- {
- Reporter.informUser(this, ex);
- }
-
- active = false;
- }
-
/**
! * Helper method so we can quickly activate ourselves on access
*/
! protected final void checkActive()
! {
! if (!active)
! {
! Activator.activate(this);
! }
! }
/**
--- 279,286 ----
}
/**
! * A synchronization lock point to prevent us from doing 2 index runs at a time.
*/
! private static final Object creating = new Object();
/**
***************
*** 313,331 ****
/**
- * Are we in the middle of generating an index?
- */
- private boolean generating = false;
-
- /**
- * The lucene search index directory
- */
- protected static final String DIR_LUCENE = "lucene"; //$NON-NLS-1$
-
- /**
- * The segments directory
- */
- protected static final String DIR_SEGMENTS = "segments"; //$NON-NLS-1$
-
- /**
* The Lucene field for the verse name
*/
--- 295,298 ----
***************
*** 345,349 ****
* The location of this index
*/
! private URL url;
/**
--- 312,316 ----
* The location of this index
*/
! private URL storage;
/**
Index: Msg.properties
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/search/lucene/Msg.properties,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** Msg.properties 29 Sep 2004 22:21:24 -0000 1.2
--- Msg.properties 9 Oct 2004 21:45:05 -0000 1.3
***************
*** 6,9 ****
--- 6,12 ----
# It should have no spaces or other punctuation (e.g. _, -, ', ...)
+ LuceneIndexManager.TypeIndexGen=Generating index for this work. Search results will be more accurate when index is complete.
+ LuceneIndexManager.Indexing=Indexing Bible Data
+
LuceneIndex.LuceneInit=Failed to initialise Lucene search engine.
LuceneIndex.SearchFailed=Search failed.
--- NEW FILE: LuceneIndexManager.java ---
package org.crosswire.jsword.book.search.lucene;
import java.io.IOException;
import java.net.URL;
import java.util.HashMap;
import java.util.Map;
import org.crosswire.common.util.Logger;
import org.crosswire.common.util.NetUtil;
import org.crosswire.common.util.Reporter;
import org.crosswire.jsword.book.Book;
import org.crosswire.jsword.book.BookException;
import org.crosswire.jsword.book.IndexStatus;
import org.crosswire.jsword.book.search.Index;
import org.crosswire.jsword.book.search.IndexManager;
import org.crosswire.jsword.util.Project;
/**
* .
*
*
*
*
* Distribution Licence:
* JSword 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
* here , or by writing to:
* Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
* MA 02111-1307, USA
* The copyright to this program is held by it's authors.
*
* @see gnu.gpl.Licence
* @author Joe Walker [joe at eireneh dot com]
* @version $Id: LuceneIndexManager.java,v 1.1 2004/10/09 21:45:05 joe Exp $
*/
public class LuceneIndexManager implements IndexManager
{
/* (non-Javadoc)
* @see org.crosswire.jsword.book.search.AbstractIndex#isIndexed()
*/
public boolean isIndexed(Book book)
{
try
{
URL storage = getStorageArea(book);
URL longer = NetUtil.lengthenURL(storage, DIR_SEGMENTS);
return NetUtil.isFile(longer);
}
catch (IOException ex)
{
log.error("Failed to find lucene index storage area.", ex); //$NON-NLS-1$
return false;
}
}
/* (non-Javadoc)
* @see org.crosswire.jsword.book.search.IndexManager#getIndex(org.crosswire.jsword.book.Book)
*/
public Index getIndex(Book book) throws BookException
{
try
{
Index reply = (Index) indexes.get(book);
if (reply == null)
{
URL storage = getStorageArea(book);
reply = new LuceneIndex(book, storage);
indexes.put(book, reply);
}
return reply;
}
catch (IOException ex)
{
throw new BookException(Msg.LUCENE_INIT, ex);
}
}
/* (non-Javadoc)
* @see org.crosswire.jsword.book.search.AbstractIndex#generateSearchIndex(org.crosswire.common.progress.Job)
*/
public void scheduleIndexCreation(final Book book)
{
book.getBookMetaData().setIndexStatus(IndexStatus.SCHEDULED);
Thread work = new Thread(new Runnable()
{
public void run()
{
try
{
URL storage = getStorageArea(book);
Index index = new LuceneIndex(book, storage, true);
indexes.put(book, index);
}
catch (Exception ex)
{
Reporter.informUser(LuceneIndexManager.this, ex);
}
}
});
work.start();
}
/* (non-Javadoc)
* @see org.crosswire.jsword.book.search.IndexManager#deleteIndex(org.crosswire.jsword.book.Book)
*/
public void deleteIndex(Book book) throws BookException
{
try
{
// TODO(joe): This needs some checks that it isn't being used
URL storage = getStorageArea(book);
NetUtil.delete(storage);
}
catch (IOException ex)
{
throw new BookException(Msg.DELETE_FAILED, ex);
}
}
/**
* Determine where an index should be stored
* @param book The book to be indexed
* @return A URL to store stuff in
* @throws IOException If there is a problem in finding where to store stuff
*/
protected URL getStorageArea(Book book) throws IOException
{
String driverName = book.getBookMetaData().getDriverName();
String bookName = book.getBookMetaData().getInitials();
assert driverName != null;
assert bookName != null;
URL base = Project.instance().getTempScratchSpace(DIR_LUCENE, false);
URL driver = NetUtil.lengthenURL(base, driverName);
return NetUtil.lengthenURL(driver, bookName);
}
/**
* The created indexes
*/
protected static final Map indexes = new HashMap();
/**
* The segments directory
*/
private static final String DIR_SEGMENTS = "segments"; //$NON-NLS-1$
/**
* The lucene search index directory
*/
private static final String DIR_LUCENE = "lucene"; //$NON-NLS-1$
/**
* The log stream
*/
private static final Logger log = Logger.getLogger(LuceneIndexManager.class);
}
Index: Msg.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/search/lucene/Msg.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** Msg.java 29 Sep 2004 22:21:24 -0000 1.9
--- Msg.java 9 Oct 2004 21:45:05 -0000 1.10
***************
*** 29,32 ****
--- 29,35 ----
class Msg extends MsgBase
{
+ static final Msg TYPE_INDEXGEN = new Msg("LuceneIndexManager.TypeIndexGen"); //$NON-NLS-1$
+ static final Msg INDEX_START = new Msg("LuceneIndexManager.Indexing"); //$NON-NLS-1$
+
static final Msg LUCENE_INIT = new Msg("LuceneIndex.LuceneInit"); //$NON-NLS-1$
static final Msg SEARCH_FAILED = new Msg("LuceneIndex.SearchFailed"); //$NON-NLS-1$
From jswordcvs at crosswire.org Sat Oct 9 14:45:07 2004
From: jswordcvs at crosswire.org (jswordcvs@crosswire.org)
Date: Sat Oct 9 14:45:12 2004
Subject: [jsword-svn] jsword/java/jsword/org/crosswire/jsword/book s
Message-ID: <200410092145.i99Lj7Fg030155@www.crosswire.org>
Update of /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book
In directory www.crosswire.org:/tmp/cvs-serv30045/java/jsword/org/crosswire/jsword/book
Modified Files:
BookMetaData.java Book.java StudyTool.java BookType.java
Added Files:
IndexStatus.java
Removed Files:
Search.java
Log Message:
indexing updates
--- Search.java DELETED ---
Index: BookType.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/BookType.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** BookType.java 21 Sep 2004 17:46:23 -0000 1.6
--- BookType.java 9 Oct 2004 21:45:05 -0000 1.7
***************
*** 3,7 ****
import java.io.Serializable;
-
/**
* An Enumeration of the possible types of Book.
--- 3,6 ----
Index: StudyTool.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/StudyTool.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** StudyTool.java 27 Jul 2004 21:42:36 -0000 1.8
--- StudyTool.java 9 Oct 2004 21:45:05 -0000 1.9
***************
*** 43,48 ****
public Collection getTranslations(Book bible, String word) throws BookException
{
! Search search = new Search(word, false);
! Key key = bible.find(search);
BookData data = bible.getData(key);
--- 43,47 ----
public Collection getTranslations(Book bible, String word) throws BookException
{
! Key key = bible.find(word);
BookData data = bible.getData(key);
***************
*** 92,97 ****
public Collection getTranslations(Book bible, Strongs number) throws BookException
{
! Search search = new Search(number, false);
! Key key = bible.find(search);
BookData data = bible.getData(key);
--- 91,95 ----
public Collection getTranslations(Book bible, Strongs number) throws BookException
{
! Key key = bible.find(number.getOLBName());
BookData data = bible.getData(key);
--- NEW FILE: IndexStatus.java ---
package org.crosswire.jsword.book;
import java.io.Serializable;
/**
* An Enumeration of the possible types of Book.
*
* NOTE(joe): consider giving each a number (1,2,4,8) and allowing combinations
*
*
*
*
* Distribution Licence:
* JSword 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
* here , or by writing to:
* Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
* MA 02111-1307, USA
* The copyright to this program is held by it's authors.
*
* @see gnu.gpl.Licence
* @author Joe Walker [joe at eireneh dot com]
* @version $Id: IndexStatus.java,v 1.1 2004/10/09 21:45:05 joe Exp $
*/
public class IndexStatus implements Serializable
{
/**
* There is a complete and ready to use search index
*/
public static final IndexStatus DONE = new IndexStatus("Indexed"); //$NON-NLS-1$
/**
* There is no search index, and no plans to create one
*/
public static final IndexStatus UNDONE = new IndexStatus("No Index"); //$NON-NLS-1$
/**
* This Book has been scheduled for index creation
*/
public static final IndexStatus SCHEDULED = new IndexStatus("Scheduled"); //$NON-NLS-1$
/**
* An index is currently being generated for this Book
*/
public static final IndexStatus CREATING = new IndexStatus("Creating"); //$NON-NLS-1$
/**
* All the known values
*/
private static final IndexStatus[] VALUES =
{
DONE,
UNDONE,
SCHEDULED,
CREATING,
};
/**
* @param name The name of the BookType
*/
private IndexStatus(String name)
{
this.name = name;
}
/**
* Lookup method to convert from a String
*/
public static IndexStatus fromString(String name)
{
for (int i = 0; i < VALUES.length; i++)
{
IndexStatus o = VALUES[i];
if (o.name.equalsIgnoreCase(name))
{
return o;
}
}
// cannot get here
assert false;
return null;
}
/**
* Lookup method to convert from an integer
*/
public static IndexStatus fromInteger(int i)
{
return VALUES[i];
}
/**
* Prevent subclasses from overriding canonical identity based Object methods
* @see java.lang.Object#equals(java.lang.Object)
*/
public final boolean equals(Object o)
{
return super.equals(o);
}
/**
* Prevent subclasses from overriding canonical identity based Object methods
* @see java.lang.Object#hashCode()
*/
public final int hashCode()
{
return super.hashCode();
}
/* (non-Javadoc)
* @see java.lang.Object#toString()
*/
public String toString()
{
return name;
}
/**
* The name of the BookType
*/
private String name;
// Support for serialization
private static int nextObj;
private final int obj = nextObj++;
Object readResolve()
{
return VALUES[obj];
}
/**
* SERIALUID(dms): A placeholder for the ultimate version id.
*/
private static final long serialVersionUID = 1L;
}
Index: Book.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/Book.java,v
retrieving revision 1.20
retrieving revision 1.21
diff -C2 -d -r1.20 -r1.21
*** Book.java 21 Sep 2004 17:46:23 -0000 1.20
--- Book.java 9 Oct 2004 21:45:05 -0000 1.21
***************
*** 63,66 ****
* @throws BookException If anything goes wrong with this method
*/
! public Key find(Search search) throws BookException;
}
--- 63,66 ----
* @throws BookException If anything goes wrong with this method
*/
! public Key find(String search) throws BookException;
}
Index: BookMetaData.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/BookMetaData.java,v
retrieving revision 1.21
retrieving revision 1.22
diff -C2 -d -r1.21 -r1.22
*** BookMetaData.java 5 Oct 2004 22:03:09 -0000 1.21
--- BookMetaData.java 9 Oct 2004 21:45:05 -0000 1.22
***************
*** 1,4 ****
--- 1,5 ----
package org.crosswire.jsword.book;
+ import java.beans.PropertyChangeListener;
import java.util.Map;
***************
*** 106,110 ****
* Calculated field: The name of the name, which could be helpful to
* distinguish similar Books available through 2 BookDrivers.
! * @return The name name
*/
public String getDriverName();
--- 107,111 ----
* Calculated field: The name of the name, which could be helpful to
* distinguish similar Books available through 2 BookDrivers.
! * @return The driver name
*/
public String getDriverName();
***************
*** 116,120 ****
* @return true if the orientation for the dominate language is LeftToRight.
*/
-
public boolean isLeftToRight();
--- 117,120 ----
***************
*** 123,132 ****
* The returned Properties will be read-only so any attempts to alter it
* will fail.
- * This method is designed to support finding out more about a book
- * rather than as a covert method of
*/
public Map getProperties();
/**
* The key for the type in the properties map
*/
--- 123,159 ----
* The returned Properties will be read-only so any attempts to alter it
* will fail.
*/
public Map getProperties();
/**
+ * Has anyone generated a search index for this Book?
+ * @see org.crosswire.jsword.book.search.IndexManager
+ */
+ public IndexStatus getIndexStatus();
+
+ /**
+ * This method does not alter the index status, however it is for Indexers
+ * that are responsible for indexing and have changed the status themselves.
+ * @see org.crosswire.jsword.book.search.IndexManager
+ */
+ public void setIndexStatus(IndexStatus status);
+
+ /**
+ * Adds a PropertyChangeListener
to the listener list.
+ * The listener is registered for all properties. However the only one likely
+ * to change at the time of writing is the Index Status.
+ * A PropertyChangeEvent
will get fired in response
+ * to setting a bound property, such as setIndexStatus
.
+ * @param li the PropertyChangeListener
to be added
+ */
+ public void addPropertyChangeListener(PropertyChangeListener li);
+
+ /**
+ * Removes a PropertyChangeListener
from the listener list.
+ * @param li the PropertyChangeListener
to be removed
+ */
+ public void removePropertyChangeListener(PropertyChangeListener li);
+
+ /**
* The key for the type in the properties map
*/
***************
*** 158,160 ****
--- 185,191 ----
public static final String KEY_INITIALS = "Initials"; //$NON-NLS-1$
+ /**
+ * The key for the indexed status in the properties map
+ */
+ public static final String KEY_INDEXSTATUS = "IndexStatus"; //$NON-NLS-1$
}
From jswordcvs at crosswire.org Sat Oct 9 14:45:07 2004
From: jswordcvs at crosswire.org (jswordcvs@crosswire.org)
Date: Sat Oct 9 14:45:13 2004
Subject: [jsword-svn] jsword/java/jsword/org/crosswire/jsword/book/basic s
Message-ID: <200410092145.i99Lj7uL030111@www.crosswire.org>
Update of /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/basic
In directory www.crosswire.org:/tmp/cvs-serv30045/java/jsword/org/crosswire/jsword/book/basic
Modified Files:
DefaultBookMetaData.java AbstractBook.java Verifier.java
Added Files:
AbstractBookMetaData.java
Log Message:
indexing updates
--- NEW FILE: AbstractBookMetaData.java ---
package org.crosswire.jsword.book.basic;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import javax.swing.event.EventListenerList;
import org.crosswire.jsword.book.BookMetaData;
/**
* An implementaion of the Propery Change methods from BookMetaData.
*
*
*
*
* Distribution Licence:
* JSword 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
* here , or by writing to:
* Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
* MA 02111-1307, USA
* The copyright to this program is held by it's authors.
*
* @see gnu.gpl.Licence
* @author Joe Walker [joe at eireneh dot com]
* @version $Id: AbstractBookMetaData.java,v 1.16 2004/10/09 21:45:04 joe Exp $
*/
public abstract class AbstractBookMetaData implements BookMetaData
{
/* (non-Javadoc)
* @see org.crosswire.jsword.book.BookMetaData#addPropertyChangeListener(java.beans.PropertyChangeListener)
*/
public void addPropertyChangeListener(PropertyChangeListener listener)
{
if (listeners == null)
{
listeners = new EventListenerList();
}
listeners.add(PropertyChangeListener.class, listener);
}
/* (non-Javadoc)
* @see org.crosswire.jsword.book.BookMetaData#removePropertyChangeListener(java.beans.PropertyChangeListener)
*/
public void removePropertyChangeListener(PropertyChangeListener listener)
{
if (listeners == null)
{
return;
}
listeners.remove(PropertyChangeListener.class, listener);
}
/**
* Reports bound property changes.
* If oldValue
and newValue
are not equal and the
* PropertyChangeEvent
listener list isn't empty,
* then fire a PropertyChange
event to each listener.
* @param propertyName the programmatic name of the property that was changed
* @param oldValue the old value of the property (as an Object)
* @param newValue the new value of the property (as an Object)
* @see java.beans.PropertyChangeSupport
*/
protected void firePropertyChange(String propertyName, Object oldValue, Object newValue)
{
if (listeners != null)
{
if (oldValue != null && newValue != null && oldValue.equals(newValue))
{
return;
}
if (listeners != null)
{
Object[] listenerList = listeners.getListenerList();
for (int i = 0; i <= listenerList.length - 2; i += 2)
{
if (listenerList[i] == PropertyChangeListener.class)
{
PropertyChangeEvent ev = new PropertyChangeEvent(this, propertyName, oldValue, newValue);
PropertyChangeListener li = (PropertyChangeListener) listenerList[i + 1];
li.propertyChange(ev);
}
}
}
}
}
/**
* The list of property change listeners
*/
private transient EventListenerList listeners;
}
Index: DefaultBookMetaData.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/basic/DefaultBookMetaData.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -d -r1.13 -r1.14
*** DefaultBookMetaData.java 5 Oct 2004 22:03:09 -0000 1.13
--- DefaultBookMetaData.java 9 Oct 2004 21:45:04 -0000 1.14
***************
*** 10,13 ****
--- 10,16 ----
import org.crosswire.jsword.book.BookMetaData;
import org.crosswire.jsword.book.BookType;
+ import org.crosswire.jsword.book.IndexStatus;
+ import org.crosswire.jsword.book.search.IndexManager;
+ import org.crosswire.jsword.book.search.IndexManagerFactory;
/**
***************
*** 39,43 ****
* @version $Id$
*/
! public class DefaultBookMetaData implements BookMetaData
{
/**
--- 42,46 ----
* @version $Id$
*/
! public class DefaultBookMetaData extends AbstractBookMetaData
{
/**
***************
*** 54,59 ****
setName(prop.getProperty(BookMetaData.KEY_NAME));
setType(prop.getProperty(BookMetaData.KEY_TYPE));
-
setLanguage(prop.getProperty(BookMetaData.KEY_LANGUAGE));
}
--- 57,71 ----
setName(prop.getProperty(BookMetaData.KEY_NAME));
setType(prop.getProperty(BookMetaData.KEY_TYPE));
setLanguage(prop.getProperty(BookMetaData.KEY_LANGUAGE));
+
+ IndexManager imanager = IndexManagerFactory.getIndexManager();
+ if (imanager.isIndexed(book))
+ {
+ setIndexStatus(IndexStatus.DONE);
+ }
+ else
+ {
+ setIndexStatus(IndexStatus.UNDONE);
+ }
}
***************
*** 167,170 ****
--- 179,201 ----
}
+ /* (non-Javadoc)
+ * @see org.crosswire.jsword.book.BookMetaData#getIndexStatus()
+ */
+ public IndexStatus getIndexStatus()
+ {
+ return indexStatus;
+ }
+
+ /* (non-Javadoc)
+ * @see org.crosswire.jsword.book.BookMetaData#setIndexStatus(java.lang.String)
+ */
+ public void setIndexStatus(IndexStatus newValue)
+ {
+ IndexStatus oldValue = this.indexStatus;
+ this.indexStatus = newValue;
+ map.put(KEY_INDEXSTATUS, newValue);
+ firePropertyChange(KEY_INDEXSTATUS, oldValue, newValue);
+ }
+
/**
* @param book The book to set.
***************
*** 333,335 ****
--- 364,367 ----
private String language = ""; //$NON-NLS-1$
private String initials = ""; //$NON-NLS-1$
+ private IndexStatus indexStatus = IndexStatus.UNDONE;
}
Index: AbstractBook.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/basic/AbstractBook.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -d -r1.10 -r1.11
*** AbstractBook.java 29 Sep 2004 22:21:24 -0000 1.10
--- AbstractBook.java 9 Oct 2004 21:45:04 -0000 1.11
***************
*** 6,18 ****
import org.crosswire.jsword.book.BookException;
import org.crosswire.jsword.book.BookMetaData;
- import org.crosswire.jsword.book.Search;
- import org.crosswire.jsword.book.search.Index;
- import org.crosswire.jsword.book.search.IndexFactory;
- import org.crosswire.jsword.book.search.Matcher;
- import org.crosswire.jsword.book.search.MatcherFactory;
import org.crosswire.jsword.book.search.Searcher;
import org.crosswire.jsword.book.search.SearcherFactory;
- import org.crosswire.jsword.book.search.Thesaurus;
- import org.crosswire.jsword.book.search.ThesaurusFactory;
import org.crosswire.jsword.passage.Key;
--- 6,11 ----
***************
*** 76,118 ****
/* (non-Javadoc)
! * @see org.crosswire.jsword.book.search.Searcher#search(org.crosswire.jsword.book.Search)
*/
! public Key find(Search search) throws BookException
{
! try
{
! if (index == null)
! {
! index = IndexFactory.getIndexForBook(this);
! }
!
! if (thesaurus == null)
! {
! thesaurus = ThesaurusFactory.createThesaurus();
! }
!
! if (search.isBestMatch())
{
! if (matcher == null)
! {
! matcher = MatcherFactory.createMatcher(index, thesaurus);
! }
!
! return matcher.bestMatch(search.getMatch(), search.getRestriction());
}
! else
{
! if (searcher == null)
! {
! searcher = SearcherFactory.createSearcher(index);
! }
!
! return searcher.search(search.getMatch(), search.getRestriction());
}
}
! catch (InstantiationException ex)
! {
! throw new BookException(Msg.INDEX_FAIL);
! }
}
--- 69,89 ----
/* (non-Javadoc)
! * @see org.crosswire.jsword.book.Book#find(java.lang.String)
*/
! public Key find(String search) throws BookException
{
! if (searcher == null)
{
! try
{
! searcher = SearcherFactory.createSearcher(this);
}
! catch (InstantiationException ex)
{
! throw new BookException(Msg.INDEX_FAIL);
}
}
!
! return searcher.search(search);
}
***************
*** 126,144 ****
/**
- * The global thesaurus
- */
- private Thesaurus thesaurus;
-
- /**
- * The search index for this book
- */
- private Index index;
-
- /**
- * How do we perform best matches
- */
- private Matcher matcher;
-
- /**
* How do we perform searches
*/
--- 97,100 ----
Index: Verifier.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/basic/Verifier.java,v
retrieving revision 1.27
retrieving revision 1.28
diff -C2 -d -r1.27 -r1.28
*** Verifier.java 29 Sep 2004 22:21:24 -0000 1.27
--- Verifier.java 9 Oct 2004 21:45:04 -0000 1.28
***************
*** 10,14 ****
import org.crosswire.jsword.book.BookData;
import org.crosswire.jsword.book.BookException;
- import org.crosswire.jsword.book.Search;
import org.crosswire.jsword.passage.BibleInfo;
import org.crosswire.jsword.passage.Key;
--- 10,13 ----
***************
*** 198,203 ****
private void checkSinglePassage(String word, PrintWriter out) throws BookException
{
! Key ref1 = book1.find(new Search(word, false));
! Key ref2 = book2.find(new Search(word, false));
// Check
--- 197,202 ----
private void checkSinglePassage(String word, PrintWriter out) throws BookException
{
! Key ref1 = book1.find(word);
! Key ref2 = book2.find(word);
// Check
From jswordcvs at crosswire.org Sat Oct 9 14:45:07 2004
From: jswordcvs at crosswire.org (jswordcvs@crosswire.org)
Date: Sat Oct 9 14:45:13 2004
Subject: [jsword-svn] jsword/java/limbo/org/crosswire/jsword/book/remote s
Message-ID: <200410092145.i99Lj7P6030115@www.crosswire.org>
Update of /cvs/jsword/jsword/java/limbo/org/crosswire/jsword/book/remote
In directory www.crosswire.org:/tmp/cvs-serv30045/java/limbo/org/crosswire/jsword/book/remote
Modified Files:
LocalRemoter.java ParamName.java RemoteMethodTest.java
RemoteBook.java
Log Message:
indexing updates
Index: RemoteBook.java
===================================================================
RCS file: /cvs/jsword/jsword/java/limbo/org/crosswire/jsword/book/remote/RemoteBook.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** RemoteBook.java 5 Oct 2004 22:03:09 -0000 1.7
--- RemoteBook.java 9 Oct 2004 21:45:05 -0000 1.8
***************
*** 8,12 ****
import org.crosswire.jsword.book.BookMetaData;
import org.crosswire.jsword.book.BookType;
- import org.crosswire.jsword.book.Search;
import org.crosswire.jsword.book.basic.AbstractBook;
import org.crosswire.jsword.book.basic.DefaultBookMetaData;
--- 8,11 ----
***************
*** 103,107 ****
* @see org.crosswire.jsword.book.Bible#findPassage(org.crosswire.jsword.book.Search)
*/
! public Key find(Search search) throws BookException
{
try
--- 102,106 ----
* @see org.crosswire.jsword.book.Bible#findPassage(org.crosswire.jsword.book.Search)
*/
! public Key find(String search) throws BookException
{
try
***************
*** 109,115 ****
RemoteMethod method = new RemoteMethod(MethodName.FINDPASSAGE);
method.addParam(ParamName.PARAM_BIBLE, driver.getID(getBookMetaData()));
! method.addParam(ParamName.PARAM_FINDSTRING, search.getMatch());
! method.addParam(ParamName.PARAM_FINDMATCH, Boolean.toString(search.isBestMatch()));
! method.addParam(ParamName.PARAM_FINDRANGE, search.getRestriction().getName());
Document doc = remoter.execute(method);
--- 108,112 ----
RemoteMethod method = new RemoteMethod(MethodName.FINDPASSAGE);
method.addParam(ParamName.PARAM_BIBLE, driver.getID(getBookMetaData()));
! method.addParam(ParamName.PARAM_FINDSTRING, search);
Document doc = remoter.execute(method);
Index: RemoteMethodTest.java
===================================================================
RCS file: /cvs/jsword/jsword/java/limbo/org/crosswire/jsword/book/remote/RemoteMethodTest.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** RemoteMethodTest.java 21 Sep 2004 17:46:23 -0000 1.2
--- RemoteMethodTest.java 9 Oct 2004 21:45:05 -0000 1.3
***************
*** 64,69 ****
rmt1.addParam(ParamName.PARAM_BIBLE, "v1:1"); //$NON-NLS-1$
- rmt2.addParam(ParamName.PARAM_FINDMATCH, "v2:1"); //$NON-NLS-1$
- rmt2.addParam(ParamName.PARAM_FINDRANGE, "v2:2"); //$NON-NLS-1$
rmt3.addParam(ParamName.PARAM_FINDSTRING, "v3:1"); //$NON-NLS-1$
rmt3.addParam(ParamName.PARAM_PASSAGE, "v3:2"); //$NON-NLS-1$
--- 64,67 ----
***************
*** 82,87 ****
assertEquals(null, rmt1.getParameter(ParamName.PARAM_BIBLE));
- assertEquals("v2:1", rmt2.getParameter(ParamName.PARAM_FINDMATCH)); //$NON-NLS-1$
- assertEquals("v2:2", rmt2.getParameter(ParamName.PARAM_FINDRANGE)); //$NON-NLS-1$
assertEquals("v3:1", rmt3.getParameter(ParamName.PARAM_FINDSTRING)); //$NON-NLS-1$
assertEquals("v3:2", rmt3.getParameter(ParamName.PARAM_PASSAGE)); //$NON-NLS-1$
--- 80,83 ----
Index: ParamName.java
===================================================================
RCS file: /cvs/jsword/jsword/java/limbo/org/crosswire/jsword/book/remote/ParamName.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** ParamName.java 21 Sep 2004 17:46:23 -0000 1.2
--- ParamName.java 9 Oct 2004 21:45:05 -0000 1.3
***************
*** 32,37 ****
static final ParamName PARAM_PASSAGE = new ParamName("passage"); //$NON-NLS-1$
static final ParamName PARAM_FINDSTRING = new ParamName("word"); //$NON-NLS-1$
- static final ParamName PARAM_FINDMATCH = new ParamName("match"); //$NON-NLS-1$
- static final ParamName PARAM_FINDRANGE = new ParamName("range"); //$NON-NLS-1$
/**
--- 32,35 ----
***************
*** 111,115 ****
private static final ParamName[] VALUES =
{
! PARAM_BIBLE, PARAM_PASSAGE, PARAM_FINDSTRING, PARAM_FINDMATCH, PARAM_FINDRANGE
};
}
\ No newline at end of file
--- 109,115 ----
private static final ParamName[] VALUES =
{
! PARAM_BIBLE,
! PARAM_PASSAGE,
! PARAM_FINDSTRING,
};
}
\ No newline at end of file
Index: LocalRemoter.java
===================================================================
RCS file: /cvs/jsword/jsword/java/limbo/org/crosswire/jsword/book/remote/LocalRemoter.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** LocalRemoter.java 5 Oct 2004 22:03:09 -0000 1.4
--- LocalRemoter.java 9 Oct 2004 21:45:05 -0000 1.5
***************
*** 12,16 ****
import org.crosswire.jsword.book.BookMetaData;
import org.crosswire.jsword.book.Books;
- import org.crosswire.jsword.book.Search;
import org.crosswire.jsword.passage.Key;
import org.jdom.Document;
--- 12,15 ----
***************
*** 91,101 ****
String word = method.getParameter(ParamName.PARAM_FINDSTRING);
! boolean match = Boolean.getBoolean(method.getParameter(ParamName.PARAM_FINDMATCH));
! String refstr = method.getParameter(ParamName.PARAM_FINDRANGE);
! Key range = book.getKey(refstr);
! Search search = new Search(word, match);
! search.setRestriction(range);
!
! Key key = book.find(search);
return Converter.convertKeyListToDocument(key);
}
--- 90,94 ----
String word = method.getParameter(ParamName.PARAM_FINDSTRING);
! Key key = book.find(word);
return Converter.convertKeyListToDocument(key);
}
From jswordcvs at crosswire.org Sat Oct 9 14:45:07 2004
From: jswordcvs at crosswire.org (jswordcvs@crosswire.org)
Date: Sat Oct 9 14:45:13 2004
Subject: [jsword-svn]
jsword/java/jsword/org/crosswire/jsword/book/search/parse s
Message-ID: <200410092145.i99Lj7LQ030160@www.crosswire.org>
Update of /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/search/parse
In directory www.crosswire.org:/tmp/cvs-serv30045/java/jsword/org/crosswire/jsword/book/search/parse
Modified Files:
Msg.properties PhraseParamWord.java IndexSearcher.java
Msg.java
Log Message:
indexing updates
Index: Msg.properties
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/search/parse/Msg.properties,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** Msg.properties 27 Jun 2004 22:09:15 -0000 1.2
--- Msg.properties 9 Oct 2004 21:45:05 -0000 1.3
***************
*** 22,23 ****
--- 22,25 ----
PassageLeftParamWord.IllegalPassage=Syntax Error: Invalid passage "{0}"
CustomTokenizer.UnmatchedEscape=Syntax Error: Unmatched brackets - [ and ]
+ PhraseParamWord.SingleParam=Can''t get a word from a sub-expression (processing ''"'').
+ PhraseParamWord.NoThesaurus=Couldn't create a thesaurus.
Index: IndexSearcher.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/search/parse/IndexSearcher.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** IndexSearcher.java 2 Oct 2004 23:51:12 -0000 1.2
--- IndexSearcher.java 9 Oct 2004 21:45:05 -0000 1.3
***************
*** 11,15 ****
import org.crosswire.common.util.ResourceUtil;
import org.crosswire.jsword.book.BookException;
- import org.crosswire.jsword.book.Search;
import org.crosswire.jsword.book.search.Index;
import org.crosswire.jsword.book.search.Searcher;
--- 11,14 ----
***************
*** 65,79 ****
* @see org.crosswire.jsword.book.search.Searcher#search(java.lang.String, org.crosswire.jsword.passage.Key)
*/
! public Key search(String search, Key restriction) throws BookException
{
output = CustomTokenizer.tokenize(search, commands);
! Key key = search(output);
!
! if (restriction != Search.UNRESTRICTED)
! {
! key.retainAll(restriction);
! }
!
! return key;
}
--- 64,71 ----
* @see org.crosswire.jsword.book.search.Searcher#search(java.lang.String, org.crosswire.jsword.passage.Key)
*/
! public Key search(String search) throws BookException
{
output = CustomTokenizer.tokenize(search, commands);
! return search(output);
}
***************
*** 290,298 ****
* Accessor for the cached list of known special lookup words
*/
! public static Map getPreferredMap()
{
// Check the maps have been created
getWordMap();
! return preferredMap;
}
--- 282,290 ----
* Accessor for the cached list of known special lookup words
*/
! public static String getPreferredSyntax(Class command)
{
// Check the maps have been created
getWordMap();
! return (String) preferredMap.get(command);
}
Index: PhraseParamWord.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/search/parse/PhraseParamWord.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** PhraseParamWord.java 2 Oct 2004 23:51:12 -0000 1.1
--- PhraseParamWord.java 9 Oct 2004 21:45:05 -0000 1.2
***************
*** 1,10 ****
package org.crosswire.jsword.book.search.parse;
import java.util.Iterator;
import org.crosswire.jsword.book.BookException;
! import org.crosswire.jsword.book.search.Index;
import org.crosswire.jsword.passage.Key;
! import org.crosswire.jsword.passage.NoSuchKeyException;
/**
--- 1,15 ----
package org.crosswire.jsword.book.search.parse;
+ import java.util.Collection;
import java.util.Iterator;
import org.crosswire.jsword.book.BookException;
! import org.crosswire.jsword.book.SentanceUtil;
! import org.crosswire.jsword.book.search.Grammar;
! import org.crosswire.jsword.book.search.Thesaurus;
! import org.crosswire.jsword.book.search.ThesaurusFactory;
import org.crosswire.jsword.passage.Key;
! import org.crosswire.jsword.passage.PassageTally;
! import org.crosswire.jsword.passage.RestrictionType;
/**
***************
*** 40,44 ****
public String getWord(IndexSearcher engine) throws BookException
{
! throw new BookException(Msg.LEFT_PARAM);
}
--- 45,49 ----
public String getWord(IndexSearcher engine) throws BookException
{
! throw new BookException(Msg.SINGLE_PARAM);
}
***************
*** 51,55 ****
StringBuffer buff = new StringBuffer();
- int paren_level = 1;
while (true)
{
--- 56,59 ----
***************
*** 63,76 ****
if (word instanceof PhraseParamWord)
{
- paren_level++;
- }
-
- if (word instanceof PassageRightParamWord)
- {
- paren_level--;
- }
-
- if (paren_level == 0)
- {
break;
}
--- 67,70 ----
***************
*** 80,93 ****
}
! try
{
! Index index = engine.getIndex();
! return index.getKey(buff.toString());
}
! catch (NoSuchKeyException ex)
{
! throw new BookException(Msg.ILLEGAL_PASSAGE, ex, new Object[] { buff.toString() });
}
}
}
--- 74,141 ----
}
! return bestMatch(engine, buff.toString());
! }
!
! /* (non-Javadoc)
! * @see org.crosswire.jsword.book.search.Matcher#bestMatch(java.lang.String, org.crosswire.jsword.passage.Key)
! */
! public Key bestMatch(IndexSearcher engine, String sought) throws BookException
! {
! if (thesaurus == null)
{
! try
! {
! thesaurus = ThesaurusFactory.createThesaurus();
! }
! catch (InstantiationException ex)
! {
! throw new BookException(Msg.NO_THESAURUS, ex);
! }
! }
! String[] words = SentanceUtil.getWords(sought);
! words = Grammar.stripSmallWords(words);
! // log.fine("words="+StringUtil.toString(words));
!
! PassageTally tally = new PassageTally();
! tally.blur(BLUR_BY, RestrictionType.NONE);
!
! for (int i = 0; i < words.length; i++)
! {
! tally.addAll(engine.getIndex().findWord(words[i]));
}
!
! // This uses updatePassageTallyFlat() so that words like God
! // that have many startsWith() matches, and hence many verse
! // matches, do not end up with wrongly high scores.
! for (int i = 0; i < words.length; i++)
{
! // log.fine(" root="+root);
! Collection col = thesaurus.getSynonyms(words[i]);
! String[] grWords = (String[]) col.toArray(new String[col.size()]);
!
! // log.fine(" gr_words="+StringUtil.toString(gr_words));
! PassageTally temp = new PassageTally();
!
! for (int j = 0; j < grWords.length; j++)
! {
! temp.addAll(engine.getIndex().findWord(grWords[j]));
! }
!
! temp.flatten();
! tally.addAll(temp);
}
+
+ return tally;
}
+
+ /**
+ * How we get related words
+ */
+ private Thesaurus thesaurus;
+
+ /**
+ * How many verses do we blur by?
+ */
+ private static final int BLUR_BY = 2;
}
Index: Msg.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/search/parse/Msg.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** Msg.java 29 Sep 2004 22:21:23 -0000 1.9
--- Msg.java 9 Oct 2004 21:45:05 -0000 1.10
***************
*** 45,48 ****
--- 45,50 ----
static final Msg ILLEGAL_PASSAGE = new Msg("PassageLeftParamWord.IllegalPassage"); //$NON-NLS-1$
static final Msg UNMATCHED_ESCAPE = new Msg("CustomTokenizer.UnmatchedEscape"); //$NON-NLS-1$
+ static final Msg SINGLE_PARAM = new Msg("PhraseParamWord.SingleParam"); //$NON-NLS-1$
+ static final Msg NO_THESAURUS = new Msg("PhraseParamWord.NoThesaurus"); //$NON-NLS-1$
/**
From jswordcvs at crosswire.org Sat Oct 9 14:45:26 2004
From: jswordcvs at crosswire.org (jswordcvs@crosswire.org)
Date: Sat Oct 9 14:45:27 2004
Subject: [jsword-svn]
bibledesktop/java/main/org/crosswire/bibledesktop/desktop s
Message-ID: <200410092145.i99LjQdb030332@www.crosswire.org>
Update of /cvs/jsword/bibledesktop/java/main/org/crosswire/bibledesktop/desktop
In directory www.crosswire.org:/tmp/cvs-serv30310/java/main/org/crosswire/bibledesktop/desktop
Modified Files:
Desktop.java
Log Message:
indexing updates
Index: Desktop.java
===================================================================
RCS file: /cvs/jsword/bibledesktop/java/main/org/crosswire/bibledesktop/desktop/Desktop.java,v
retrieving revision 1.31
retrieving revision 1.32
diff -C2 -d -r1.31 -r1.32
*** Desktop.java 6 Oct 2004 22:52:29 -0000 1.31
--- Desktop.java 9 Oct 2004 21:45:24 -0000 1.32
***************
*** 349,354 ****
sptBooks.setOpaque(true);
sptBooks.setBorder(null);
- BibleViewPane bvp = (BibleViewPane) views.getSelected();
- bvp.adjustFocus();
addWindowListener(new WindowAdapter()
--- 349,352 ----
***************
*** 406,414 ****
display.removeURLEventListener(this);
display.removeURLEventListener(barStatus);
- BibleViewPane bvp = (BibleViewPane) getViews().getSelected();
- if (bvp != null)
- {
- bvp.adjustFocus();
- }
}
--- 404,407 ----
From jswordcvs at crosswire.org Sat Oct 9 14:45:26 2004
From: jswordcvs at crosswire.org (jswordcvs@crosswire.org)
Date: Sat Oct 9 14:45:27 2004
Subject: [jsword-svn]
bibledesktop/java/main/org/crosswire/bibledesktop/book/parse s
Message-ID: <200410092145.i99LjQl3030327@www.crosswire.org>
Update of /cvs/jsword/bibledesktop/java/main/org/crosswire/bibledesktop/book/parse
In directory www.crosswire.org:/tmp/cvs-serv30310/java/main/org/crosswire/bibledesktop/book/parse
Removed Files:
Msg.java AdvancedSearchPane.properties Msg.properties
AdvancedSearchPane.java package.html
Log Message:
indexing updates
--- package.html DELETED ---
--- Msg.properties DELETED ---
--- AdvancedSearchPane.properties DELETED ---
--- AdvancedSearchPane.java DELETED ---
--- Msg.java DELETED ---
From jswordcvs at crosswire.org Sat Oct 9 14:45:26 2004
From: jswordcvs at crosswire.org (jswordcvs@crosswire.org)
Date: Sat Oct 9 14:45:27 2004
Subject: [jsword-svn]
bibledesktop/java/main/org/crosswire/bibledesktop/book s
Message-ID: <200410092145.i99LjQGV030318@www.crosswire.org>
Update of /cvs/jsword/bibledesktop/java/main/org/crosswire/bibledesktop/book
In directory www.crosswire.org:/tmp/cvs-serv30310/java/main/org/crosswire/bibledesktop/book
Modified Files:
DisplaySelectPane.java Msg.properties Msg.java
DisplaySelectPane.properties BibleViewPane.java
Added Files:
AdvancedSearchPane.java AdvancedSearchPane.properties
Log Message:
indexing updates
Index: DisplaySelectPane.properties
===================================================================
RCS file: /cvs/jsword/bibledesktop/java/main/org/crosswire/bibledesktop/book/DisplaySelectPane.properties,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** DisplaySelectPane.properties 2 Oct 2004 23:51:06 -0000 1.7
--- DisplaySelectPane.properties 9 Oct 2004 21:45:24 -0000 1.8
***************
*** 64,65 ****
--- 64,71 ----
Advanced.LargeIcon=toolbarButtonGraphics/general/Find24.gif
Advanced.MnemonicKey=V
+
+ # for the index button
+ Index.Name=Generate or Download Index
+ Index.ShortDescription=Generate an index
+ Index.LongDescription=Generate a search index to enable searching
+ Index.MnemonicKey=X
--- NEW FILE: AdvancedSearchPane.java ---
package org.crosswire.bibledesktop.book;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Font;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.SystemColor;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import javax.swing.BorderFactory;
import javax.swing.ComboBoxModel;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JComponent;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.KeyStroke;
import javax.swing.WindowConstants;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import org.crosswire.common.swing.ActionFactory;
import org.crosswire.common.swing.GuiUtil;
import org.crosswire.common.swing.LookAndFeelUtil;
import org.crosswire.common.util.Logger;
import org.crosswire.common.util.StringUtil;
import org.crosswire.jsword.book.search.parse.IndexSearcher;
import org.crosswire.jsword.book.search.parse.PassageLeftParamWord;
import org.crosswire.jsword.book.search.parse.PassageRightParamWord;
import org.crosswire.jsword.book.search.parse.PhraseParamWord;
import org.crosswire.jsword.book.search.parse.RemoveCommandWord;
import org.crosswire.jsword.book.search.parse.RetainCommandWord;
/**
* An advanced search dialog.
*
*
*
*
* Distribution Licence:
* JSword 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
* here , or by writing to:
* Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
* MA 02111-1307, USA
* The copyright to this program is held by it's authors.
*
* @see gnu.gpl.Licence
* @author Joe Walker [joe at eireneh dot com]
* @version $Id: AdvancedSearchPane.java,v 1.1 2004/10/09 21:45:24 joe Exp $
*/
public class AdvancedSearchPane extends JPanel implements DocumentListener
{
/**
* This is the default constructor
*/
public AdvancedSearchPane()
{
presets = Msg.PRESETS.toString().split("\\|"); //$NON-NLS-1$
initialize();
}
/**
* This method initializes this GUI
*/
private void initialize()
{
actions = new ActionFactory(AdvancedSearchPane.class, this);
// SystemColor.controlShadow
JLabel temp = new JLabel();
Color headBG = SystemColor.control.darker();
Color headFG = Color.BLACK;
Font headFont = temp.getFont().deriveFont(Font.BOLD);
lblHeading = actions.createJLabel(HEAD_BASE);
lblHeading.setBorder(BorderFactory.createLineBorder(headBG, 3));
lblHeading.setBackground(headBG);
lblHeading.setForeground(headFG);
lblHeading.setFont(headFont);
lblHeading.setOpaque(true);
lblPhrase = actions.createJLabel(PHRASE);
txtPhrase = new JTextField();
txtPhrase.getDocument().addDocumentListener(this);
txtIncludes = new JTextField();
txtIncludes.getDocument().addDocumentListener(this);
lblIncludes = actions.createJLabel(INCLUDES);
lblIncludes.setLabelFor(txtIncludes);
txtExcludes = new JTextField();
txtExcludes.getDocument().addDocumentListener(this);
lblExcludes = actions.createJLabel(EXCLUDES);
lblExcludes.setLabelFor(txtExcludes);
chkRestrict = new JCheckBox(actions.getAction(HEAD_RESTRICT));
chkRestrict.setBackground(headBG);
chkRestrict.setForeground(headFG);
chkRestrict.setFont(headFont);
lblPresets = actions.createJLabel(PRESETS);
lblPresets.setVisible(false);
cboPresets = new JComboBox(presets);
cboPresets.setVisible(false);
cboPresets.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent ev)
{
updatePreset();
}
});
lblRestrict = actions.createJLabel(RESTRICT);
lblRestrict.setVisible(false);
txtRestrict = new JTextField();
txtRestrict.setVisible(false);
txtRestrict.getDocument().addDocumentListener(this);
btnRestrict = new JButton(actions.getAction(RESTRICT_SELECT));
btnRestrict.setVisible(false);
chkSummary = new JCheckBox(actions.getAction(HEAD_SUMMARY));
chkSummary.setBackground(headBG);
chkSummary.setForeground(headFG);
chkSummary.setFont(headFont);
lblSummary = actions.createJLabel(SUMMARY);
lblSummary.setVisible(false);
txtSummary = new JTextArea();
txtSummary.setBackground(SystemColor.control);
txtSummary.setLineWrap(true);
txtSummary.setEditable(false);
txtSummary.setRows(2);
scrSummary = new JScrollPane(txtSummary);
scrSummary.setVisible(false);
// chkHebGrk = new JCheckBox(actions.getAction(HEAD_ORIGINAL));
// chkHebGrk.setBackground(headBG);
// chkHebGrk.setForeground(headFG);
// chkHebGrk.setFont(headFont);
// lblHebInc = actions.createJLabel(HEBREW_INCLUDE);
// lblHebInc.setVisible(false);
// txtHebInc = new JTextField();
// txtHebInc.setVisible(false);
// txtHebInc.getDocument().addDocumentListener(this);
// lblHebExc = actions.createJLabel(HEBREW_EXCLUDE);
// lblHebExc.setVisible(false);
// txtHebExc = new JTextField();
// txtHebExc.setVisible(false);
// txtHebExc.getDocument().addDocumentListener(this);
// lblGrkInc = actions.createJLabel(GREEK_INCLUDE);
// lblGrkInc.setVisible(false);
// txtGrkInc = new JTextField();
// txtGrkInc.setVisible(false);
// txtGrkInc.getDocument().addDocumentListener(this);
// lblGrkExc = actions.createJLabel(GREEK_EXCLUDE);
// lblGrkExc.setVisible(false);
// txtGrkExc = new JTextField();
// txtGrkExc.setVisible(false);
// txtGrkExc.getDocument().addDocumentListener(this);
//
// chkTime = new JCheckBox(actions.getAction(HEAD_TIME));
// chkTime.setBackground(headBG);
// chkTime.setForeground(headFG);
// chkTime.setFont(headFont);
// lblAfter = actions.createJLabel(AFTER);
// lblAfter.setVisible(false);
// txtAfter = new JTextField();
// txtAfter.setVisible(false);
// txtAfter.getDocument().addDocumentListener(this);
// lblBefore = actions.createJLabel(BEFORE);
// lblBefore.setVisible(false);
// txtBefore = new JTextField();
// txtBefore.setVisible(false);
// txtBefore.getDocument().addDocumentListener(this);
btnGo = new JButton(actions.getAction(DONE));
this.setBorder(BorderFactory.createLineBorder(SystemColor.control, 5));
this.setLayout(new GridBagLayout());
this.add(lblHeading, new GridBagConstraints(0, 1, 3, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(2, 2, 2, 2), 0, 0));
this.add(lblPhrase, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
this.add(txtPhrase, new GridBagConstraints(1, 2, 2, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(2, 5, 2, 5), 0, 0));
this.add(lblIncludes, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
this.add(txtIncludes, new GridBagConstraints(1, 3, 2, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(2, 5, 2, 5), 0, 0));
this.add(lblExcludes, new GridBagConstraints(0, 4, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
this.add(txtExcludes, new GridBagConstraints(1, 4, 2, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(2, 5, 2, 5), 0, 0));
this.add(chkRestrict, new GridBagConstraints(0, 5, 3, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(2, 2, 2, 2), 0, 0));
this.add(lblPresets, new GridBagConstraints(0, 6, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
this.add(cboPresets, new GridBagConstraints(1, 6, 2, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(2, 5, 2, 5), 0, 0));
this.add(lblRestrict, new GridBagConstraints(0, 7, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
this.add(txtRestrict, new GridBagConstraints(1, 7, 1, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(2, 5, 2, 5), 0, 0));
this.add(btnRestrict, new GridBagConstraints(2, 7, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 5), 0, 0));
// this.add(chkHebGrk, new GridBagConstraints(0, 8, 3, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(2, 2, 2, 2), 0, 0));
// this.add(lblHebInc, new GridBagConstraints(0, 9, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
// this.add(txtHebInc, new GridBagConstraints(1, 9, 2, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(2, 5, 2, 5), 0, 0));
// this.add(lblHebExc, new GridBagConstraints(0, 10, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
// this.add(txtHebExc, new GridBagConstraints(1, 10, 2, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(2, 5, 2, 5), 0, 0));
// this.add(lblGrkInc, new GridBagConstraints(0, 11, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
// this.add(txtGrkInc, new GridBagConstraints(1, 11, 2, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(2, 5, 2, 5), 0, 0));
// this.add(lblGrkExc, new GridBagConstraints(0, 12, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
// this.add(txtGrkExc, new GridBagConstraints(1, 12, 2, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(2, 5, 2, 5), 0, 0));
// this.add(chkTime, new GridBagConstraints(0, 13, 3, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(2, 2, 2, 2), 0, 0));
// this.add(lblAfter, new GridBagConstraints(0, 14, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
// this.add(txtAfter, new GridBagConstraints(1, 14, 2, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(2, 5, 2, 5), 0, 0));
// this.add(lblBefore, new GridBagConstraints(0, 15, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
// this.add(txtBefore, new GridBagConstraints(1, 15, 2, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(2, 5, 2, 5), 0, 0));
this.add(chkSummary, new GridBagConstraints(0, 16, 3, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(2, 2, 2, 2), 0, 0));
this.add(lblSummary, new GridBagConstraints(0, 17, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
this.add(scrSummary, new GridBagConstraints(1, 17, 2, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(2, 5, 2, 5), 0, 0));
this.add(btnGo, new GridBagConstraints(2, 18, 1, 1, 0.0, 0.0, GridBagConstraints.SOUTH, GridBagConstraints.NONE, new Insets(10, 0, 5, 5), 0, 0));
}
/**
* Open us in a new (optionally modal) dialog window
* @param parent The component to which to attach the new dialog
* @param title The title for the new dialog
*/
public String showInDialog(Component parent, String title, boolean modal, String search)
{
txtSummary.setText(search);
dlgMain = new JDialog(JOptionPane.getFrameForComponent(parent));
KeyStroke esc = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0);
bailout = true;
ActionListener closer = new ActionListener()
{
public void actionPerformed(ActionEvent ev)
{
dlgMain.dispose();
}
};
dlgMain.getContentPane().setLayout(new BorderLayout());
dlgMain.getContentPane().add(this, BorderLayout.CENTER);
dlgMain.getRootPane().setDefaultButton(btnGo);
dlgMain.getRootPane().registerKeyboardAction(closer, esc, JComponent.WHEN_IN_FOCUSED_WINDOW);
dlgMain.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
dlgMain.setTitle(title);
dlgMain.setModal(modal);
GuiUtil.restrainedPack(dlgMain, 0.5f, 0.75f);
GuiUtil.centerWindow(dlgMain);
dlgMain.setVisible(true);
if (bailout)
{
return null;
}
else
{
return txtSummary.getText();
}
}
/**
* Someone clicked the restrict toggle button
*/
public void doHeadRestrict()
{
boolean visible = chkRestrict.isSelected();
lblPresets.setVisible(visible);
cboPresets.setVisible(visible);
lblRestrict.setVisible(visible);
txtRestrict.setVisible(visible);
btnRestrict.setVisible(visible);
if (dlgMain != null)
{
dlgMain.pack();
}
}
/**
* Someone clicked the restrict toggle button
*/
public void doHeadSummary()
{
boolean visible = chkSummary.isSelected();
lblSummary.setVisible(visible);
scrSummary.setVisible(visible);
if (dlgMain != null)
{
dlgMain.pack();
}
}
/**
* Someone clicked the original strongs toggle button
*/
public void doHeadOriginal()
{
// boolean visible = chkHebGrk.isSelected();
//
// lblHebInc.setVisible(visible);
// txtHebInc.setVisible(visible);
// lblHebExc.setVisible(visible);
// txtHebExc.setVisible(visible);
// lblGrkInc.setVisible(visible);
// txtGrkInc.setVisible(visible);
// lblGrkExc.setVisible(visible);
// txtGrkExc.setVisible(visible);
//
// if (dlgMain != null)
// {
// dlgMain.pack();
// }
}
/**
* Someone clicked the original strongs toggle button
*/
public void doHeadTime()
{
// boolean visible = chkTime.isSelected();
//
// lblBefore.setVisible(visible);
// txtBefore.setVisible(visible);
// lblAfter.setVisible(visible);
// txtAfter.setVisible(visible);
//
// if (dlgMain != null)
// {
// dlgMain.pack();
// }
}
/**
*
*/
public void doRestrictSelect()
{
if (dlgSelect == null)
{
dlgSelect = new PassageSelectionPane();
}
String passg = dlgSelect.showInDialog(this, Msg.ADVANCED_SELECT_TITLE.toString(), true, txtRestrict.getText());
if (passg != null)
{
cboPresets.setSelectedItem(presets[presets.length - 1]);
txtRestrict.setText(passg);
}
}
/**
* Someone clicked on OK
*/
public void doDone()
{
bailout = false;
dlgMain.dispose();
}
/**
*
*/
public void updatePreset()
{
if (editingRestrict)
{
return;
}
String include = ""; //$NON-NLS-1$
String preset = (String) cboPresets.getSelectedItem();
if (preset != null)
{
int open = preset.indexOf(PRESET_START);
int close = preset.indexOf(PRESET_END);
if (open != -1 && close != -1)
{
include = preset.substring(open + 1, close);
}
}
txtRestrict.setText(include);
}
/**
* Regenerate the search string from the input boxes
*/
private void updateSearchString()
{
String quote = IndexSearcher.getPreferredSyntax(PhraseParamWord.class);
String plus = IndexSearcher.getPreferredSyntax(RetainCommandWord.class);
String minus = IndexSearcher.getPreferredSyntax(RemoveCommandWord.class);
String open = IndexSearcher.getPreferredSyntax(PassageLeftParamWord.class);
String close = IndexSearcher.getPreferredSyntax(PassageRightParamWord.class);
StringBuffer search = new StringBuffer();
String phrase = txtPhrase.getText();
if (phrase != null && phrase.trim().length() > 0)
{
search.append(quote);
search.append(phrase);
search.append(quote);
}
String includes = txtIncludes.getText();
if (includes != null && includes.trim().length() > 0)
{
if (search.length() != 0)
{
search.append(SPACE);
}
String[] words = includes.split(SPACE);
search.append(plus);
search.append(StringUtil.join(words, SPACE + plus));
}
String excludes = txtExcludes.getText();
if (excludes != null && excludes.trim().length() > 0)
{
if (search.length() != 0)
{
search.append(SPACE);
}
String[] words = excludes.split(SPACE);
search.append(minus);
search.append(StringUtil.join(words, SPACE + minus));
}
String restrict = txtRestrict.getText();
if (restrict != null && restrict.trim().length() > 0)
{
if (search.length() != 0)
{
search.append(SPACE);
}
search.append(plus);
search.append(open);
search.append(restrict);
search.append(close);
}
txtSummary.setText(search.toString());
// Check that the presets match the combo
editingRestrict = true;
boolean match = false;
ComboBoxModel model = cboPresets.getModel();
String find = PRESET_START + restrict + PRESET_END;
for (int i = 0; !match && i < model.getSize(); i++)
{
String element = (String) model.getElementAt(i);
if (element.indexOf(find) != -1)
{
cboPresets.setSelectedIndex(i);
match = true;
}
}
if (!match)
{
cboPresets.setSelectedItem(presets[presets.length - 1]);
}
editingRestrict = false;
}
/* (non-Javadoc)
* @see javax.swing.event.DocumentListener#changedUpdate(javax.swing.event.DocumentEvent)
*/
public void changedUpdate(DocumentEvent ev)
{
updateSearchString();
}
/* (non-Javadoc)
* @see javax.swing.event.DocumentListener#insertUpdate(javax.swing.event.DocumentEvent)
*/
public void insertUpdate(DocumentEvent ev)
{
updateSearchString();
}
/* (non-Javadoc)
* @see javax.swing.event.DocumentListener#removeUpdate(javax.swing.event.DocumentEvent)
*/
public void removeUpdate(DocumentEvent ev)
{
updateSearchString();
}
/**
* Quick test method
*/
public static void main(String[] args)
{
LookAndFeelUtil.initialize();
AdvancedSearchPane adv = new AdvancedSearchPane();
String reply = adv.showInDialog(null, "Advanced Search", true, "test"); //$NON-NLS-1$ //$NON-NLS-2$
log.debug(reply);
System.exit(0);
}
/*
* Action constants
*/
private static final String DONE = "Done"; //$NON-NLS-1$
private static final String PHRASE = "Phrase"; //$NON-NLS-1$
private static final String RESTRICT = "Restrict"; //$NON-NLS-1$
private static final String HEAD_RESTRICT = "HeadRestrict"; //$NON-NLS-1$
private static final String HEAD_BASE = "HeadBase"; //$NON-NLS-1$
private static final String INCLUDES = "Includes"; //$NON-NLS-1$
private static final String EXCLUDES = "Excludes"; //$NON-NLS-1$
private static final String PRESETS = "Presets"; //$NON-NLS-1$
private static final String RESTRICT_SELECT = "RestrictSelect"; //$NON-NLS-1$
private static final String HEAD_SUMMARY = "HeadSummary"; //$NON-NLS-1$
private static final String SUMMARY = "Summary"; //$NON-NLS-1$
// private static final String HEAD_ORIGINAL = "HeadOriginal"; //$NON-NLS-1$
// private static final String HEBREW_INCLUDE = "HebrewInclude"; //$NON-NLS-1$
// private static final String HEBREW_EXCLUDE = "HebrewExclude"; //$NON-NLS-1$
// private static final String GREEK_INCLUDE = "GreekInclude"; //$NON-NLS-1$
// private static final String GREEK_EXCLUDE = "GreekExclude"; //$NON-NLS-1$
// private static final String HEAD_TIME = "HeadTime"; //$NON-NLS-1$
// private static final String AFTER = "After"; //$NON-NLS-1$
// private static final String BEFORE = "Before"; //$NON-NLS-1$
/**
* In our parsing we use space quite a lot and this ensures there is only
* one and that we don't have lots of NON-NLS comments everywhere
*/
private static final String SPACE = " "; //$NON-NLS-1$
private static final String PRESET_END = ")"; //$NON-NLS-1$
private static final String PRESET_START = "("; //$NON-NLS-1$
/**
* If escape was pressed we don't want to update the parent
*/
protected boolean bailout;
/**
* The ActionFactory holding the actions used by this Component.
*/
private ActionFactory actions;
/**
* The entries in the restrictions preset
*/
private String[] presets = null;
/**
* If we are editing the restrict text box, ignore preset updates
*/
private boolean editingRestrict = false;
/*
* GUI Components
*/
private PassageSelectionPane dlgSelect;
private JLabel lblPhrase = null;
private JLabel lblIncludes = null;
private JTextField txtIncludes = null;
private JTextField txtPhrase = null;
private JLabel lblExcludes = null;
private JTextField txtExcludes = null;
private JLabel lblHeading = null;
private JCheckBox chkRestrict = null;
private JLabel lblRestrict = null;
private JTextField txtRestrict = null;
private JButton btnRestrict = null;
private JButton btnGo = null;
private JLabel lblPresets = null;
private JComboBox cboPresets = null;
protected JDialog dlgMain = null;
// private JCheckBox chkHebGrk = null;
// private JLabel lblHebInc = null;
// private JTextField txtHebInc = null;
// private JLabel lblHebExc = null;
// private JTextField txtHebExc = null;
// private JLabel lblGrkInc = null;
// private JTextField txtGrkInc = null;
// private JLabel lblGrkExc = null;
// private JTextField txtGrkExc = null;
// private JCheckBox chkTime = null;
// private JLabel lblBefore = null;
// private JTextField txtBefore = null;
// private JLabel lblAfter = null;
// private JTextField txtAfter = null;
private JLabel lblSummary = null;
private JCheckBox chkSummary = null;
private JTextArea txtSummary = null;
private JScrollPane scrSummary = null;
/**
* The log stream
*/
private static final Logger log = Logger.getLogger(AdvancedSearchPane.class);
}
Index: Msg.java
===================================================================
RCS file: /cvs/jsword/bibledesktop/java/main/org/crosswire/bibledesktop/book/Msg.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -d -r1.10 -r1.11
*** Msg.java 2 Oct 2004 23:51:06 -0000 1.10
--- Msg.java 9 Oct 2004 21:45:24 -0000 1.11
***************
*** 70,73 ****
--- 70,76 ----
static final Msg SUMMARY = new Msg("PassageSelectionPane.Summary"); //$NON-NLS-1$
+ static final Msg PRESETS = new Msg("AdvancedSearchPane.Presets"); //$NON-NLS-1$
+ static final Msg ADVANCED_SELECT_TITLE = new Msg("AdvancedSearchPane.SelectPassageTitle"); //$NON-NLS-1$
+
/**
* Passthrough ctor
Index: DisplaySelectPane.java
===================================================================
RCS file: /cvs/jsword/bibledesktop/java/main/org/crosswire/bibledesktop/book/DisplaySelectPane.java,v
retrieving revision 1.15
retrieving revision 1.16
diff -C2 -d -r1.15 -r1.16
*** DisplaySelectPane.java 2 Oct 2004 23:51:06 -0000 1.15
--- DisplaySelectPane.java 9 Oct 2004 21:45:24 -0000 1.16
***************
*** 12,15 ****
--- 12,17 ----
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
+ import java.beans.PropertyChangeEvent;
+ import java.beans.PropertyChangeListener;
import java.util.ArrayList;
import java.util.List;
***************
*** 25,29 ****
import javax.swing.JTextField;
- import org.crosswire.bibledesktop.book.parse.AdvancedSearchPane;
import org.crosswire.bibledesktop.passage.KeyChangeEvent;
import org.crosswire.bibledesktop.passage.KeyChangeListener;
--- 27,30 ----
***************
*** 35,39 ****
import org.crosswire.jsword.book.BookFilters;
import org.crosswire.jsword.book.BookMetaData;
! import org.crosswire.jsword.book.Search;
import org.crosswire.jsword.passage.Key;
import org.crosswire.jsword.passage.NoSuchVerseException;
--- 36,43 ----
import org.crosswire.jsword.book.BookFilters;
import org.crosswire.jsword.book.BookMetaData;
! import org.crosswire.jsword.book.IndexStatus;
! import org.crosswire.jsword.book.search.IndexManagerFactory;
! import org.crosswire.jsword.book.search.parse.IndexSearcher;
! import org.crosswire.jsword.book.search.parse.PhraseParamWord;
import org.crosswire.jsword.passage.Key;
import org.crosswire.jsword.passage.NoSuchVerseException;
***************
*** 87,91 ****
mdlBible = new BooksComboBoxModel(BookFilters.getBibles());
JComboBox cboBible = new JComboBox(mdlBible);
! Object selected = mdlBible.getSelectedItem();
if (selected != null)
{
--- 91,95 ----
mdlBible = new BooksComboBoxModel(BookFilters.getBibles());
JComboBox cboBible = new JComboBox(mdlBible);
! selected = mdlBible.getSelectedBookMetaData();
if (selected != null)
{
***************
*** 131,138 ****
}
});
! JButton btnKey = new JButton(actions.getAction(MORE));
btnKey.setIcon(ICON_SELECT);
btnKey.setBorderPainted(false);
! JButton btnKeyGo = new JButton(actions.getAction(GO_PASSAGE));
txtSearch = new JTextField();
--- 135,142 ----
}
});
! btnKey = new JButton(actions.getAction(MORE));
btnKey.setIcon(ICON_SELECT);
btnKey.setBorderPainted(false);
! btnKeyGo = new JButton(actions.getAction(GO_PASSAGE));
txtSearch = new JTextField();
***************
*** 140,144 ****
JLabel lblSearch = actions.createJLabel(SEARCH_LABEL);
lblSearch.setLabelFor(txtSearch);
! JButton btnSearch = new JButton(actions.getAction(GO_SEARCH));
JButton btnHelp = new JButton(actions.getAction(HELP));
--- 144,148 ----
JLabel lblSearch = actions.createJLabel(SEARCH_LABEL);
lblSearch.setLabelFor(txtSearch);
! btnSearch = new JButton(actions.getAction(GO_SEARCH));
JButton btnHelp = new JButton(actions.getAction(HELP));
***************
*** 148,153 ****
dlgHelp = new QuickHelpDialog(GuiUtil.getFrame(this), Msg.HELP_TITLE.toString(), Msg.HELP_TEXT.toString());
! JButton btnAdvanced = new JButton(actions.getAction(ADVANCED));
btnAdvanced.setBorderPainted(false);
chkMatch = new JCheckBox(actions.getAction(MATCH));
--- 152,158 ----
dlgHelp = new QuickHelpDialog(GuiUtil.getFrame(this), Msg.HELP_TITLE.toString(), Msg.HELP_TEXT.toString());
! btnAdvanced = new JButton(actions.getAction(ADVANCED));
btnAdvanced.setBorderPainted(false);
+ btnIndex = new JButton(actions.getAction(INDEX));
chkMatch = new JCheckBox(actions.getAction(MATCH));
***************
*** 163,170 ****
--- 168,178 ----
this.add(btnHelp, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
this.add(lblSearch, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 5), 0, 0));
+ this.add(btnIndex, new GridBagConstraints(2, 2, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
this.add(txtSearch, new GridBagConstraints(2, 2, 1, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
this.add(chkMatch, new GridBagConstraints(3, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
this.add(btnAdvanced, new GridBagConstraints(4, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
this.add(btnSearch, new GridBagConstraints(5, 2, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 2, 2, 2), 0, 0));
+
+ enableComponents();
}
***************
*** 194,198 ****
updateDisplay();
-
}
--- 202,205 ----
***************
*** 254,262 ****
String param = txtSearch.getText();
Book book = bmd.getBook();
- boolean match = chkMatch.isSelected();
! Search search = new Search(param, match);
! Key key = book.find(search);
// we get PassageTallys for best match searches
--- 261,272 ----
String param = txtSearch.getText();
Book book = bmd.getBook();
! if (chkMatch.isSelected())
! {
! String quote = IndexSearcher.getPreferredSyntax(PhraseParamWord.class);
! param = quote + param + quote;
! }
! Key key = book.find(param);
// we get PassageTallys for best match searches
***************
*** 309,312 ****
--- 319,338 ----
/**
+ * Someone clicked one the index button
+ */
+ public void doIndex()
+ {
+ BookMetaData bmd = mdlBible.getSelectedBookMetaData();
+ if (bmd == null)
+ {
+ noBookInstalled();
+ return;
+ }
+
+ IndexManagerFactory.getIndexManager().scheduleIndexCreation(bmd.getBook());
+ enableComponents();
+ }
+
+ /**
* Sync the viewed passage with the passage text box
*/
***************
*** 338,348 ****
/**
- * Set the focus to the right initial component
- */
- public void adjustFocus()
- {
- }
-
- /**
* Accessor for the default name
*/
--- 364,367 ----
***************
*** 379,384 ****
protected void changeVersion()
{
! BookMetaData bmd = mdlBible.getSelectedBookMetaData();
! if (bmd == null)
{
noBookInstalled();
--- 398,414 ----
protected void changeVersion()
{
! BookMetaData newSelected = mdlBible.getSelectedBookMetaData();
!
! if (selected != null && selected != newSelected)
! {
! selected.removePropertyChangeListener(pcl);
! newSelected.addPropertyChangeListener(pcl);
! }
!
! selected = newSelected;
!
! enableComponents();
!
! if (selected == null)
{
noBookInstalled();
***************
*** 388,392 ****
try
{
! Book book = bmd.getBook();
Key key = book.getKey(txtKey.getText());
--- 418,422 ----
try
{
! Book book = selected.getBook();
Key key = book.getKey(txtKey.getText());
***************
*** 400,403 ****
--- 430,444 ----
/**
+ * Keep the selection up to date with indexing.
+ */
+ private PropertyChangeListener pcl = new PropertyChangeListener()
+ {
+ public void propertyChange(PropertyChangeEvent ev)
+ {
+ enableComponents();
+ }
+ };
+
+ /**
* Display a dialog indicating that no Bible is installed.
*/
***************
*** 409,412 ****
--- 450,476 ----
/**
+ * Ensure that the right components are enabled
+ */
+ protected void enableComponents()
+ {
+ boolean readable = selected != null;
+ boolean searchable = readable && selected.getIndexStatus().equals(IndexStatus.DONE);
+ boolean indexable = readable && selected.getIndexStatus().equals(IndexStatus.UNDONE);
+
+ txtSearch.setEnabled(searchable);
+ txtSearch.setBackground(searchable ? SystemColor.text : SystemColor.control);
+ txtSearch.setVisible(searchable);
+ chkMatch.setEnabled(searchable);
+ btnAdvanced.setEnabled(searchable);
+ btnSearch.setEnabled(searchable);
+ txtKey.setEnabled(readable);
+ txtKey.setBackground(readable ? SystemColor.text : SystemColor.control);
+ btnKey.setEnabled(readable);
+ btnKeyGo.setEnabled(readable);
+ btnIndex.setVisible(indexable);
+ btnIndex.setEnabled(indexable);
+ }
+
+ /**
* Someone clicked the "..." button
*/
***************
*** 511,514 ****
--- 575,579 ----
private static final String MATCH = "Match"; //$NON-NLS-1$
private static final String BIBLE = "Bible"; //$NON-NLS-1$
+ private static final String INDEX = "Index"; //$NON-NLS-1$
private static final ImageIcon ICON_SELECT = GuiUtil.getIcon("toolbarButtonGraphics/general/Edit16.gif"); //$NON-NLS-1$
***************
*** 518,540 ****
private static int base = 1;
! private String title;
! private transient List listeners;
private QuickHelpDialog dlgHelp = null;
- private BooksComboBoxModel mdlBible = null;
-
- private PassageSelectionPane dlgSelect = null;
-
private ActionFactory actions = null;
! private JTextField txtKey = null;
private JTextField txtSearch = null;
-
private JCheckBox chkMatch = null;
!
private AdvancedSearchPane advanced = new AdvancedSearchPane();
/**
--- 583,610 ----
private static int base = 1;
! private String title = null;
! private transient List listeners = null;
private QuickHelpDialog dlgHelp = null;
private ActionFactory actions = null;
! private BookMetaData selected = null;
+ /*
+ * GUI Components
+ */
+ private BooksComboBoxModel mdlBible = null;
+ private PassageSelectionPane dlgSelect = null;
+ private JTextField txtKey = null;
private JTextField txtSearch = null;
private JCheckBox chkMatch = null;
! private JButton btnAdvanced = null;
! private JButton btnSearch = null;
! private JButton btnKey = null;
! private JButton btnKeyGo = null;
private AdvancedSearchPane advanced = new AdvancedSearchPane();
+ private JButton btnIndex = null;
/**
Index: Msg.properties
===================================================================
RCS file: /cvs/jsword/bibledesktop/java/main/org/crosswire/bibledesktop/book/Msg.properties,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** Msg.properties 2 Oct 2004 23:51:06 -0000 1.8
--- Msg.properties 9 Oct 2004 21:45:24 -0000 1.9
***************
*** 53,54 ****
--- 53,70 ----
PassageSelectionPane.Error=Error: {0}
PassageSelectionPane.Summary=Summary: {0}
+
+ AdvancedSearchPane.Presets=The Whole Bible|\
+ All Prophecy (Deu 28, Isa-Mal, Rev)|\
+ Old Testament (Gen-Mal)|\
+ New Testament (Mat-Rev)|\
+ The Penteteuch (Gen-Deu)|\
+ History (Josh-Est)|\
+ Poetry (Job-Song)|\
+ Major Prophets (Isa-Dan)|\
+ Minor Prophets (Hos-Mal)|\
+ Gospels and Acts (Mat-Act)|\
+ Letters to People (Rom-Heb)|\
+ Letters from People (Jam-Jude)|\
+ Custom
+
+ AdvancedSearchPane.SelectPassageTitle=Select Passages to Restrict Search to
--- NEW FILE: AdvancedSearchPane.properties ---
HeadBase.Name:Search for verses with the following details
Phrase.Name=Includes this phrase:
Includes.Name=Includes these words:
Excludes.Name=Excludes all these words:
HeadRestrict.Name:Restrict search to parts of the Bible
Restrict.Name:Include these verses:
RestrictSelect.Name=Select
RestrictSelect.MnemonicKey=T
Presets.Name=Preset Ranges:
HeadSummary.Name:Show quick search syntax
Summary.Name:Quick search syntax:
HeadOriginal.Name:Contains Strongs Hebrew and Greek
HebrewInclude.Name:Includes Hebrew Nos:
HebrewExclude.Name:Excludes Hebrew Nos:
GreekInclude.Name:Includes Greek Nos:
GreekExclude.Name:Excludes Greek Nos:
HeadTime.Name:Narrow search by time peroid
After.Name:Restrict to verses written after:
Before.Name:Restrict to verses written before:
Done.Name=Search
Done.MnemonicKey=S
Index: BibleViewPane.java
===================================================================
RCS file: /cvs/jsword/bibledesktop/java/main/org/crosswire/bibledesktop/book/BibleViewPane.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -d -r1.10 -r1.11
*** BibleViewPane.java 8 Sep 2004 19:57:58 -0000 1.10
--- BibleViewPane.java 9 Oct 2004 21:45:24 -0000 1.11
***************
*** 108,118 ****
/**
! * Allow the current
*/
- public void adjustFocus()
- {
- pnlSelect.adjustFocus();
- }
-
public void clear()
{
--- 108,113 ----
/**
! * Make it as though no-one is using this view
*/
public void clear()
{
***************
*** 124,127 ****
--- 119,125 ----
}
+ /**
+ * Has anyone started using this view
+ */
public boolean isClear()
{
From jswordcvs at crosswire.org Sat Oct 9 14:45:33 2004
From: jswordcvs at crosswire.org (jswordcvs@crosswire.org)
Date: Sat Oct 9 14:45:34 2004
Subject: [jsword-svn] jsword-web/java/main/org/crosswire/jsword/view/web s
Message-ID: <200410092145.i99LjXxs030375@www.crosswire.org>
Update of /cvs/jsword/jsword-web/java/main/org/crosswire/jsword/view/web
In directory www.crosswire.org:/tmp/cvs-serv30369/java/main/org/crosswire/jsword/view/web
Modified Files:
DemoServlet.java
Log Message:
indexing updates
Index: DemoServlet.java
===================================================================
RCS file: /cvs/jsword/jsword-web/java/main/org/crosswire/jsword/view/web/DemoServlet.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** DemoServlet.java 25 Aug 2004 22:53:48 -0000 1.5
--- DemoServlet.java 9 Oct 2004 21:45:31 -0000 1.6
***************
*** 16,20 ****
import org.crosswire.jsword.book.BookData;
import org.crosswire.jsword.book.Books;
! import org.crosswire.jsword.book.Search;
import org.crosswire.jsword.passage.Key;
import org.crosswire.jsword.passage.Passage;
--- 16,21 ----
import org.crosswire.jsword.book.BookData;
import org.crosswire.jsword.book.Books;
! import org.crosswire.jsword.book.search.parse.IndexSearcher;
! import org.crosswire.jsword.book.search.parse.PhraseParamWord;
import org.crosswire.jsword.passage.Key;
import org.crosswire.jsword.passage.Passage;
***************
*** 83,87 ****
{
request.setAttribute(FIELD_SEARCH, search);
! key = book.find(new Search(search, false));
}
--- 84,88 ----
{
request.setAttribute(FIELD_SEARCH, search);
! key = book.find(search);
}
***************
*** 90,94 ****
{
request.setAttribute(FIELD_MATCH, match);
! PassageTally tally = (PassageTally) book.find(new Search(match, true));
tally.setOrdering(PassageTally.ORDER_TALLY);
tally.trimRanges(tallyTrim, RestrictionType.NONE);
--- 91,96 ----
{
request.setAttribute(FIELD_MATCH, match);
! String quote = IndexSearcher.getPreferredSyntax(PhraseParamWord.class);
! PassageTally tally = (PassageTally) book.find(quote + match + quote);
tally.setOrdering(PassageTally.ORDER_TALLY);
tally.trimRanges(tallyTrim, RestrictionType.NONE);
From jswordcvs at crosswire.org Sun Oct 10 15:12:04 2004
From: jswordcvs at crosswire.org (jswordcvs@crosswire.org)
Date: Sun Oct 10 15:12:05 2004
Subject: [jsword-svn]
jsword/java/limbo/org/crosswire/jsword/book/search/ser s
Message-ID: <200410102212.i9AMC40d025215@www.crosswire.org>
Update of /cvs/jsword/jsword/java/limbo/org/crosswire/jsword/book/search/ser
In directory www.crosswire.org:/tmp/cvs-serv25203/java/limbo/org/crosswire/jsword/book/search/ser
Modified Files:
Msg.java SerIndexManager.java Msg.properties
Log Message:
basics of downloadable indexers
Index: Msg.properties
===================================================================
RCS file: /cvs/jsword/jsword/java/limbo/org/crosswire/jsword/book/search/ser/Msg.properties,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** Msg.properties 9 Oct 2004 21:45:04 -0000 1.1
--- Msg.properties 10 Oct 2004 22:12:02 -0000 1.2
***************
*** 13,14 ****
--- 13,15 ----
SerIndex.WritingWords=Writing Words ({0})
SerIndex.Saving=Saving Index
+ SerIndex.InstallFailed=Installation failed
Index: Msg.java
===================================================================
RCS file: /cvs/jsword/jsword/java/limbo/org/crosswire/jsword/book/search/ser/Msg.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** Msg.java 9 Oct 2004 21:45:04 -0000 1.1
--- Msg.java 10 Oct 2004 22:12:02 -0000 1.2
***************
*** 36,39 ****
--- 36,40 ----
static final Msg WRITING_WORDS = new Msg("SerIndex.WritingWords"); //$NON-NLS-1$
static final Msg SAVING = new Msg("SerIndex.Saving"); //$NON-NLS-1$
+ static final Msg INSTALL_FAIL = new Msg("SerIndex.InstallFailed"); //$NON-NLS-1$
/**
Index: SerIndexManager.java
===================================================================
RCS file: /cvs/jsword/jsword/java/limbo/org/crosswire/jsword/book/search/ser/SerIndexManager.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** SerIndexManager.java 9 Oct 2004 21:45:04 -0000 1.1
--- SerIndexManager.java 10 Oct 2004 22:12:02 -0000 1.2
***************
*** 1,4 ****
--- 1,5 ----
package org.crosswire.jsword.book.search.ser;
+ import java.io.File;
import java.io.IOException;
import java.net.URL;
***************
*** 6,9 ****
--- 7,11 ----
import java.util.Map;
+ import org.crosswire.common.util.IOUtil;
import org.crosswire.common.util.Logger;
import org.crosswire.common.util.NetUtil;
***************
*** 16,20 ****
/**
! * .
*
*
--- 18,22 ----
/**
! * An implementation of IndexManager that controls Ser indexes.
*
*
***************
*** 107,110 ****
--- 109,129 ----
/* (non-Javadoc)
+ * @see org.crosswire.jsword.book.search.IndexManager#installDownloadedIndex(org.crosswire.jsword.book.Book, java.net.URL)
+ */
+ public void installDownloadedIndex(Book book, URL tempDest) throws BookException
+ {
+ try
+ {
+ URL storage = getStorageArea(book);
+ File zip = NetUtil.getAsFile(storage);
+ IOUtil.unpackZip(zip, storage);
+ }
+ catch (IOException ex)
+ {
+ throw new BookException(Msg.INSTALL_FAIL, ex);
+ }
+ }
+
+ /* (non-Javadoc)
* @see org.crosswire.jsword.book.search.IndexManager#deleteIndex(org.crosswire.jsword.book.Book)
*/
From jswordcvs at crosswire.org Sun Oct 10 15:12:04 2004
From: jswordcvs at crosswire.org (jswordcvs@crosswire.org)
Date: Sun Oct 10 15:12:05 2004
Subject: [jsword-svn] jsword/java/jsword/org/crosswire/jsword/book/install s
Message-ID: <200410102212.i9AMC4fY025225@www.crosswire.org>
Update of /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/install
In directory www.crosswire.org:/tmp/cvs-serv25203/java/jsword/org/crosswire/jsword/book/install
Modified Files:
Installer.java
Log Message:
basics of downloadable indexers
Index: Installer.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/install/Installer.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** Installer.java 2 Oct 2004 14:01:42 -0000 1.6
--- Installer.java 10 Oct 2004 22:12:02 -0000 1.7
***************
*** 50,54 ****
* then we should just return an empty list and not attempt to contact the
* remote source. See notes on reload for more information.
! * @see Installer#reloadIndex()
*/
public List getBookMetaDatas();
--- 50,54 ----
* then we should just return an empty list and not attempt to contact the
* remote source. See notes on reload for more information.
! * @see Installer#reloadBookList()
*/
public List getBookMetaDatas();
***************
*** 60,64 ****
* Christians then this action might give the game away.
*/
! public void reloadIndex() throws InstallException;
/**
--- 60,64 ----
* Christians then this action might give the game away.
*/
! public void reloadBookList() throws InstallException;
/**
***************
*** 71,75 ****
/**
! * @param bmd
* @return the remote url for the BookMetaData
*/
--- 71,85 ----
/**
! * Download a search index for the given Book.
! * The installation of the search index is the responsibility of the
! * IndexManager.
! * @param bmd The book to download a search index for.
! * @param tempDest A temporary URL for downloading to. Passed to the
! * IndexManager for installation.
! */
! public void downloadSearchIndex(BookMetaData bmd, URL tempDest) throws InstallException;
!
! /**
! * @param bmd The book meta-data to get a URL from.
* @return the remote url for the BookMetaData
*/
***************
*** 77,81 ****
/**
! * @param bmd
* @return the url for the directory for BookMetaData
*/
--- 87,91 ----
/**
! * @param bmd The book meta-data to get a URL from.
* @return the url for the directory for BookMetaData
*/
***************
*** 85,89 ****
* Return true if the module is not installed or there is a newer
* version to install.
! * @param bmd
* @return whether there is a newer version to install
*/
--- 95,99 ----
* Return true if the module is not installed or there is a newer
* version to install.
! * @param bmd The book meta-data to check on.
* @return whether there is a newer version to install
*/
From jswordcvs at crosswire.org Sun Oct 10 15:12:04 2004
From: jswordcvs at crosswire.org (jswordcvs@crosswire.org)
Date: Sun Oct 10 15:12:07 2004
Subject: [jsword-svn] jsword/java/jsword/org/crosswire/jsword/book/search s
Message-ID: <200410102212.i9AMC4xl025237@www.crosswire.org>
Update of /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/search
In directory www.crosswire.org:/tmp/cvs-serv25203/java/jsword/org/crosswire/jsword/book/search
Modified Files:
IndexManager.java
Log Message:
basics of downloadable indexers
Index: IndexManager.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/search/IndexManager.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** IndexManager.java 9 Oct 2004 21:45:04 -0000 1.2
--- IndexManager.java 10 Oct 2004 22:12:02 -0000 1.3
***************
*** 1,4 ****
--- 1,6 ----
package org.crosswire.jsword.book.search;
+ import java.net.URL;
+
import org.crosswire.jsword.book.Book;
import org.crosswire.jsword.book.BookException;
***************
*** 47,50 ****
--- 49,60 ----
/**
+ * We have downloaded a search index to a zip file. It should be installed
+ * from here.
+ * @param book The book that we downloaded an index for
+ * @param tempDest The URL of a zip file to install
+ */
+ public void installDownloadedIndex(Book book, URL tempDest) throws BookException;
+
+ /**
* Tidy up after yourself and remove all the files that make up any indexes
* you created.
From jswordcvs at crosswire.org Sun Oct 10 15:12:04 2004
From: jswordcvs at crosswire.org (jswordcvs@crosswire.org)
Date: Sun Oct 10 15:12:07 2004
Subject: [jsword-svn]
jsword/java/jsword/org/crosswire/jsword/book/search/lucene s
Message-ID: <200410102212.i9AMC4jk025221@www.crosswire.org>
Update of /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/search/lucene
In directory www.crosswire.org:/tmp/cvs-serv25203/java/jsword/org/crosswire/jsword/book/search/lucene
Modified Files:
Msg.properties Msg.java LuceneIndexManager.java
Log Message:
basics of downloadable indexers
Index: Msg.properties
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/search/lucene/Msg.properties,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** Msg.properties 9 Oct 2004 21:45:05 -0000 1.3
--- Msg.properties 10 Oct 2004 22:12:02 -0000 1.4
***************
*** 14,15 ****
--- 14,16 ----
LuceneIndex.Optimizing=Optimizing
LuceneIndex.DeleteFailed=Failed to delete search index
+ LuceneIndex.InstallFailed=Installation failed
Index: LuceneIndexManager.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/search/lucene/LuceneIndexManager.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** LuceneIndexManager.java 9 Oct 2004 21:45:05 -0000 1.1
--- LuceneIndexManager.java 10 Oct 2004 22:12:02 -0000 1.2
***************
*** 1,4 ****
--- 1,5 ----
package org.crosswire.jsword.book.search.lucene;
+ import java.io.File;
import java.io.IOException;
import java.net.URL;
***************
*** 6,9 ****
--- 7,11 ----
import java.util.Map;
+ import org.crosswire.common.util.IOUtil;
import org.crosswire.common.util.Logger;
import org.crosswire.common.util.NetUtil;
***************
*** 17,21 ****
/**
! * .
*
*
--- 19,23 ----
/**
! * An implementation of IndexManager for Lucene indexes.
*
*
***************
*** 110,113 ****
--- 112,132 ----
/* (non-Javadoc)
+ * @see org.crosswire.jsword.book.search.IndexManager#installDownloadedIndex(org.crosswire.jsword.book.Book, java.net.URL)
+ */
+ public void installDownloadedIndex(Book book, URL tempDest) throws BookException
+ {
+ try
+ {
+ URL storage = getStorageArea(book);
+ File zip = NetUtil.getAsFile(storage);
+ IOUtil.unpackZip(zip, storage);
+ }
+ catch (IOException ex)
+ {
+ throw new BookException(Msg.INSTALL_FAIL, ex);
+ }
+ }
+
+ /* (non-Javadoc)
* @see org.crosswire.jsword.book.search.IndexManager#deleteIndex(org.crosswire.jsword.book.Book)
*/
Index: Msg.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/search/lucene/Msg.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -d -r1.10 -r1.11
*** Msg.java 9 Oct 2004 21:45:05 -0000 1.10
--- Msg.java 10 Oct 2004 22:12:02 -0000 1.11
***************
*** 37,40 ****
--- 37,41 ----
static final Msg OPTIMIZING = new Msg("LuceneIndex.Optimizing"); //$NON-NLS-1$
static final Msg DELETE_FAILED = new Msg("LuceneIndex.DeleteFailed"); //$NON-NLS-1$
+ static final Msg INSTALL_FAIL = new Msg("LuceneIndex.InstallFailed"); //$NON-NLS-1$
/**
From jswordcvs at crosswire.org Sun Oct 10 15:12:04 2004
From: jswordcvs at crosswire.org (jswordcvs@crosswire.org)
Date: Sun Oct 10 15:12:07 2004
Subject: [jsword-svn]
jsword/java/jsword/org/crosswire/jsword/book/install/sword s
Message-ID: <200410102212.i9AMC4qj025232@www.crosswire.org>
Update of /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/install/sword
In directory www.crosswire.org:/tmp/cvs-serv25203/java/jsword/org/crosswire/jsword/book/install/sword
Modified Files:
HttpSwordInstaller.java FtpSwordInstaller.java
Log Message:
basics of downloadable indexers
Index: HttpSwordInstaller.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/install/sword/HttpSwordInstaller.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -d -r1.10 -r1.11
*** HttpSwordInstaller.java 5 Oct 2004 22:03:09 -0000 1.10
--- HttpSwordInstaller.java 10 Oct 2004 22:12:02 -0000 1.11
***************
*** 14,27 ****
import java.util.ArrayList;
import java.util.Collections;
- import java.util.Enumeration;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.zip.GZIPInputStream;
- import java.util.zip.ZipEntry;
- import java.util.zip.ZipFile;
import org.crosswire.common.progress.Job;
import org.crosswire.common.progress.JobManager;
import org.crosswire.common.util.Logger;
import org.crosswire.common.util.NetUtil;
--- 14,25 ----
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.zip.GZIPInputStream;
import org.crosswire.common.progress.Job;
import org.crosswire.common.progress.JobManager;
+ import org.crosswire.common.util.IOUtil;
import org.crosswire.common.util.Logger;
import org.crosswire.common.util.NetUtil;
***************
*** 103,107 ****
* @see org.crosswire.jsword.book.install.Installer#reloadIndex()
*/
! public void reloadIndex() throws InstallException
{
URL scratchfile = getCachedIndexFile();
--- 101,105 ----
* @see org.crosswire.jsword.book.install.Installer#reloadIndex()
*/
! public void reloadBookList() throws InstallException
{
URL scratchfile = getCachedIndexFile();
***************
*** 144,171 ****
finally
{
! if (null != in)
! {
! try
! {
! in.close();
! }
! catch (IOException e)
! {
! e.printStackTrace();
! }
! }
! if (null != out)
! {
! try
! {
! out.close();
! }
! catch (IOException e1)
! {
! e1.printStackTrace();
! }
! }
}
}
--- 142,171 ----
finally
{
! IOUtil.close(in);
! IOUtil.close(out);
! }
! }
! /* (non-Javadoc)
! * @see org.crosswire.jsword.book.install.Installer#downloadSearchIndex(org.crosswire.jsword.book.BookMetaData, java.net.URL)
! */
! public void downloadSearchIndex(BookMetaData bmd, URL localDest) throws InstallException
! {
! Job job = JobManager.createJob(Msg.JOB_DOWNLOADING.toString(), Thread.currentThread(), false);
!
! try
! {
! String dir = directory + '/' + SEARCH_DIR + '/' + bmd.getInitials() + ZIP_SUFFIX;
! downloadZip(job, host, dir, localDest);
}
+ catch (Exception ex)
+ {
+ job.ignoreTimings();
+ throw new InstallException(Msg.UNKNOWN_ERROR, ex);
+ }
+ finally
+ {
+ job.done();
+ }
}
***************
*** 186,194 ****
--- 186,197 ----
{
job.setProgress(Msg.JOB_DOWNLOADING.toString());
+
URL zipurl = new URL("http://" + site + dir); //$NON-NLS-1$
File f = File.createTempFile("swd", "zip"); //$NON-NLS-1$ //$NON-NLS-2$
out = new FileOutputStream(f);
+
URLConnection urlConnection = zipurl.openConnection();
in = urlConnection.getInputStream();
+
byte[] buf = new byte[4096];
for (int count = 0; -1 != (count = in.read(buf)); )
***************
*** 196,216 ****
out.write(buf, 0, count);
}
! // unpack the zip.
! ZipFile zf = new ZipFile(f);
! Enumeration entries = zf.entries();
! while (entries.hasMoreElements())
! {
! ZipEntry entry = (ZipEntry) entries.nextElement();
! String entrypath = entry.getName();
! String filename = entrypath.substring(entrypath.lastIndexOf('/') + 1);
! URL child = NetUtil.lengthenURL(destdir, filename);
! OutputStream dataOut = NetUtil.getOutputStream(child);
! InputStream dataIn = zf.getInputStream(entry);
! for (int count = 0; -1 != (count = dataIn.read(buf)); )
! {
! dataOut.write(buf, 0, count);
! }
! dataOut.close();
! }
}
catch (IOException ex)
--- 199,204 ----
out.write(buf, 0, count);
}
!
! IOUtil.unpackZip(f, destdir);
}
catch (IOException ex)
***************
*** 220,245 ****
finally
{
! if (null != in)
! {
! try
! {
! in.close();
! }
! catch (IOException ex)
! {
! ex.printStackTrace();
! }
! }
! if (null != out)
! {
! try
! {
! out.close();
! }
! catch (IOException ex)
! {
! ex.printStackTrace();
! }
! }
}
}
--- 208,213 ----
finally
{
! IOUtil.close(in);
! IOUtil.close(out);
}
}
***************
*** 326,330 ****
return new URL(NetUtil.PROTOCOL_HTTP, host, directory + '/' + PACKAGE_DIR + '/' + sbmd.getInitials() + ZIP_SUFFIX); //$NON-NLS-1$
}
! catch (MalformedURLException e)
{
return null;
--- 294,298 ----
return new URL(NetUtil.PROTOCOL_HTTP, host, directory + '/' + PACKAGE_DIR + '/' + sbmd.getInitials() + ZIP_SUFFIX); //$NON-NLS-1$
}
! catch (MalformedURLException ex)
{
return null;
***************
*** 342,346 ****
return new URL(NetUtil.PROTOCOL_FILE, null, fulldir.getAbsolutePath());
}
! catch (MalformedURLException e)
{
assert false;
--- 310,314 ----
return new URL(NetUtil.PROTOCOL_FILE, null, fulldir.getAbsolutePath());
}
! catch (MalformedURLException ex)
{
assert false;
***************
*** 492,497 ****
if (!NetUtil.isFile(cache))
{
! reloadIndex();
}
try
{
--- 460,466 ----
if (!NetUtil.isFile(cache))
{
! reloadBookList();
}
+
try
{
***************
*** 521,524 ****
--- 490,494 ----
internal = internal.substring(0, internal.length() - 5);
}
+
if (internal.startsWith(SwordConstants.DIR_CONF + '/'))
{
***************
*** 541,547 ****
}
! tin.close();
! gin.close();
! in.close();
loaded = true;
}
--- 511,518 ----
}
! IOUtil.close(tin);
! IOUtil.close(gin);
! IOUtil.close(in);
!
loaded = true;
}
***************
*** 602,605 ****
--- 573,581 ----
/**
+ * The relative path of the dir holding the search index files
+ */
+ private static final String SEARCH_DIR = "seach/jsword/L1"; //$NON-NLS-1$
+
+ /**
* The suffix of zip modules on this server
*/
Index: FtpSwordInstaller.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/install/sword/FtpSwordInstaller.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** FtpSwordInstaller.java 5 Oct 2004 22:03:09 -0000 1.7
--- FtpSwordInstaller.java 10 Oct 2004 22:12:02 -0000 1.8
***************
*** 224,230 ****
/* (non-Javadoc)
* @see org.crosswire.jsword.book.install.Installer#reloadIndex()
*/
! public void reloadIndex() throws InstallException
{
URL scratchfile = getCachedIndexFile();
--- 224,253 ----
/* (non-Javadoc)
+ * @see org.crosswire.jsword.book.install.Installer#downloadSearchIndex(org.crosswire.jsword.book.BookMetaData, java.net.URL)
+ */
+ public void downloadSearchIndex(BookMetaData bmd, URL localDest) throws InstallException
+ {
+ Job job = JobManager.createJob(Msg.JOB_DOWNLOADING.toString(), Thread.currentThread(), false);
+
+ try
+ {
+ String dir = directory + '/' + SEARCH_DIR;
+ download(host, USERNAME, PASSWORD, dir, bmd.getInitials() + ZIP_SUFFIX, localDest);
+ }
+ catch (Exception ex)
+ {
+ job.ignoreTimings();
+ throw new InstallException(Msg.UNKNOWN_ERROR, ex);
+ }
+ finally
+ {
+ job.done();
+ }
+ }
+
+ /* (non-Javadoc)
* @see org.crosswire.jsword.book.install.Installer#reloadIndex()
*/
! public void reloadBookList() throws InstallException
{
URL scratchfile = getCachedIndexFile();
***************
*** 243,247 ****
if (!NetUtil.isFile(cache))
{
! reloadIndex();
}
try
--- 266,270 ----
if (!NetUtil.isFile(cache))
{
! reloadBookList();
}
try
***************
*** 693,696 ****
--- 716,724 ----
/**
+ * The relative path of the dir holding the search index files
+ */
+ private static final String SEARCH_DIR = "seach/jsword/L1"; //$NON-NLS-1$
+
+ /**
* The default anon password
*/
From jswordcvs at crosswire.org Sun Oct 10 15:12:13 2004
From: jswordcvs at crosswire.org (jswordcvs@crosswire.org)
Date: Sun Oct 10 15:12:15 2004
Subject: [jsword-svn]
bibledesktop/java/main/org/crosswire/bibledesktop/book s
Message-ID: <200410102212.i9AMCDuX025300@www.crosswire.org>
Update of /cvs/jsword/bibledesktop/java/main/org/crosswire/bibledesktop/book
In directory www.crosswire.org:/tmp/cvs-serv25280/java/main/org/crosswire/bibledesktop/book
Modified Files:
Msg.properties DisplaySelectPane.java Msg.java
EditSitePane.java SitePane.java
Added Files:
InstallManagerComboBoxModel.java IndexResolver.java
Removed Files:
InstallManagerListModel.java
Log Message:
basics of downloadable indexers
Index: SitePane.java
===================================================================
RCS file: /cvs/jsword/bibledesktop/java/main/org/crosswire/bibledesktop/book/SitePane.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -d -r1.11 -r1.12
*** SitePane.java 2 Oct 2004 14:01:38 -0000 1.11
--- SitePane.java 10 Oct 2004 22:12:11 -0000 1.12
***************
*** 212,216 ****
try
{
! installer.reloadIndex();
treAvailable.setModel(new BooksTreeModel(installer));
--- 212,216 ----
try
{
! installer.reloadBookList();
treAvailable.setModel(new BooksTreeModel(installer));
Index: Msg.java
===================================================================
RCS file: /cvs/jsword/bibledesktop/java/main/org/crosswire/bibledesktop/book/Msg.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -d -r1.11 -r1.12
*** Msg.java 9 Oct 2004 21:45:24 -0000 1.11
--- Msg.java 10 Oct 2004 22:12:11 -0000 1.12
***************
*** 73,76 ****
--- 73,86 ----
static final Msg ADVANCED_SELECT_TITLE = new Msg("AdvancedSearchPane.SelectPassageTitle"); //$NON-NLS-1$
+ static final Msg HOW_MESSAGE_TITLE = new Msg("IndexResolver.HowMessageTitle"); //$NON-NLS-1$
+ static final Msg HOW_MESSAGE = new Msg("IndexResolver.HowMessage"); //$NON-NLS-1$
+ static final Msg HOW_GENERATE_TITLE = new Msg("IndexResolver.HowGenerateTitle"); //$NON-NLS-1$
+ static final Msg HOW_GENERATE = new Msg("IndexResolver.HowGenerate"); //$NON-NLS-1$
+ static final Msg HOW_SITE_TITLE = new Msg("IndexResolver.HowSiteTitle"); //$NON-NLS-1$
+ static final Msg HOW_SITE = new Msg("IndexResolver.HowSite"); //$NON-NLS-1$
+ static final Msg OPTION_DOWNLOAD = new Msg("IndexResolver.OptionDownload"); //$NON-NLS-1$
+ static final Msg OPTION_GENERATE = new Msg("IndexResolver.OptionGenerate"); //$NON-NLS-1$
+ static final Msg OPTION_CANCEL = new Msg("IndexResolver.OptionCancel"); //$NON-NLS-1$
+
/**
* Passthrough ctor
Index: DisplaySelectPane.java
===================================================================
RCS file: /cvs/jsword/bibledesktop/java/main/org/crosswire/bibledesktop/book/DisplaySelectPane.java,v
retrieving revision 1.16
retrieving revision 1.17
diff -C2 -d -r1.16 -r1.17
*** DisplaySelectPane.java 9 Oct 2004 21:45:24 -0000 1.16
--- DisplaySelectPane.java 10 Oct 2004 22:12:11 -0000 1.17
***************
*** 37,41 ****
import org.crosswire.jsword.book.BookMetaData;
import org.crosswire.jsword.book.IndexStatus;
- import org.crosswire.jsword.book.search.IndexManagerFactory;
import org.crosswire.jsword.book.search.parse.IndexSearcher;
import org.crosswire.jsword.book.search.parse.PhraseParamWord;
--- 37,40 ----
***************
*** 170,174 ****
this.add(btnIndex, new GridBagConstraints(2, 2, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
this.add(txtSearch, new GridBagConstraints(2, 2, 1, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
! this.add(chkMatch, new GridBagConstraints(3, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
this.add(btnAdvanced, new GridBagConstraints(4, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
this.add(btnSearch, new GridBagConstraints(5, 2, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 2, 2, 2), 0, 0));
--- 169,173 ----
this.add(btnIndex, new GridBagConstraints(2, 2, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
this.add(txtSearch, new GridBagConstraints(2, 2, 1, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
! this.add(chkMatch, new GridBagConstraints(3, 2, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
this.add(btnAdvanced, new GridBagConstraints(4, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
this.add(btnSearch, new GridBagConstraints(5, 2, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 2, 2, 2), 0, 0));
***************
*** 323,328 ****
public void doIndex()
{
! BookMetaData bmd = mdlBible.getSelectedBookMetaData();
! if (bmd == null)
{
noBookInstalled();
--- 322,326 ----
public void doIndex()
{
! if (selected == null)
{
noBookInstalled();
***************
*** 330,334 ****
}
! IndexManagerFactory.getIndexManager().scheduleIndexCreation(bmd.getBook());
enableComponents();
}
--- 328,332 ----
}
! IndexResolver.scheduleIndex(selected, this);
enableComponents();
}
--- NEW FILE: InstallManagerComboBoxModel.java ---
package org.crosswire.bibledesktop.book;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import javax.swing.AbstractListModel;
import javax.swing.ComboBoxModel;
import org.crosswire.jsword.book.install.InstallManager;
import org.crosswire.jsword.book.install.InstallerEvent;
import org.crosswire.jsword.book.install.InstallerListener;
/**
* A ListModel for a JList that uses the list of Installers given by the
* InstallManager.
*
*
*
*
* Distribution Licence:
* JSword 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
* here , or by writing to:
* Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
* MA 02111-1307, USA
* The copyright to this program is held by it's authors.
*
* @see gnu.gpl.Licence
* @author Joe Walker [joe at eireneh dot com]
* @version $Id: InstallManagerComboBoxModel.java,v 1.1 2004/10/10 22:12:11 joe Exp $
*/
public class InstallManagerComboBoxModel extends AbstractListModel implements ComboBoxModel
{
/**
* Simple ctor
*/
public InstallManagerComboBoxModel(InstallManager imanager)
{
this.imanager = imanager;
update(null);
selection = getElementAt(0);
imanager.addInstallerListener(new CustomInstallerListener());
}
/* (non-Javadoc)
* @see javax.swing.ComboBoxModel#getSelectedItem()
*/
public Object getSelectedItem()
{
return selection;
}
/* (non-Javadoc)
* @see javax.swing.ComboBoxModel#setSelectedItem(java.lang.Object)
*/
public void setSelectedItem(Object selection)
{
this.selection = selection;
}
/* (non-Javadoc)
* @see javax.swing.ListModel#getSize()
*/
public int getSize()
{
return names.size();
}
/* (non-Javadoc)
* @see javax.swing.ListModel#getElementAt(int)
*/
public Object getElementAt(int index)
{
return names.get(index);
}
/**
* Listens to the InstallManager for Installer changes
*/
private class CustomInstallerListener implements InstallerListener
{
/* (non-Javadoc)
* @see org.crosswire.jsword.book.install.InstallerListener#installerAdded(org.crosswire.jsword.book.install.InstallerEvent)
*/
public void installerAdded(InstallerEvent ev)
{
update(ev);
}
/* (non-Javadoc)
* @see org.crosswire.jsword.book.install.InstallerListener#installerRemoved(org.crosswire.jsword.book.install.InstallerEvent)
*/
public void installerRemoved(InstallerEvent ev)
{
update(ev);
}
}
/**
* Simple way to avoid eclipse private/protected warning
*/
protected void update(InstallerEvent ev)
{
int oldmax = names.size();
names.clear();
names.addAll(imanager.getInstallers().keySet());
Collections.sort(names);
if (ev != null)
{
fireContentsChanged(ev.getSource(), 0, oldmax);
}
}
/**
* The currently selected object
*/
private Object selection;
/**
* A cache of the names in the Install Manager
*/
private List names = new ArrayList();
/**
* The install manager that we are representing
*/
private InstallManager imanager;
}
--- NEW FILE: IndexResolver.java ---
package org.crosswire.bibledesktop.book;
import java.awt.BorderLayout;
import java.awt.Component;
import java.io.IOException;
import java.net.URL;
import java.util.Iterator;
import java.util.Map;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import org.crosswire.common.util.Logger;
import org.crosswire.common.util.NetUtil;
import org.crosswire.jsword.book.BookException;
import org.crosswire.jsword.book.BookMetaData;
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.book.search.IndexManager;
import org.crosswire.jsword.book.search.IndexManagerFactory;
/**
* A class to prompt the user to download or create a search index and to do
* carry out the users wishes.
*
*
*
*
* Distribution Licence:
* JSword 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
* here , or by writing to:
* Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
* MA 02111-1307, USA
* The copyright to this program is held by it's authors.
*
* @see gnu.gpl.Licence
* @author Joe Walker [joe at eireneh dot com]
* @version $Id: IndexResolver.java,v 1.1 2004/10/10 22:12:11 joe Exp $
*/
public class IndexResolver
{
/**
* Prevent instansiation
*/
private IndexResolver()
{
}
/**
* The options that we show to the user for how to get a search index
*/
private static Object[] options = new Object[]
{
Msg.OPTION_DOWNLOAD,
Msg.OPTION_GENERATE,
Msg.OPTION_CANCEL,
};
/**
* @param parent
*
*/
public static void scheduleIndex(BookMetaData bmd, Component parent)
{
String title = Msg.HOW_MESSAGE_TITLE.toString();
Msg msg = Msg.HOW_MESSAGE;
int choice = JOptionPane.showOptionDialog(parent, msg, title, JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[0]);
switch (choice)
{
case 0: // download
Installer installer = selectInstaller(parent);
if (installer != null)
{
try
{
downloadIndex(bmd, installer);
}
catch (Exception ex)
{
log.error("index download failed: ", ex); //$NON-NLS-1$
//Reporter.informUser(parent, ex);
String gtitle = Msg.HOW_GENERATE_TITLE.toString();
Msg gmsg = Msg.HOW_GENERATE;
int yn = JOptionPane.showConfirmDialog(parent, gmsg, gtitle, JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
if (yn == JOptionPane.YES_OPTION)
{
IndexManagerFactory.getIndexManager().scheduleIndexCreation(bmd.getBook());
}
}
}
break;
case 1: // generate
IndexManagerFactory.getIndexManager().scheduleIndexCreation(bmd.getBook());
break;
default: // cancel
break;
}
}
/**
* Download and install a search index
* @param bmd The book to get an index for
*/
private static void downloadIndex(BookMetaData bmd, Installer installer) throws IOException, InstallException, BookException
{
// Get a temp home
URL tempDownload = NetUtil.getTemporaryURL(TEMP_PREFIX, TEMP_SUFFIX);
try
{
// Now we know what installer to use, download to the temp file
installer.downloadSearchIndex(bmd, tempDownload);
// And install from that file.
IndexManager idxman = IndexManagerFactory.getIndexManager();
idxman.installDownloadedIndex(bmd.getBook(), tempDownload);
}
finally
{
// tidy up after ourselves
if (tempDownload != null)
{
NetUtil.delete(tempDownload);
}
}
}
/**
* Pick an installer
* @param parent A component to tie dialogs to
* @return The chosen installer or null if the user cancelled.
*/
private static Installer selectInstaller(Component parent)
{
// Pick an installer
InstallManager insman = new InstallManager();
Map installers = insman.getInstallers();
Installer installer = null;
if (installers.size() == 1)
{
Iterator it = installers.values().iterator();
assert it.hasNext();
installer = (Installer) it.next();
}
else
{
JComboBox choice = new JComboBox(new InstallManagerComboBoxModel(insman));
JLabel label = new JLabel(Msg.HOW_SITE.toString());
JPanel panel = new JPanel(new BorderLayout());
panel.add(label, BorderLayout.NORTH);
panel.add(choice, BorderLayout.CENTER);
String title = Msg.HOW_SITE_TITLE.toString();
int yn = JOptionPane.showConfirmDialog(parent, panel, title, JOptionPane.YES_OPTION);
if (yn == JOptionPane.YES_OPTION)
{
installer = (Installer) choice.getSelectedItem();
}
}
return installer;
}
/**
* The log stream
*/
private static final Logger log = Logger.getLogger(IndexResolver.class);
private static final String TEMP_SUFFIX = "dat"; //$NON-NLS-1$
private static final String TEMP_PREFIX = "jsword-index"; //$NON-NLS-1$
}
Index: Msg.properties
===================================================================
RCS file: /cvs/jsword/bibledesktop/java/main/org/crosswire/bibledesktop/book/Msg.properties,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** Msg.properties 9 Oct 2004 21:45:24 -0000 1.9
--- Msg.properties 10 Oct 2004 22:12:11 -0000 1.10
***************
*** 69,70 ****
--- 69,84 ----
AdvancedSearchPane.SelectPassageTitle=Select Passages to Restrict Search to
+
+ IndexResolver.HowMessageTitle=Download or generate?
+ IndexResolver.HowMessage=Do you wish to try to download and index or generate one for yourself?\n\
+ Downloading (2-3Mb) will take around 10 mins on a modem or 1 min on broadband.\n\
+ Generating an index will take around 5 mins on an average computer.\n\
+ Not all books have indexes so download may not be possible.
+ IndexResolver.HowSiteTitle=Which download site?
+ IndexResolver.HowSite=Which download site do you wish to use?
+ IndexResolver.HowGenerateTitle=Generate an index anyway?
+ IndexResolver.HowGenerate=Downloading failed.\n\
+ Do you wish to generate an index anyway?
+ IndexResolver.OptionDownload=Download
+ IndexResolver.OptionGenerate=Generate
+ IndexResolver.OptionCancel=Cancel
--- InstallManagerListModel.java DELETED ---
Index: EditSitePane.java
===================================================================
RCS file: /cvs/jsword/bibledesktop/java/main/org/crosswire/bibledesktop/book/EditSitePane.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** EditSitePane.java 30 Aug 2004 09:26:13 -0000 1.8
--- EditSitePane.java 10 Oct 2004 22:12:11 -0000 1.9
***************
*** 91,95 ****
actions = new ActionFactory(EditSitePane.class, this);
! lstSite = new JList(new InstallManagerListModel(imanager));
JScrollPane scrSite = new JScrollPane();
scrSite.add(lstSite, null);
--- 91,95 ----
actions = new ActionFactory(EditSitePane.class, this);
! lstSite = new JList(new InstallManagerComboBoxModel(imanager));
JScrollPane scrSite = new JScrollPane();
scrSite.add(lstSite, null);
From jswordcvs at crosswire.org Sun Oct 10 15:12:19 2004
From: jswordcvs at crosswire.org (jswordcvs@crosswire.org)
Date: Sun Oct 10 15:12:21 2004
Subject: [jsword-svn] common/java/core/org/crosswire/common/util s
Message-ID: <200410102212.i9AMCJ17025330@www.crosswire.org>
Update of /cvs/jsword/common/java/core/org/crosswire/common/util
In directory www.crosswire.org:/tmp/cvs-serv25322/java/core/org/crosswire/common/util
Modified Files:
NetUtil.java
Added Files:
IOUtil.java
Log Message:
basics of downloadable indexers
Index: NetUtil.java
===================================================================
RCS file: /cvs/jsword/common/java/core/org/crosswire/common/util/NetUtil.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -d -r1.13 -r1.14
*** NetUtil.java 2 Oct 2004 14:01:35 -0000 1.13
--- NetUtil.java 10 Oct 2004 22:12:17 -0000 1.14
***************
*** 636,639 ****
--- 636,669 ----
/**
+ * Get a URL version of the given file.
+ * @param file The File to turn into a URL
+ * @return a URL for the given file
+ */
+ public static URL getURL(File file)
+ {
+ try
+ {
+ return new URL(PROTOCOL_FILE, null, -1, file.getCanonicalPath());
+ }
+ catch (IOException ex)
+ {
+ log.error("Failed to create URL", ex); //$NON-NLS-1$
+ assert false;
+ throw new IllegalArgumentException();
+ }
+ }
+
+ /**
+ * A URL version of File.createTempFile()
+ * @return A new temporary URL
+ * @throws IOException If something goes wrong creating the temp URL
+ */
+ public static URL getTemporaryURL(String prefix, String suffix) throws IOException
+ {
+ File tempFile = File.createTempFile(prefix, suffix);
+ return getURL(tempFile);
+ }
+
+ /**
* Check that the directories in the version directory really
* represent versions.
--- NEW FILE: IOUtil.java ---
package org.crosswire.common.util;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.URL;
import java.util.Enumeration;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
/**
* .
*
*
*
*
* Distribution Licence:
* JSword 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
* here , or by writing to:
* Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
* MA 02111-1307, USA
* The copyright to this program is held by it's authors.
*
* @see gnu.gpl.Licence
* @author Joe Walker [joe at eireneh dot com]
* @version $Id: IOUtil.java,v 1.1 2004/10/10 22:12:17 joe Exp $
*/
public class IOUtil
{
/**
* Prevent instansiation
*/
private IOUtil()
{
}
/**
* Unpack a zip file to a given directory
* @param f The zip file to download
* @param destdir The directory to unpack up
* @throws IOException If there is an file error
*/
public static void unpackZip(File f, URL destdir) throws IOException
{
// unpack the zip.
byte[] dbuf = new byte[4096];
ZipFile zf = new ZipFile(f);
Enumeration entries = zf.entries();
while (entries.hasMoreElements())
{
ZipEntry entry = (ZipEntry) entries.nextElement();
String entrypath = entry.getName();
String filename = entrypath.substring(entrypath.lastIndexOf('/') + 1);
URL child = NetUtil.lengthenURL(destdir, filename);
OutputStream dataOut = NetUtil.getOutputStream(child);
InputStream dataIn = zf.getInputStream(entry);
for (int count = 0; -1 != (count = dataIn.read(dbuf)); )
{
dataOut.write(dbuf, 0, count);
}
dataOut.close();
}
}
/**
* Close the stream whatever without complaining
* @param out The stream to close
*/
public static void close(OutputStream out)
{
if (null != out)
{
try
{
out.close();
}
catch (IOException ex)
{
log.error("close", ex); //$NON-NLS-1$
}
}
}
/**
* Close the stream whatever without complaining
* @param in The stream to close
*/
public static void close(InputStream in)
{
if (null != in)
{
try
{
in.close();
}
catch (IOException ex)
{
log.error("close", ex); //$NON-NLS-1$
}
}
}
/**
* The log stream
*/
private static final Logger log = Logger.getLogger(IOUtil.class);
}
From jswordcvs at crosswire.org Fri Oct 15 16:28:09 2004
From: jswordcvs at crosswire.org (jswordcvs@crosswire.org)
Date: Fri Oct 15 16:28:10 2004
Subject: [jsword-svn]
jsword/java/limbo/org/crosswire/jsword/book/search/ser s
Message-ID: <200410152328.i9FNS9rJ030334@www.crosswire.org>
Update of /cvs/jsword/jsword/java/limbo/org/crosswire/jsword/book/search/ser
In directory www.crosswire.org:/tmp/cvs-serv30320/java/limbo/org/crosswire/jsword/book/search/ser
Modified Files:
SerIndexManager.java
Log Message:
progress on downloading index
Index: SerIndexManager.java
===================================================================
RCS file: /cvs/jsword/jsword/java/limbo/org/crosswire/jsword/book/search/ser/SerIndexManager.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** SerIndexManager.java 10 Oct 2004 22:12:02 -0000 1.2
--- SerIndexManager.java 15 Oct 2004 23:28:07 -0000 1.3
***************
*** 13,16 ****
--- 13,17 ----
import org.crosswire.jsword.book.Book;
import org.crosswire.jsword.book.BookException;
+ import org.crosswire.jsword.book.BookMetaData;
import org.crosswire.jsword.book.search.Index;
import org.crosswire.jsword.book.search.IndexManager;
***************
*** 50,54 ****
try
{
! URL storage = getStorageArea(book);
URL longer = NetUtil.lengthenURL(storage, SerIndex.FILE_INDEX);
return NetUtil.isFile(longer);
--- 51,55 ----
try
{
! URL storage = getStorageArea(book.getBookMetaData());
URL longer = NetUtil.lengthenURL(storage, SerIndex.FILE_INDEX);
return NetUtil.isFile(longer);
***************
*** 71,75 ****
if (reply == null)
{
! URL storage = getStorageArea(book);
reply = new SerIndex(book, storage);
indexes.put(book, reply);
--- 72,76 ----
if (reply == null)
{
! URL storage = getStorageArea(book.getBookMetaData());
reply = new SerIndex(book, storage);
indexes.put(book, reply);
***************
*** 95,99 ****
try
{
! URL storage = getStorageArea(book);
Index index = new SerIndex(book, storage, true);
indexes.put(book, index);
--- 96,100 ----
try
{
! URL storage = getStorageArea(book.getBookMetaData());
Index index = new SerIndex(book, storage, true);
indexes.put(book, index);
***************
*** 111,120 ****
* @see org.crosswire.jsword.book.search.IndexManager#installDownloadedIndex(org.crosswire.jsword.book.Book, java.net.URL)
*/
! public void installDownloadedIndex(Book book, URL tempDest) throws BookException
{
try
{
! URL storage = getStorageArea(book);
! File zip = NetUtil.getAsFile(storage);
IOUtil.unpackZip(zip, storage);
}
--- 112,121 ----
* @see org.crosswire.jsword.book.search.IndexManager#installDownloadedIndex(org.crosswire.jsword.book.Book, java.net.URL)
*/
! public void installDownloadedIndex(BookMetaData bmd, URL tempDest) throws BookException
{
try
{
! URL storage = getStorageArea(bmd);
! File zip = NetUtil.getAsFile(tempDest);
IOUtil.unpackZip(zip, storage);
}
***************
*** 133,137 ****
{
// TODO(joe): This needs some checks that it isn't being used
! URL storage = getStorageArea(book);
NetUtil.delete(storage);
}
--- 134,138 ----
{
// TODO(joe): This needs some checks that it isn't being used
! URL storage = getStorageArea(book.getBookMetaData());
NetUtil.delete(storage);
}
***************
*** 144,155 ****
/**
* Determine where an index should be stored
! * @param book The book to be indexed
* @return A URL to store stuff in
* @throws IOException If there is a problem in finding where to store stuff
*/
! protected URL getStorageArea(Book book) throws IOException
{
! String driverName = book.getBookMetaData().getDriverName();
! String bookName = book.getBookMetaData().getInitials();
assert driverName != null;
--- 145,156 ----
/**
* Determine where an index should be stored
! * @param bmd The book to be indexed
* @return A URL to store stuff in
* @throws IOException If there is a problem in finding where to store stuff
*/
! protected URL getStorageArea(BookMetaData bmd) throws IOException
{
! String driverName = bmd.getDriverName();
! String bookName = bmd.getInitials();
assert driverName != null;
From jswordcvs at crosswire.org Fri Oct 15 16:28:10 2004
From: jswordcvs at crosswire.org (jswordcvs@crosswire.org)
Date: Fri Oct 15 16:28:12 2004
Subject: [jsword-svn] jsword/java/jsword/org/crosswire/jsword/book/search s
Message-ID: <200410152328.i9FNSAR8030360@www.crosswire.org>
Update of /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/search
In directory www.crosswire.org:/tmp/cvs-serv30320/java/jsword/org/crosswire/jsword/book/search
Modified Files:
IndexManager.java
Log Message:
progress on downloading index
Index: IndexManager.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/search/IndexManager.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** IndexManager.java 10 Oct 2004 22:12:02 -0000 1.3
--- IndexManager.java 15 Oct 2004 23:28:08 -0000 1.4
***************
*** 5,11 ****
import org.crosswire.jsword.book.Book;
import org.crosswire.jsword.book.BookException;
/**
! * .
*
*
--- 5,12 ----
import org.crosswire.jsword.book.Book;
import org.crosswire.jsword.book.BookException;
+ import org.crosswire.jsword.book.BookMetaData;
/**
! * A way of managing a way of creating a search index for a book.
*
*
***************
*** 51,58 ****
* We have downloaded a search index to a zip file. It should be installed
* from here.
! * @param book The book that we downloaded an index for
* @param tempDest The URL of a zip file to install
*/
! public void installDownloadedIndex(Book book, URL tempDest) throws BookException;
/**
--- 52,59 ----
* We have downloaded a search index to a zip file. It should be installed
* from here.
! * @param bmd The book that we downloaded an index for
* @param tempDest The URL of a zip file to install
*/
! public void installDownloadedIndex(BookMetaData bmd, URL tempDest) throws BookException;
/**
From jswordcvs at crosswire.org Fri Oct 15 16:28:10 2004
From: jswordcvs at crosswire.org (jswordcvs@crosswire.org)
Date: Fri Oct 15 16:28:12 2004
Subject: [jsword-svn] jsword/java/jsword/org/crosswire/jsword/book/install s
Message-ID: <200410152328.i9FNSAHQ030341@www.crosswire.org>
Update of /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/install
In directory www.crosswire.org:/tmp/cvs-serv30320/java/jsword/org/crosswire/jsword/book/install
Modified Files:
Installer.java
Log Message:
progress on downloading index
Index: Installer.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/install/Installer.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** Installer.java 10 Oct 2004 22:12:02 -0000 1.7
--- Installer.java 15 Oct 2004 23:28:07 -0000 1.8
***************
*** 46,49 ****
--- 46,61 ----
/**
+ * @param bmd The book meta-data to get a URL from.
+ * @return the remote url for the BookMetaData
+ */
+ public URL toRemoteURL(BookMetaData bmd);
+
+ /**
+ * @param bmd The book meta-data to get a URL from.
+ * @return the url for the directory for BookMetaData
+ */
+ public URL toLocalURL(BookMetaData bmd);
+
+ /**
* Get a list of BookMetaData objects that represent downloadable modules.
* If no list has been retrieved from the remote source using reloadIndex()
***************
*** 55,58 ****
--- 67,78 ----
/**
+ * Return true if the module is not installed or there is a newer
+ * version to install.
+ * @param bmd The book meta-data to check on.
+ * @return whether there is a newer version to install
+ */
+ public boolean isNewer(BookMetaData bmd);
+
+ /**
* Refetch a list of names from the remote source.
* It would make sense if the user was warned about the implications
***************
*** 79,101 ****
*/
public void downloadSearchIndex(BookMetaData bmd, URL tempDest) throws InstallException;
-
- /**
- * @param bmd The book meta-data to get a URL from.
- * @return the remote url for the BookMetaData
- */
- public URL toRemoteURL(BookMetaData bmd);
-
- /**
- * @param bmd The book meta-data to get a URL from.
- * @return the url for the directory for BookMetaData
- */
- public URL toLocalURL(BookMetaData bmd);
-
- /**
- * Return true if the module is not installed or there is a newer
- * version to install.
- * @param bmd The book meta-data to check on.
- * @return whether there is a newer version to install
- */
- public boolean isNewer(BookMetaData bmd);
}
--- 99,101 ----
From jswordcvs at crosswire.org Fri Oct 15 16:28:10 2004
From: jswordcvs at crosswire.org (jswordcvs@crosswire.org)
Date: Fri Oct 15 16:28:12 2004
Subject: [jsword-svn]
jsword/java/jsword/org/crosswire/jsword/book/search/lucene s
Message-ID: <200410152328.i9FNSAY6030350@www.crosswire.org>
Update of /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/search/lucene
In directory www.crosswire.org:/tmp/cvs-serv30320/java/jsword/org/crosswire/jsword/book/search/lucene
Modified Files:
LuceneIndexManager.java
Log Message:
progress on downloading index
Index: LuceneIndexManager.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/search/lucene/LuceneIndexManager.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** LuceneIndexManager.java 10 Oct 2004 22:12:02 -0000 1.2
--- LuceneIndexManager.java 15 Oct 2004 23:28:08 -0000 1.3
***************
*** 13,16 ****
--- 13,17 ----
import org.crosswire.jsword.book.Book;
import org.crosswire.jsword.book.BookException;
+ import org.crosswire.jsword.book.BookMetaData;
import org.crosswire.jsword.book.IndexStatus;
import org.crosswire.jsword.book.search.Index;
***************
*** 51,55 ****
try
{
! URL storage = getStorageArea(book);
URL longer = NetUtil.lengthenURL(storage, DIR_SEGMENTS);
return NetUtil.isFile(longer);
--- 52,56 ----
try
{
! URL storage = getStorageArea(book.getBookMetaData());
URL longer = NetUtil.lengthenURL(storage, DIR_SEGMENTS);
return NetUtil.isFile(longer);
***************
*** 72,76 ****
if (reply == null)
{
! URL storage = getStorageArea(book);
reply = new LuceneIndex(book, storage);
indexes.put(book, reply);
--- 73,77 ----
if (reply == null)
{
! URL storage = getStorageArea(book.getBookMetaData());
reply = new LuceneIndex(book, storage);
indexes.put(book, reply);
***************
*** 98,102 ****
try
{
! URL storage = getStorageArea(book);
Index index = new LuceneIndex(book, storage, true);
indexes.put(book, index);
--- 99,103 ----
try
{
! URL storage = getStorageArea(book.getBookMetaData());
Index index = new LuceneIndex(book, storage, true);
indexes.put(book, index);
***************
*** 114,123 ****
* @see org.crosswire.jsword.book.search.IndexManager#installDownloadedIndex(org.crosswire.jsword.book.Book, java.net.URL)
*/
! public void installDownloadedIndex(Book book, URL tempDest) throws BookException
{
try
{
! URL storage = getStorageArea(book);
! File zip = NetUtil.getAsFile(storage);
IOUtil.unpackZip(zip, storage);
}
--- 115,124 ----
* @see org.crosswire.jsword.book.search.IndexManager#installDownloadedIndex(org.crosswire.jsword.book.Book, java.net.URL)
*/
! public void installDownloadedIndex(BookMetaData bmd, URL tempDest) throws BookException
{
try
{
! URL storage = getStorageArea(bmd);
! File zip = NetUtil.getAsFile(tempDest);
IOUtil.unpackZip(zip, storage);
}
***************
*** 136,140 ****
{
// TODO(joe): This needs some checks that it isn't being used
! URL storage = getStorageArea(book);
NetUtil.delete(storage);
}
--- 137,141 ----
{
// TODO(joe): This needs some checks that it isn't being used
! URL storage = getStorageArea(book.getBookMetaData());
NetUtil.delete(storage);
}
***************
*** 147,158 ****
/**
* Determine where an index should be stored
! * @param book The book to be indexed
* @return A URL to store stuff in
* @throws IOException If there is a problem in finding where to store stuff
*/
! protected URL getStorageArea(Book book) throws IOException
{
! String driverName = book.getBookMetaData().getDriverName();
! String bookName = book.getBookMetaData().getInitials();
assert driverName != null;
--- 148,159 ----
/**
* Determine where an index should be stored
! * @param bmd The book to be indexed
* @return A URL to store stuff in
* @throws IOException If there is a problem in finding where to store stuff
*/
! protected URL getStorageArea(BookMetaData bmd) throws IOException
{
! String driverName = bmd.getDriverName();
! String bookName = bmd.getInitials();
assert driverName != null;
From jswordcvs at crosswire.org Fri Oct 15 16:28:10 2004
From: jswordcvs at crosswire.org (jswordcvs@crosswire.org)
Date: Fri Oct 15 16:28:12 2004
Subject: [jsword-svn] jsword/java/jsword/org/crosswire/jsword/util s
Message-ID: <200410152328.i9FNSAjA030356@www.crosswire.org>
Update of /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/util
In directory www.crosswire.org:/tmp/cvs-serv30320/java/jsword/org/crosswire/jsword/util
Added Files:
IndexDownloader.java
Log Message:
progress on downloading index
--- NEW FILE: IndexDownloader.java ---
package org.crosswire.jsword.util;
import java.io.IOException;
import java.net.URL;
import org.crosswire.common.util.NetUtil;
import org.crosswire.jsword.book.BookException;
import org.crosswire.jsword.book.BookMetaData;
import org.crosswire.jsword.book.install.InstallException;
import org.crosswire.jsword.book.install.Installer;
import org.crosswire.jsword.book.search.IndexManager;
import org.crosswire.jsword.book.search.IndexManagerFactory;
/**
* .
*
*
*
*
* Distribution Licence:
* JSword 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
* here , or by writing to:
* Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
* MA 02111-1307, USA
* The copyright to this program is held by it's authors.
*
* @see gnu.gpl.Licence
* @author Joe Walker [joe at eireneh dot com]
* @version $Id: IndexDownloader.java,v 1.1 2004/10/15 23:28:08 joe Exp $
*/
public class IndexDownloader
{
/**
* Prevent instansiation
*/
private IndexDownloader()
{
}
/**
* Download and install a search index
* @param bmd The book to get an index for
*/
public static void downloadIndex(BookMetaData bmd, Installer installer) throws IOException, InstallException, BookException
{
// Get a temp home
URL tempDownload = NetUtil.getTemporaryURL(TEMP_PREFIX, TEMP_SUFFIX);
try
{
// Now we know what installer to use, download to the temp file
installer.downloadSearchIndex(bmd, tempDownload);
// And install from that file.
IndexManager idxman = IndexManagerFactory.getIndexManager();
idxman.installDownloadedIndex(bmd, tempDownload);
}
finally
{
// tidy up after ourselves
if (tempDownload != null)
{
NetUtil.delete(tempDownload);
}
}
}
/**
* Temp file prefix
*/
private static final String TEMP_PREFIX = "jsword-index"; //$NON-NLS-1$
/**
* Temp file suffix
*/
private static final String TEMP_SUFFIX = "dat"; //$NON-NLS-1$
}
From jswordcvs at crosswire.org Fri Oct 15 16:28:14 2004
From: jswordcvs at crosswire.org (jswordcvs@crosswire.org)
Date: Fri Oct 15 16:28:16 2004
Subject: [jsword-svn] jsword-web/web s
Message-ID: <200410152328.i9FNSEng030443@www.crosswire.org>
Update of /cvs/jsword/jsword-web/web
In directory www.crosswire.org:/tmp/cvs-serv30399/web
Modified Files:
index.html
Log Message:
progress on downloading index
Index: index.html
===================================================================
RCS file: /cvs/jsword/jsword-web/web/index.html,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** index.html 26 Sep 2004 09:19:27 -0000 1.5
--- index.html 15 Oct 2004 23:28:12 -0000 1.6
***************
*** 72,77 ****
! Atlassian supports our efforts by contributing their bug tracking and issue tracking application, JIRA, to our project.
! Atlassian is an innovative Australian software company providing enterprise software solutions to the world's leading organisations. Atlassian's leading software product, JIRA is a bug tracking and issue tracking application developed to track and manage the issues and bugs that emerge during a project. JIRA customers include departments from NASA, Boeing, Cisco, JP Morgan, 3M, BP, Sony and more. Try it for yourself today.
--- 72,77 ----
! Atlassian supports our efforts by contributing JIRA, their bug tracking and issue tracking application, to our project.
! JIRA is developed to track and manage the issues and bugs that emerge during a project. Try it for yourself.
***************
*** 79,84 ****
! Jakarta Lucene is a high-performance, full-featured text search engine library written entirely in Java. It is a technology suitable for nearly any application that requires full-text search, especially cross-platform.
! Jakarta Lucene is an open source project available for free download from Apache Jakarta. Please use the links on the left to access Lucene.
--- 79,84 ----
! Jakarta Lucene is an open source, high-performance, full-featured text search engine library written entirely in Java.
! It is a technology suitable for nearly any application that requires full-text search.
***************
*** 86,91 ****
! We intend to provide a solution for using XML from Java that is as simple as Java itself.
! There is no compelling reason for a Java API to manipulate XML to be complex, tricky, unintuitive, or a pain in the neck. JDOM is both Java-centric and Java-optimized. It behaves like Java, it uses Java collections, it is completely natural API for current Java developers, and it provides a low-cost entry point for using XML.
--- 86,90 ----
! JDOM provides a solution for using XML from Java that is as simple as Java itself.
From jswordcvs at crosswire.org Fri Oct 15 16:28:19 2004
From: jswordcvs at crosswire.org (jswordcvs@crosswire.org)
Date: Fri Oct 15 16:28:20 2004
Subject: [jsword-svn] common/java/core/org/crosswire/common/util s
Message-ID: <200410152328.i9FNSJGJ030471@www.crosswire.org>
Update of /cvs/jsword/common/java/core/org/crosswire/common/util
In directory www.crosswire.org:/tmp/cvs-serv30453/java/core/org/crosswire/common/util
Modified Files:
NetUtil.java
Log Message:
progress on downloading index
Index: NetUtil.java
===================================================================
RCS file: /cvs/jsword/common/java/core/org/crosswire/common/util/NetUtil.java,v
retrieving revision 1.14
retrieving revision 1.15
diff -C2 -d -r1.14 -r1.15
*** NetUtil.java 10 Oct 2004 22:12:17 -0000 1.14
--- NetUtil.java 15 Oct 2004 23:28:17 -0000 1.15
***************
*** 402,406 ****
else
{
! return url.openConnection().getOutputStream();
}
}
--- 402,408 ----
else
{
! URLConnection cnx = url.openConnection();
! cnx.setDoOutput(true);
! return cnx.getOutputStream();
}
}
From jswordcvs at crosswire.org Fri Oct 15 16:28:24 2004
From: jswordcvs at crosswire.org (jswordcvs@crosswire.org)
Date: Fri Oct 15 16:28:25 2004
Subject: [jsword-svn]
bibledesktop/java/main/org/crosswire/bibledesktop/book s
Message-ID: <200410152328.i9FNSOMp030490@www.crosswire.org>
Update of /cvs/jsword/bibledesktop/java/main/org/crosswire/bibledesktop/book
In directory www.crosswire.org:/tmp/cvs-serv30479/java/main/org/crosswire/bibledesktop/book
Modified Files:
Msg.properties Msg.java SitesPane.java SitePane.properties
SitePane.java IndexResolver.java SitesPane.properties
Log Message:
progress on downloading index
Index: SitePane.properties
===================================================================
RCS file: /cvs/jsword/bibledesktop/java/main/org/crosswire/bibledesktop/book/SitePane.properties,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** SitePane.properties 27 Aug 2004 11:41:33 -0000 1.2
--- SitePane.properties 15 Oct 2004 23:28:22 -0000 1.3
***************
*** 34,45 ****
Install.ShortDescription=Install a book.
Install.LongDescription=Install the selected book
- Install.SmallIcon=
- Install.LargeIcon=
Install.MnemonicKey=I
! Install.AcceleratorKey=
! Install.AcceleratorKey.Modifiers=
Refresh.Enabled=true
! Refresh.Name=Update Index
Refresh.ShortDescription=Refresh the list of books.
Refresh.LongDescription=Download a current listing of books.
--- 34,47 ----
Install.ShortDescription=Install a book.
Install.LongDescription=Install the selected book
Install.MnemonicKey=I
!
! InstallSearch.Enabled=false
! InstallSearch.Name=Install with Search
! InstallSearch.ShortDescription=Download a book and search index.
! InstallSearch.LongDescription=Install the selected book along with a search index.
! InstallSearch.MnemonicKey=S
Refresh.Enabled=true
! Refresh.Name=Update Available Books
Refresh.ShortDescription=Refresh the list of books.
Refresh.LongDescription=Download a current listing of books.
Index: SitePane.java
===================================================================
RCS file: /cvs/jsword/bibledesktop/java/main/org/crosswire/bibledesktop/book/SitePane.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -d -r1.12 -r1.13
*** SitePane.java 10 Oct 2004 22:12:11 -0000 1.12
--- SitePane.java 15 Oct 2004 23:28:22 -0000 1.13
***************
*** 29,32 ****
--- 29,33 ----
import org.crosswire.jsword.book.install.InstallException;
import org.crosswire.jsword.book.install.Installer;
+ import org.crosswire.jsword.util.IndexDownloader;
/**
***************
*** 73,76 ****
--- 74,80 ----
}
+ /**
+ * Internal ctor
+ */
private SitePane(Installer bookListInstaller, String labelAcronymn)
{
***************
*** 80,84 ****
BookList bl = installer;
! if (installer == null)
{
bl = Books.installed();
--- 84,88 ----
BookList bl = installer;
! if (bl == null)
{
bl = Books.installed();
***************
*** 93,100 ****
--- 97,144 ----
private void initialize(String labelAcronymn, BookList books)
{
+ lblDesc = new JLabel();
+ lblDesc.setBorder(BorderFactory.createEmptyBorder(5, 5, 0, 0));
+
Component left = createAvailablePanel(labelAcronymn, books);
Component right = createSelectedPanel();
this.setLayout(new BorderLayout());
+ this.add(lblDesc, BorderLayout.NORTH);
this.add(createSplitPane(left, right), BorderLayout.CENTER);
+
+ updateDescription();
+ }
+
+ /**
+ *
+ */
+ private void updateDescription()
+ {
+ String desc = "#ERROR#"; //$NON-NLS-1$
+
+ if (installer == null)
+ {
+ int bookCount = Books.installed().getBookMetaDatas().size();
+ desc = Msg.INSTALLED_DESC.toString(new Object[]
+ {
+ new Integer(bookCount)
+ });
+ }
+ else
+ {
+ int bookCount = installer.getBookMetaDatas().size();
+ if (bookCount == 0)
+ {
+ desc = Msg.NONE_AVAILABLE_DESC.toString();
+ }
+ else
+ {
+ desc = Msg.AVAILABLE_DESC.toString(new Object[]
+ {
+ new Integer(bookCount)
+ });
+ }
+ }
+
+ lblDesc.setText(desc);
}
***************
*** 187,190 ****
--- 231,235 ----
{
panel.add(new JButton(actions.getAction(INSTALL)));
+ panel.add(new JButton(actions.getAction(INSTALL_SEARCH)));
panel.add(new JButton(actions.getAction(REFRESH)));
}
***************
*** 240,244 ****
// Is the book already installed? Then nothing to do.
BookMetaData bmd = Books.installed().getBookMetaData(name.getName());
! if (bmd != null && ! installer.isNewer(bmd))
{
Reporter.informUser(this, Msg.INSTALLED, name.getName());
--- 285,289 ----
// Is the book already installed? Then nothing to do.
BookMetaData bmd = Books.installed().getBookMetaData(name.getName());
! if (bmd != null && !installer.isNewer(bmd))
{
Reporter.informUser(this, Msg.INSTALLED, name.getName());
***************
*** 253,257 ****
installer.install(name);
}
-
}
catch (InstallException ex)
--- 298,301 ----
***************
*** 264,267 ****
--- 308,333 ----
/**
+ * Kick off the installer
+ */
+ public void doInstallSearch()
+ {
+ doInstall();
+
+ TreePath path = treAvailable.getSelectionPath();
+ if (path != null)
+ {
+ try
+ {
+ BookMetaData bmd = (BookMetaData) path.getLastPathComponent();
+ IndexDownloader.downloadIndex(bmd, installer);
+ }
+ catch (Exception ex)
+ {
+ Reporter.informUser(this, ex);
+ }
+ }
+ }
+
+ /**
* Something has been (un)selected in the tree
*/
***************
*** 286,289 ****
--- 352,356 ----
//actions.getAction(DELETE).setEnabled(bookSelected);
actions.getAction(INSTALL).setEnabled(bookSelected);
+ actions.getAction(INSTALL_SEARCH).setEnabled(bookSelected);
}
***************
*** 293,296 ****
--- 360,364 ----
private static final String REFRESH = "Refresh"; //$NON-NLS-1$
private static final String INSTALL = "Install"; //$NON-NLS-1$
+ private static final String INSTALL_SEARCH = "InstallSearch"; //$NON-NLS-1$
//private static final String DELETE = "Delete"; //$NON-NLS-1$
***************
*** 308,314 ****
* GUI Components
*/
! private JTree treAvailable;
! private JTable tblSelected;
! private MapTableModel emptyTableModel;
/**
--- 376,383 ----
* GUI Components
*/
! private JTree treAvailable = null;
! private JTable tblSelected = null;
! private MapTableModel emptyTableModel = null;
! private JLabel lblDesc = null;
/**
***************
*** 316,318 ****
*/
private static final long serialVersionUID = 1L;
! }
--- 385,387 ----
*/
private static final long serialVersionUID = 1L;
! }
\ No newline at end of file
Index: Msg.java
===================================================================
RCS file: /cvs/jsword/bibledesktop/java/main/org/crosswire/bibledesktop/book/Msg.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -d -r1.12 -r1.13
*** Msg.java 10 Oct 2004 22:12:11 -0000 1.12
--- Msg.java 15 Oct 2004 23:28:22 -0000 1.13
***************
*** 58,61 ****
--- 58,64 ----
static final Msg CONFIRMATION_TITLE = new Msg("SitePane.ConfirmationTitle"); //$NON-NLS-1$
static final Msg INSTALLED = new Msg("SitePane.Installed"); //$NON-NLS-1$
+ static final Msg INSTALLED_DESC = new Msg("SitePane.InstalledDesc"); //$NON-NLS-1$
+ static final Msg AVAILABLE_DESC = new Msg("SitePane.AvailableDesc"); //$NON-NLS-1$
+ static final Msg NONE_AVAILABLE_DESC = new Msg("SitePane.NoneAvailableDesc"); //$NON-NLS-1$
static final Msg EDIT_SITE_TITLE = new Msg("EditSitePane.EditSitesTitle"); //$NON-NLS-1$
Index: IndexResolver.java
===================================================================
RCS file: /cvs/jsword/bibledesktop/java/main/org/crosswire/bibledesktop/book/IndexResolver.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** IndexResolver.java 10 Oct 2004 22:12:11 -0000 1.1
--- IndexResolver.java 15 Oct 2004 23:28:22 -0000 1.2
***************
*** 3,8 ****
import java.awt.BorderLayout;
import java.awt.Component;
- import java.io.IOException;
- import java.net.URL;
import java.util.Iterator;
import java.util.Map;
--- 3,6 ----
***************
*** 14,25 ****
import org.crosswire.common.util.Logger;
- import org.crosswire.common.util.NetUtil;
- import org.crosswire.jsword.book.BookException;
import org.crosswire.jsword.book.BookMetaData;
- 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.book.search.IndexManager;
import org.crosswire.jsword.book.search.IndexManagerFactory;
/**
--- 12,20 ----
import org.crosswire.common.util.Logger;
import org.crosswire.jsword.book.BookMetaData;
import org.crosswire.jsword.book.install.InstallManager;
import org.crosswire.jsword.book.install.Installer;
import org.crosswire.jsword.book.search.IndexManagerFactory;
+ import org.crosswire.jsword.util.IndexDownloader;
/**
***************
*** 85,89 ****
try
{
! downloadIndex(bmd, installer);
}
catch (Exception ex)
--- 80,84 ----
try
{
! IndexDownloader.downloadIndex(bmd, installer);
}
catch (Exception ex)
***************
*** 114,145 ****
/**
- * Download and install a search index
- * @param bmd The book to get an index for
- */
- private static void downloadIndex(BookMetaData bmd, Installer installer) throws IOException, InstallException, BookException
- {
- // Get a temp home
- URL tempDownload = NetUtil.getTemporaryURL(TEMP_PREFIX, TEMP_SUFFIX);
-
- try
- {
- // Now we know what installer to use, download to the temp file
- installer.downloadSearchIndex(bmd, tempDownload);
-
- // And install from that file.
- IndexManager idxman = IndexManagerFactory.getIndexManager();
- idxman.installDownloadedIndex(bmd.getBook(), tempDownload);
- }
- finally
- {
- // tidy up after ourselves
- if (tempDownload != null)
- {
- NetUtil.delete(tempDownload);
- }
- }
- }
-
- /**
* Pick an installer
* @param parent A component to tie dialogs to
--- 109,112 ----
***************
*** 182,187 ****
*/
private static final Logger log = Logger.getLogger(IndexResolver.class);
-
- private static final String TEMP_SUFFIX = "dat"; //$NON-NLS-1$
- private static final String TEMP_PREFIX = "jsword-index"; //$NON-NLS-1$
}
--- 149,151 ----
Index: Msg.properties
===================================================================
RCS file: /cvs/jsword/bibledesktop/java/main/org/crosswire/bibledesktop/book/Msg.properties,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -d -r1.10 -r1.11
*** Msg.properties 10 Oct 2004 22:12:11 -0000 1.10
--- Msg.properties 15 Oct 2004 23:28:22 -0000 1.11
***************
*** 42,45 ****
--- 42,48 ----
SitePane.ConfirmationTitle=Download Book
SitePane.Installed=Book already installed: {0}
+ SitePane.InstalledDesc={0} books installed.
+ SitePane.AvailableDesc={0} books available for download.
+ SitePane.NoneAvailableDesc=Click ''Update Available Books'' to download an up to date book list.
EditSitePane.EditSitesTitle=Edit Update Sites
Index: SitesPane.properties
===================================================================
RCS file: /cvs/jsword/bibledesktop/java/main/org/crosswire/bibledesktop/book/SitesPane.properties,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** SitesPane.properties 27 Aug 2004 11:41:33 -0000 1.2
--- SitesPane.properties 15 Oct 2004 23:28:22 -0000 1.3
***************
*** 2,20 ****
SitesClose.Enabled=true
SitesClose.Name=OK
- SitesClose.ShortDescription=Close the window.
- SitesClose.LongDescription=Close the window.
- SitesClose.SmallIcon=
- SitesClose.LargeIcon=
SitesClose.MnemonicKey=O
- SitesClose.AcceleratorKey=
- SitesClose.AcceleratorKey.Modifiers=
ManageSites.Enabled=true
ManageSites.Name=Edit Sites ...
- ManageSites.ShortDescription=Edit the site.
- ManageSites.LongDescription=Edit the site.
- ManageSites.SmallIcon=
- ManageSites.LargeIcon=
ManageSites.MnemonicKey=S
- ManageSites.AcceleratorKey=
- ManageSites.AcceleratorKey.Modifiers=
--- 2,8 ----
Index: SitesPane.java
===================================================================
RCS file: /cvs/jsword/bibledesktop/java/main/org/crosswire/bibledesktop/book/SitesPane.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** SitesPane.java 2 Oct 2004 14:01:38 -0000 1.8
--- SitesPane.java 15 Oct 2004 23:28:22 -0000 1.9
***************
*** 118,124 ****
protected void addAllInstallers()
{
- // Add the panel for the locally installed books
- tabMain.add(Msg.LOCAL_BOOKS.toString(), new SitePane());
-
// Now add panels for book installation sites
for (Iterator it = installers.keySet().iterator(); it.hasNext(); )
--- 118,121 ----
***************
*** 130,133 ****
--- 127,133 ----
tabMain.add(name, site);
}
+
+ // Add the panel for the locally installed books
+ tabMain.add(Msg.LOCAL_BOOKS.toString(), new SitePane());
}
From jswordcvs at crosswire.org Fri Oct 15 16:28:10 2004
From: jswordcvs at crosswire.org (jswordcvs@crosswire.org)
Date: Sat Oct 16 01:00:56 2004
Subject: [jsword-svn]
jsword/java/jsword/org/crosswire/jsword/book/install/sword s
Message-ID: <200410152328.i9FNSAS5030345@www.crosswire.org>
Update of /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/install/sword
In directory www.crosswire.org:/tmp/cvs-serv30320/java/jsword/org/crosswire/jsword/book/install/sword
Modified Files:
HttpSwordInstaller.java FtpSwordInstaller.java
Added Files:
AbstractSwordInstaller.java
Log Message:
progress on downloading index
--- NEW FILE: AbstractSwordInstaller.java ---
package org.crosswire.jsword.book.install.sword;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.zip.GZIPInputStream;
import org.crosswire.common.progress.Job;
import org.crosswire.common.progress.JobManager;
import org.crosswire.common.util.IOUtil;
import org.crosswire.common.util.Logger;
import org.crosswire.common.util.NetUtil;
import org.crosswire.common.util.Reporter;
import org.crosswire.jsword.book.BookMetaData;
import org.crosswire.jsword.book.Books;
import org.crosswire.jsword.book.basic.AbstractBookList;
import org.crosswire.jsword.book.install.InstallException;
import org.crosswire.jsword.book.install.Installer;
import org.crosswire.jsword.book.sword.ModuleType;
import org.crosswire.jsword.book.sword.SwordBookDriver;
import org.crosswire.jsword.book.sword.SwordBookMetaData;
import org.crosswire.jsword.book.sword.SwordConstants;
import org.crosswire.jsword.util.Project;
import com.ice.tar.TarEntry;
import com.ice.tar.TarInputStream;
/**
* .
*
*
*
*
* Distribution Licence:
* JSword 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
* here , or by writing to:
* Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
* MA 02111-1307, USA
* The copyright to this program is held by it's authors.
*
* @see gnu.gpl.Licence
* @author Joe Walker [joe at eireneh dot com]
* @version $Id: AbstractSwordInstaller.java,v 1.1 2004/10/15 23:28:08 joe Exp $
*/
public abstract class AbstractSwordInstaller extends AbstractBookList implements Installer
{
/**
* Utility to download a file from a remote site
* @param job The way of noting progress
* @param dir The directory from which to download the file
* @param file The file to download
* @throws InstallException
*/
protected abstract void download(Job job, String dir, String file, URL dest) throws InstallException;
/* (non-Javadoc)
* @see org.crosswire.jsword.book.install.Installer#toLocalURL(org.crosswire.jsword.book.BookMetaData)
*/
public URL toLocalURL(BookMetaData bmd)
{
File fulldir = toLocalDirectory(bmd);
try
{
return new URL(NetUtil.PROTOCOL_FILE, null, fulldir.getAbsolutePath());
}
catch (MalformedURLException ex)
{
log.error("Failed to create URL for file: "+fulldir, ex); //$NON-NLS-1$
assert false;
return null;
}
}
/* (non-Javadoc)
* @see org.crosswire.jsword.book.install.Installer#isNewer(org.crosswire.jsword.book.BookMetaData)
*/
public boolean isNewer(BookMetaData bmd)
{
URL local = toLocalURL(bmd);
SwordBookMetaData sbmd = (SwordBookMetaData) bmd;
URL conf = NetUtil.lengthenURL(local, sbmd.getDiskName() + SwordConstants.EXTENSION_CONF);
URL remote = toRemoteURL(bmd);
return NetUtil.isNewer(remote, conf);
}
/* (non-Javadoc)
* @see org.crosswire.jsword.book.BookList#getBookMetaDatas()
*/
public List getBookMetaDatas()
{
try
{
if (!loaded)
{
loadCachedIndex();
}
List mutable = new ArrayList();
mutable.addAll(entries.values());
return Collections.unmodifiableList(mutable);
}
catch (InstallException ex)
{
log.error("Failed to reload cached index file", ex); //$NON-NLS-1$
return new ArrayList();
}
}
/* (non-Javadoc)
* @see org.crosswire.jsword.book.install.Installer#install(org.crosswire.jsword.book.BookMetaData)
*/
public void install(BookMetaData bmd)
{
if (!(bmd instanceof SwordBookMetaData))
{
assert false;
return;
}
// Is the book already installed? Then nothing to do.
if (Books.installed().getBookMetaData(bmd.getName()) != null)
{
return;
}
final SwordBookMetaData sbmd = (SwordBookMetaData) bmd;
// So now we know what we want to install - all we need to do
// is installer.install(name) however we are doing it in the
// background so we create a job for it.
final Thread worker = new Thread("DisplayPreLoader") //$NON-NLS-1$
{
public void run()
{
URL predicturl = Project.instance().getWritablePropertiesURL("sword-install"); //$NON-NLS-1$
Job job = JobManager.createJob(Msg.INSTALLING.toString(sbmd.getName()), predicturl, this, true);
yield();
try
{
job.setProgress(Msg.JOB_INIT.toString());
URL desturl = toLocalURL(sbmd);
NetUtil.makeDirectory(desturl);
URL temp = NetUtil.getTemporaryURL("swd", "zip"); //$NON-NLS-1$ //$NON-NLS-2$
download(job, directory + '/' + PACKAGE_DIR, sbmd.getInitials() + ZIP_SUFFIX, temp);
IOUtil.unpackZip(NetUtil.getAsFile(temp), desturl);
File dldir = SwordBookDriver.getDownloadDir();
job.setProgress(Msg.JOB_CONFIG.toString());
File confdir = new File(dldir, SwordConstants.DIR_CONF);
confdir.mkdirs();
File conf = new File(confdir, sbmd.getDiskName() + SwordConstants.EXTENSION_CONF);
URL configurl = new URL(NetUtil.PROTOCOL_FILE, null, conf.getAbsolutePath());
sbmd.save(configurl);
SwordBookDriver.registerNewBook(sbmd, dldir);
}
catch (Exception ex)
{
Reporter.informUser(this, ex);
job.ignoreTimings();
}
finally
{
job.done();
}
}
};
// this actually starts the thread off
worker.setPriority(Thread.MIN_PRIORITY);
worker.start();
}
/* (non-Javadoc)
* @see org.crosswire.jsword.book.install.Installer#reloadIndex()
*/
public void reloadBookList() throws InstallException
{
Job job = JobManager.createJob(Msg.JOB_DOWNLOADING.toString(), Thread.currentThread(), false);
try
{
URL scratchfile = getCachedIndexFile();
download(job, LIST_DIR + '/' + directory, FILE_LIST_GZ, scratchfile);
loaded = false;
}
catch (InstallException ex)
{
job.ignoreTimings();
throw ex;
}
finally
{
job.done();
}
}
/* (non-Javadoc)
* @see org.crosswire.jsword.book.install.Installer#downloadSearchIndex(org.crosswire.jsword.book.BookMetaData, java.net.URL)
*/
public void downloadSearchIndex(BookMetaData bmd, URL localDest) throws InstallException
{
Job job = JobManager.createJob(Msg.JOB_DOWNLOADING.toString(), Thread.currentThread(), false);
try
{
download(job, directory + '/' + SEARCH_DIR, bmd.getInitials() + ZIP_SUFFIX, localDest);
}
catch (Exception ex)
{
job.ignoreTimings();
throw new InstallException(Msg.UNKNOWN_ERROR, ex);
}
finally
{
job.done();
}
}
/**
* Load the cached index file into memory
*/
private void loadCachedIndex() throws InstallException
{
entries.clear();
URL cache = getCachedIndexFile();
if (!NetUtil.isFile(cache))
{
reloadBookList();
}
try
{
InputStream in = cache.openStream();
GZIPInputStream gin = new GZIPInputStream(in);
TarInputStream tin = new TarInputStream(gin);
while (true)
{
TarEntry entry = tin.getNextEntry();
if (entry == null)
{
break;
}
String internal = entry.getName();
if (!entry.isDirectory())
{
try
{
int size = (int) entry.getSize();
byte[] buffer = new byte[size];
tin.read(buffer);
if (internal.endsWith(SwordConstants.EXTENSION_CONF))
{
internal = internal.substring(0, internal.length() - 5);
}
if (internal.startsWith(SwordConstants.DIR_CONF + '/'))
{
internal = internal.substring(7);
}
Reader rin = new InputStreamReader(new ByteArrayInputStream(buffer));
SwordBookMetaData sbmd = new SwordBookMetaData(rin, internal);
if (sbmd.isSupported())
{
entries.put(sbmd.getName(), sbmd);
}
}
catch (Exception ex)
{
log.warn("Failed to load config for entry: " + internal, ex); //$NON-NLS-1$
}
}
}
IOUtil.close(tin);
IOUtil.close(gin);
IOUtil.close(in);
loaded = true;
}
catch (IOException ex)
{
throw new InstallException(Msg.CACHE_ERROR, ex);
}
}
/**
* @return Returns the directory.
*/
public String getDirectory()
{
return directory;
}
/**
* @param directory The directory to set.
*/
public void setDirectory(String directory)
{
this.directory = directory;
loaded = false;
}
/**
* @return Returns the host.
*/
public String getHost()
{
return host;
}
/**
* @param host The host to set.
*/
public void setHost(String host)
{
this.host = host;
loaded = false;
}
/**
* The URL for the cached index file for this installer
*/
protected URL getCachedIndexFile() throws InstallException
{
try
{
URL scratchdir = Project.instance().getTempScratchSpace(getTempFileExtension(host, directory), false);
return NetUtil.lengthenURL(scratchdir, FILE_LIST_GZ);
}
catch (IOException ex)
{
throw new InstallException(Msg.URL_FAILED, ex);
}
}
/**
* What are we using as a temp filename?
*/
private static String getTempFileExtension(String host, String directory)
{
return DOWNLOAD_PREFIX + host + directory.replace('/', '_'); //$NON-NLS-1$
}
/**
* Get a local directory to which a book is installed
*/
protected File toLocalDirectory(BookMetaData bmd)
{
if (!(bmd instanceof SwordBookMetaData))
{
assert false;
return null;
}
SwordBookMetaData sbmd = (SwordBookMetaData) bmd;
ModuleType type = sbmd.getModuleType();
String modpath = type.getInstallDirectory();
String destname = modpath + '/' + sbmd.getDiskName();
File dldir = SwordBookDriver.getDownloadDir();
File moddir = new File(dldir, SwordConstants.DIR_DATA);
return new File(moddir, destname);
}
/* (non-Javadoc)
* @see java.lang.Object#equals(java.lang.Object)
*/
public boolean equals(Object object)
{
if (!(object instanceof AbstractSwordInstaller))
{
return false;
}
AbstractSwordInstaller that = (AbstractSwordInstaller) object;
if (!equals(this.host, that.host))
{
return false;
}
if (!equals(this.directory, that.directory))
{
return false;
}
return true;
}
/* (non-Javadoc)
* @see java.lang.Comparable#compareTo(java.lang.Object)
*/
public int compareTo(Object arg0)
{
HttpSwordInstaller myClass = (HttpSwordInstaller) arg0;
int ret = host.compareTo(myClass.host);
if (ret != 0)
{
ret = directory.compareTo(myClass.directory);
}
return ret;
}
/* (non-Javadoc)
* @see java.lang.Object#hashCode()
*/
public int hashCode()
{
return host.hashCode() + directory.hashCode();
}
/**
* Quick utility to check to see if 2 (potentially null) strings are equal
*/
protected boolean equals(String string1, String string2)
{
if (string1 == null)
{
return string2 == null;
}
return string1.equals(string2);
}
/**
* The relative path of the dir holding the zip files
*/
protected static final String PACKAGE_DIR = "packages/rawzip"; //$NON-NLS-1$
/**
* The relative path of the dir holding the index file
*/
private static final String LIST_DIR = "raw"; //$NON-NLS-1$
/**
* A map of the entries in this download area
*/
protected Map entries = new HashMap();
/**
* The remote hostname.
*/
protected String host;
/**
* The directory containing modules on the host
.
*/
protected String directory = "/"; //$NON-NLS-1$
/**
* Do we need to reload the index file
*/
protected boolean loaded;
/**
* The sword index file
*/
protected static final String FILE_LIST_GZ = "mods.d.tar.gz"; //$NON-NLS-1$
/**
* The suffix of zip modules on this server
*/
protected static final String ZIP_SUFFIX = ".zip"; //$NON-NLS-1$
/**
* The log stream
*/
private static final Logger log = Logger.getLogger(AbstractSwordInstaller.class);
/**
* The relative path of the dir holding the search index files
*/
protected static final String SEARCH_DIR = "seach/jsword/L1"; //$NON-NLS-1$
/**
* When we cache a download index
*/
protected static final String DOWNLOAD_PREFIX = "download-"; //$NON-NLS-1$
}
Index: HttpSwordInstaller.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/install/sword/HttpSwordInstaller.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -d -r1.11 -r1.12
*** HttpSwordInstaller.java 10 Oct 2004 22:12:02 -0000 1.11
--- HttpSwordInstaller.java 15 Oct 2004 23:28:08 -0000 1.12
***************
*** 1,42 ****
package org.crosswire.jsword.book.install.sword;
- import java.io.ByteArrayInputStream;
- import java.io.File;
- import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
- import java.io.InputStreamReader;
import java.io.OutputStream;
- import java.io.Reader;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
- import java.util.ArrayList;
- import java.util.Collections;
- import java.util.HashMap;
- import java.util.List;
- import java.util.Map;
- import java.util.zip.GZIPInputStream;
import org.crosswire.common.progress.Job;
- import org.crosswire.common.progress.JobManager;
import org.crosswire.common.util.IOUtil;
- import org.crosswire.common.util.Logger;
import org.crosswire.common.util.NetUtil;
- import org.crosswire.common.util.Reporter;
import org.crosswire.jsword.book.BookMetaData;
- import org.crosswire.jsword.book.Books;
- import org.crosswire.jsword.book.BooksListener;
- import org.crosswire.jsword.book.basic.AbstractBookList;
import org.crosswire.jsword.book.install.InstallException;
- import org.crosswire.jsword.book.install.Installer;
- import org.crosswire.jsword.book.sword.ModuleType;
- import org.crosswire.jsword.book.sword.SwordBookDriver;
import org.crosswire.jsword.book.sword.SwordBookMetaData;
- import org.crosswire.jsword.book.sword.SwordConstants;
- import org.crosswire.jsword.util.Project;
-
- import com.ice.tar.TarEntry;
- import com.ice.tar.TarInputStream;
/**
--- 1,17 ----
***************
*** 65,69 ****
* @version $Id$
*/
! public class HttpSwordInstaller extends AbstractBookList implements Installer, Comparable
{
/* (non-Javadoc)
--- 40,44 ----
* @version $Id$
*/
! public class HttpSwordInstaller extends AbstractSwordInstaller implements Comparable
{
/* (non-Javadoc)
***************
*** 72,182 ****
public String getURL()
{
! return PROTOCOL_WEB + ":" + host + directory; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
/* (non-Javadoc)
! * @see org.crosswire.jsword.book.BookList#getBookMetaDatas()
*/
! public List getBookMetaDatas()
{
! try
! {
! if (!loaded)
! {
! loadCachedIndex();
! }
!
! List mutable = new ArrayList();
! mutable.addAll(entries.values());
! return Collections.unmodifiableList(mutable);
! }
! catch (InstallException ex)
{
! log.error("Failed to reload cached index file", ex); //$NON-NLS-1$
! return new ArrayList();
}
- }
! /* (non-Javadoc)
! * @see org.crosswire.jsword.book.install.Installer#reloadIndex()
! */
! public void reloadBookList() throws InstallException
! {
! URL scratchfile = getCachedIndexFile();
! download(host, directory, FILE_LIST_GZ, scratchfile);
! loaded = false;
! }
- /**
- * Utility to download a file by HTTP from a remote site
- * @param site The place to download from
- * @param dir The directory from which to download the file
- * @param file The file to download
- * @throws InstallException
- */
- private static void download(String site, String dir, String file, URL dest) throws InstallException
- {
- InputStream in = null;
- OutputStream out = null;
try
{
! URL url = new URL("http://" + site + dir + '/' + LIST_DIR + '/' + file); //$NON-NLS-1$
! byte[] buf = new byte[4096];
!
! // Check the download directory exists
! URL parent = NetUtil.shortenURL(dest, FILE_LIST_GZ);
! NetUtil.makeDirectory(parent);
!
! // Download the index file
! out = NetUtil.getOutputStream(dest);
! in = url.openStream();
! for (int read = 0; -1 != (read = in.read(buf)); )
! {
! out.write(buf, 0, read);
! }
! }
! catch (IOException ex)
! {
! throw new InstallException(Msg.UNKNOWN_ERROR, ex);
}
! finally
{
! IOUtil.close(in);
! IOUtil.close(out);
}
}
/* (non-Javadoc)
! * @see org.crosswire.jsword.book.install.Installer#downloadSearchIndex(org.crosswire.jsword.book.BookMetaData, java.net.URL)
*/
! public void downloadSearchIndex(BookMetaData bmd, URL localDest) throws InstallException
{
- Job job = JobManager.createJob(Msg.JOB_DOWNLOADING.toString(), Thread.currentThread(), false);
-
try
{
! String dir = directory + '/' + SEARCH_DIR + '/' + bmd.getInitials() + ZIP_SUFFIX;
! downloadZip(job, host, dir, localDest);
}
! catch (Exception ex)
{
- job.ignoreTimings();
throw new InstallException(Msg.UNKNOWN_ERROR, ex);
}
- finally
- {
- job.done();
- }
}
/**
- * Utility to download a file by HTTP from a remote site
* @param job
! * @param site
! * @param dir
! * @param destdir
! * @throws InstallException
*/
! protected static void downloadZip(Job job, String site, String dir, URL destdir) throws InstallException
{
InputStream in = null;
--- 47,99 ----
public String getURL()
{
! return PROTOCOL_WEB + ":" + host + directory; //$NON-NLS-1$
}
/* (non-Javadoc)
! * @see org.crosswire.jsword.book.install.Installer#toURL(org.crosswire.jsword.book.BookMetaData)
*/
! public URL toRemoteURL(BookMetaData bmd)
{
! if (!(bmd instanceof SwordBookMetaData))
{
! assert false;
! return null;
}
! SwordBookMetaData sbmd = (SwordBookMetaData) bmd;
try
{
! return new URL(NetUtil.PROTOCOL_HTTP, host, directory + '/' + PACKAGE_DIR + '/' + sbmd.getInitials() + ZIP_SUFFIX); //$NON-NLS-1$
}
! catch (MalformedURLException ex)
{
! return null;
}
}
/* (non-Javadoc)
! * @see org.crosswire.jsword.book.install.sword.AbstractSwordInstaller#download(java.lang.String, java.lang.String, java.net.URL)
*/
! protected void download(Job job, String dir, String file, URL dest) throws InstallException
{
try
{
! URL url = new URL("http://" + host + dir + '/' + file); //$NON-NLS-1$
! copy(job, dest, url);
}
! catch (IOException ex)
{
throw new InstallException(Msg.UNKNOWN_ERROR, ex);
}
}
/**
* @param job
! * @param url
! * @param dest
! * @throws IOException
*/
! private void copy(Job job, URL url, URL dest) throws IOException
{
InputStream in = null;
***************
*** 185,195 ****
try
{
! job.setProgress(Msg.JOB_DOWNLOADING.toString());
! URL zipurl = new URL("http://" + site + dir); //$NON-NLS-1$
! File f = File.createTempFile("swd", "zip"); //$NON-NLS-1$ //$NON-NLS-2$
! out = new FileOutputStream(f);
! URLConnection urlConnection = zipurl.openConnection();
in = urlConnection.getInputStream();
--- 102,114 ----
try
{
! if (job != null)
! {
! job.setProgress(Msg.JOB_DOWNLOADING.toString());
! }
! // Download the index file
! out = NetUtil.getOutputStream(dest);
! URLConnection urlConnection = url.openConnection();
in = urlConnection.getInputStream();
***************
*** 199,208 ****
out.write(buf, 0, count);
}
-
- IOUtil.unpackZip(f, destdir);
- }
- catch (IOException ex)
- {
- throw new InstallException(Msg.UNKNOWN_ERROR, ex);
}
finally
--- 118,121 ----
***************
*** 214,418 ****
/* (non-Javadoc)
- * @see org.crosswire.jsword.book.install.Installer#install(org.crosswire.jsword.book.BookMetaData)
- */
- public void install(BookMetaData bmd) throws InstallException
- {
- if (!(bmd instanceof SwordBookMetaData))
- {
- assert false;
- return;
- }
-
- // Is the book already installed? Then nothing to do.
- if (Books.installed().getBookMetaData(bmd.getName()) != null)
- {
- return;
- }
-
- final SwordBookMetaData sbmd = (SwordBookMetaData) bmd;
-
- // So now we know what we want to install - all we need to do
- // is installer.install(name) however we are doing it in the
- // background so we create a job for it.
- final Thread worker = new Thread("DisplayPreLoader") //$NON-NLS-1$
- {
- public void run()
- {
- URL predicturl = Project.instance().getWritablePropertiesURL("sword-install"); //$NON-NLS-1$
- Job job = JobManager.createJob(Msg.INSTALLING.toString(sbmd.getName()), predicturl, this, true);
-
- try
- {
- job.setProgress(Msg.JOB_INIT.toString());
-
- URL desturl = toLocalURL(sbmd);
- NetUtil.makeDirectory(desturl);
- downloadZip(job, host, directory + '/' + PACKAGE_DIR + '/' + sbmd.getInitials() + ZIP_SUFFIX, desturl);
-
- File dldir = SwordBookDriver.getDownloadDir();
- job.setProgress(Msg.JOB_CONFIG.toString());
- File confdir = new File(dldir, SwordConstants.DIR_CONF);
- confdir.mkdirs();
- File conf = new File(confdir, sbmd.getDiskName() + SwordConstants.EXTENSION_CONF);
- URL configurl = new URL(NetUtil.PROTOCOL_FILE, null, conf.getAbsolutePath());
- sbmd.save(configurl);
-
- SwordBookDriver.registerNewBook(sbmd, dldir);
- }
- catch (Exception ex)
- {
- Reporter.informUser(this, ex);
- job.ignoreTimings();
- }
- finally
- {
- job.done();
- }
- }
- };
-
- // this actually starts the thread off
- worker.setPriority(Thread.MIN_PRIORITY);
- worker.start();
- }
-
- /* (non-Javadoc)
- * @see org.crosswire.jsword.book.install.Installer#toURL(org.crosswire.jsword.book.BookMetaData)
- */
- public URL toRemoteURL(BookMetaData bmd)
- {
- if (!(bmd instanceof SwordBookMetaData))
- {
- assert false;
- return null;
- }
-
- SwordBookMetaData sbmd = (SwordBookMetaData) bmd;
-
- try
- {
- return new URL(NetUtil.PROTOCOL_HTTP, host, directory + '/' + PACKAGE_DIR + '/' + sbmd.getInitials() + ZIP_SUFFIX); //$NON-NLS-1$
- }
- catch (MalformedURLException ex)
- {
- return null;
- }
- }
-
- /* (non-Javadoc)
- * @see org.crosswire.jsword.book.install.Installer#toLocalURL(org.crosswire.jsword.book.BookMetaData)
- */
- public URL toLocalURL(BookMetaData bmd)
- {
- File fulldir = toLocalDirectory(bmd);
- try
- {
- return new URL(NetUtil.PROTOCOL_FILE, null, fulldir.getAbsolutePath());
- }
- catch (MalformedURLException ex)
- {
- assert false;
- return null;
- }
- }
-
- /* (non-Javadoc)
- * @see org.crosswire.jsword.book.install.Installer#isNewer(org.crosswire.jsword.book.BookMetaData)
- */
- public boolean isNewer(BookMetaData bmd)
- {
- URL local = toLocalURL(bmd);
- SwordBookMetaData sbmd = (SwordBookMetaData) bmd;
- local = NetUtil.lengthenURL(local, sbmd.getDiskName() + SwordConstants.EXTENSION_CONF);
- URL remote = toRemoteURL(bmd);
- return NetUtil.isNewer(remote, local);
- }
-
- /* (non-Javadoc)
- * @see org.crosswire.jsword.book.install.Installer#toLocalURL(org.crosswire.jsword.book.BookMetaData)
- */
- public File toLocalDirectory(BookMetaData bmd)
- {
- if (!(bmd instanceof SwordBookMetaData))
- {
- assert false;
- return null;
- }
-
- SwordBookMetaData sbmd = (SwordBookMetaData) bmd;
-
- ModuleType type = sbmd.getModuleType();
- String modpath = type.getInstallDirectory();
- String destname = modpath + '/' + sbmd.getDiskName();
-
- File dldir = SwordBookDriver.getDownloadDir();
- File moddir = new File(dldir, SwordConstants.DIR_DATA);
- return new File(moddir, destname);
- }
-
- /* (non-Javadoc)
- * @see java.lang.Comparable#compareTo(java.lang.Object)
- */
- public int compareTo(Object arg0)
- {
- HttpSwordInstaller myClass = (HttpSwordInstaller) arg0;
-
- int ret = host.compareTo(myClass.host);
- if (ret != 0)
- {
- ret = directory.compareTo(myClass.directory);
- }
- return ret;
- }
-
- /* (non-Javadoc)
- * @see org.crosswire.jsword.book.BookList#addBooksListener(org.crosswire.jsword.book.BooksListener)
- */
- public void addBooksListener(BooksListener li)
- {
- listeners.add(li);
- }
-
- /* (non-Javadoc)
- * @see org.crosswire.jsword.book.BookList#removeBooksListener(org.crosswire.jsword.book.BooksListener)
- */
- public void removeBooksListener(BooksListener li)
- {
- listeners.remove(li);
- }
-
- /**
- * @return Returns the directory.
- */
- public String getDirectory()
- {
- return directory;
- }
-
- /**
- * @param directory The directory to set.
- */
- public void setDirectory(String directory)
- {
- this.directory = directory;
- }
-
- /**
- * @return Returns the host.
- */
- public String getHost()
- {
- return host;
- }
-
- /**
- * @param host The host to set.
- */
- public void setHost(String host)
- {
- this.host = host;
- }
-
- /* (non-Javadoc)
* @see java.lang.Object#equals(java.lang.Object)
*/
--- 127,130 ----
***************
*** 425,434 ****
HttpSwordInstaller that = (HttpSwordInstaller) object;
! if (!equals(this.host, that.host))
! {
! return false;
! }
!
! if (!equals(this.directory, that.directory))
{
return false;
--- 137,141 ----
HttpSwordInstaller that = (HttpSwordInstaller) object;
! if (!super.equals(that))
{
return false;
***************
*** 439,599 ****
/**
! * Quick utility to check to see if 2 (potentially null) strings are equal
! */
! private boolean equals(String string1, String string2)
! {
! if (string1 == null)
! {
! return string2 == null;
! }
! return string1.equals(string2);
! }
!
! /**
! * Load the cached index file into memory
! */
! private void loadCachedIndex() throws InstallException
! {
! entries.clear();
!
! URL cache = getCachedIndexFile();
! if (!NetUtil.isFile(cache))
! {
! reloadBookList();
! }
!
! try
! {
! InputStream in = cache.openStream();
! GZIPInputStream gin = new GZIPInputStream(in);
! TarInputStream tin = new TarInputStream(gin);
!
! while (true)
! {
! TarEntry entry = tin.getNextEntry();
! if (entry == null)
! {
! break;
! }
!
! String internal = entry.getName();
! if (!entry.isDirectory())
! {
! try
! {
! int size = (int) entry.getSize();
! byte[] buffer = new byte[size];
! tin.read(buffer);
!
! if (internal.endsWith(SwordConstants.EXTENSION_CONF))
! {
! internal = internal.substring(0, internal.length() - 5);
! }
!
! if (internal.startsWith(SwordConstants.DIR_CONF + '/'))
! {
! internal = internal.substring(7);
! }
!
! Reader rin = new InputStreamReader(new ByteArrayInputStream(buffer));
! SwordBookMetaData sbmd = new SwordBookMetaData(rin, internal);
!
! if (sbmd.isSupported())
! {
! entries.put(sbmd.getName(), sbmd);
! }
! }
! catch (Exception ex)
! {
! log.warn("Failed to load config for entry: " + internal, ex); //$NON-NLS-1$
! }
! }
! }
!
! IOUtil.close(tin);
! IOUtil.close(gin);
! IOUtil.close(in);
!
! loaded = true;
! }
! catch (IOException ex)
! {
! throw new InstallException(Msg.CACHE_ERROR, ex);
! }
! }
!
! /**
! * The URL for the cached index file for this installer
! */
! private URL getCachedIndexFile() throws InstallException
! {
! try
! {
! URL scratchdir = Project.instance().getTempScratchSpace(getTempFileExtension(host, directory), false);
! return NetUtil.lengthenURL(scratchdir, FILE_LIST_GZ);
! }
! catch (IOException ex)
! {
! throw new InstallException(Msg.URL_FAILED, ex);
! }
! }
!
! /**
! * What are we using as a temp filename?
! */
! private static String getTempFileExtension(String host, String directory)
! {
! return DOWNLOAD_PREFIX + host + directory.replace('/', '_'); //$NON-NLS-1$
! }
!
! /**
! * Do we need to reload the index file
! */
! private boolean loaded;
!
! /**
! * A map of the entries in this download area
! */
! protected Map entries = new HashMap();
!
! /**
! * The sword index file
! */
! private static final String FILE_LIST_GZ = "mods.d.tar.gz"; //$NON-NLS-1$
!
! /**
! * The relative path of the dir holding the index file
! */
! private static final String LIST_DIR = "raw"; //$NON-NLS-1$
!
! /**
! * The relative path of the dir holding the zip files
! */
! private static final String PACKAGE_DIR = "packages/rawzip"; //$NON-NLS-1$
!
! /**
! * The relative path of the dir holding the search index files
! */
! private static final String SEARCH_DIR = "seach/jsword/L1"; //$NON-NLS-1$
!
! /**
! * The suffix of zip modules on this server
! */
! private static final String ZIP_SUFFIX = ".zip"; //$NON-NLS-1$
!
! /**
! * When we cache a download index
*/
- private static final String DOWNLOAD_PREFIX = "download-"; //$NON-NLS-1$
-
- private ArrayList listeners = new ArrayList();
- protected String host;
- protected String directory;
-
private static final String PROTOCOL_WEB = "web"; //$NON-NLS-1$
-
- /**
- * The log stream
- */
- private static final Logger log = Logger.getLogger(HttpSwordInstaller.class);
}
--- 146,151 ----
/**
! * We need to be ablee to provide a URL as part of the API
*/
private static final String PROTOCOL_WEB = "web"; //$NON-NLS-1$
}
Index: FtpSwordInstaller.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/install/sword/FtpSwordInstaller.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** FtpSwordInstaller.java 10 Oct 2004 22:12:02 -0000 1.8
--- FtpSwordInstaller.java 15 Oct 2004 23:28:08 -0000 1.9
***************
*** 1,42 ****
package org.crosswire.jsword.book.install.sword;
- import java.io.ByteArrayInputStream;
- import java.io.File;
import java.io.IOException;
- import java.io.InputStream;
- import java.io.InputStreamReader;
import java.io.OutputStream;
- import java.io.Reader;
import java.net.MalformedURLException;
import java.net.URL;
- import java.util.ArrayList;
- import java.util.Collections;
- import java.util.HashMap;
- import java.util.List;
- import java.util.Map;
- import java.util.zip.GZIPInputStream;
import org.apache.commons.net.ftp.FTP;
import org.apache.commons.net.ftp.FTPClient;
- import org.apache.commons.net.ftp.FTPFile;
import org.apache.commons.net.ftp.FTPReply;
import org.crosswire.common.progress.Job;
- import org.crosswire.common.progress.JobManager;
import org.crosswire.common.util.Logger;
import org.crosswire.common.util.NetUtil;
- import org.crosswire.common.util.Reporter;
import org.crosswire.jsword.book.BookMetaData;
- import org.crosswire.jsword.book.Books;
- import org.crosswire.jsword.book.basic.AbstractBookList;
import org.crosswire.jsword.book.install.InstallException;
- import org.crosswire.jsword.book.install.Installer;
- import org.crosswire.jsword.book.sword.ModuleType;
- import org.crosswire.jsword.book.sword.SwordBookDriver;
import org.crosswire.jsword.book.sword.SwordBookMetaData;
- import org.crosswire.jsword.book.sword.SwordConstants;
- import org.crosswire.jsword.util.Project;
-
- import com.ice.tar.TarEntry;
- import com.ice.tar.TarInputStream;
/**
--- 1,18 ----
***************
*** 64,90 ****
* @version $Id$
*/
! public class FtpSwordInstaller extends AbstractBookList implements Installer, Comparable
{
/* (non-Javadoc)
! * @see org.crosswire.jsword.book.install.Installer#getIndex()
*/
! public List getBookMetaDatas()
{
! try
! {
! if (!loaded)
! {
! loadCachedIndex();
! }
!
! List mutable = new ArrayList();
! mutable.addAll(entries.values());
! return Collections.unmodifiableList(mutable);
! }
! catch (InstallException ex)
! {
! log.error("Failed to reload cached index file", ex); //$NON-NLS-1$
! return new ArrayList();
! }
}
--- 40,51 ----
* @version $Id$
*/
! public class FtpSwordInstaller extends AbstractSwordInstaller implements Comparable
{
/* (non-Javadoc)
! * @see org.crosswire.jsword.book.install.Installer#getURL()
*/
! public String getURL()
{
! return PROTOCOL_SWORD + ":" + username + ":" + password + "@" + host + directory; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
***************
*** 102,106 ****
SwordBookMetaData sbmd = (SwordBookMetaData) bmd;
! try
{
return new URL(NetUtil.PROTOCOL_FTP, host, directory + "/" + sbmd.getInitials() + ZIP_SUFFIX); //$NON-NLS-1$ //$NON-NLS-2$
--- 63,67 ----
SwordBookMetaData sbmd = (SwordBookMetaData) bmd;
! try
{
return new URL(NetUtil.PROTOCOL_FTP, host, directory + "/" + sbmd.getInitials() + ZIP_SUFFIX); //$NON-NLS-1$ //$NON-NLS-2$
***************
*** 110,369 ****
return null;
}
- }
-
- /* (non-Javadoc)
- * @see org.crosswire.jsword.book.install.Installer#toLocalURL(org.crosswire.jsword.book.BookMetaData)
- */
- public URL toLocalURL(BookMetaData bmd)
- {
- if (!(bmd instanceof SwordBookMetaData))
- {
- assert false;
- return null;
- }
-
- SwordBookMetaData sbmd = (SwordBookMetaData) bmd;
-
- ModuleType type = sbmd.getModuleType();
- String modpath = type.getInstallDirectory();
- String destname = modpath + '/' + sbmd.getDiskName();
-
- File dldir = SwordBookDriver.getDownloadDir();
- File moddir = new File(dldir, SwordConstants.DIR_DATA);
- File fulldir = new File(moddir, destname);
- try
- {
- return new URL(NetUtil.PROTOCOL_FILE, null, fulldir.getAbsolutePath());
- }
- catch (MalformedURLException e)
- {
- assert false;
- return null;
- }
- }
-
- /* (non-Javadoc)
- * @see org.crosswire.jsword.book.install.Installer#isNewer(org.crosswire.jsword.book.BookMetaData)
- */
- public boolean isNewer(BookMetaData bmd)
- {
- URL local = toLocalURL(bmd);
- URL remote = toRemoteURL(bmd);
- return NetUtil.isNewer(remote, local);
}
/* (non-Javadoc)
! * @see org.crosswire.jsword.book.install.Installer#install(java.lang.String)
*/
! public void install(BookMetaData bmd)
{
! if (!(bmd instanceof SwordBookMetaData))
! {
! assert false;
! return;
! }
!
! // Is the book already installed? Then nothing to do.
! if (Books.installed().getBookMetaData(bmd.getName()) != null)
! {
! return;
! }
!
! final SwordBookMetaData sbmd = (SwordBookMetaData) bmd;
! // So now we know what we want to install - all we need to do
! // is installer.install(name) however we are doing it in the
! // background so we create a job for it.
! final Thread worker = new Thread("DisplayPreLoader") //$NON-NLS-1$
{
! public void run()
{
! URL predicturl = Project.instance().getWritablePropertiesURL("sword-install"); //$NON-NLS-1$
! Job job = JobManager.createJob(Msg.INSTALLING.toString(sbmd.getName()), predicturl, this, true);
!
! yield();
!
! try
! {
! job.setProgress(Msg.JOB_INIT.toString());
!
! URL desturl = toLocalURL(sbmd);
! NetUtil.makeDirectory(desturl);
!
! ModuleType type = sbmd.getModuleType();
! String modpath = type.getInstallDirectory();
! String destname = modpath + '/' + sbmd.getDiskName();
! downloadAll(job, host, USERNAME, PASSWORD, directory + '/' + SwordConstants.DIR_DATA + '/' + destname, desturl);
!
! File dldir = SwordBookDriver.getDownloadDir();
! job.setProgress(Msg.JOB_CONFIG.toString());
! File confdir = new File(dldir, SwordConstants.DIR_CONF);
! confdir.mkdirs();
! File conf = new File(confdir, sbmd.getDiskName() + SwordConstants.EXTENSION_CONF);
! URL configurl = new URL(NetUtil.PROTOCOL_FILE, null, conf.getAbsolutePath());
! sbmd.save(configurl);
!
! SwordBookDriver.registerNewBook(sbmd, dldir);
! }
! catch (Exception ex)
! {
! Reporter.informUser(this, ex);
! job.ignoreTimings();
! }
! finally
! {
! job.done();
! }
}
! };
!
! // this actually starts the thread off
! worker.setPriority(Thread.MIN_PRIORITY);
! worker.start();
! }
!
! /* (non-Javadoc)
! * @see org.crosswire.jsword.book.install.Installer#downloadSearchIndex(org.crosswire.jsword.book.BookMetaData, java.net.URL)
! */
! public void downloadSearchIndex(BookMetaData bmd, URL localDest) throws InstallException
! {
! Job job = JobManager.createJob(Msg.JOB_DOWNLOADING.toString(), Thread.currentThread(), false);
!
! try
! {
! String dir = directory + '/' + SEARCH_DIR;
! download(host, USERNAME, PASSWORD, dir, bmd.getInitials() + ZIP_SUFFIX, localDest);
! }
! catch (Exception ex)
! {
! job.ignoreTimings();
! throw new InstallException(Msg.UNKNOWN_ERROR, ex);
! }
! finally
! {
! job.done();
! }
! }
!
! /* (non-Javadoc)
! * @see org.crosswire.jsword.book.install.Installer#reloadIndex()
! */
! public void reloadBookList() throws InstallException
! {
! URL scratchfile = getCachedIndexFile();
! download(host, USERNAME, PASSWORD, directory, FILE_LIST_GZ, scratchfile);
! loaded = false;
! }
!
! /**
! * Load the cached index file into memory
! */
! private void loadCachedIndex() throws InstallException
! {
! entries.clear();
!
! URL cache = getCachedIndexFile();
! if (!NetUtil.isFile(cache))
! {
! reloadBookList();
! }
! try
! {
! InputStream in = cache.openStream();
! GZIPInputStream gin = new GZIPInputStream(in);
! TarInputStream tin = new TarInputStream(gin);
!
! while (true)
{
! TarEntry entry = tin.getNextEntry();
! if (entry == null)
! {
! break;
! }
!
! String internal = entry.getName();
! if (!entry.isDirectory())
! {
! try
! {
! int size = (int) entry.getSize();
! byte[] buffer = new byte[size];
! tin.read(buffer);
!
! if (internal.endsWith(SwordConstants.EXTENSION_CONF))
! {
! internal = internal.substring(0, internal.length() - 5);
! }
! if (internal.startsWith(SwordConstants.DIR_CONF + '/'))
! {
! internal = internal.substring(7);
! }
!
! Reader rin = new InputStreamReader(new ByteArrayInputStream(buffer));
! SwordBookMetaData sbmd = new SwordBookMetaData(rin, internal);
!
! if (sbmd.isSupported())
! {
! entries.put(sbmd.getName(), sbmd);
! }
! }
! catch (Exception ex)
! {
! log.warn("Failed to load config for entry: " + internal, ex); //$NON-NLS-1$
! }
! }
}
!
! tin.close();
! gin.close();
! in.close();
! loaded = true;
! }
! catch (IOException ex)
! {
! throw new InstallException(Msg.CACHE_ERROR, ex);
! }
! }
!
! /**
! * The URL for the cached index file for this installer
! */
! private URL getCachedIndexFile() throws InstallException
! {
! try
! {
! URL scratchdir = Project.instance().getTempScratchSpace(getTempFileExtension(host, directory), false);
! return NetUtil.lengthenURL(scratchdir, FILE_LIST_GZ);
! }
! catch (IOException ex)
! {
! throw new InstallException(Msg.URL_FAILED, ex);
! }
! }
!
! /**
! * What are we using as a temp filename?
! */
! private static String getTempFileExtension(String host, String directory)
! {
! return DOWNLOAD_PREFIX + host + directory.replace('/', '_'); //$NON-NLS-1$
! }
!
! /**
! * Utility to download a file by FTP from a remote site
! * @param site The place to download from
! * @param user The user that does the downloading
! * @param password The password of the above user
! * @param dir The directory from which to download the file
! * @param file The file to download
! * @throws InstallException
! */
! private static void download(String site, String user, String password, String dir, String file, URL dest) throws InstallException
! {
! FTPClient ftp = new FTPClient();
!
! try
! {
! ftpInit(ftp, site, user, password, dir);
// Check the download directory exists
--- 71,125 ----
return null;
}
}
/* (non-Javadoc)
! * @see org.crosswire.jsword.book.install.sword.AbstractSwordInstaller#download(java.lang.String, java.lang.String, java.net.URL)
*/
! protected void download(Job job, String dir, String file, URL dest) throws InstallException
{
! FTPClient ftp = new FTPClient();
! try
{
! log.info("Connecting to site=" + host + " dir=" + dir); //$NON-NLS-1$ //$NON-NLS-2$
!
! // First connect
! ftp.connect(host);
! Thread.yield();
!
! log.info(ftp.getReplyString());
! int reply1 = ftp.getReplyCode();
! if (!FTPReply.isPositiveCompletion(reply1))
{
! String text1 = ftp.getReplyString();
! throw new InstallException(Msg.CONNECT_REFUSED, new Object[] { host, new Integer(reply1), text1 });
}
!
! // Authenticate
! ftp.login(username, password);
! Thread.yield();
!
! log.info(ftp.getReplyString());
! reply1 = ftp.getReplyCode();
! if (!FTPReply.isPositiveCompletion(reply1))
{
! String text2 = ftp.getReplyString();
! throw new InstallException(Msg.AUTH_REFUSED, new Object[] { username, new Integer(reply1), text2 });
}
!
! // Change directory
! ftp.changeWorkingDirectory(dir);
! Thread.yield();
!
! log.info(ftp.getReplyString());
! reply1 = ftp.getReplyCode();
! if (!FTPReply.isPositiveCompletion(reply1))
! {
! String text3 = ftp.getReplyString();
! throw new InstallException(Msg.CWD_REFUSED, new Object[] { dir, new Integer(reply1), text3 });
! }
!
! ftp.setFileType(FTP.BINARY_FILE_TYPE);
! Thread.yield();
// Check the download directory exists
***************
*** 389,526 ****
finally
{
! disconnect(ftp);
! }
! }
!
! /**
! * Utility to download a file by FTP from a remote site
! * @param site The place to download from
! * @param user The user that does the downloading
! * @param password The password of the above user
! * @param dir The directory from which to download the file
! * @throws InstallException
! */
! protected static void downloadAll(Job job, String site, String user, String password, String dir, URL destdir) throws InstallException
! {
! FTPClient ftp = new FTPClient();
!
! try
! {
! job.setProgress(Msg.JOB_LOGIN.toString());
! ftpInit(ftp, site, user, password, dir);
!
! job.setProgress(Msg.JOB_DOWNLOADING.toString());
! downloadContents(destdir, ftp);
! }
! catch (InstallException ex)
! {
! throw ex;
! }
! catch (IOException ex)
! {
! throw new InstallException(Msg.UNKNOWN_ERROR, ex);
! }
! finally
! {
! disconnect(ftp);
! }
! }
!
! /**
! * Recursively download the contents of the current ftp directory
! * to the given url
! */
! private static void downloadContents(URL destdir, FTPClient ftp) throws IOException, InstallException
! {
! FTPFile[] files = ftp.listFiles();
! for (int i = 0; i < files.length; i++)
! {
! String name = files[i].getName();
! URL child = NetUtil.lengthenURL(destdir, name);
!
! if (files[i].isFile())
{
! OutputStream out = NetUtil.getOutputStream(child);
!
! ftp.retrieveFile(name, out);
! Thread.yield();
!
! int reply = ftp.getReplyCode();
! if (!FTPReply.isPositiveCompletion(reply))
{
! String text = ftp.getReplyString();
! throw new InstallException(Msg.DOWNLOAD_REFUSED, new Object[] { FILE_LIST_GZ, new Integer(reply), text });
}
- out.close();
- }
- else
- {
- downloadContents(child, ftp);
- }
- }
- }
-
- /**
- * Simple tway to connect to a remote site in preparation for a file listing
- * or a download.
- */
- private static void ftpInit(FTPClient ftp, String site, String user, String password, String dir) throws IOException, InstallException
- {
- log.info("Connecting to site=" + site + " dir=" + dir); //$NON-NLS-1$ //$NON-NLS-2$
-
- // First connect
- ftp.connect(site);
- Thread.yield();
-
- log.info(ftp.getReplyString());
- int reply = ftp.getReplyCode();
- if (!FTPReply.isPositiveCompletion(reply))
- {
- String text = ftp.getReplyString();
- throw new InstallException(Msg.CONNECT_REFUSED, new Object[] { site, new Integer(reply), text });
- }
-
- // Authenticate
- ftp.login(user, password);
- Thread.yield();
-
- log.info(ftp.getReplyString());
- reply = ftp.getReplyCode();
- if (!FTPReply.isPositiveCompletion(reply))
- {
- String text = ftp.getReplyString();
- throw new InstallException(Msg.AUTH_REFUSED, new Object[] { user, new Integer(reply), text });
- }
-
- // Change directory
- ftp.changeWorkingDirectory(dir);
- Thread.yield();
-
- log.info(ftp.getReplyString());
- reply = ftp.getReplyCode();
- if (!FTPReply.isPositiveCompletion(reply))
- {
- String text = ftp.getReplyString();
- throw new InstallException(Msg.CWD_REFUSED, new Object[] { dir, new Integer(reply), text });
- }
-
- ftp.setFileType(FTP.BINARY_FILE_TYPE);
- Thread.yield();
- }
-
- /**
- * Silently close an ftp connection, ignoring any exceptions
- */
- private static void disconnect(FTPClient ftp)
- {
- if (ftp.isConnected())
- {
- try
- {
- ftp.disconnect();
- }
- catch (IOException ex2)
- {
- log.error("disconnect error", ex2); //$NON-NLS-1$
}
}
--- 145,158 ----
finally
{
! if (ftp.isConnected())
{
! try
{
! ftp.disconnect();
! }
! catch (IOException ex2)
! {
! log.error("disconnect error", ex2); //$NON-NLS-1$
}
}
}
***************
*** 528,565 ****
/**
- * @return Returns the directory.
- */
- public String getDirectory()
- {
- return directory;
- }
-
- /**
- * @param directory The directory to set.
- */
- public void setDirectory(String directory)
- {
- this.directory = directory;
- loaded = false;
- }
-
- /**
- * @return Returns the host.
- */
- public String getHost()
- {
- return host;
- }
-
- /**
- * @param host The host to set.
- */
- public void setHost(String host)
- {
- this.host = host;
- loaded = false;
- }
-
- /**
* @return Returns the password.
*/
--- 160,163 ----
***************
*** 593,604 ****
}
- /* (non-Javadoc)
- * @see org.crosswire.jsword.book.install.Installer#getURL()
- */
- public String getURL()
- {
- return PROTOCOL_SWORD + ":" + username + ":" + password + "@" + host + directory; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
-
/**
* Like getURL() except that we skip the password for display purposes.
--- 191,194 ----
***************
*** 622,631 ****
FtpSwordInstaller that = (FtpSwordInstaller) object;
! if (!equals(this.host, that.host))
! {
! return false;
! }
!
! if (!equals(this.directory, that.directory))
{
return false;
--- 212,216 ----
FtpSwordInstaller that = (FtpSwordInstaller) object;
! if (!super.equals(that))
{
return false;
***************
*** 645,660 ****
}
- /**
- * Quick utility to check to see if 2 (potentially null) strings are equal
- */
- private boolean equals(String string1, String string2)
- {
- if (string1 == null)
- {
- return string2 == null;
- }
- return string1.equals(string2);
- }
-
/* (non-Javadoc)
* @see java.lang.Object#hashCode()
--- 230,233 ----
***************
*** 662,694 ****
public int hashCode()
{
! return host.hashCode() + directory.hashCode() + username.hashCode() + password.hashCode();
! }
!
! /* (non-Javadoc)
! * @see java.lang.Comparable#compareTo(java.lang.Object)
! */
! public int compareTo(Object object)
! {
! FtpSwordInstaller myClass = (FtpSwordInstaller) object;
!
! int ret = host.compareTo(myClass.host);
! if (ret != 0)
! {
! ret = directory.compareTo(myClass.directory);
! }
! return ret;
}
/**
- * Do we need to reload the index file
- */
- private boolean loaded;
-
- /**
- * The remote hostname.
- */
- protected String host;
-
- /**
* The remote username for a valid account on the host
.
*/
--- 235,242 ----
public int hashCode()
{
! return super.hashCode() + username.hashCode() + password.hashCode();
}
/**
* The remote username for a valid account on the host
.
*/
***************
*** 701,734 ****
/**
- * The directory containing modules on the host
.
- */
- protected String directory = "/"; //$NON-NLS-1$
-
- /**
- * A map of the entries in this download area
- */
- protected Map entries = new HashMap();
-
- /**
- * The default anon username
- */
- private static final String USERNAME = "anonymous"; //$NON-NLS-1$
-
- /**
- * The relative path of the dir holding the search index files
- */
- private static final String SEARCH_DIR = "seach/jsword/L1"; //$NON-NLS-1$
-
- /**
- * The default anon password
- */
- private static final String PASSWORD = "anon@anon.com"; //$NON-NLS-1$
-
- /**
- * The sword index file
- */
- private static final String FILE_LIST_GZ = "mods.d.tar.gz"; //$NON-NLS-1$
-
- /**
* We need to be ablee to provide a URL as part of the API
*/
--- 249,252 ----
***************
*** 736,751 ****
/**
- * When we cache a download index
- */
- private static final String DOWNLOAD_PREFIX = "download-"; //$NON-NLS-1$
-
- /**
* The log stream
*/
private static final Logger log = Logger.getLogger(FtpSwordInstaller.class);
-
- /**
- * The suffix of zip modules on this server
- */
- private static final String ZIP_SUFFIX = ".zip"; //$NON-NLS-1$
}
--- 254,259 ----
From jswordcvs at crosswire.org Sat Oct 16 02:07:45 2004
From: jswordcvs at crosswire.org (jswordcvs@crosswire.org)
Date: Sat Oct 16 02:07:46 2004
Subject: [jsword-svn] jsword/java/jsword/org/crosswire/jsword/book/sword s
Message-ID: <200410160907.i9G97jCB004971@www.crosswire.org>
Update of /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/sword
In directory www.crosswire.org:/tmp/cvs-serv4965/java/jsword/org/crosswire/jsword/book/sword
Modified Files:
SwordBookMetaData.java
Log Message:
install bug fixes
Index: SwordBookMetaData.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/sword/SwordBookMetaData.java,v
retrieving revision 1.33
retrieving revision 1.34
diff -C2 -d -r1.33 -r1.34
*** SwordBookMetaData.java 9 Oct 2004 21:45:05 -0000 1.33
--- SwordBookMetaData.java 16 Oct 2004 09:07:43 -0000 1.34
***************
*** 863,869 ****
/**
* @param driver The driver to set.
*/
! protected void setDriver(BookDriver driver)
{
this.driver = driver;
--- 863,871 ----
/**
+ * This setter is public because access is needed from *SwordInstallers as
+ * well as the normal sword drivers. Where is C++ friend when you need it!
* @param driver The driver to set.
*/
! public void setDriver(BookDriver driver)
{
this.driver = driver;
From jswordcvs at crosswire.org Sat Oct 16 02:07:46 2004
From: jswordcvs at crosswire.org (jswordcvs@crosswire.org)
Date: Sat Oct 16 02:07:47 2004
Subject: [jsword-svn]
jsword/java/jsword/org/crosswire/jsword/book/install/sword s
Message-ID: <200410160907.i9G97jJi004977@www.crosswire.org>
Update of /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/install/sword
In directory www.crosswire.org:/tmp/cvs-serv4965/java/jsword/org/crosswire/jsword/book/install/sword
Modified Files:
AbstractSwordInstaller.java
Log Message:
install bug fixes
Index: AbstractSwordInstaller.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/install/sword/AbstractSwordInstaller.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** AbstractSwordInstaller.java 15 Oct 2004 23:28:08 -0000 1.1
--- AbstractSwordInstaller.java 16 Oct 2004 09:07:43 -0000 1.2
***************
*** 22,25 ****
--- 22,26 ----
import org.crosswire.common.util.NetUtil;
import org.crosswire.common.util.Reporter;
+ import org.crosswire.jsword.book.BookDriver;
import org.crosswire.jsword.book.BookMetaData;
import org.crosswire.jsword.book.Books;
***************
*** 116,119 ****
--- 117,122 ----
}
+ // We need to create a List from the Set returned by
+ // entries.values() so we can create an unmodifiable list from it.
List mutable = new ArrayList();
mutable.addAll(entries.values());
***************
*** 249,252 ****
--- 252,259 ----
private void loadCachedIndex() throws InstallException
{
+ // We need a sword book driver so the installer can use the driver
+ // name to use in deciding where to put the index.
+ BookDriver fake = new SwordBookDriver();
+
entries.clear();
***************
*** 292,295 ****
--- 299,303 ----
Reader rin = new InputStreamReader(new ByteArrayInputStream(buffer));
SwordBookMetaData sbmd = new SwordBookMetaData(rin, internal);
+ sbmd.setDriver(fake);
if (sbmd.isSupported())
From jswordcvs at crosswire.org Sat Oct 16 02:07:49 2004
From: jswordcvs at crosswire.org (jswordcvs@crosswire.org)
Date: Sat Oct 16 02:07:50 2004
Subject: [jsword-svn]
bibledesktop/java/main/org/crosswire/bibledesktop/book s
Message-ID: <200410160907.i9G97nrt005007@www.crosswire.org>
Update of /cvs/jsword/bibledesktop/java/main/org/crosswire/bibledesktop/book
In directory www.crosswire.org:/tmp/cvs-serv4994/java/main/org/crosswire/bibledesktop/book
Modified Files:
IndexResolver.java
Log Message:
install bug fixes
Index: IndexResolver.java
===================================================================
RCS file: /cvs/jsword/bibledesktop/java/main/org/crosswire/bibledesktop/book/IndexResolver.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** IndexResolver.java 15 Oct 2004 23:28:22 -0000 1.2
--- IndexResolver.java 16 Oct 2004 09:07:47 -0000 1.3
***************
*** 122,126 ****
{
Iterator it = installers.values().iterator();
! assert it.hasNext();
installer = (Installer) it.next();
}
--- 122,127 ----
{
Iterator it = installers.values().iterator();
! boolean hasNext = it.hasNext();
! assert hasNext;
installer = (Installer) it.next();
}