return "Insert a row at a specified index";
}
@Override
protected Widget onInitialize() {
CustomForm form = new CustomForm();
// Row selection
final TextBox rowBox = new TextBox();
rowBox.setText("3");
rowBox.setWidth("50px");
form.addLabeledWidget("Row Index:", rowBox);
// Add button to insert one row
{
Button button = new Button("Insert 1 Row", new ClickHandler() {
public void onClick(ClickEvent event) {
try {
int row = Integer.parseInt(rowBox.getText());
insertDataRows(row, 1);
} catch (NumberFormatException e) {
Window.alert("Please enter valid integers for the row and column.");
} catch (IndexOutOfBoundsException e) {
Window.alert("The row or column index you entered is out of bounds.");
}
}
});
form.addButton(button);
}
// Add button to insert 10 rows
{
Button button = new Button("Insert 10 Rows", new ClickHandler() {
public void onClick(ClickEvent event) {
try {
int row = Integer.parseInt(rowBox.getText());
insertDataRows(row, 10);
} catch (NumberFormatException e) {
Window.alert("Please enter valid integers for the row and column.");
} catch (IndexOutOfBoundsException e) {
Window.alert("The row or column index you entered is out of bounds.");
}
}
});
form.addButton(button);
}
// Add button to insert 100 rows
{
Button button = new Button("Insert 100 Rows", new ClickHandler() {
public void onClick(ClickEvent event) {
try {
int row = Integer.parseInt(rowBox.getText());
insertDataRows(row, 100);
} catch (NumberFormatException e) {
Window.alert("Please enter valid integers for the row and column.");
} catch (IndexOutOfBoundsException e) {
Window.alert("The row or column index you entered is out of bounds.");
}
}
});
form.addButton(button);
}
// Add button to remove a row
{
Button button = new Button("Remove Row", new ClickHandler() {
public void onClick(ClickEvent event) {
try {
int row = Integer.parseInt(rowBox.getText());
ScrollTableDemo.get().getDataTable().removeRow(row);
} catch (NumberFormatException e) {
Window.alert("Please enter valid integers for the row and column.");
} catch (IndexOutOfBoundsException e) {
Window.alert("The row or column index you entered is out of bounds.");
}
}
});
form.addButton(button);
}
return form;
}