@Override
protected void onFirstShowPage() {
super.onFirstShowPage();
final PScrollPanel scroll = new PScrollPanel();
final PFlowPanel layout = new PFlowPanel();
final PFlexTable formContainer = new PFlexTable();
final PSimplePanel listContainer = new PSimplePanel();
layout.add(formContainer);
final PButton add = new PButton("Add");
add.addClickHandler(new PClickHandler() {
@Override
public void onClick(final PClickEvent event) {
final Integer i = Integer.parseInt(line.getText());
final Pony father = dataGrid.getVisibleItem(i);
final List<Pony> copy = new ArrayList<Pony>();
for (int j = 0; j < 3; j++) {
final Pony p = new Pony(father.getId(), "Copy-" + father.getName(), father.getAge(), father.getRace());
copy.add(p);
}
dataGrid.insertSubList(father, copy);
}
});
final PButton remove = new PButton("Remove");
remove.addClickHandler(new PClickHandler() {
@Override
public void onClick(final PClickEvent event) {
final Integer i = Integer.parseInt(line.getText());
final Pony father = dataGrid.getVisibleItem(i);
dataGrid.removeSubList(father);
}
});
layout.add(line);
layout.add(add);
layout.add(remove);
layout.add(listContainer);
scroll.setWidget(layout);
examplePanel.setWidget(scroll);
// Register handler
addHandler(SubmitFormEvent.TYPE, this);