Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: com/eireneh/bible/view/swing/beans/Study.java


1   
2   package com.eireneh.bible.view.swing.beans;
3   
4   import java.net.*;
5   import java.awt.*;
6   import java.awt.event.*;
7   import javax.swing.*;
8   import javax.swing.event.*;
9   import javax.swing.tree.*;
10  
11  import com.eireneh.swing.*;
12  import com.eireneh.bible.passage.*;
13  import com.eireneh.bible.passage.swing.*;
14  import com.eireneh.bible.book.*;
15  import com.eireneh.bible.control.*;
16  
17  /**
18  * Displays the results of a search. 
19  * <p><b>ImageIcon</b>s: I've had a fight with Icons. Eventually I found
20  * that this syntax worked:<pre>
21  *  URL url = getClass().getResource("/com/eireneh/resources/list.gif");
22  *  Icon icon = new ImageIcon(url);
23  * </pre>
24  * Then I discovered that so did this one:<pre>
25  *  Icon icon = new ImageIcon("com/eireneh/resources/list.gif");
26  * </pre>
27  * But the second doesn't seem to make much sense to me from the docs. I
28  * am going to leave the second in place because it is much cleaner but
29  * if it ever breaks then maybe I should be doing the first.
30  * 
31  * <table border='1' cellPadding='3' cellSpacing='0' width="100%">
32  * <tr><td bgColor='white'class='TableRowColor'><font size='-7'>
33  * Distribution Licence:<br />
34  * Project B is free software; you can redistribute it
35  * and/or modify it under the terms of the GNU General Public License,
36  * version 2 as published by the Free Software Foundation.<br />
37  * This program is distributed in the hope that it will be useful,
38  * but WITHOUT ANY WARRANTY; without even the implied warranty of
39  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
40  * General Public License for more details.<br />
41  * The License is available on the internet
42  * <a href='http://www.gnu.org/copyleft/gpl.html'>here</a>, by writing to
43  * <i>Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
44  * MA 02111-1307, USA</i>, Or locally at the Licence link below.<br />
45  * The copyright to this program is held by it's authors.
46  * </font></td></tr></table>
47  * @see <a href='http://www.eireneh.com/servlets/Web'>Project B Home</a>
48  * @see docs.Licence
49  * @author Joe Walker
50  * @version D2.I0.T0
51  */
52  public class Study extends JPanel
53  {
54      /**
55      * Create a new Study
56      */
57      public Study()
58      {
59          JScrollPane list_scroll = new JScrollPane();
60          JScrollPane tree_scroll = new JScrollPane();
61          JScrollPane page_scroll = new JScrollPane();
62  
63          list.setModel(new PassageListModel(ref, PassageListModel.LIST_RANGES));
64          list.setCellRenderer(new PassageListCellRenderer());
65          list_scroll.getViewport().setView(list);
66          list_scroll.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
67          list_scroll.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
68  
69          BibleTreeNode root = new BibleTreeNode();
70          root.setPassage(ref, false);
71          tree.setModel(new DefaultTreeModel(root));
72          tree_scroll.getViewport().setView(tree);
73  
74          // page.setPassage(ref);
75          page_scroll.getViewport().setView(page);
76          page_scroll.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
77          page_scroll.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
78  
79          tab.addTab("List",
80                     new ImageIcon("com/eireneh/resources/list.gif"),
81                     list_scroll,
82                     "See the matches as a flat list");
83  
84          tab.addTab("Tree",
85                     new ImageIcon("com/eireneh/resources/tree.gif"),
86                     tree_scroll,
87                     "Display a tree containing the matching verses");
88  
89          tab.addTab("Page",
90                     new ImageIcon("com/eireneh/resources/page.gif"),
91                     page_scroll,
92                     "Show a page with the passages in full");
93  
94          tab.setTabPlacement(SwingConstants.BOTTOM);
95  
96          setLayout(new BorderLayout());
97          add("Center", tab);
98      }
99  
100     /**
101     * Get a title for any windows that we are in
102     * @return a window title
103     */
104     public String getTitle()
105     {
106         return ref.getName();
107     }
108 
109     /**
110     * Get the Passage that we are working on
111     * @return The current reference
112     */
113     public Passage getPassage()
114     {
115         return ref;
116     }
117 
118     /**
119     * Make the current reference equal to this one
120     * @return awindow title
121     */
122     public void setPassage(Passage newref)
123     {
124         ref.clear();
125         ref.addAll(newref);
126     }
127 
128     /** The search engine */
129     private Passage ref = PassageFactory.createPassage();
130 
131     /** The view selector */
132     private JTabbedPane tab = new JTabbedPane();
133 
134     /** The list view */
135     private JList list = new JList();
136 
137     /** The full Tree */
138     private JTree tree = new JTree();
139 
140     /** The Page */
141     private TaskPane page = new TaskPane(new FileState());
142 }