1 package com.bonevich.erj.ui.editor;
2
3 import com.bonevich.erj.model.Attribute;
4
5 import javax.swing.table.AbstractTableModel;
6 import java.util.ArrayList;
7 import java.util.List;
8
9 public final class AttributeTableModel extends AbstractTableModel
10 {
11 //////////////////////////////////////////////////////////
12 // Constants
13 private static final String[] _COLUMNS = {"Attribute","Type","Constraint","Default"};
14
15 //////////////////////////////////////////////////////////
16 // Attributes
17 private List _attributes = new ArrayList(10);
18
19 public Object getValueAt(int row, int col)
20 {
21 //System.err.println("(model) getValueAt called");
22 Attribute attr = (Attribute)_attributes.get(row);
23 switch (col)
24 {
25 case 0 : return attr.getIdentifier();
26 case 1 : return attr.getType().toString();
27 case 2 : return attr.getConstraint().toString();
28 case 3 : return attr.getDefaultValue().toString();
29 default: System.err.println("Undefined attribute method");
30 return null;
31 }
32 }
33
34 public int getRowCount()
35 {
36 //System.err.println("(model) getRowCount called");
37 return _attributes.size();
38 }
39
40 public int getColumnCount()
41 {
42 //System.err.println("(model) getColumnCount called");
43 return _COLUMNS.length;
44 }
45
46 public String getColumnName(int col)
47 {
48 //System.err.println("(model) getColumnName called");
49 return _COLUMNS[col];
50 }
51
52 public Attribute getRow(int row)
53 {
54 //System.err.println("(model) getRow called row = " + row);
55 return (Attribute)_attributes.get(row);
56 }
57 public void setRow(Attribute attr)
58 {
59 _attributes.add(attr);
60 }
61
62 public void clearRows()
63 {
64 _attributes.clear();
65 }
66
67 } /* end class AttributeTableModel */
This page was automatically generated by Maven