1 46 package groovy.model; 47 48 import javax.swing.table.TableColumn ; 49 50 57 public class DefaultTableColumn extends TableColumn { 58 59 private ValueModel valueModel; 60 61 public DefaultTableColumn(ValueModel valueModel) { 62 this.valueModel = valueModel; 63 } 64 65 public DefaultTableColumn(Object header, ValueModel valueModel) { 66 this(valueModel); 67 setHeaderValue(header); 68 } 69 70 public String toString() { 71 return super.toString() + "[header:" + getHeaderValue() + " valueModel:" + valueModel + "]"; 72 } 73 74 77 public Object getValue(Object row, int rowIndex, int columnIndex) { 78 if (valueModel instanceof NestedValueModel) { 79 NestedValueModel nestedModel = (NestedValueModel) valueModel; 80 nestedModel.getSourceModel().setValue(row); 81 } 82 return valueModel.getValue(); 83 } 84 85 public void setValue(Object row, Object value, int rowIndex, int columnIndex) { 86 if (valueModel instanceof NestedValueModel) { 87 NestedValueModel nestedModel = (NestedValueModel) valueModel; 88 nestedModel.getSourceModel().setValue(row); 89 } 90 valueModel.setValue(value); 91 } 92 93 96 99 public Class getType() { 100 return valueModel.getType(); 101 } 102 103 public ValueModel getValueModel() { 104 return valueModel; 105 } 106 107 } 108 | Popular Tags |