01: //** Copyright Statement ***************************************************
02: //The Salmon Open Framework for Internet Applications (SOFIA)
03: // Copyright (C) 1999 - 2002, Salmon LLC
04: //
05: // This program is free software; you can redistribute it and/or
06: // modify it under the terms of the GNU General Public License version 2
07: // as published by the Free Software Foundation;
08: //
09: // This program is distributed in the hope that it will be useful,
10: // but WITHOUT ANY WARRANTY; without even the implied warranty of
11: // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12: // GNU General Public License for more details.
13: //
14: // You should have received a copy of the GNU General Public License
15: // along with this program; if not, write to the Free Software
16: // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17: //
18: // For more information please visit http://www.salmonllc.com
19: //** End Copyright Statement ***************************************************
20: package com.salmonllc.ideTools;
21:
22: /////////////////////////
23: //$Archive: /SOFIA/SourceCode/com/salmonllc/ideTools/LModel.java $
24: //$Author: Dan $
25: //$Revision: 6 $
26: //$Modtime: 6/11/03 4:27p $
27: /////////////////////////
28: import javax.swing.*;
29: import java.util.Vector;
30:
31: public class LModel extends AbstractListModel {
32: private Vector _data;
33:
34: public LModel() {
35: _data = new Vector();
36: }
37:
38: public LModel(Vector data) {
39: _data = data;
40: }
41:
42: public void addElement(Object o) {
43: _data.addElement(o);
44: fireContentsChanged(o, _data.size() - 1, _data.size() - 1);
45: }
46:
47: public Object getElementAt(int i) {
48: return _data.elementAt(i);
49: }
50:
51: public int getSize() {
52: return _data.size();
53: }
54:
55: public void insertElementAt(Object o, int i) {
56: _data.insertElementAt(o, i);
57: fireContentsChanged(o, i, i);
58: }
59:
60: public void remove(int i) {
61: Object o = _data.elementAt(i);
62: _data.remove(i);
63: fireContentsChanged(o, i, i);
64: }
65:
66: public void removeAllElements() {
67: if (_data.size() > 0) {
68: _data.removeAllElements();
69: fireContentsChanged(null, 0, 0);
70: }
71: }
72:
73: public void setElementAt(Object o, int i) {
74: _data.setElementAt(o, i);
75: fireContentsChanged(o, i, i);
76: }
77: }
|