1 package com.opensymphony.workflow.designer.model; 2 3 import java.util.List ; 4 import java.util.ArrayList ; 5 import java.util.Collections ; 6 import javax.swing.table.AbstractTableModel ; 7 8 13 public abstract class ListTableModel extends AbstractTableModel 14 { 15 protected List list = new ArrayList (); 16 17 public int getRowCount() 18 { 19 return list == null ? 0 : list.size(); 20 } 21 22 public void setList(List l) 23 { 24 this.list = l; 25 fireTableDataChanged(); 26 } 27 28 public List getList() 29 { 30 return Collections.unmodifiableList(list); 31 } 32 33 public void add(Object 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 get(int i) 46 { 47 return list.get(i); 48 } 49 } 50 | Popular Tags |