Column<Attribute, String> valueColumn = new Column<Attribute, String>(new CustomEditTextCell()) {
public String getValue(Attribute attribute) {
return attribute.getValue();
}
};
final EditTextCell partialScoreCell = new EditTextCell();
Column<Attribute, String> partialScoreColumn = new Column<Attribute, String>(partialScoreCell) {
public String getValue(Attribute attribute) {
return "" + attribute.getPartialScore();
}
};
Column<Attribute, String> reasonCodeColumn = new Column<Attribute, String>(new EditTextCell()) {
public String getValue(Attribute attribute) {
return attribute.getReasonCode();
}
};
ActionCell.Delegate<Attribute> delegate = new ActionCell.Delegate<Attribute>() {
public void execute(Attribute attribute) {
if (Window.confirm("Remove this attribute?")) {
List<Attribute> list = characteristicsAttrMap.get(cGrid).getList();
list.remove(attribute);
((EnumDropDown) cGrid.getWidget(2, 0)).setEnabled(list.size() == 0);
((EnumDropDown) cGrid.getWidget(2, 1)).setEnabled(list.size() == 0);
((Button)cGrid.getWidget(0, 3)).setEnabled(list.size() != 2);
attributeCellTable.redraw();
}
}
};
Cell<Attribute> actionCell = new ActionCell<Attribute>("Remove",delegate);
Column<Attribute, String> actionColumn = new IdentityColumn(actionCell);
reasonCodeColumn.setFieldUpdater(new FieldUpdater<Attribute, String>() {
public void update(int index, Attribute object, String value) {
object.setReasonCode(value);
attributeCellTable.redraw();
}
});
operatorColumn.setFieldUpdater(new FieldUpdater<Attribute, String>() {
public void update(int index, Attribute object, String value) {
object.setOperator(value);
attributeCellTable.redraw();
}
});
valueColumn.setFieldUpdater(new FieldUpdater<Attribute, String>() {
public void update(int index, Attribute object, String value) {
object.setValue(value);
attributeCellTable.redraw();
}
});
partialScoreColumn.setFieldUpdater(new FieldUpdater<Attribute, String>() {
public void update(int index, Attribute object, String value) {
try {
double d = Double.parseDouble(value);
object.setPartialScore(d);
} catch (Exception e1) {
partialScoreCell.clearViewData(object);
}
attributeCellTable.redraw();
}
});
// Add the columns.