public void render(final Object obj, final TableBodyGroup rowGroup) {
final Person person = (Person)obj;
final TableRow tr = rowGroup.newTableRow();
final TableCell a = tr.newTableDataCell();
final CheckBox checkBox = new CheckBox();
checkBox.setEnabled(false);
checkBox.setTitle("Doesn't do anything.");
a.add(checkBox);
a.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
a.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
a.setRowSpan(2);
tr.add(a);
final TableCell nameCell = tr.newTableDataCell();
nameCell.addStyleName("name");
final TextBox tb = new TextBox();
tb.addChangeListener(new ChangeListener() {
public void onChange(final Widget sender) {
final TextBox tb = (TextBox)sender;
person.setName(tb.getText());
}
});
tb.addKeyboardListener(new KeyboardListenerAdapter() {
public void onKeyUp(final Widget sender, final char keyCode, final int modifiers) {
super.onKeyUp(sender, keyCode, modifiers);
if (KeyboardListener.KEY_ENTER == keyCode) {
final TextBox tb = (TextBox)sender;
tb.setFocus(false);
}
}
});
tb.addFocusListener(new FocusListenerAdapter() {
public void onFocus(final Widget sender) {
tb.setSelectionRange(0, tb.getText().length());
}
});
tb.setText(person.getName());
nameCell.add(tb);
tr.add(nameCell);
final TableCell ageCell = tr.newTableDataCell();
ageCell.addStyleName("age");
//ageCell.add(new Label(Integer.toString(person.getAge())));
ageCell.add(new AgeLabel(person.getAge()));
ageCell.setWidth("5em");
ageCell.setAlignment(HasHorizontalAlignment.ALIGN_CENTER, HasVerticalAlignment.ALIGN_MIDDLE);
tr.add(ageCell);
final TableCell removeCell = tr.newTableDataCell();
removeCell.addStyleName("remove");
final Button button = new Button("Remove");
button.addClickListener(new ClickListener() {
public void onClick(final Widget sender) {
ot.getObjects().remove(person);
}
});
removeCell.add(button);
tr.add(removeCell);
rowGroup.add(tr);
final TableRow tr2 = rowGroup.newTableRow();
final TableCell tc2 = tr2.newTableDataCell();
tc2.addStyleName("random");
tc2.add(new Label("Something " + Math.random()));
//tc2.add(makeMenuBar());
tc2.setColSpan(3);
tc2.setAxis("summary");
tr2.add(tc2);
rowGroup.add(tr2);
}