| KeyListListModel.java |
1 /**
2 * Distribution License:
3 * BibleDesktop is free software; you can redistribute it and/or modify it under
4 * the terms of the GNU General Public License, version 2 as published by
5 * the Free Software Foundation. This program is distributed in the hope
6 * that it will be useful, but WITHOUT ANY WARRANTY; without even the
7 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
8 * See the GNU General Public License for more details.
9 *
10 * The License is available on the internet at:
11 * http://www.gnu.org/copyleft/gpl.html
12 * or by writing to:
13 * Free Software Foundation, Inc.
14 * 59 Temple Place - Suite 330
15 * Boston, MA 02111-1307, USA
16 *
17 * Copyright: 2005
18 * The copyright to this program is held by it's authors.
19 *
20 * ID: $Id: KeyListListModel.java 1966 2009-10-30 01:15:14Z dmsmith $
21 */
22 package org.crosswire.bibledesktop.passage;
23
24 import javax.swing.AbstractListModel;
25
26 import org.crosswire.jsword.passage.Key;
27
28 /**
29 * A simple implementation of ListModel that is backed by a SortedSet.
30 *
31 * @see gnu.gpl.License for license details.<br>
32 * The copyright to this program is held by it's authors.
33 * @author Joe Walker [joe at eireneh dot com]
34 */
35 public class KeyListListModel extends AbstractListModel {
36 /**
37 * Constructor for ListListModel.
38 */
39 public KeyListListModel(Key keys) {
40 this.keys = keys;
41 }
42
43 /* (non-Javadoc)
44 * @see javax.swing.ListModel#getSize()
45 */
46 public int getSize() {
47 return keys != null ? keys.getCardinality() : 0;
48 }
49
50 /**
51 * There must be a faster way of doing this?
52 *
53 * @see javax.swing.ListModel#getElementAt(int)
54 */
55 public Object getElementAt(int index) {
56 return keys != null ? keys.get(index) : null;
57 }
58
59 private Key keys;
60
61 /**
62 * Serialization ID
63 */
64 private static final long serialVersionUID = 3546356240990286645L;
65 }
66