1 19 20 package org.netbeans.modules.j2ee.ddloaders.multiview; 21 22 import org.netbeans.modules.j2ee.dd.api.ejb.Query; 23 24 import javax.swing.*; 25 import javax.swing.table.TableCellEditor ; 26 27 30 public class SelectMethodsTableModel extends QueryMethodsTableModel { 31 32 protected static final String [] COLUMN_NAMES = {Utils.getBundleMessage("LBL_Method"), 33 Utils.getBundleMessage("LBL_ReturnType"), 34 Utils.getBundleMessage("LBL_Query"), 35 Utils.getBundleMessage("LBL_Description")}; 36 protected static final int[] COLUMN_WIDTHS = new int[]{200, 100, 200, 100}; 37 40 public SelectMethodsTableModel(EntityHelper.Queries queries) { 41 super(COLUMN_NAMES, COLUMN_WIDTHS, queries); 42 } 43 44 public int addRow() { 45 return getRowCount() - 1; 47 } 48 49 50 public boolean editRow(int row) { 51 QueryMethodHelper helper = getQueryMethodHelper(row); 52 return true; 64 } 65 66 public QueryMethodHelper getQueryMethodHelper(int row) { 67 return queries.getSelectMethodHelper(row); 68 } 69 70 public int getRowCount() { 71 return queries.getSelectMethodCount(); 72 } 73 74 public Object getValueAt(int rowIndex, int columnIndex) { 75 QueryMethodHelper queryMethodHelper = getQueryMethodHelper(rowIndex); 76 switch (columnIndex) { 77 case 0: 78 return queryMethodHelper.getQueryMethod().getMethodName(); 79 case 1: 80 return queryMethodHelper.getReturnType(); 81 case 2: 82 return queryMethodHelper.getEjbQl(); 83 case 3: 84 return queryMethodHelper.getDefaultDescription(); 85 } 86 return null; 87 } 88 89 public void setValueAt(Object value, int rowIndex, int columnIndex) { 90 Query query = (Query) queries.getSelecMethod(rowIndex).clone(); 91 if (columnIndex == 3) { 92 query.setDescription((String ) value); 93 } 94 QueryMethodHelper helper = getQueryMethodHelper(rowIndex); 95 } 98 99 public TableCellEditor getCellEditor(int columnIndex) { 100 return null; 102 } 103 104 public boolean isCellEditable(int rowIndex, int columnIndex) { 105 if (columnIndex == 3) { 106 return true; 107 } else { 108 return super.isCellEditable(rowIndex, columnIndex); 109 } 110 } 111 } 112 | Popular Tags |