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 19 public class CampaignTableModel extends AbstractTableModel { 20 private String [] columnNames = { 21 "Campaign Name", "Type", "Product Group", "Product Line", 22 "Leads Generated" }; 23 24 private ArrayList wholeList = null; 25 private Campaign sample = new Campaign(); 26 27 31 public CampaignTableModel(ArrayList wholeList) { 32 this.wholeList = wholeList; 33 sample.setName("camp 1"); 34 sample.setType("type 1"); 35 sample.setProductGroup("group 1"); 36 sample.setProductLine("line 1"); 37 sample.setLeadCount(new Integer (3)); 38 setLang(); 39 } 40 41 45 public final void addCampaign(Campaign f) { 46 wholeList.add(f); 47 } 48 49 54 public final Campaign getCampaign(int index) { 55 return (Campaign)(wholeList.get(index)); 56 } 57 58 62 public final void deleteCampaign(int index) { 63 wholeList.remove(index); 64 } 65 66 70 public final ArrayList getCampaigns() { 71 return wholeList; 72 } 73 74 80 public final Object getValueAt(int row, int col) { 81 Campaign sample=null; 82 sample = (Campaign)wholeList.get(row); 83 switch (col) { 84 case 0: return sample.getName(); 86 case 1: return sample.getType(); 88 case 2: return sample.getProductGroup(); 90 case 3: return sample.getProductLine(); 92 case 4: return sample.getLeadCount(); 94 default: 95 System.out.println("oops its dorked"); 96 break; 97 } 98 return null; 99 } 100 101 105 public final int getRowCount() { 106 return wholeList.size(); 107 } 108 109 113 public final int getColumnCount() { 114 return columnNames.length; 115 } 116 117 123 public final String getColumnName(int col) { 124 return columnNames[col]; 125 } 126 127 132 public final Class getColumnClass(int col) { 133 switch (col) { 134 case 0: return sample.getName().getClass(); 136 case 1: return sample.getType().getClass(); 138 case 2: return sample.getProductGroup().getClass(); 140 case 3: return sample.getProductLine().getClass(); 142 case 4: return sample.getLeadCount().getClass(); 144 default: 145 System.out.println("oops its dorked"); 146 break; 147 } 148 return null; 149 } 150 151 157 public final void setValueAt(Object value, int row, int col) { 158 Campaign f = null; 159 f = (Campaign)wholeList.get(row); 160 switch (col) { 161 case 0: sample.setName((String )value); 163 break; 164 case 1: sample.setType((String )value); 166 break; 167 case 2: sample.setProductGroup((String )value); 169 break; 170 case 3: sample.setProductLine((String )value); 172 break; 173 case 4: sample.setLeadCount((Integer )value); 175 break; 176 default: 177 System.out.println("oops its dorked"); 178 break; 179 } 180 fireTableCellUpdated(row, col); 181 } 182 183 189 public final boolean isCellEditable(int row, int col) { 190 Class cls = getColumnClass(col); 191 String name = getColumnName(col); 192 193 return false; 194 } 195 196 199 public final void setLang() { 200 Whiteboard wb = MainWindow.getWhiteboard(); 201 202 columnNames[0] = wb.getLang().getString("campaignName"); 203 columnNames[1] = wb.getLang().getString("type"); 204 columnNames[2] = wb.getLang().getString("productGroup"); 205 columnNames[3] = wb.getLang().getString("productLine"); 206 columnNames[4] = wb.getLang().getString("leadsGenerated"); 207 208 } 209 } 210 | Popular Tags |