* Handle click events from the buttons in this panel.
*
* @param sender
*/
public void onClick(Widget sender) {
ScrollTable scrollTable = ScrollTableDemo.getScrollTable();
SortableGrid dataTable = ScrollTableDemo.getDataTable();
try {
if (sender == moveRowUpButton) {
// Move row up
int row1 = Integer.parseInt(rowIndexBox1.getText());
dataTable.moveRowUp(row1);
rowIndexBox1.setText((row1 - 1) + "");
} else if (sender == moveRowDownButton) {
// Move row down
int row1 = Integer.parseInt(rowIndexBox1.getText());
dataTable.moveRowDown(row1);
rowIndexBox1.setText((row1 + 1) + "");
} else if (sender == swapRowsButton) {
// Swap two rows
int row1 = Integer.parseInt(rowIndexBox1.getText());
int row2 = Integer.parseInt(rowIndexBox2.getText());
dataTable.swapRows(row1, row2);
} else if (sender == reverseRowsButton) {
// Reverse all rows
dataTable.reverseRows();
} else if (sender == sortColumnButton) {
// Sort a column
int column = Integer.parseInt(columnIndexBox.getText());
dataTable.sortColumn(column);
} else if (sender == makeSortableButton) {
// Make column sortable
int column = Integer.parseInt(columnIndexBox.getText());
scrollTable.setColumnSortable(column, true);
} else if (sender == makeUnsortableButton) {
// Make column unsortable
int column = Integer.parseInt(columnIndexBox.getText());
scrollTable.setColumnSortable(column, false);
} else if (sender == toggleSortingButton) {
if (scrollTable.isSortingEnabled()) {
scrollTable.setSortingEnabled(false);
grid.setHTML(3, 1, "disabled");
} else {
scrollTable.setSortingEnabled(true);
grid.setHTML(3, 1, "enabled");
}
}
} catch (IndexOutOfBoundsException e) {
Window.alert("The row or column index you entered is out of bounds.");