1 56 57 package org.objectstyle.cayenne.dataview.dvmodeler; 58 59 import java.util.*; 60 import javax.swing.table.*; 61 62 67 68 public class RelationshipsTableModel extends AbstractTableModel { 69 private List objRelationships = new ArrayList(); 70 private String [] columnNames= {"Name", 71 "Source", 72 "Target", 73 "To Many"}; 74 75 76 public RelationshipsTableModel() { 77 } 78 79 80 public void setObjRelationships(List relationships){ 81 objRelationships = relationships; 82 fireTableStructureChanged(); 83 } 84 85 86 public int getRowCount(){ 87 return objRelationships.size(); 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 106 public Object getValueAt(int row, int column){ 107 ObjRelationship relationship = (ObjRelationship)objRelationships.get(row); 108 switch (column){ 109 case 0: 110 return relationship.getName(); 111 case 1: 112 return relationship.getSourceObjEntity(); 113 case 2: 114 return relationship.getTargetObjEntity(); 115 case 3: 116 return Boolean.valueOf(relationship.isToMany()); 117 118 default: return null; 119 } 120 121 } 122 } 123 | Popular Tags |