Ignore errors when current row no longer exists in a table

If the row that was our current row has been deleted from the table
and currentRow is now out of range don't throw an exception, but
instead ignore the error and just position on the new current row.

This is caused by bugs in table users, where they removed rows but
didn't refocus onto an existing row as the current row, confusing
the table state.

Signed-off-by: Shawn O. Pearce <sop@google.com>
This commit is contained in:
Shawn O. Pearce
2009-02-24 16:11:59 -08:00
parent b546c9b2e6
commit e98904a162

View File

@@ -175,7 +175,8 @@ public abstract class FancyFlexTable<RowItem> extends Composite implements
protected void movePointerTo(final int newRow) {
final CellFormatter fmt = table.getCellFormatter();
if (currentRow >= 0) {
final boolean clear = 0 <= currentRow && currentRow < table.getRowCount();
if (clear) {
final Element tr = DOM.getParent(fmt.getElement(currentRow, C_ARROW));
UIObject.setStyleName(tr, S_ACTIVE_ROW, false);
}
@@ -184,7 +185,7 @@ public abstract class FancyFlexTable<RowItem> extends Composite implements
final Element tr = DOM.getParent(fmt.getElement(newRow, C_ARROW));
UIObject.setStyleName(tr, S_ACTIVE_ROW, true);
tr.scrollIntoView();
} else if (currentRow >= 0) {
} else if (clear) {
table.setWidget(currentRow, C_ARROW, null);
}
currentRow = newRow;