aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenri Sara <hesara@vaadin.com>2015-11-09 12:33:07 +0200
committerHenri Sara <hesara@vaadin.com>2016-01-15 14:42:57 +0200
commitcdd9a98241fadcd2254267e733cbb99f675f7e1e (patch)
tree40b747e6d52918c9f155efd277011c6cce129be6
parent733a33ab8dde7af788ff207d84e8cd8b1972cc1a (diff)
downloadvaadin-framework-cdd9a98241fadcd2254267e733cbb99f675f7e1e.tar.gz
vaadin-framework-cdd9a98241fadcd2254267e733cbb99f675f7e1e.zip
Move ComboBox pageLength to state (#19929)
Use shared state for the page length and update related tests. This change also removes an unused widget field. Change-Id: Id8719661121a9570be40028da09e32f27bec82b5
-rw-r--r--client/src/com/vaadin/client/ui/VFilterSelect.java3
-rw-r--r--client/src/com/vaadin/client/ui/combobox/ComboBoxConnector.java5
-rw-r--r--server/src/com/vaadin/ui/ComboBox.java31
-rw-r--r--shared/src/com/vaadin/shared/ui/combobox/ComboBoxState.java4
-rw-r--r--uitest/src/com/vaadin/tests/components/combobox/Comboboxes.java2
-rw-r--r--uitest/src/com/vaadin/tests/layouts/MovingComponentsWhileOldParentInvisible.java2
6 files changed, 17 insertions, 30 deletions
diff --git a/client/src/com/vaadin/client/ui/VFilterSelect.java b/client/src/com/vaadin/client/ui/VFilterSelect.java
index 82c324e186..a783b957bc 100644
--- a/client/src/com/vaadin/client/ui/VFilterSelect.java
+++ b/client/src/com/vaadin/client/ui/VFilterSelect.java
@@ -1229,9 +1229,6 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler,
public ComboBoxConnector connector;
/** For internal use only. May be removed or replaced in the future. */
- public String paintableId;
-
- /** For internal use only. May be removed or replaced in the future. */
public int currentPage;
/**
diff --git a/client/src/com/vaadin/client/ui/combobox/ComboBoxConnector.java b/client/src/com/vaadin/client/ui/combobox/ComboBoxConnector.java
index 3af86d324c..e763895690 100644
--- a/client/src/com/vaadin/client/ui/combobox/ComboBoxConnector.java
+++ b/client/src/com/vaadin/client/ui/combobox/ComboBoxConnector.java
@@ -80,6 +80,8 @@ public class ComboBoxConnector extends AbstractFieldConnector implements
getWidget().inputPrompt = "";
}
+ getWidget().pageLength = getState().pageLength;
+
Profiler.leave("ComboBoxConnector.onStateChanged update content");
}
@@ -91,9 +93,6 @@ public class ComboBoxConnector extends AbstractFieldConnector implements
*/
@Override
public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
- // Save details
- getWidget().paintableId = uidl.getId();
-
if (!isRealUpdate(uidl)) {
return;
}
diff --git a/server/src/com/vaadin/ui/ComboBox.java b/server/src/com/vaadin/ui/ComboBox.java
index 271e273c46..42996803d3 100644
--- a/server/src/com/vaadin/ui/ComboBox.java
+++ b/server/src/com/vaadin/ui/ComboBox.java
@@ -112,11 +112,6 @@ public class ComboBox extends AbstractSelect implements
}
};
- /**
- * Holds value of property pageLength. 0 disables paging.
- */
- protected int pageLength = 10;
-
// Current page when the user is 'paging' trough options
private int currentPage = -1;
@@ -222,11 +217,6 @@ public class ComboBox extends AbstractSelect implements
// clear caption change listeners
getCaptionChangeListener().clear();
- // The tab ordering number
- if (getTabIndex() != 0) {
- target.addAttribute("tabindex", getTabIndex());
- }
-
// If the field is modified, but not committed, set modified
// attribute
if (isModified()) {
@@ -250,8 +240,6 @@ public class ComboBox extends AbstractSelect implements
String[] selectedKeys = new String[(getValue() == null
&& getNullSelectionItemId() == null ? 0 : 1)];
- target.addAttribute("pagelength", pageLength);
-
target.addAttribute("filteringmode", getFilteringMode().toString());
// Paints the options and create array of selected id keys
@@ -435,7 +423,7 @@ public class ComboBox extends AbstractSelect implements
protected List<?> getOptionsWithFilter(boolean needNullSelectOption) {
Container container = getContainerDataSource();
- if (pageLength == 0 && !isFilteringNeeded()) {
+ if (getPageLength() == 0 && !isFilteringNeeded()) {
// no paging or filtering: return all items
filteredSize = container.size();
assert filteredSize >= 0;
@@ -557,7 +545,7 @@ public class ComboBox extends AbstractSelect implements
*/
private List<?> sanitetizeList(List<?> options, boolean needNullSelectOption) {
- if (pageLength != 0 && options.size() > pageLength) {
+ if (getPageLength() != 0 && options.size() > getPageLength()) {
int indexToEnsureInView = -1;
@@ -602,7 +590,7 @@ public class ComboBox extends AbstractSelect implements
int size) {
// Not all options are visible, find out which ones are on the
// current "page".
- int first = currentPage * pageLength;
+ int first = currentPage * getPageLength();
if (needNullSelectOption && currentPage > 0) {
first--;
}
@@ -629,7 +617,7 @@ public class ComboBox extends AbstractSelect implements
private int getLastItemIndexOnCurrentPage(boolean needNullSelectOption,
int size, int first) {
// page length usable for non-null items
- int effectivePageLength = pageLength
+ int effectivePageLength = getPageLength()
- (needNullSelectOption && (currentPage == 0) ? 1 : 0);
return Math.min(size - 1, first + effectivePageLength - 1);
}
@@ -657,12 +645,12 @@ public class ComboBox extends AbstractSelect implements
int indexToEnsureInView, int size) {
if (indexToEnsureInView != -1) {
int newPage = (indexToEnsureInView + (needNullSelectOption ? 1 : 0))
- / pageLength;
+ / getPageLength();
page = newPage;
}
// adjust the current page if beyond the end of the list
- if (page * pageLength > size) {
- page = (size + (needNullSelectOption ? 1 : 0)) / pageLength;
+ if (page * getPageLength() > size) {
+ page = (size + (needNullSelectOption ? 1 : 0)) / getPageLength();
}
return page;
}
@@ -856,7 +844,7 @@ public class ComboBox extends AbstractSelect implements
* @return the pageLength
*/
public int getPageLength() {
- return pageLength;
+ return getState(false).pageLength;
}
/**
@@ -867,8 +855,7 @@ public class ComboBox extends AbstractSelect implements
* the pageLength to set
*/
public void setPageLength(int pageLength) {
- this.pageLength = pageLength;
- markAsDirty();
+ getState().pageLength = pageLength;
}
/**
diff --git a/shared/src/com/vaadin/shared/ui/combobox/ComboBoxState.java b/shared/src/com/vaadin/shared/ui/combobox/ComboBoxState.java
index 1856aac00d..21bf4b9340 100644
--- a/shared/src/com/vaadin/shared/ui/combobox/ComboBoxState.java
+++ b/shared/src/com/vaadin/shared/ui/combobox/ComboBoxState.java
@@ -44,4 +44,8 @@ public class ComboBoxState extends AbstractSelectState {
*/
public String inputPrompt = null;
+ /**
+ * Number of items to show per page or 0 to disable paging.
+ */
+ public int pageLength = 10;
}
diff --git a/uitest/src/com/vaadin/tests/components/combobox/Comboboxes.java b/uitest/src/com/vaadin/tests/components/combobox/Comboboxes.java
index 5b2608b389..cf754d3fee 100644
--- a/uitest/src/com/vaadin/tests/components/combobox/Comboboxes.java
+++ b/uitest/src/com/vaadin/tests/components/combobox/Comboboxes.java
@@ -78,7 +78,7 @@ public class Comboboxes extends ComponentTestCase<ComboBox> {
public class PageLength0ComboBox extends ComboBox {
public PageLength0ComboBox() {
super();
- pageLength = 0;
+ setPageLength(0);
}
}
diff --git a/uitest/src/com/vaadin/tests/layouts/MovingComponentsWhileOldParentInvisible.java b/uitest/src/com/vaadin/tests/layouts/MovingComponentsWhileOldParentInvisible.java
index 364a0e267a..04d318c62c 100644
--- a/uitest/src/com/vaadin/tests/layouts/MovingComponentsWhileOldParentInvisible.java
+++ b/uitest/src/com/vaadin/tests/layouts/MovingComponentsWhileOldParentInvisible.java
@@ -39,7 +39,7 @@ public class MovingComponentsWhileOldParentInvisible extends TestBase {
ComboBox componentContainerSelect = new ComboBox("Container") {
{
- pageLength = 0;
+ setPageLength(0);
}
};
componentContainerSelect.setId("componentContainerSelect");