KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > opensymphony > workflow > designer > model > ListTableModel


1 package com.opensymphony.workflow.designer.model;
2
3 import java.util.List JavaDoc;
4 import java.util.ArrayList JavaDoc;
5 import java.util.Collections JavaDoc;
6 import javax.swing.table.AbstractTableModel JavaDoc;
7
8 /**
9  * @author Hani Suleiman (hani@formicary.net)
10  * Date: May 21, 2003
11  * Time: 10:20:51 PM
12  */

13 public abstract class ListTableModel extends AbstractTableModel JavaDoc
14 {
15   protected List JavaDoc list = new ArrayList JavaDoc();
16
17   public int getRowCount()
18   {
19     return list == null ? 0 : list.size();
20   }
21
22   public void setList(List JavaDoc l)
23   {
24     this.list = l;
25     fireTableDataChanged();
26   }
27
28     public List JavaDoc getList()
29     {
30         return Collections.unmodifiableList(list);
31     }
32
33   public void add(Object JavaDoc item)
34   {
35     list.add(item);
36     fireTableRowsInserted(list.size(), list.size());
37   }
38
39   public void remove(int index)
40   {
41     list.remove(index);
42     fireTableRowsDeleted(index, index);
43   }
44
45   public Object JavaDoc get(int i)
46   {
47     return list.get(i);
48   }
49 }
50
Popular Tags