summaryrefslogtreecommitdiffstats
path: root/src/com/itmill/toolkit
diff options
context:
space:
mode:
authorMarko Grönroos <magi@iki.fi>2008-05-30 16:27:18 +0000
committerMarko Grönroos <magi@iki.fi>2008-05-30 16:27:18 +0000
commite9eaef41d0278bc08fbb1f631a891e1c8b241000 (patch)
treec208d9fa12f1ea475c52061f4a8d58d31fde2a81 /src/com/itmill/toolkit
parentc6127ec35780e6cdf14cd16055b26c3ba32d7407 (diff)
downloadvaadin-framework-e9eaef41d0278bc08fbb1f631a891e1c8b241000.tar.gz
vaadin-framework-e9eaef41d0278bc08fbb1f631a891e1c8b241000.zip
Better table example for manual.
svn changeset:4719/svn branch:trunk
Diffstat (limited to 'src/com/itmill/toolkit')
-rw-r--r--src/com/itmill/toolkit/tests/book/BookTestApplication.java15
-rw-r--r--src/com/itmill/toolkit/tests/book/TableExample1.java43
-rw-r--r--src/com/itmill/toolkit/tests/book/TableExample2.java62
3 files changed, 114 insertions, 6 deletions
diff --git a/src/com/itmill/toolkit/tests/book/BookTestApplication.java b/src/com/itmill/toolkit/tests/book/BookTestApplication.java
index 9e024b25a3..e0e524c964 100644
--- a/src/com/itmill/toolkit/tests/book/BookTestApplication.java
+++ b/src/com/itmill/toolkit/tests/book/BookTestApplication.java
@@ -62,7 +62,7 @@ public class BookTestApplication extends com.itmill.toolkit.Application {
int getwincount = 0;
public void init() {
- setTheme("tests-magi");
+ setTheme("tests-book");
setMainWindow(main);
}
@@ -96,11 +96,11 @@ public class BookTestApplication extends com.itmill.toolkit.Application {
main.setLayout(new OrderedLayout());
if (example.equals("index")) {
- final Object examples[] = { "defaultbutton", "label",
+ final String examples[] = { "defaultbutton", "label",
"labelcontent", "tree", "embedded", "textfield",
"textfieldvalidation", "datefield", "button",
"select/select", "select/native", "select/optiongroup",
- "select/twincol", "filterselect", "validator", "table",
+ "select/twincol", "filterselect", "validator", "table", "table/select",
"upload", "link", "gridlayout", "orderedlayout",
"formlayout", "panel", "expandlayout", "tabsheet",
"alignment", "alignment/grid", "window", "window/opener",
@@ -109,8 +109,8 @@ public class BookTestApplication extends com.itmill.toolkit.Application {
"customlayout", "spacing", "margin", "clientinfo",
"fillinform/templates"};
for (int i = 0; i < examples.length; i++) {
- main.addComponent(new Label("<a href='/tk/testbench2/"
- + examples[i] + "'>" + examples[i] + "</a>",
+ main.addComponent(new Label("<a href='" + context.toString() +
+ examples[i] + "'>" + examples[i] + "</a>",
Label.CONTENT_XHTML));
}
return null;
@@ -494,7 +494,10 @@ public class BookTestApplication extends com.itmill.toolkit.Application {
}
void example_Table(Window main, String param) {
- main.addComponent(new TableExample());
+ if (param.equals("select")) {
+ main.addComponent(new TableExample2());
+ } else
+ main.addComponent(new TableExample1());
}
void example_Upload(Window main, String param) {
diff --git a/src/com/itmill/toolkit/tests/book/TableExample1.java b/src/com/itmill/toolkit/tests/book/TableExample1.java
new file mode 100644
index 0000000000..6b76a89df9
--- /dev/null
+++ b/src/com/itmill/toolkit/tests/book/TableExample1.java
@@ -0,0 +1,43 @@
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+
+package com.itmill.toolkit.tests.book;
+
+import com.itmill.toolkit.data.Property;
+import com.itmill.toolkit.data.Property.ValueChangeEvent;
+import com.itmill.toolkit.ui.CustomComponent;
+import com.itmill.toolkit.ui.Label;
+import com.itmill.toolkit.ui.OrderedLayout;
+import com.itmill.toolkit.ui.Table;
+
+public class TableExample1 extends CustomComponent {
+ /* A layout needed for the example. */
+ OrderedLayout layout = new OrderedLayout(OrderedLayout.ORIENTATION_VERTICAL);
+
+ TableExample1() {
+ setCompositionRoot(layout);
+
+ /* Create the table with a caption. */
+ Table table = new Table("This is my Table");
+
+ /* Define the names and data types of columns.
+ * The "default value" parameter is meaningless here. */
+ table.addContainerProperty("First Name", String.class, null);
+ table.addContainerProperty("Last Name", String.class, null);
+ table.addContainerProperty("Year", Integer.class, null);
+
+ /* Add a few items in the table. */
+ table.addItem(new Object[] {"Nicolaus","Copernicus",new Integer(1473)}, new Integer(1));
+ table.addItem(new Object[] {"Tycho", "Brahe", new Integer(1546)}, new Integer(2));
+ table.addItem(new Object[] {"Giordano","Bruno", new Integer(1548)}, new Integer(3));
+ table.addItem(new Object[] {"Galileo", "Galilei", new Integer(1564)}, new Integer(4));
+ table.addItem(new Object[] {"Johannes","Kepler", new Integer(1571)}, new Integer(5));
+ table.addItem(new Object[] {"Isaac", "Newton", new Integer(1643)}, new Integer(6));
+
+ /* Set number of visible rows. */
+ table.setPageLength(5);
+
+ layout.addComponent(table);
+ }
+}
diff --git a/src/com/itmill/toolkit/tests/book/TableExample2.java b/src/com/itmill/toolkit/tests/book/TableExample2.java
new file mode 100644
index 0000000000..f82c96c68d
--- /dev/null
+++ b/src/com/itmill/toolkit/tests/book/TableExample2.java
@@ -0,0 +1,62 @@
+/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+
+package com.itmill.toolkit.tests.book;
+
+import com.itmill.toolkit.data.Property;
+import com.itmill.toolkit.data.Property.ValueChangeEvent;
+import com.itmill.toolkit.ui.CustomComponent;
+import com.itmill.toolkit.ui.Label;
+import com.itmill.toolkit.ui.OrderedLayout;
+import com.itmill.toolkit.ui.Table;
+
+public class TableExample2 extends CustomComponent {
+ /* A layout needed for the example. */
+ OrderedLayout layout = new OrderedLayout(OrderedLayout.ORIENTATION_VERTICAL);
+
+ TableExample2() {
+ setCompositionRoot(layout);
+
+ /* Create the table with a caption. */
+ final Table table = new Table();
+
+ /* Define the names and data types of columns.
+ * The "default value" parameter is meaningless here. */
+ table.addContainerProperty("First Name", String.class, null);
+ table.addContainerProperty("Last Name", String.class, null);
+ table.addContainerProperty("Year", Integer.class, null);
+
+ /* Add a few items in the table. */
+ table.addItem(new Object[] {"Nicolaus","Copernicus",new Integer(1473)}, new Integer(1));
+ table.addItem(new Object[] {"Tycho", "Brahe", new Integer(1546)}, new Integer(2));
+ table.addItem(new Object[] {"Giordano","Bruno", new Integer(1548)}, new Integer(3));
+ table.addItem(new Object[] {"Galileo", "Galilei", new Integer(1564)}, new Integer(4));
+ table.addItem(new Object[] {"Johannes","Kepler", new Integer(1571)}, new Integer(5));
+ table.addItem(new Object[] {"Isaac", "Newton", new Integer(1643)}, new Integer(6));
+
+ /* Set number of visible rows. */
+ table.setPageLength(5);
+
+ /* Allow selecting items from the table. */
+ table.setSelectable(true);
+
+ /* When an item is selected, the selection is sent immediately to server. */
+ table.setImmediate(true);
+
+ /* Feedback from selection. */
+ final Label current = new Label("Selected: -");
+
+ /* Handle selection change. */
+ table.addListener(new Property.ValueChangeListener() {
+ public void valueChange(ValueChangeEvent event) {
+ current.setValue("Selected: " + table.getValue());
+ }
+ });
+
+ table.setNullSelectionAllowed(false);
+
+ layout.addComponent(table);
+ layout.addComponent(current);
+ }
+}