summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenri Sara <hesara@vaadin.com>2016-09-13 12:29:26 +0300
committerVaadin Code Review <review@vaadin.com>2016-09-13 09:55:37 +0000
commite8397bf3c96a0be1c3c635f99c1b1dfacd058a89 (patch)
tree62245a580d6d337cf7335f3a8227809f1d0a83d5
parentd08c72efa5519a8d90fc301911efc9dc8db9e055 (diff)
downloadvaadin-framework-e8397bf3c96a0be1c3c635f99c1b1dfacd058a89.tar.gz
vaadin-framework-e8397bf3c96a0be1c3c635f99c1b1dfacd058a89.zip
Make ComboBoxConnector extend AbstractListingConnector
Change-Id: I146b13d99b77beb2cf99019c5878b26f61b69b6c
-rw-r--r--client/src/main/java/com/vaadin/client/ui/combobox/ComboBoxConnector.java24
-rw-r--r--shared/src/main/java/com/vaadin/shared/ui/combobox/ComboBoxState.java4
2 files changed, 11 insertions, 17 deletions
diff --git a/client/src/main/java/com/vaadin/client/ui/combobox/ComboBoxConnector.java b/client/src/main/java/com/vaadin/client/ui/combobox/ComboBoxConnector.java
index d0758b726b..56db5b56cb 100644
--- a/client/src/main/java/com/vaadin/client/ui/combobox/ComboBoxConnector.java
+++ b/client/src/main/java/com/vaadin/client/ui/combobox/ComboBoxConnector.java
@@ -18,9 +18,10 @@ package com.vaadin.client.ui.combobox;
import com.vaadin.client.Profiler;
import com.vaadin.client.communication.RpcProxy;
import com.vaadin.client.communication.StateChangeEvent;
+import com.vaadin.client.connectors.AbstractListingConnector;
import com.vaadin.client.connectors.data.HasDataSource;
import com.vaadin.client.data.DataSource;
-import com.vaadin.client.ui.AbstractFieldConnector;
+import com.vaadin.client.ui.HasErrorIndicator;
import com.vaadin.client.ui.SimpleManagedLayout;
import com.vaadin.client.ui.VComboBox;
import com.vaadin.client.ui.VComboBox.DataReceivedHandler;
@@ -28,6 +29,7 @@ import com.vaadin.shared.EventId;
import com.vaadin.shared.Registration;
import com.vaadin.shared.communication.FieldRpc.FocusAndBlurServerRpc;
import com.vaadin.shared.data.DataCommunicatorConstants;
+import com.vaadin.shared.data.selection.SelectionModel;
import com.vaadin.shared.ui.Connect;
import com.vaadin.shared.ui.combobox.ComboBoxClientRpc;
import com.vaadin.shared.ui.combobox.ComboBoxConstants;
@@ -38,8 +40,9 @@ import com.vaadin.ui.ComboBox;
import elemental.json.JsonObject;
@Connect(ComboBox.class)
-public class ComboBoxConnector extends AbstractFieldConnector
- implements HasDataSource, SimpleManagedLayout {
+public class ComboBoxConnector
+ extends AbstractListingConnector<SelectionModel.Single<?>>
+ implements HasDataSource, SimpleManagedLayout, HasErrorIndicator {
protected ComboBoxServerRpc rpc = RpcProxy.create(ComboBoxServerRpc.class,
this);
@@ -47,8 +50,6 @@ public class ComboBoxConnector extends AbstractFieldConnector
protected FocusAndBlurServerRpc focusAndBlurRpc = RpcProxy
.create(FocusAndBlurServerRpc.class, this);
- private DataSource<JsonObject> dataSource;
-
private Registration dataChangeHandlerRegistration;
@Override
@@ -245,7 +246,7 @@ public class ComboBoxConnector extends AbstractFieldConnector
@Override
public void setDataSource(DataSource<JsonObject> dataSource) {
- this.dataSource = dataSource;
+ super.setDataSource(dataSource);
dataChangeHandlerRegistration = dataSource
.addDataChangeHandler(range -> {
// try to find selected item if requested
@@ -258,8 +259,7 @@ public class ComboBoxConnector extends AbstractFieldConnector
for (int i = 0; i < getDataSource().size(); ++i) {
JsonObject row = getDataSource().getRow(i);
if (row != null) {
- String key = row.getString(
- DataCommunicatorConstants.KEY);
+ String key = getRowKey(row);
if (getWidget().selectedOptionKey.equals(key)) {
if (getWidget().nullSelectionAllowed) {
getWidget().currentPage = (i + 1)
@@ -304,8 +304,7 @@ public class ComboBoxConnector extends AbstractFieldConnector
JsonObject row = getDataSource().getRow(i);
if (row != null) {
- String key = row
- .getString(DataCommunicatorConstants.KEY);
+ String key = getRowKey(row);
String caption = row
.getString(DataCommunicatorConstants.NAME);
String style = row
@@ -331,9 +330,4 @@ public class ComboBoxConnector extends AbstractFieldConnector
dataChangeHandlerRegistration.remove();
}
- @Override
- public DataSource<JsonObject> getDataSource() {
- return dataSource;
- }
-
}
diff --git a/shared/src/main/java/com/vaadin/shared/ui/combobox/ComboBoxState.java b/shared/src/main/java/com/vaadin/shared/ui/combobox/ComboBoxState.java
index 72d10b87d6..7aa4cbfc72 100644
--- a/shared/src/main/java/com/vaadin/shared/ui/combobox/ComboBoxState.java
+++ b/shared/src/main/java/com/vaadin/shared/ui/combobox/ComboBoxState.java
@@ -15,16 +15,16 @@
*/
package com.vaadin.shared.ui.combobox;
-import com.vaadin.shared.AbstractFieldState;
import com.vaadin.shared.annotations.DelegateToWidget;
import com.vaadin.shared.annotations.NoLayout;
+import com.vaadin.shared.ui.TabIndexState;
/**
* Shared state for the ComboBox component.
*
* @since 7.0
*/
-public class ComboBoxState extends AbstractFieldState {
+public class ComboBoxState extends TabIndexState {
{
// TODO ideally this would be v-combobox, but that would affect a lot of
// themes