1 56 57 package org.objectstyle.cayenne.dataview.dvmodeler; 58 59 import javax.swing.table.*; 60 61 67 68 public class AttributesTableModel extends AbstractTableModel { 69 private ObjEntity objEntity; 70 private String [] columnNames= {"Name", "Type"}; 71 72 73 public AttributesTableModel() { 74 } 75 76 public void setObjEntity(ObjEntity objEntity){ 77 this.objEntity = objEntity; 78 fireTableStructureChanged(); 79 } 80 81 82 public int getRowCount(){ 83 if (objEntity != null){ 84 return objEntity.getObjAttributeCount(); 85 }else{ 86 return 0; 87 } 88 } 89 90 91 public int getColumnCount(){ 92 return columnNames.length; 93 } 94 95 96 public String getColumnName(int col) { 97 return columnNames[col]; 98 } 99 100 101 public Class getColumnClass(int c) { 102 return getValueAt(0, c).getClass(); 103 } 104 105 public Object getValueAt(int row, int column){ 106 ObjAttribute attribute = objEntity.getObjAttribute(row); 107 switch (column){ 108 case 0: 109 return attribute.getName(); 110 case 1: 111 return attribute.getType(); 112 default: return null; 113 } 114 } 115 } 116 117 | Popular Tags |