1 19 package org.netbeans.modules.j2ee.ddloaders.multiview; 20 21 import org.netbeans.modules.j2ee.dd.api.ejb.Entity; 22 import org.netbeans.modules.j2ee.dd.api.ejb.Query; 23 24 import java.beans.PropertyChangeEvent ; 25 import java.beans.PropertyChangeListener ; 26 27 30 public abstract class QueryMethodsTableModel extends InnerTableModel { 31 32 protected final EntityHelper.Queries queries; 33 34 public QueryMethodsTableModel(String [] columnNames, int[] columnWidths, final EntityHelper.Queries queries) { 35 super(null, columnNames, columnWidths); 36 this.queries = queries; 37 queries.addPropertyChangeListener(new PropertyChangeListener () { 38 public void propertyChange(PropertyChangeEvent evt) { 39 Object source = evt.getSource(); 40 if (source instanceof Entity) { 41 tableChanged(); 42 } else if (source instanceof Query) { 43 for (int i = 0, n = getRowCount(); i < n; i++) { 44 QueryMethodHelper queryMethodHelper = getQueryMethodHelper(i); 45 if (queryMethodHelper.query == source) { 46 fireTableRowsUpdated(i, i); 47 return; 48 } 49 } 50 } else { 51 fireTableDataChanged(); 52 } 53 } 54 }); 55 } 56 57 public void removeRow(int row) { 58 getQueryMethodHelper(row).removeQuery(); 59 } 60 61 public boolean isCellEditable(int rowIndex, int columnIndex) { 62 return false; 63 } 64 65 public abstract QueryMethodHelper getQueryMethodHelper(int row); 66 67 } 68 | Popular Tags |