table.deselectAll();
}
- private int getScrollSelectionIndex(int selection) {
+ protected int getScrollSelectionIndex(int selection) {
int size = table.getVerticalBar().getThumb() / 2;
int output = selection - size;
return -1;
}
- private boolean checkText(FindProperty findProperty, GridItem items) {
+ protected boolean checkText(FindProperty findProperty, GridItem items) {
GridColumn[] columns = table.getColumns();
int columnSize = columns.length;
String input = findProperty.getLastSearch();
this.timeColumnIndex = timeColumnIndex;
}
+ @Override
public int getScrollSelectionIndex(int selection) {
- return 1;
+ int size = vScrollbar.getThumb() / 2;
+ int output = selection - size;
+
+ output = (output < 0) ? 0 : output;
+ return output;
}
+ @Override
public int searchString(FindProperty findProperty) {
+ GridItem[] items = table.getItems();
+ int size = items.length;
+ boolean next = !findProperty.isBackward();
+ int start = findProperty.getIndex();
+ setFindProferty(findProperty);
+
+ // forward
+ if (next) {
+ for (int i = start; i < size; i++) {
+ if (checkText(findProperty, items[i])) {
+ vScrollbar.setSelection(getScrollSelectionIndex(i));
+ table.setSelection(i);
+ updateTable();
+ return i;
+ }
+ }
+ // can't find
+ for (int i = 0; i < start; i++) {
+ if (checkText(findProperty, items[i])) {
+ vScrollbar.setSelection(getScrollSelectionIndex(i));
+ table.setSelection(i);
+ updateTable();
+ return i;
+ }
+ }
+ } else { // back
+ for (int i = start; i >= 0; i--) {
+ if (checkText(findProperty, items[i])) {
+ vScrollbar.setSelection(getScrollSelectionIndex(i));
+ table.setSelection(i);
+ updateTable();
+ return i;
+ }
+ }
+
+ for (int i = size - 1; i > start; i--) {
+ if (checkText(findProperty, items[i])) {
+ vScrollbar.setSelection(getScrollSelectionIndex(i));
+ table.setSelection(i);
+ updateTable();
+ return i;
+ }
+ }
+ }
+ table.deselectAll();
return -1;
}