Source code: com/eireneh/bible/book/swing/BiblesComboBoxModel.java
1
2 package com.eireneh.bible.book.swing;
3
4 import java.io.*;
5 import java.awt.*;
6 import javax.swing.*;
7 import javax.swing.event.*;
8 import javax.swing.border.*;
9
10 import com.eireneh.util.*;
11 import com.eireneh.bible.book.*;
12
13 /**
14 * The BibleModels class implements a number of swing DataModels
15 * and gives access to the list of current Bibles.
16 *
17 * <table border='1' cellPadding='3' cellSpacing='0' width="100%">
18 * <tr><td bgColor='white'class='TableRowColor'><font size='-7'>
19 * Distribution Licence:<br />
20 * Project B is free software; you can redistribute it
21 * and/or modify it under the terms of the GNU General Public License,
22 * version 2 as published by the Free Software Foundation.<br />
23 * This program is distributed in the hope that it will be useful,
24 * but WITHOUT ANY WARRANTY; without even the implied warranty of
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
26 * General Public License for more details.<br />
27 * The License is available on the internet
28 * <a href='http://www.gnu.org/copyleft/gpl.html'>here</a>, by writing to
29 * <i>Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
30 * MA 02111-1307, USA</i>, Or locally at the Licence link below.<br />
31 * The copyright to this program is held by it's authors.
32 * </font></td></tr></table>
33 * @see <a href='http://www.eireneh.com/servlets/Web'>Project B Home</a>
34 * @see docs.Licence
35 * @author Joe Walker
36 * @version D0.I0.T0
37 */
38 public class BiblesComboBoxModel extends BiblesListModel implements ComboBoxModel
39 {
40 /**
41 * Basic Constructor
42 */
43 public BiblesComboBoxModel()
44 {
45 if (bibles.length > 0)
46 current = bibles[0];
47 }
48
49 /**
50 * implements javax.swing.ComboBoxModel
51 */
52 public void setSelectedItem(Object current)
53 {
54 this.current = current;
55 fireContentsChanged(this, -1, -1);
56 }
57
58 /**
59 * implements javax.swing.ComboBoxModel
60 */
61 public Object getSelectedItem()
62 {
63 return current;
64 }
65
66 /**
67 * Get the selected Bible
68 * @return A Bible
69 */
70 public Bible getSelectedBible()
71 {
72 try
73 {
74 return Bibles.getBible(getBibleName(current));
75 }
76 catch (BookException ex)
77 {
78 log.warning("current="+current);
79 log.warning("bible="+getBibleName(current));
80
81 throw new LogicError(ex);
82 }
83 }
84
85 /** The currently selected version */
86 protected Object current;
87
88 /** The log stream */
89 protected static Logger log = Logger.getLogger("bible.book");
90 }