]> source.dussan.org Git - vaadin-framework.git/commitdiff
Make ComboBoxConnector extend AbstractListingConnector
authorHenri Sara <hesara@vaadin.com>
Tue, 13 Sep 2016 09:29:26 +0000 (12:29 +0300)
committerVaadin Code Review <review@vaadin.com>
Tue, 13 Sep 2016 09:55:37 +0000 (09:55 +0000)
Change-Id: I146b13d99b77beb2cf99019c5878b26f61b69b6c

client/src/main/java/com/vaadin/client/ui/combobox/ComboBoxConnector.java
shared/src/main/java/com/vaadin/shared/ui/combobox/ComboBoxState.java

index d0758b726bd24191b65a2af28b0269b83e9f0e9a..56db5b56cb977d75e85ad468c373608201609a3b 100644 (file)
@@ -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;
-    }
-
 }
index 72d10b87d6601e09b72d800aebeb7fb32491cbbb..7aa4cbfc727a5f7b1a4c47e36e9bbc3a82666ccf 100644 (file)
  */
 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