Send focus and blur events using RPC instead of in UIDL. This change does not use ConnectorFocusAndBlurHandler to preserve old timings. Change-Id: I1d58756e3955a11864b1ef00abcd27525a4db593feature/eventbus
@@ -2206,9 +2206,8 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler, | |||
// If a focus event is not going to be sent, send the options | |||
// request immediately; otherwise queue in the same burst as the | |||
// focus event. Fixes #8321. | |||
ApplicationConnection client = connector.getConnection(); | |||
boolean immediate = focused | |||
|| !client.hasEventListeners(this, EventId.FOCUS); | |||
|| !connector.hasEventListener(EventId.FOCUS); | |||
filterOptions(-1, "", immediate); | |||
popupOpenerClicked = true; | |||
lastFilter = ""; | |||
@@ -2303,14 +2302,12 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler, | |||
} | |||
addStyleDependentName("focus"); | |||
ApplicationConnection client = connector.getConnection(); | |||
if (client.hasEventListeners(this, EventId.FOCUS)) { | |||
client.updateVariable(paintableId, EventId.FOCUS, "", true); | |||
if (connector.sendFocusEvent()) { | |||
afterUpdateClientVariables(); | |||
} | |||
client.getVTooltip().showAssistive( | |||
connector.getTooltipInfo(getElement())); | |||
connector.getConnection().getVTooltip() | |||
.showAssistive(connector.getTooltipInfo(getElement())); | |||
} | |||
/** | |||
@@ -2366,9 +2363,7 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler, | |||
} | |||
removeStyleDependentName("focus"); | |||
ApplicationConnection client = connector.getConnection(); | |||
if (client.hasEventListeners(this, EventId.BLUR)) { | |||
client.updateVariable(paintableId, EventId.BLUR, "", true); | |||
if (connector.sendBlurEvent()) { | |||
afterUpdateClientVariables(); | |||
} | |||
} |
@@ -31,6 +31,8 @@ import com.vaadin.client.ui.AbstractFieldConnector; | |||
import com.vaadin.client.ui.SimpleManagedLayout; | |||
import com.vaadin.client.ui.VFilterSelect; | |||
import com.vaadin.client.ui.VFilterSelect.FilterSelectSuggestion; | |||
import com.vaadin.shared.EventId; | |||
import com.vaadin.shared.communication.FieldRpc.FocusAndBlurServerRpc; | |||
import com.vaadin.shared.ui.Connect; | |||
import com.vaadin.shared.ui.combobox.ComboBoxConstants; | |||
import com.vaadin.shared.ui.combobox.ComboBoxServerRpc; | |||
@@ -45,6 +47,9 @@ public class ComboBoxConnector extends AbstractFieldConnector implements | |||
protected ComboBoxServerRpc rpc = RpcProxy.create(ComboBoxServerRpc.class, | |||
this); | |||
protected FocusAndBlurServerRpc focusAndBlurRpc = RpcProxy.create( | |||
FocusAndBlurServerRpc.class, this); | |||
// oldSuggestionTextMatchTheOldSelection is used to detect when it's safe to | |||
// update textbox text by a changed item caption. | |||
private boolean oldSuggestionTextMatchTheOldSelection; | |||
@@ -440,4 +445,46 @@ public class ComboBoxConnector extends AbstractFieldConnector implements | |||
immediate); | |||
} | |||
/** | |||
* Notify the server that the combo box received focus. | |||
* | |||
* For timing reasons, ConnectorFocusAndBlurHandler is not used at the | |||
* moment. | |||
* | |||
* This method is for internal use only and may be removed in future | |||
* versions. | |||
* | |||
* @since | |||
* @return true if an event was sent (there are registered listeners), false | |||
* otherwise | |||
*/ | |||
public boolean sendFocusEvent() { | |||
boolean registeredListeners = hasEventListener(EventId.FOCUS); | |||
if (registeredListeners) { | |||
focusAndBlurRpc.focus(); | |||
} | |||
return registeredListeners; | |||
} | |||
/** | |||
* Notify the server that the combo box lost focus. | |||
* | |||
* For timing reasons, ConnectorFocusAndBlurHandler is not used at the | |||
* moment. | |||
* | |||
* This method is for internal use only and may be removed in future | |||
* versions. | |||
* | |||
* @since | |||
* @return true if an event was sent (there are registered listeners), false | |||
* otherwise | |||
*/ | |||
public boolean sendBlurEvent() { | |||
boolean registeredListeners = hasEventListener(EventId.BLUR); | |||
if (registeredListeners) { | |||
focusAndBlurRpc.blur(); | |||
} | |||
return registeredListeners; | |||
} | |||
} |
@@ -29,6 +29,7 @@ import com.vaadin.data.util.filter.SimpleStringFilter; | |||
import com.vaadin.event.FieldEvents; | |||
import com.vaadin.event.FieldEvents.BlurEvent; | |||
import com.vaadin.event.FieldEvents.BlurListener; | |||
import com.vaadin.event.FieldEvents.FocusAndBlurServerRpcImpl; | |||
import com.vaadin.event.FieldEvents.FocusEvent; | |||
import com.vaadin.event.FieldEvents.FocusListener; | |||
import com.vaadin.server.PaintException; | |||
@@ -90,6 +91,13 @@ public class ComboBox extends AbstractSelect implements | |||
} | |||
}; | |||
FocusAndBlurServerRpcImpl focusBlurRpc = new FocusAndBlurServerRpcImpl(this) { | |||
@Override | |||
protected void fireEvent(LegacyEvent event) { | |||
ComboBox.this.fireEvent(event); | |||
} | |||
}; | |||
/** | |||
* Holds value of property pageLength. 0 disables paging. | |||
*/ | |||
@@ -170,6 +178,7 @@ public class ComboBox extends AbstractSelect implements | |||
*/ | |||
private void init() { | |||
registerRpc(rpc); | |||
registerRpc(focusBlurRpc); | |||
setNewItemsAllowed(false); | |||
setImmediate(true); | |||
@@ -759,14 +768,6 @@ public class ComboBox extends AbstractSelect implements | |||
} | |||
requestRepaint(); | |||
} | |||
if (variables.containsKey(FocusEvent.EVENT_ID)) { | |||
fireEvent(new FocusEvent(this)); | |||
} | |||
if (variables.containsKey(BlurEvent.EVENT_ID)) { | |||
fireEvent(new BlurEvent(this)); | |||
} | |||
} | |||
@Override |