1 package sellwin.gui; 2 3 import sellwin.domain.*; 4 import javax.swing.*; 5 import javax.swing.text.*; 6 import javax.swing.table.*; 7 import java.util.*; 8 import java.text.*; 9 10 14 18 public class LeadTableModel extends AbstractTableModel { 19 private String [] columnNames = { 20 "Contact", "Company", "Phone No.", "Interest Level", "Contacted By", 21 "Notes", "Converted to Opp" }; 22 23 private ArrayList wholeList = null; 24 private Lead lead = new Lead(); 25 26 31 public LeadTableModel(ArrayList wholeList) { 32 this.wholeList = wholeList; 33 Address a = new Address(); 34 lead.setAddress(a); 35 lead.setCompany("EDS"); 36 lead.setInterestLevel("NONE"); 37 SalesPerson s = new SalesPerson(); 38 lead.setContactedBy(s); 39 lead.setContactDate(new java.util.Date ()); 40 lead.setConverted(new Boolean (false)); 41 setLang(); 42 } 43 44 48 public final void addLead(Lead f) { 49 wholeList.add(f); 50 } 51 52 57 public final Lead getLead(int index) { 58 return (Lead)(wholeList.get(index)); 59 } 60 61 65 public final void deleteLead(int index) { 66 wholeList.remove(index); 67 } 68 69 73 public final ArrayList getLeads() { 74 return wholeList; 75 } 76 77 80 public Object getValueAt(int row, int col) { 81 Lead lead=null; 82 lead = (Lead)wholeList.get(row); 83 switch (col) { 84 case 0: return lead.getAddress().getFormattedName(); 86 case 1: return lead.getCompany(); 88 case 2: return lead.getAddress().getPhone(); 90 case 3: return lead.getInterestLevel(); 92 case 4: return lead.getContactedBy().getAddress().getFormattedName(); 94 case 5: return lead.getContactDate(); 96 case 6: return lead.getConverted(); 98 default: 99 System.out.println("oops its dorked"); 100 break; 101 } 102 return null; 103 } 104 105 106 109 public Class getColumnClass(int col) { 110 switch (col) { 111 case 0: return lead.getAddress().getFormattedName().getClass(); 113 case 1: return String .class; 116 case 2: return String .class; 119 case 3: return String .class; 122 case 4: return String .class; 125 case 5: return lead.getContactDate().getClass(); 127 case 6: return lead.getConverted().getClass(); 129 default: 130 System.out.println("oops its dorked"); 131 break; 132 } 133 return null; 134 } 135 136 140 public void setValueAt(Object value, int row, int col) { 141 Lead f = null; 142 f = (Lead)wholeList.get(row); 143 switch (col) { 144 case 0: break; 146 case 1: break; 148 case 2: break; 150 case 3: break; 152 case 4: break; 154 case 5: break; 156 case 6: break; 158 default: 159 System.out.println("oops its dorked"); 160 break; 161 } 162 fireTableCellUpdated(row, col); 163 } 164 165 168 public boolean isCellEditable(int row, int col) { 169 Class cls = getColumnClass(col); 170 String name = getColumnName(col); 171 172 return false; 173 } 174 175 178 public int getRowCount() { 179 return wholeList.size(); 180 } 181 182 185 public int getColumnCount() { 186 return columnNames.length; 187 } 188 189 192 public String getColumnName(int col) { 193 return columnNames[col]; 194 } 195 196 public final void setLang() { 197 Whiteboard wb = MainWindow.getWhiteboard(); 198 columnNames[0] = wb.getLang().getString("contact"); 199 columnNames[1] = wb.getLang().getString("company"); 200 columnNames[2] = wb.getLang().getString("phone"); 201 columnNames[3] = wb.getLang().getString("interestLevel"); 202 columnNames[4] = wb.getLang().getString("contactedBy"); 203 columnNames[5] = wb.getLang().getString("notes"); 204 columnNames[6] = wb.getLang().getString("convertedToOpp"); 205 } 206 } 207 | Popular Tags |