1 19 20 package org.netbeans.modules.j2ee.ddloaders.multiview; 21 22 23 24 27 public class EnvironmentEntriesTableModel extends InnerTableModel { 28 29 private EjbHelper ejbHelper; 30 private static final String [] COLUMN_NAMES = {Utils.getBundleMessage("LBL_EntryName"), 31 Utils.getBundleMessage("LBL_EntryType"), 32 Utils.getBundleMessage("LBL_EntryValue"), 33 Utils.getBundleMessage("LBL_Description")}; 34 private static final int[] COLUMN_WIDTHS = new int[]{100, 120, 100, 150}; 35 36 public EnvironmentEntriesTableModel(EjbHelper ejbHelper) { 37 super(null, COLUMN_NAMES, COLUMN_WIDTHS); 38 this.ejbHelper = ejbHelper; 39 } 40 41 public void setValueAt(Object value, int rowIndex, int columnIndex) { 42 EjbHelper.EnvEntryHelper envEntryHelper = ejbHelper.getEnvEntryHelper(rowIndex); 43 switch (columnIndex) { 44 case 0: 45 envEntryHelper.setEnvEntryName((String ) value); 46 break; 47 case 1: 48 envEntryHelper.setEnvEntryType((String ) value); 49 break; 50 case 2: 51 envEntryHelper.setEnvEntryValue((String ) value); 52 break; 53 case 3: 54 envEntryHelper.setDescription((String ) value); 55 break; 56 } 57 fireTableCellUpdated(rowIndex, columnIndex); 58 } 59 60 public int getRowCount() { 61 return ejbHelper.getEnvEntryCount(); 62 } 63 64 public Object getValueAt(int rowIndex, int columnIndex) { 65 EjbHelper.EnvEntryHelper envEntryHelper = ejbHelper.getEnvEntryHelper(rowIndex); 66 switch (columnIndex) { 67 case 0: 68 return envEntryHelper.getEnvEntryName(); 69 case 1: 70 return envEntryHelper.getEnvEntryType(); 71 case 2: 72 return envEntryHelper.getEnvEntryValue(); 73 case 3: 74 return envEntryHelper.getDefaultDescription(); 75 } 76 return null; 77 } 78 79 public int addRow() { 80 ejbHelper.newEnvEntry(); 81 int row = getRowCount() - 1; 82 return row; 83 } 84 85 public void removeRow(final int row) { 86 ejbHelper.removeEnvEntry(row); 87 } 88 } 89 | Popular Tags |