From dca930baca68ec965407b7ab113eb0ef674452b5 Mon Sep 17 00:00:00 2001 From: Henri Sara Date: Tue, 10 Nov 2015 14:42:41 +0200 Subject: Move combo popup opener clicked flag to connector (#19929) The flag is only used by the connector to temporarily block certain operations. Change-Id: I90cabcb26d938a6db342ff549ac2e4b8d8998aeb --- client/src/com/vaadin/client/ui/VFilterSelect.java | 34 ++-------------------- .../client/ui/combobox/ComboBoxConnector.java | 32 ++++++++++++++++---- 2 files changed, 30 insertions(+), 36 deletions(-) diff --git a/client/src/com/vaadin/client/ui/VFilterSelect.java b/client/src/com/vaadin/client/ui/VFilterSelect.java index 7f23b6f84a..888c66bb87 100644 --- a/client/src/com/vaadin/client/ui/VFilterSelect.java +++ b/client/src/com/vaadin/client/ui/VFilterSelect.java @@ -1242,10 +1242,10 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler, public String selectedOptionKey; /** For internal use only. May be removed or replaced in the future. */ - public boolean waitingForFilteringResponse = false; + private boolean waitingForFilteringResponse = false; /** For internal use only. May be removed or replaced in the future. */ - public boolean updateSelectionWhenReponseIsReceived = false; + private boolean updateSelectionWhenReponseIsReceived = false; /** For internal use only. May be removed or replaced in the future. */ public boolean initDone = false; @@ -1292,15 +1292,6 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler, /** For internal use only. May be removed or replaced in the future. */ public boolean prompting = false; - /** - * Set true when popupopened has been clicked. Cleared on each UIDL-update. - * This handles the special case where are not filtering yet and the - * selected value has changed on the server-side. See #2119 - *

- * For internal use only. May be removed or replaced in the future. - */ - public boolean popupOpenerClicked; - /** For internal use only. May be removed or replaced in the future. */ public int suggestionPopupMinWidth = 0; @@ -1978,7 +1969,7 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler, boolean immediate = focused || !connector.hasEventListener(EventId.FOCUS); filterOptions(-1, "", immediate); - setPopupOpenerClicked(true); + connector.popupOpenerClicked(); lastFilter = ""; } DOM.eventPreventDefault(DOM.eventGetCurrentEvent()); @@ -2364,23 +2355,4 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler, this.updateSelectionWhenReponseIsReceived = updateSelectionWhenReponseIsReceived; } - /** - * 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 7b66bcef6f..df6e800893 100644 --- a/client/src/com/vaadin/client/ui/combobox/ComboBoxConnector.java +++ b/client/src/com/vaadin/client/ui/combobox/ComboBoxConnector.java @@ -56,6 +56,15 @@ public class ComboBoxConnector extends AbstractFieldConnector implements private Runnable pageChangeCallback; + /** + * Set true when popupopened has been clicked. Cleared on each UIDL-update. + * This handles the special case where are not filtering yet and the + * selected value has changed on the server-side. See #2119 + *

+ * For internal use only. May be removed or replaced in the future. + */ + private boolean popupOpenerClicked; + @Override protected void init() { super.init(); @@ -216,7 +225,7 @@ public class ComboBoxConnector extends AbstractFieldConnector implements getWidget().setWaitingForFilteringResponse(false); - if (!getWidget().isPopupOpenerClicked()) { + if (!popupOpenerClicked) { navigateItemAfterPageChange(); } @@ -229,7 +238,7 @@ public class ComboBoxConnector extends AbstractFieldConnector implements // Calculate minimum textarea width getWidget().updateSuggestionPopupMinWidth(); - getWidget().setPopupOpenerClicked(false); + popupOpenerClicked = false; /* * if this is our first time we need to recalculate the root width. @@ -282,7 +291,7 @@ public class ComboBoxConnector extends AbstractFieldConnector implements continue; } if (!getWidget().isWaitingForFilteringResponse() - || getWidget().isPopupOpenerClicked()) { + || popupOpenerClicked) { if (!suggestionKey.equals(getWidget().selectedOptionKey) || suggestion.getReplacementString().equals( getWidget().tb.getText()) @@ -311,8 +320,7 @@ public class ComboBoxConnector extends AbstractFieldConnector implements } private void resetSelection() { - if (!getWidget().isWaitingForFilteringResponse() - || getWidget().isPopupOpenerClicked()) { + if (!getWidget().isWaitingForFilteringResponse() || popupOpenerClicked) { // select nulled if (!getWidget().focused) { /* @@ -493,4 +501,18 @@ public class ComboBoxConnector extends AbstractFieldConnector implements pageChangeCallback = null; } + /** + * Record that the popup opener has been clicked and the popup should be + * opened on the next request. + * + * This handles the special case where are not filtering yet and the + * selected value has changed on the server-side. See #2119. The flag is + * cleared on each UIDL reply. + * + * @since + */ + public void popupOpenerClicked() { + popupOpenerClicked = true; + } + } -- cgit v1.2.3