| 1 package sellwin.gui; 2 3 import sellwin.domain.*; 4 import sellwin.utils.*; 5 6 import javax.swing.*; 7 import javax.swing.text.*; 8 import javax.swing.table.*; 9 import java.util.*; 10 import java.text.*; 11 12 16 21 public class QuoteTableModel extends AbstractTableModel { 22 private String [] columnNames = { 23 "Quote Name", "Created On", "Created By" }; 24 25 private ArrayList wholeList = null; 26 private Quote quote = new Quote(); 27 28 33 public QuoteTableModel(ArrayList wholeList) { 34 this.wholeList = wholeList; 35 quote.setName("hi"); 36 quote.setModifiedBy("bob"); 37 38 setLang(); 39 } 40 41 45 public final void addQuote(Quote f) { 46 wholeList.add(f); 47 } 48 49 55 public final Quote getQuote(int index) { 56 return (Quote)(wholeList.get(index)); 57 } 58 59 63 public final void deleteQuote(int index) { 64 wholeList.remove(index); 65 } 66 67 71 public final ArrayList getQuotes() { 72 return wholeList; 73 } 74 75 78 public final Object getValueAt(int row, int col) { 79 Quote quote=null; 80 quote = (Quote)wholeList.get(row); 81 switch (col) { 82 case 0: return quote.getName(); 84 case 1: return quote.getModifiedDate(); 86 case 2: return quote.getModifiedBy(); 88 default: 89 System.out.println("oops its dorked"); 90 break; 91 } 92 return null; 93 } 94 95 98 public final int getRowCount() { 99 return wholeList.size(); 100 } 101 102 105 public final int getColumnCount() { 106 return columnNames.length; 107 } 108 109 112 public final String getColumnName(int col) { 113 return columnNames[col]; 114 } 115 116 119 public final Class getColumnClass(int col) { 120 switch (col) { 121 case 0: return quote.getName().getClass(); 123 case 1: return quote.getModifiedDate().getClass(); 125 case 2: return quote.getModifiedBy().getClass(); 127 default: 128 System.out.println("oops its dorked"); 129 break; 130 } 131 return null; 132 } 133 134 137 public final void setValueAt(Object value, int row, int col) { 138 Quote f = null; 139 f = (Quote)wholeList.get(row); 140 switch (col) { 141 case 0: quote.setName((String )value); 143 break; 144 case 1: quote.setModifiedDate((java.util.Date )value); 146 break; 147 case 2: quote.setModifiedBy((String )value); 149 break; 150 default: 151 System.out.println("oops its dorked"); 152 break; 153 } 154 fireTableCellUpdated(row, col); 155 } 156 157 160 public final boolean isCellEditable(int row, int col) { 161 Class cls = getColumnClass(col); 162 String name = getColumnName(col); 163 164 return false; 165 } 166 167 public final void setLang() { 168 Whiteboard wb = MainWindow.getWhiteboard(); 169 columnNames[0] = wb.getLang().getString("quoteName"); 170 columnNames[1] = wb.getLang().getString("createdDate"); 171 columnNames[2] = wb.getLang().getString("createdBy"); 172 } 173 } 174 | Popular Tags |