/**
* @author mattitahvonen
- *
+ *
*/
public class SuggestionPopup extends PopupPanel implements PositionCallback {
private SuggestionMenu menu;
int index = 1 + menu.getItems().indexOf(cur);
if (menu.getItems().size() > index)
menu.selectItem((MenuItem) menu.getItems().get(index));
- else
+ else if (!clientSideFiltering && hasNextPage())
filterOptions(currentPage + 1);
}
if (index > -1)
menu.selectItem((MenuItem) menu.getItems().get(index));
else if (index == -1) {
- filterOptions(currentPage - 1);
+ if(currentPage > 0)
+ filterOptions(currentPage - 1);
} else {
menu.selectItem((MenuItem) menu.getItems().get(
menu.getItems().size() - 1));
isPagingEnabled = paging;
}
-
- /* (non-Javadoc)
- * @see com.google.gwt.user.client.ui.PopupPanel$PositionCallback#setPosition(int, int)
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.google.gwt.user.client.ui.PopupPanel$PositionCallback#setPosition(int,
+ * int)
*/
public void setPosition(int offsetWidth, int offsetHeight) {
ApplicationConnection.getConsole().log("callback");
popupOpener.addClickListener(this);
}
+ public boolean hasNextPage() {
+ if (totalSuggestions > (this.currentPage + 1) * PAGELENTH)
+ return true;
+ else
+ return false;
+ }
+
public void filterOptions(int page) {
filterOptions(page, tb.getText());
}
suggestionPopup.selectPrevItem();
break;
case KeyboardListener.KEY_PAGEDOWN:
- if (totalSuggestions > currentPage * (PAGELENTH + 1))
+ if (hasNextPage())
filterOptions(currentPage + 1, lastFilter);
break;
case KeyboardListener.KEY_PAGEUP: