]> source.dussan.org Git - vaadin-framework.git/commitdiff
ComboBox should have getter and setter methods for pageLength #5381 75/475/3
authorPekka Hyvönen <pekka@vaadin.com>
Tue, 11 Dec 2012 10:47:49 +0000 (12:47 +0200)
committerPekka Hyvönen <pekka@vaadin.com>
Tue, 11 Dec 2012 10:47:49 +0000 (12:47 +0200)
Change-Id: I92597e49f2dc12c9fb90c2a35a213386da56bb3f

server/src/com/vaadin/ui/ComboBox.java
uitest/src/com/vaadin/tests/components/combobox/ComboBoxPageLength.html [new file with mode: 0644]
uitest/src/com/vaadin/tests/components/combobox/ComboBoxPageLength.java [new file with mode: 0644]

index c35ecdb21fecaa99a08e0b5e5f010a87e251f599..3bf6ee992bff8c47f458a9cc559d8e088049d1b0 100644 (file)
@@ -791,6 +791,27 @@ public class ComboBox extends AbstractSelect implements
         return false;
     }
 
+    /**
+     * Returns the page length of the suggestion popup.
+     * 
+     * @return the pageLength
+     */
+    public int getPageLength() {
+        return pageLength;
+    }
+
+    /**
+     * Sets the page length for the suggestion popup. Setting the page length to
+     * 0 will disable suggestion popup paging (all items visible).
+     * 
+     * @param pageLength
+     *            the pageLength to set
+     */
+    public void setPageLength(int pageLength) {
+        this.pageLength = pageLength;
+        markAsDirty();
+    }
+
     /**
      * Sets whether to scroll the selected item visible (directly open the page
      * on which it is) when opening the combo box popup or not. Only applies to
diff --git a/uitest/src/com/vaadin/tests/components/combobox/ComboBoxPageLength.html b/uitest/src/com/vaadin/tests/components/combobox/ComboBoxPageLength.html
new file mode 100644 (file)
index 0000000..3f07827
--- /dev/null
@@ -0,0 +1,176 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head profile="http://selenium-ide.openqa.org/profiles/test-case">
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+<link rel="selenium.base" href="" />
+<title>SelectPageLength</title>
+</head>
+<body>
+<table cellpadding="1" cellspacing="1" border="1">
+<thead>
+<tr><td rowspan="1" colspan="3">SelectPageLength</td></tr>
+</thead><tbody>
+<tr>
+       <td>open</td>
+       <td>/run/com.vaadin.tests.components.combobox.ComboBoxPageLength?restartApplication</td>
+       <td></td>
+</tr>
+<tr>
+       <td>mouseClick</td>
+       <td>vaadin=runcomvaadintestscomponentscomboboxComboBoxPageLength::/VVerticalLayout[0]/VVerticalLayout[0]/VFilterSelect[0]#button</td>
+       <td>9,12</td>
+</tr>
+<tr>
+       <td>mouseClick</td>
+       <td>vaadin=runcomvaadintestscomponentscomboboxComboBoxPageLength::Root/VFilterSelect$SuggestionPopup[0]/VFilterSelect$SuggestionMenu[0]#item7</td>
+       <td>61,8</td>
+</tr>
+<tr>
+       <td>mouseClick</td>
+       <td>vaadin=runcomvaadintestscomponentscomboboxComboBoxPageLength::/VVerticalLayout[0]/VVerticalLayout[0]/VFilterSelect[0]#button</td>
+       <td>10,14</td>
+</tr>
+<tr>
+       <td>assertElementPresent</td>
+       <td>vaadin=runcomvaadintestscomponentscomboboxComboBoxPageLength::Root/VFilterSelect$SuggestionPopup[0]/VFilterSelect$SuggestionMenu[0]#item7</td>
+       <td>pagelength-8-page-1</td>
+</tr>
+<tr>
+       <td>assertElementNotPresent</td>
+       <td>vaadin=runcomvaadintestscomponentscomboboxComboBoxPageLength::Root/VFilterSelect$SuggestionPopup[0]/domChild[0]/domChild[1]/domChild[0]/domChild[0]/domChild[8]</td>
+       <td>pagelength-8-page-1</td>
+</tr>
+<tr>
+       <td>mouseClick</td>
+       <td>vaadin=runcomvaadintestscomponentscomboboxComboBoxPageLength::Root/VFilterSelect$SuggestionPopup[0]/domChild[0]/domChild[2]/domChild[0]</td>
+       <td>68,7</td>
+</tr>
+<tr>
+       <td>assertElementPresent</td>
+       <td>vaadin=runcomvaadintestscomponentscomboboxComboBoxPageLength::Root/VFilterSelect$SuggestionPopup[0]/VFilterSelect$SuggestionMenu[0]#item0</td>
+       <td>pagelength-8-page-2</td>
+</tr>
+<tr>
+       <td>assertElementPresent</td>
+       <td>vaadin=runcomvaadintestscomponentscomboboxComboBoxPageLength::Root/VFilterSelect$SuggestionPopup[0]/VFilterSelect$SuggestionMenu[0]#item7</td>
+       <td>pagelength-8-page-2</td>
+</tr>
+<tr>
+       <td>assertElementNotPresent</td>
+       <td>vaadin=runcomvaadintestscomponentscomboboxComboBoxPageLength::Root/VFilterSelect$SuggestionPopup[0]/domChild[0]/domChild[1]/domChild[0]/domChild[0]/domChild[8]</td>
+       <td>pagelength-8-page-2</td>
+</tr>
+<tr>
+       <td>mouseClick</td>
+       <td>vaadin=runcomvaadintestscomponentscomboboxComboBoxPageLength::Root/VFilterSelect$SuggestionPopup[0]/domChild[0]/domChild[2]/domChild[0]</td>
+       <td>68,7</td>
+</tr>
+<tr>
+       <td>assertElementPresent</td>
+       <td>vaadin=runcomvaadintestscomponentscomboboxComboBoxPageLength::Root/VFilterSelect$SuggestionPopup[0]/VFilterSelect$SuggestionMenu[0]#item0</td>
+       <td>pagelength-8-page-3</td>
+</tr>
+<tr>
+       <td>assertElementPresent</td>
+       <td>vaadin=runcomvaadintestscomponentscomboboxComboBoxPageLength::Root/VFilterSelect$SuggestionPopup[0]/VFilterSelect$SuggestionMenu[0]#item3</td>
+       <td>pagelength-8-page-3</td>
+</tr>
+<tr>
+       <td>waitForElementNotPresent</td>
+       <td>vaadin=runcomvaadintestscomponentscomboboxComboBoxPageLength::Root/VFilterSelect$SuggestionPopup[0]/domChild[0]/domChild[1]/domChild[0]/domChild[0]/domChild[4]</td>
+       <td></td>
+</tr>
+<tr>
+       <td>assertElementNotPresent</td>
+       <td>vaadin=runcomvaadintestscomponentscomboboxComboBoxPageLength::Root/VFilterSelect$SuggestionPopup[0]/domChild[0]/domChild[1]/domChild[0]/domChild[0]/domChild[4]</td>
+       <td>pagelength-8-page-3</td>
+</tr>
+<tr>
+       <td>mouseClick</td>
+       <td>vaadin=runcomvaadintestscomponentscomboboxComboBoxPageLength::Root/VFilterSelect$SuggestionPopup[0]/VFilterSelect$SuggestionMenu[0]#item3</td>
+       <td>38,6</td>
+</tr>
+<tr>
+       <td>mouseClick</td>
+       <td>vaadin=runcomvaadintestscomponentscomboboxComboBoxPageLength::/VVerticalLayout[0]/VVerticalLayout[0]/VFilterSelect[0]#button</td>
+       <td>7,9</td>
+</tr>
+<tr>
+       <td>assertElementPresent</td>
+       <td>vaadin=runcomvaadintestscomponentscomboboxComboBoxPageLength::Root/VFilterSelect$SuggestionPopup[0]/VFilterSelect$SuggestionMenu[0]#item0</td>
+       <td>pagelength-20-page-1</td>
+</tr>
+<tr>
+       <td>assertElementPresent</td>
+       <td>vaadin=runcomvaadintestscomponentscomboboxComboBoxPageLength::Root/VFilterSelect$SuggestionPopup[0]/VFilterSelect$SuggestionMenu[0]#item19</td>
+       <td>pagelength-20-page-1</td>
+</tr>
+<tr>
+       <td>assertElementNotPresent</td>
+       <td>vaadin=runcomvaadintestscomponentscomboboxComboBoxPageLength::Root/VFilterSelect$SuggestionPopup[0]/domChild[0]/domChild[1]/domChild[0]/domChild[0]/domChild[20]</td>
+       <td>pagelength-20-page-1</td>
+</tr>
+<tr>
+       <td>mouseClick</td>
+       <td>vaadin=runcomvaadintestscomponentscomboboxComboBoxPageLength::Root/VFilterSelect$SuggestionPopup[0]/VFilterSelect$SuggestionMenu[0]#item1</td>
+       <td>126,7</td>
+</tr>
+<tr>
+       <td>mouseClick</td>
+       <td>vaadin=runcomvaadintestscomponentscomboboxComboBoxPageLength::/VVerticalLayout[0]/VVerticalLayout[0]/VMenuBar[0]#item0</td>
+       <td>40,5</td>
+</tr>
+<tr>
+       <td>mouseClick</td>
+       <td>vaadin=runcomvaadintestscomponentscomboboxComboBoxPageLength::Root/VOverlay[0]/VMenuBar[0]#item4</td>
+       <td>18,11</td>
+</tr>
+<tr>
+       <td>mouseClick</td>
+       <td>vaadin=runcomvaadintestscomponentscomboboxComboBoxPageLength::Root/VOverlay[1]/VMenuBar[0]#item0</td>
+       <td>51,10</td>
+</tr>
+<tr>
+       <td>mouseClick</td>
+       <td>vaadin=runcomvaadintestscomponentscomboboxComboBoxPageLength::/VVerticalLayout[0]/VVerticalLayout[0]/VFilterSelect[0]#button</td>
+       <td>11,13</td>
+</tr>
+<tr>
+       <td>assertElementPresent</td>
+       <td>vaadin=runcomvaadintestscomponentscomboboxComboBoxPageLength::Root/VFilterSelect$SuggestionPopup[0]/VFilterSelect$SuggestionMenu[0]#item0</td>
+       <td>pagelength-2-page-2</td>
+</tr>
+<tr>
+       <td>assertElementPresent</td>
+       <td>vaadin=runcomvaadintestscomponentscomboboxComboBoxPageLength::Root/VFilterSelect$SuggestionPopup[0]/VFilterSelect$SuggestionMenu[0]#item1</td>
+       <td>pagelength-2-page-2</td>
+</tr>
+<tr>
+       <td>assertElementNotPresent</td>
+       <td>vaadin=runcomvaadintestscomponentscomboboxComboBoxPageLength::Root/VFilterSelect$SuggestionPopup[0]/domChild[0]/domChild[1]/domChild[0]/domChild[0]/domChild[2]</td>
+       <td>pagelength-2-page-2</td>
+</tr>
+<tr>
+       <td>mouseClick</td>
+       <td>vaadin=runcomvaadintestscomponentscomboboxComboBoxPageLength::Root/VFilterSelect$SuggestionPopup[0]/domChild[0]/domChild[0]/domChild[0]</td>
+       <td>78,4</td>
+</tr>
+<tr>
+       <td>assertElementPresent</td>
+       <td>vaadin=runcomvaadintestscomponentscomboboxComboBoxPageLength::Root/VFilterSelect$SuggestionPopup[0]/VFilterSelect$SuggestionMenu[0]#item0</td>
+       <td>pagelength-2-page-1</td>
+</tr>
+<tr>
+       <td>assertElementPresent</td>
+       <td>vaadin=runcomvaadintestscomponentscomboboxComboBoxPageLength::Root/VFilterSelect$SuggestionPopup[0]/VFilterSelect$SuggestionMenu[0]#item1</td>
+       <td>pagelength-2-page-1</td>
+</tr>
+<tr>
+       <td>assertElementNotPresent</td>
+       <td>vaadin=runcomvaadintestscomponentscomboboxComboBoxPageLength::Root/VFilterSelect$SuggestionPopup[0]/domChild[0]/domChild[1]/domChild[0]/domChild[0]/domChild[2]</td>
+       <td>pagelength-2-page-1</td>
+</tr>
+</tbody></table>
+</body>
+</html>
\ No newline at end of file
diff --git a/uitest/src/com/vaadin/tests/components/combobox/ComboBoxPageLength.java b/uitest/src/com/vaadin/tests/components/combobox/ComboBoxPageLength.java
new file mode 100644 (file)
index 0000000..6807b21
--- /dev/null
@@ -0,0 +1,40 @@
+package com.vaadin.tests.components.combobox;
+
+import com.vaadin.data.Property.ValueChangeEvent;
+import com.vaadin.data.Property.ValueChangeListener;
+import com.vaadin.ui.ComboBox;
+
+public class ComboBoxPageLength extends ComboBoxes2<ComboBox> {
+
+    @Override
+    public void initializeComponents() {
+        super.initializeComponents();
+        getComponent().addValueChangeListener(new ValueChangeListener() {
+
+            @Override
+            public void valueChange(ValueChangeEvent event) {
+                if (event.getProperty() != null) {
+                    if (event.getProperty().getValue() != null) {
+                        Integer value = Integer.parseInt(((String) event
+                                .getProperty().getValue()).split(" ")[1]);
+                        getComponent().setPageLength(value);
+                    } else {
+                        getComponent().setPageLength(0);
+                    }
+                }
+            }
+        });
+    }
+
+    @Override
+    protected Integer getTicketNumber() {
+        return 5381;
+    }
+
+    @Override
+    protected String getDescription() {
+        return super.getDescription()
+                + ", changing ComboBox value will change the ComboBox pageLength to the # of the selected item, or to 0 in null selection.";
+    }
+
+}