aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenri Sara <hesara@vaadin.com>2015-11-10 13:44:33 +0200
committerHenri Sara <hesara@vaadin.com>2016-01-15 14:42:57 +0200
commit376dbae5c4edd373cac8194af2389f2c5ce45ff9 (patch)
treea3caccf267051c848110ca55f38244ee52c40825
parente70bcba3e4466d4dd1f37a5d7109b22172b0b522 (diff)
downloadvaadin-framework-376dbae5c4edd373cac8194af2389f2c5ce45ff9.tar.gz
vaadin-framework-376dbae5c4edd373cac8194af2389f2c5ce45ff9.zip
Use accessors for combo internal state (#19929)
This is an intermediate step towards refactoring the communication related client side internal state management. Change-Id: I31ba382fb195b7b7c80de35f464db2510ecd9515
-rw-r--r--client/src/com/vaadin/client/ui/VFilterSelect.java113
-rw-r--r--client/src/com/vaadin/client/ui/combobox/ComboBoxConnector.java26
2 files changed, 114 insertions, 25 deletions
diff --git a/client/src/com/vaadin/client/ui/VFilterSelect.java b/client/src/com/vaadin/client/ui/VFilterSelect.java
index c6c63a95f8..f2a002a0d9 100644
--- a/client/src/com/vaadin/client/ui/VFilterSelect.java
+++ b/client/src/com/vaadin/client/ui/VFilterSelect.java
@@ -557,7 +557,7 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler,
public void run() {
debug("VFS.SP.LPS: run()");
if (pagesToScroll != 0) {
- if (!waitingForFilteringResponse) {
+ if (!isWaitingForFilteringResponse()) {
/*
* Avoid scrolling while we are waiting for a response
* because otherwise the waiting flag will be reset in
@@ -947,8 +947,8 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler,
return;
}
- updateSelectionWhenReponseIsReceived = waitingForFilteringResponse;
- if (!waitingForFilteringResponse) {
+ setUpdateSelectionWhenReponseIsReceived(isWaitingForFilteringResponse());
+ if (!isWaitingForFilteringResponse()) {
doPostFilterSelectedItemAction();
}
}
@@ -961,7 +961,7 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler,
final MenuItem item = getSelectedItem();
final String enteredItemValue = tb.getText();
- updateSelectionWhenReponseIsReceived = false;
+ setUpdateSelectionWhenReponseIsReceived(false);
// check for exact match in menu
int p = getItems().size();
@@ -1507,7 +1507,7 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler,
}
}
- waitingForFilteringResponse = true;
+ setWaitingForFilteringResponse(true);
connector.requestPage(filter, page);
afterUpdateClientVariables();
@@ -1607,7 +1607,7 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler,
debug("VFS: onSuggestionSelected(" + suggestion.caption + ": "
+ suggestion.key + ")");
}
- updateSelectionWhenReponseIsReceived = false;
+ setUpdateSelectionWhenReponseIsReceived(false);
currentSuggestion = suggestion;
String newKey;
@@ -1728,7 +1728,7 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler,
if (enableDebug) {
debug("VFS: key down: " + keyCode);
}
- if (waitingForFilteringResponse
+ if (isWaitingForFilteringResponse()
&& navigationKeyCodes.contains(keyCode)) {
/*
* Keyboard navigation events should not be handled while we are
@@ -1879,7 +1879,7 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler,
private void selectPrevPage() {
if (currentPage > 0) {
filterOptions(currentPage - 1, lastFilter);
- selectPopupItemWhenResponseIsReceived = Select.LAST;
+ setSelectPopupItemWhenResponseIsReceived(Select.LAST);
}
}
@@ -1889,7 +1889,7 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler,
private void selectNextPage() {
if (hasNextPage()) {
filterOptions(currentPage + 1, lastFilter);
- selectPopupItemWhenResponseIsReceived = Select.FIRST;
+ setSelectPopupItemWhenResponseIsReceived(Select.FIRST);
}
}
@@ -1980,7 +1980,7 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler,
boolean immediate = focused
|| !connector.hasEventListener(EventId.FOCUS);
filterOptions(-1, "", immediate);
- popupOpenerClicked = true;
+ setPopupOpenerClicked(true);
lastFilter = "";
}
DOM.eventPreventDefault(DOM.eventGetCurrentEvent());
@@ -2323,13 +2323,102 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler,
// We need this here to be consistent with the all the calls.
// Then set your specific selection type only after
// client.updateVariable() method call.
- selectPopupItemWhenResponseIsReceived = Select.NONE;
+ setSelectPopupItemWhenResponseIsReceived(Select.NONE);
}
@Override
public boolean isWorkPending() {
- return waitingForFilteringResponse
+ return isWaitingForFilteringResponse()
|| suggestionPopup.lazyPageScroller.isRunning();
}
+ /**
+ * 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;
+ }
+
+ /**
+ * For internal use only - this method will be removed in the future.
+ *
+ * This flag should not be set when not waiting for a reply from the server.
+ *
+ * @return true if the selection should be updated when a server response is
+ * received
+ */
+ public boolean isUpdateSelectionWhenReponseIsReceived() {
+ return updateSelectionWhenReponseIsReceived;
+ }
+
+ /**
+ * For internal use only - this method will be removed in the future.
+ *
+ * This flag should not be set when not waiting for a reply from the server.
+ *
+ * @param updateSelectionWhenReponseIsReceived
+ * true if the selection should be updated when a server response
+ * is received
+ */
+ public void setUpdateSelectionWhenReponseIsReceived(
+ boolean updateSelectionWhenReponseIsReceived) {
+ this.updateSelectionWhenReponseIsReceived = updateSelectionWhenReponseIsReceived;
+ }
+
+ /**
+ * For internal use only - this method will be removed in the future.
+ *
+ * @return enum Select indicating which item (if any) to select when a new
+ * page of data is received
+ */
+ public Select getSelectPopupItemWhenResponseIsReceived() {
+ return selectPopupItemWhenResponseIsReceived;
+ }
+
+ /**
+ * For internal use only - this method will be removed in the future.
+ *
+ * @param selectPopupItemWhenResponseIsReceived
+ * enum Select indicating which item (if any) to select when a
+ * new page of data is received
+ */
+ public void setSelectPopupItemWhenResponseIsReceived(
+ Select selectPopupItemWhenResponseIsReceived) {
+ this.selectPopupItemWhenResponseIsReceived = selectPopupItemWhenResponseIsReceived;
+ }
+
+ /**
+ * For internal use only - this method will be removed in the future.
+ *
+ * @return true if the user has requested opening the popup
+ */
+ public boolean isPopupOpenerClicked() {
+ return popupOpenerClicked;
+ }
+
+ /**
+ * For internal use only - this method will be removed in the future.
+ *
+ * @param popupOpenerClicked
+ * true if the user has requested opening the popup
+ */
+ public void setPopupOpenerClicked(boolean popupOpenerClicked) {
+ this.popupOpenerClicked = popupOpenerClicked;
+ }
+
}
diff --git a/client/src/com/vaadin/client/ui/combobox/ComboBoxConnector.java b/client/src/com/vaadin/client/ui/combobox/ComboBoxConnector.java
index ad1e77c167..5e2d4336d8 100644
--- a/client/src/com/vaadin/client/ui/combobox/ComboBoxConnector.java
+++ b/client/src/com/vaadin/client/ui/combobox/ComboBoxConnector.java
@@ -152,7 +152,7 @@ public class ComboBoxConnector extends AbstractFieldConnector implements
oldSuggestionTextMatchTheOldSelection = isWidgetsCurrentSelectionTextInTextBox();
getWidget().currentSuggestions.clear();
- if (!getWidget().waitingForFilteringResponse) {
+ if (!getWidget().isWaitingForFilteringResponse()) {
/*
* Clear the current suggestions as the server response always
* includes the new ones. Exception is when filtering, then we
@@ -193,7 +193,7 @@ public class ComboBoxConnector extends AbstractFieldConnector implements
// started.
if (selectedKeys.length > 0 && !selectedKeys[0].equals("")) {
performSelection(selectedKeys[0]);
- } else if (!getWidget().waitingForFilteringResponse
+ } else if (!getWidget().isWaitingForFilteringResponse()
&& uidl.hasAttribute("selectedCaption")) {
// scrolling to correct page is disabled, caption is passed as a
// special parameter
@@ -204,7 +204,7 @@ public class ComboBoxConnector extends AbstractFieldConnector implements
}
}
- if ((getWidget().waitingForFilteringResponse && getWidget().lastFilter
+ if ((getWidget().isWaitingForFilteringResponse() && getWidget().lastFilter
.toLowerCase().equals(uidl.getStringVariable("filter")))
|| popupOpenAndCleared) {
@@ -212,10 +212,10 @@ public class ComboBoxConnector extends AbstractFieldConnector implements
getWidget().currentSuggestions, getWidget().currentPage,
getWidget().totalMatches);
- getWidget().waitingForFilteringResponse = false;
+ getWidget().setWaitingForFilteringResponse(false);
- if (!getWidget().popupOpenerClicked
- && getWidget().selectPopupItemWhenResponseIsReceived != VFilterSelect.Select.NONE) {
+ if (!getWidget().isPopupOpenerClicked()
+ && getWidget().getSelectPopupItemWhenResponseIsReceived() != VFilterSelect.Select.NONE) {
// we're paging w/ arrows
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
@@ -226,7 +226,7 @@ public class ComboBoxConnector extends AbstractFieldConnector implements
});
}
- if (getWidget().updateSelectionWhenReponseIsReceived) {
+ if (getWidget().isUpdateSelectionWhenReponseIsReceived()) {
getWidget().suggestionPopup.menu
.doPostFilterSelectedItemAction();
}
@@ -235,7 +235,7 @@ public class ComboBoxConnector extends AbstractFieldConnector implements
// Calculate minimum textarea width
getWidget().updateSuggestionPopupMinWidth();
- getWidget().popupOpenerClicked = false;
+ getWidget().setPopupOpenerClicked(false);
/*
* if this is our first time we need to recalculate the root width.
@@ -263,7 +263,7 @@ public class ComboBoxConnector extends AbstractFieldConnector implements
* #11333
*/
private void navigateItemAfterPageChange() {
- if (getWidget().selectPopupItemWhenResponseIsReceived == VFilterSelect.Select.LAST) {
+ if (getWidget().getSelectPopupItemWhenResponseIsReceived() == VFilterSelect.Select.LAST) {
getWidget().suggestionPopup.selectLastItem();
} else {
getWidget().suggestionPopup.selectFirstItem();
@@ -283,8 +283,8 @@ public class ComboBoxConnector extends AbstractFieldConnector implements
if (!suggestionKey.equals(selectedKey)) {
continue;
}
- if (!getWidget().waitingForFilteringResponse
- || getWidget().popupOpenerClicked) {
+ if (!getWidget().isWaitingForFilteringResponse()
+ || getWidget().isPopupOpenerClicked()) {
if (!suggestionKey.equals(getWidget().selectedOptionKey)
|| suggestion.getReplacementString().equals(
getWidget().tb.getText())
@@ -313,8 +313,8 @@ public class ComboBoxConnector extends AbstractFieldConnector implements
}
private void resetSelection() {
- if (!getWidget().waitingForFilteringResponse
- || getWidget().popupOpenerClicked) {
+ if (!getWidget().isWaitingForFilteringResponse()
+ || getWidget().isPopupOpenerClicked()) {
// select nulled
if (!getWidget().focused) {
/*