1 19 20 package com.sslexplorer.table; 21 22 import java.util.ArrayList ; 23 import java.util.List ; 24 25 32 public abstract class AbstractTableItemTableModel implements TableItemModel { 33 34 protected List items; 35 36 public AbstractTableItemTableModel() { 37 super(); 38 items = new ArrayList (); 39 } 40 41 public abstract int getColumnWidth(int col); 42 43 public String [] getColumnNames() { 44 String [] cols = new String [getColumnCount()]; 45 for(int i = getColumnCount() - 1; i >= 0 ; i--) { 46 cols[i] = getColumnName(i); 47 } 48 return cols; 49 } 50 51 public List getItems() { 52 return items; 53 } 54 55 public void addItem(TableItem item) { 56 items.add(item); 57 } 58 59 public void clear() { 60 items.clear(); 61 } 62 63 public void removeItem(TableItem item) { 64 items.remove(item); 65 } 66 67 public int getRowCount() { 68 return items.size(); 69 } 70 71 public Object getValue(int row, int col) { 72 return getItem(row).getColumnValue(col); 73 } 74 75 public TableItem getItem(int row) { 76 return (TableItem)items.get(row); 77 } 78 79 public boolean contains(TableItem item) { 80 return items.contains(item); 81 } 82 83 public boolean getEmpty() { 84 return items.size() == 0; 85 } 86 } 87 | Popular Tags |