aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenri Sara <hesara@vaadin.com>2015-11-09 12:42:25 +0200
committerHenri Sara <hesara@vaadin.com>2016-01-15 14:42:57 +0200
commit4bc60dad87f68d7da451799c8300c97ba632a2a8 (patch)
tree2eaf59a08742e6401a7644282cc9b765ea64ea4b
parentcdd9a98241fadcd2254267e733cbb99f675f7e1e (diff)
downloadvaadin-framework-4bc60dad87f68d7da451799c8300c97ba632a2a8.tar.gz
vaadin-framework-4bc60dad87f68d7da451799c8300c97ba632a2a8.zip
Move ComboBox filtering mode to state (#19929)
Change-Id: Ida38de55e1fc06aa6ec5e693f34cd5bc14ac4fc5
-rw-r--r--client/src/com/vaadin/client/ui/combobox/ComboBoxConnector.java8
-rw-r--r--server/src/com/vaadin/ui/ComboBox.java14
-rw-r--r--shared/src/com/vaadin/shared/ui/combobox/ComboBoxState.java7
3 files changed, 14 insertions, 15 deletions
diff --git a/client/src/com/vaadin/client/ui/combobox/ComboBoxConnector.java b/client/src/com/vaadin/client/ui/combobox/ComboBoxConnector.java
index e763895690..5c22e684f8 100644
--- a/client/src/com/vaadin/client/ui/combobox/ComboBoxConnector.java
+++ b/client/src/com/vaadin/client/ui/combobox/ComboBoxConnector.java
@@ -36,7 +36,6 @@ import com.vaadin.shared.communication.FieldRpc.FocusAndBlurServerRpc;
import com.vaadin.shared.ui.Connect;
import com.vaadin.shared.ui.combobox.ComboBoxServerRpc;
import com.vaadin.shared.ui.combobox.ComboBoxState;
-import com.vaadin.shared.ui.combobox.FilteringMode;
import com.vaadin.ui.ComboBox;
@Connect(ComboBox.class)
@@ -82,6 +81,8 @@ public class ComboBoxConnector extends AbstractFieldConnector implements
getWidget().pageLength = getState().pageLength;
+ getWidget().filteringmode = getState().filteringMode;
+
Profiler.leave("ComboBoxConnector.onStateChanged update content");
}
@@ -100,11 +101,6 @@ public class ComboBoxConnector extends AbstractFieldConnector implements
// not a FocusWidget -> needs own tabindex handling
getWidget().tb.setTabIndex(getState().tabIndex);
- if (uidl.hasAttribute("filteringmode")) {
- getWidget().filteringmode = FilteringMode.valueOf(uidl
- .getStringAttribute("filteringmode"));
- }
-
getWidget().nullSelectionAllowed = uidl.hasAttribute("nullselect");
getWidget().nullSelectItem = uidl.hasAttribute("nullselectitem")
diff --git a/server/src/com/vaadin/ui/ComboBox.java b/server/src/com/vaadin/ui/ComboBox.java
index 42996803d3..dc064e925b 100644
--- a/server/src/com/vaadin/ui/ComboBox.java
+++ b/server/src/com/vaadin/ui/ComboBox.java
@@ -115,8 +115,6 @@ public class ComboBox extends AbstractSelect implements
// Current page when the user is 'paging' trough options
private int currentPage = -1;
- private FilteringMode filteringMode = FilteringMode.STARTSWITH;
-
private String filterstring;
private String prevfilterstring;
@@ -207,7 +205,7 @@ public class ComboBox extends AbstractSelect implements
private boolean isFilteringNeeded() {
return filterstring != null && filterstring.length() > 0
- && filteringMode != FilteringMode.OFF;
+ && getFilteringMode() != FilteringMode.OFF;
}
@Override
@@ -240,8 +238,6 @@ public class ComboBox extends AbstractSelect implements
String[] selectedKeys = new String[(getValue() == null
&& getNullSelectionItemId() == null ? 0 : 1)];
- target.addAttribute("filteringmode", getFilteringMode().toString());
-
// Paints the options and create array of selected id keys
int keyIndex = 0;
@@ -438,7 +434,7 @@ public class ComboBox extends AbstractSelect implements
Filterable filterable = (Filterable) container;
- Filter filter = buildFilter(filterstring, filteringMode);
+ Filter filter = buildFilter(filterstring, getFilteringMode());
// adding and removing filters leads to extraneous item set
// change events from the underlying container, but the ComboBox does
@@ -693,7 +689,7 @@ public class ComboBox extends AbstractSelect implements
} else {
caption = caption.toLowerCase(getLocale());
}
- switch (filteringMode) {
+ switch (getFilteringMode()) {
case CONTAINS:
if (caption.indexOf(filterstring) > -1) {
filteredOptions.add(itemId);
@@ -736,12 +732,12 @@ public class ComboBox extends AbstractSelect implements
@Override
public void setFilteringMode(FilteringMode filteringMode) {
- this.filteringMode = filteringMode;
+ getState().filteringMode = filteringMode;
}
@Override
public FilteringMode getFilteringMode() {
- return filteringMode;
+ return getState(false).filteringMode;
}
@Override
diff --git a/shared/src/com/vaadin/shared/ui/combobox/ComboBoxState.java b/shared/src/com/vaadin/shared/ui/combobox/ComboBoxState.java
index 21bf4b9340..6eae3fc46e 100644
--- a/shared/src/com/vaadin/shared/ui/combobox/ComboBoxState.java
+++ b/shared/src/com/vaadin/shared/ui/combobox/ComboBoxState.java
@@ -48,4 +48,11 @@ public class ComboBoxState extends AbstractSelectState {
* Number of items to show per page or 0 to disable paging.
*/
public int pageLength = 10;
+
+ /**
+ * Current filtering mode (look for match of the user typed string in the
+ * beginning of the item caption or anywhere in the item caption).
+ */
+ public FilteringMode filteringMode = FilteringMode.STARTSWITH;
+
}