/**
* Used by find dialog
*/
public boolean findNext(SearchContext context) {
SpreadSheetSearchContext ctx = (SpreadSheetSearchContext)context;
int row = this.getCurrentRow();
// make sure in bounds
if (row < 0)
row =0;
if (row >= getCache().getSize())
row = getCache().getSize() -1;
ListIterator i =getCache().getIterator(row);
if (ctx.getRow() != -1) { // after the first search, need to move ahead or back
if (ctx.isForward())
if (i.hasNext())
i.next();
else
if (i.hasPrevious())
i.previous();
}
boolean found = false;
GraphicNode gnode = null;
Object obj;
Node node;
while (ctx.isForward() ? i.hasNext() : i.hasPrevious()) {
gnode=(GraphicNode)(ctx.isForward() ? i.next() : i.previous());
if (gnode.isVoid())
continue;
node = gnode.getNode();
obj = node.getImpl();
if (ctx.matches(obj)) {
found = true;
break;
}
}
if (found) {
int r = getCache().getRowAt(gnode);
int col = getFieldArray().indexOf(ctx.getField())-1;
this.changeSelection(r, col, false, false);
ctx.setRow(r);
}
return found;
}