// "Scroll" if change exceeds item height
while (Math.abs(deltaSum) >= SCROLL_UNIT_PX) {
- if (!filterSelect.waitingForFilteringResponse) {
+ if (!filterSelect.dataReceivedHandler
+ .isWaitingForFilteringResponse()) {
// Move selection if page flip is not in progress
if (deltaSum < 0) {
filterSelect.suggestionPopup.selectPrevItem();
public void run() {
debug("VFS.SP.LPS: run()");
if (pagesToScroll != 0) {
- if (!isWaitingForFilteringResponse()) {
+ if (!dataReceivedHandler.isWaitingForFilteringResponse()) {
/*
* Avoid scrolling while we are waiting for a response
* because otherwise the waiting flag will be reset in
return;
}
- doPostFilterWhenReady();
- }
-
- /**
- * Perform the post-filter action either now (if not waiting for a
- * server response) or when a response is received.
- */
- private void doPostFilterWhenReady() {
- if (isWaitingForFilteringResponse()) {
- dataReceivedHandler.setUpdateOnDataReceived(true);
- } else {
- dataReceivedHandler.setUpdateOnDataReceived(false);
- doPostFilterSelectedItemAction();
- }
+ dataReceivedHandler.doPostFilterWhenReady();
}
/**
*/
private boolean popupOpenerClicked = false;
private boolean updateOnDataReceived = false;
+ /** For internal use only. May be removed or replaced in the future. */
+ private boolean waitingForFilteringResponse = false;
/**
* Called by the connector when new data for the last requested filter
suggestionPopup.showSuggestions(currentSuggestions, currentPage,
totalMatches);
- setWaitingForFilteringResponse(false);
+ waitingForFilteringResponse = false;
if (!popupOpenerClicked) {
navigateItemAfterPageChange();
return popupOpenerClicked;
}
- public void setUpdateOnDataReceived(boolean update) {
- updateOnDataReceived = update;
+ /**
+ * Cancel a pending request to perform post-filtering actions.
+ */
+ private void cancelPendingPostFiltering() {
+ updateOnDataReceived = false;
}
/**
public void serverReplyHandled() {
popupOpenerClicked = false;
}
+
+ /**
+ * For internal use only - this method will be removed in the future.
+ *
+ * @return true if the combo box is waiting for a reply from the server
+ * with a new page of data, false otherwise
+ */
+ public boolean isWaitingForFilteringResponse() {
+ return waitingForFilteringResponse;
+ }
+
+ /**
+ * Set a flag that filtering of options is pending a response from the
+ * server.
+ */
+ private void startWaitingForFilteringResponse() {
+ waitingForFilteringResponse = true;
+ }
+
+ /**
+ * Perform the post-filter action either now (if not waiting for a
+ * server response) or when a response is received.
+ */
+ private void doPostFilterWhenReady() {
+ if (isWaitingForFilteringResponse()) {
+ updateOnDataReceived = true;
+ } else {
+ updateOnDataReceived = false;
+ suggestionPopup.menu.doPostFilterSelectedItemAction();
+ }
+ }
}
@Deprecated
/** For internal use only. May be removed or replaced in the future. */
public String selectedOptionKey;
- /** For internal use only. May be removed or replaced in the future. */
- private boolean waitingForFilteringResponse = false;
-
/** For internal use only. May be removed or replaced in the future. */
public boolean initDone = false;
}
}
- setWaitingForFilteringResponse(true);
+ dataReceivedHandler.startWaitingForFilteringResponse();
connector.requestPage(filter, page);
lastFilter = filter;
debug("VFS: onSuggestionSelected(" + suggestion.caption + ": "
+ suggestion.key + ")");
}
- dataReceivedHandler.setUpdateOnDataReceived(false);
+ dataReceivedHandler.cancelPendingPostFiltering();
currentSuggestion = suggestion;
String newKey;
if (enableDebug) {
debug("VFS: key down: " + keyCode);
}
- if (isWaitingForFilteringResponse()
+ if (dataReceivedHandler.isWaitingForFilteringResponse()
&& navigationKeyCodes.contains(keyCode)) {
/*
* Keyboard navigation events should not be handled while we are
@Override
public boolean isWorkPending() {
- return isWaitingForFilteringResponse()
+ return dataReceivedHandler.isWaitingForFilteringResponse()
|| suggestionPopup.lazyPageScroller.isRunning();
}
return explicitSelectedCaption;
}
- /**
- * For internal use only - this method will be removed in the future.
- *
- * @return true if the combo box is waiting for a reply from the server with
- * a new page of data, false otherwise
- */
- public boolean isWaitingForFilteringResponse() {
- return waitingForFilteringResponse;
- }
-
- /**
- * For internal use only - this method will be removed in the future.
- *
- * @param waitingForFilteringResponse
- * true to indicate that the combo box is waiting for a new page
- * of items from the server
- */
- public void setWaitingForFilteringResponse(
- boolean waitingForFilteringResponse) {
- this.waitingForFilteringResponse = waitingForFilteringResponse;
- }
-
/**
* Returns a handler receiving notifications from the connector about
* communications.
import com.vaadin.client.ui.AbstractFieldConnector;
import com.vaadin.client.ui.SimpleManagedLayout;
import com.vaadin.client.ui.VFilterSelect;
+import com.vaadin.client.ui.VFilterSelect.DataReceivedHandler;
import com.vaadin.client.ui.VFilterSelect.FilterSelectSuggestion;
import com.vaadin.shared.EventId;
import com.vaadin.shared.communication.FieldRpc.FocusAndBlurServerRpc;
oldSuggestionTextMatchTheOldSelection = isWidgetsCurrentSelectionTextInTextBox();
getWidget().currentSuggestions.clear();
- if (!getWidget().isWaitingForFilteringResponse()) {
+ if (!getDataReceivedHandler().isWaitingForFilteringResponse()) {
/*
* Clear the current suggestions as the server response always
* includes the new ones. Exception is when filtering, then we
// it as well and clear selected caption
getWidget().setSelectedCaption(null);
- } else if (!getWidget().isWaitingForFilteringResponse()
+ } else if (!getDataReceivedHandler()
+ .isWaitingForFilteringResponse()
&& uidl.hasAttribute("selectedCaption")) {
// scrolling to correct page is disabled, caption is passed as a
// special parameter
}
// TODO even this condition should probably be moved to the handler
- if ((getWidget().isWaitingForFilteringResponse() && getWidget().lastFilter
+ if ((getDataReceivedHandler().isWaitingForFilteringResponse() && getWidget().lastFilter
.toLowerCase().equals(uidl.getStringVariable("filter")))
|| popupOpenAndCleared) {
- getWidget().getDataReceivedHandler().dataReceived();
+ getDataReceivedHandler().dataReceived();
}
// Calculate minimum textarea width
getWidget().initDone = true;
// TODO this should perhaps be moved to be a part of dataReceived()
- getWidget().getDataReceivedHandler().serverReplyHandled();
+ getDataReceivedHandler().serverReplyHandled();
}
private void performSelection(String selectedKey) {
if (!suggestionKey.equals(selectedKey)) {
continue;
}
- if (!getWidget().isWaitingForFilteringResponse()
- || getWidget().getDataReceivedHandler()
- .isPopupOpenerClicked()) {
+ if (!getDataReceivedHandler().isWaitingForFilteringResponse()
+ || getDataReceivedHandler().isPopupOpenerClicked()) {
if (!suggestionKey.equals(getWidget().selectedOptionKey)
|| suggestion.getReplacementString().equals(
getWidget().tb.getText())
}
private void resetSelection() {
- if (!getWidget().isWaitingForFilteringResponse()
- || getWidget().getDataReceivedHandler().isPopupOpenerClicked()) {
+ if (!getDataReceivedHandler().isWaitingForFilteringResponse()
+ || getDataReceivedHandler().isPopupOpenerClicked()) {
// select nulled
if (!getWidget().focused) {
/*
return (VFilterSelect) super.getWidget();
}
+ private DataReceivedHandler getDataReceivedHandler() {
+ return getWidget().getDataReceivedHandler();
+ }
+
@Override
public ComboBoxState getState() {
return (ComboBoxState) super.getState();
// We need this here to be consistent with the all the calls.
// Then set your specific selection type only after
// a server request method call.
- getWidget().getDataReceivedHandler().anyRequestSentToServer();
+ getDataReceivedHandler().anyRequestSentToServer();
}
}