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

Quick Search    Search Deep

Source code: com/eireneh/bible/passage/swing/PassageList.java


1   
2   package com.eireneh.bible.passage.swing;
3   
4   import javax.swing.*;
5   
6   import com.eireneh.bible.passage.*;
7   
8   /**
9    * A Simple extension to JList to customize it to hold a Passage and
10   * provide Passage related actions.
11   *
12   * <table border='1' cellPadding='3' cellSpacing='0' width="100%">
13   * <tr><td bgColor='white'class='TableRowColor'><font size='-7'>
14   * Distribution Licence:<br />
15   * Project B is free software; you can redistribute it
16   * and/or modify it under the terms of the GNU General Public License,
17   * version 2 as published by the Free Software Foundation.<br />
18   * This program is distributed in the hope that it will be useful,
19   * but WITHOUT ANY WARRANTY; without even the implied warranty of
20   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21   * General Public License for more details.<br />
22   * The License is available on the internet
23   * <a href='http://www.gnu.org/copyleft/gpl.html'>here</a>, by writing to
24   * <i>Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
25   * MA 02111-1307, USA</i>, Or locally at the Licence link below.<br />
26   * The copyright to this program is held by it's authors.
27   * </font></td></tr></table>
28   * @see <a href='http://www.eireneh.com/servlets/Web'>Project B Home</a>
29   * @see docs.Licence
30   * @author Joe Walker
31   * @version $Id:$
32   */
33  public class PassageList extends JList
34  {
35      /**
36       * Basic Ctor, using default range scope
37       */
38      public PassageList()
39      {
40          this(null);
41      }
42  
43      /**
44       * Ctor with a Passage, using default range scope
45       */
46      public PassageList(Passage ref)
47      {
48          this(ref, PassageListModel.LIST_RANGES);
49      }
50  
51      /**
52       * Ctor with a Passage, using default range scope
53       */
54      public PassageList(Passage ref, int scope)
55      {
56          plm = new PassageListModel(null, scope);
57          setPassage(ref);
58          setModel(plm);
59      }
60  
61      /**
62       * Accessor for the current passage
63       */
64      public void setPassage(Passage ref)
65      {
66          plm.setPassage(ref);
67      }
68  
69      /**
70       * Accessor for the current passage
71       */
72      public Passage getPassage()
73      {
74          return plm.getPassage();
75      }
76  
77      /**
78       * Remove all of the selected verses from the passage
79       */
80      public void deleteSelected()
81      {
82          Passage ref = plm.getPassage();
83          Object[] selected = this.getSelectedValues();
84          for (int i=0; i<selected.length; i++)
85          {
86              VerseRange range = (VerseRange) selected[i];
87              ref.remove(range);
88          }
89  
90          setSelectedIndices(new int[0]);
91      }
92  
93      private PassageListModel plm = null;
94  }
95