]> source.dussan.org Git - vaadin-framework.git/commitdiff
Added ComboBox example
authorMarc Englund <marc.englund@itmill.com>
Thu, 29 Nov 2007 15:08:34 +0000 (15:08 +0000)
committerMarc Englund <marc.englund@itmill.com>
Thu, 29 Nov 2007 15:08:34 +0000 (15:08 +0000)
svn changeset:3045/svn branch:trunk

src/com/itmill/toolkit/demo/featurebrowser/ComboBoxExample.java [new file with mode: 0644]
src/com/itmill/toolkit/demo/featurebrowser/FeatureBrowser.java

diff --git a/src/com/itmill/toolkit/demo/featurebrowser/ComboBoxExample.java b/src/com/itmill/toolkit/demo/featurebrowser/ComboBoxExample.java
new file mode 100644 (file)
index 0000000..3c2da7d
--- /dev/null
@@ -0,0 +1,55 @@
+package com.itmill.toolkit.demo.featurebrowser;
+
+import com.itmill.toolkit.ui.ComboBox;
+import com.itmill.toolkit.ui.CustomComponent;
+import com.itmill.toolkit.ui.OrderedLayout;
+import com.itmill.toolkit.ui.AbstractSelect.Filtering;
+
+/**
+ * 
+ */
+public class ComboBoxExample extends CustomComponent {
+
+    private static final String[] firstnames = new String[] { "John", "Mary",
+            "Joe", "Sarah", "Jeff", "Jane", "Peter", "Marc", "Robert", "Paula",
+            "Lenny", "Kenny", "Nathan", "Nicole", "Laura", "Jos", "Josie",
+            "Linus" };
+
+    private static final String[] lastnames = new String[] { "Torvalds",
+            "Smith", "Adams", "Black", "Wilson", "Richards", "Thompson",
+            "McGoff", "Halas", "Jones", "Beck", "Sheridan", "Picard", "Hill",
+            "Fielding", "Einstein" };
+
+    public ComboBoxExample() {
+        OrderedLayout main = new OrderedLayout();
+        main.setMargin(true);
+        setCompositionRoot(main);
+
+        // starts-with filter
+        ComboBox s1 = new ComboBox("Select with starts-with filter");
+        s1.setColumns(20);
+        for (int i = 0; i < 105; i++) {
+            s1
+                    .addItem(firstnames[(int) (Math.random() * (firstnames.length - 1))]
+                            + " "
+                            + lastnames[(int) (Math.random() * (lastnames.length - 1))]);
+        }
+        s1.setImmediate(true);
+        main.addComponent(s1);
+
+        // contains filter
+        ComboBox s2 = new ComboBox("Select with contains filter");
+        s2.setColumns(20);
+        for (int i = 0; i < 500; i++) {
+            s2
+                    .addItem(firstnames[(int) (Math.random() * (firstnames.length - 1))]
+                            + " "
+                            + lastnames[(int) (Math.random() * (lastnames.length - 1))]);
+        }
+        s2.setFilteringMode(Filtering.FILTERINGMODE_CONTAINS);
+        s2.setImmediate(true);
+        main.addComponent(s2);
+
+    }
+
+}
index 415ad744fc46baa91cdc9318b6667522fdc8d138..9f9fc7add487c3100fe6e8a746d6c54538c22233 100644 (file)
@@ -69,7 +69,7 @@ public class FeatureBrowser extends com.itmill.toolkit.Application implements
                     Button.class, Boolean.FALSE },
             // Organizing: ComboBox
             { "Organizing", "ComboBox", "ComboBox - the swiss army select",
-                    Button.class, Boolean.FALSE },
+                    ComboBoxExample.class, Boolean.FALSE },
             // Organizing: Table
             { "Organizing", "Table", "A dynamic Table with bells and whistles",
                     Button.class, Boolean.FALSE },