summaryrefslogtreecommitdiffstats
path: root/src/com/itmill/toolkit/demo
diff options
context:
space:
mode:
authorMarc Englund <marc.englund@itmill.com>2009-02-18 08:57:46 +0000
committerMarc Englund <marc.englund@itmill.com>2009-02-18 08:57:46 +0000
commita8b70dce24aa94572f288cfbca4866a729bb48b1 (patch)
tree3e8757f79826b10e24af6afb81a6d11fe9de6e86 /src/com/itmill/toolkit/demo
parent4d578184a5583463d2ad82b957807f374c740989 (diff)
downloadvaadin-framework-a8b70dce24aa94572f288cfbca4866a729bb48b1.tar.gz
vaadin-framework-a8b70dce24aa94572f288cfbca4866a729bb48b1.zip
Made Sampler examples that sort container use non-static container, for obvious reasons...
svn changeset:6890/svn branch:trunk
Diffstat (limited to 'src/com/itmill/toolkit/demo')
-rw-r--r--src/com/itmill/toolkit/demo/sampler/ExampleUtil.java44
-rw-r--r--src/com/itmill/toolkit/demo/sampler/features/form/FormPojoExample.java2
-rw-r--r--src/com/itmill/toolkit/demo/sampler/features/selects/ComboBoxContainsExample.java4
-rw-r--r--src/com/itmill/toolkit/demo/sampler/features/selects/ComboBoxStartsWithExample.java4
4 files changed, 33 insertions, 21 deletions
diff --git a/src/com/itmill/toolkit/demo/sampler/ExampleUtil.java b/src/com/itmill/toolkit/demo/sampler/ExampleUtil.java
index 9a630543a0..8b39a9cd52 100644
--- a/src/com/itmill/toolkit/demo/sampler/ExampleUtil.java
+++ b/src/com/itmill/toolkit/demo/sampler/ExampleUtil.java
@@ -102,21 +102,7 @@ public final class ExampleUtil {
public static final Object hw_PROPERTY_NAME = "name";
private static final IndexedContainer iso3166Container = new IndexedContainer();
static {
- iso3166Container.addContainerProperty(iso3166_PROPERTY_NAME,
- String.class, null);
- iso3166Container.addContainerProperty(iso3166_PROPERTY_SHORT,
- String.class, null);
- iso3166Container.addContainerProperty(iso3166_PROPERTY_FLAG,
- Resource.class, null);
- for (int i = 0; i < iso3166.length; i++) {
- String name = iso3166[i++];
- String id = iso3166[i];
- Item item = iso3166Container.addItem(id);
- item.getItemProperty(iso3166_PROPERTY_NAME).setValue(name);
- item.getItemProperty(iso3166_PROPERTY_SHORT).setValue(id);
- item.getItemProperty(iso3166_PROPERTY_FLAG).setValue(
- new ThemeResource("flags/" + id.toLowerCase() + ".gif"));
- }
+ fillIso3166Container(iso3166Container);
}
public static final Object locale_PROPERTY_LOCALE = "locale";
@@ -189,10 +175,36 @@ public final class ExampleUtil {
return localeContainer;
}
- public static IndexedContainer getISO3166Container() {
+ public static IndexedContainer getStaticISO3166Container() {
return iso3166Container;
}
+ public static IndexedContainer getISO3166Container() {
+ IndexedContainer c = new IndexedContainer();
+ fillIso3166Container(c);
+ return c;
+ }
+
+ private static void fillIso3166Container(IndexedContainer container) {
+ container.addContainerProperty(iso3166_PROPERTY_NAME, String.class,
+ null);
+ container.addContainerProperty(iso3166_PROPERTY_SHORT, String.class,
+ null);
+ container.addContainerProperty(iso3166_PROPERTY_FLAG, Resource.class,
+ null);
+ for (int i = 0; i < iso3166.length; i++) {
+ String name = iso3166[i++];
+ String id = iso3166[i];
+ Item item = container.addItem(id);
+ item.getItemProperty(iso3166_PROPERTY_NAME).setValue(name);
+ item.getItemProperty(iso3166_PROPERTY_SHORT).setValue(id);
+ item.getItemProperty(iso3166_PROPERTY_FLAG).setValue(
+ new ThemeResource("flags/" + id.toLowerCase() + ".gif"));
+ }
+ container.sort(new Object[] { iso3166_PROPERTY_NAME },
+ new boolean[] { true });
+ }
+
public static HierarchicalContainer getHardwareContainer() {
Item item = null;
int itemId = 0; // Increasing numbering for itemId:s
diff --git a/src/com/itmill/toolkit/demo/sampler/features/form/FormPojoExample.java b/src/com/itmill/toolkit/demo/sampler/features/form/FormPojoExample.java
index f350aed613..a4e3e0f731 100644
--- a/src/com/itmill/toolkit/demo/sampler/features/form/FormPojoExample.java
+++ b/src/com/itmill/toolkit/demo/sampler/features/form/FormPojoExample.java
@@ -101,7 +101,7 @@ public class FormPojoExample extends VerticalLayout {
public PersonFieldFactory() {
countries.setWidth("30em");
- countries.setContainerDataSource(ExampleUtil.getISO3166Container());
+ countries.setContainerDataSource(ExampleUtil.getStaticISO3166Container());
countries
.setItemCaptionPropertyId(ExampleUtil.iso3166_PROPERTY_NAME);
countries.setItemIconPropertyId(ExampleUtil.iso3166_PROPERTY_FLAG);
diff --git a/src/com/itmill/toolkit/demo/sampler/features/selects/ComboBoxContainsExample.java b/src/com/itmill/toolkit/demo/sampler/features/selects/ComboBoxContainsExample.java
index 4c170bde6d..20fcb0ffe7 100644
--- a/src/com/itmill/toolkit/demo/sampler/features/selects/ComboBoxContainsExample.java
+++ b/src/com/itmill/toolkit/demo/sampler/features/selects/ComboBoxContainsExample.java
@@ -16,7 +16,7 @@ public class ComboBoxContainsExample extends VerticalLayout implements
// Creates a new combobox using an existing container
ComboBox l = new ComboBox("Please select your country", ExampleUtil
- .getISO3166Container());
+ .getStaticISO3166Container());
// Sets the combobox to show a certain property as the item caption
l.setItemCaptionPropertyId(ExampleUtil.iso3166_PROPERTY_NAME);
@@ -43,7 +43,7 @@ public class ComboBoxContainsExample extends VerticalLayout implements
* Shows a notification when a selection is made.
*/
public void valueChange(ValueChangeEvent event) {
- Property selected = ExampleUtil.getISO3166Container()
+ Property selected = ExampleUtil.getStaticISO3166Container()
.getContainerProperty(event.getProperty().toString(), "name");
getWindow().showNotification("Selected country: " + selected);
}
diff --git a/src/com/itmill/toolkit/demo/sampler/features/selects/ComboBoxStartsWithExample.java b/src/com/itmill/toolkit/demo/sampler/features/selects/ComboBoxStartsWithExample.java
index e0909c9eb1..c06df628dc 100644
--- a/src/com/itmill/toolkit/demo/sampler/features/selects/ComboBoxStartsWithExample.java
+++ b/src/com/itmill/toolkit/demo/sampler/features/selects/ComboBoxStartsWithExample.java
@@ -16,7 +16,7 @@ public class ComboBoxStartsWithExample extends VerticalLayout implements
// Creates a new combobox using an existing container
ComboBox l = new ComboBox("Please select your country", ExampleUtil
- .getISO3166Container());
+ .getStaticISO3166Container());
// Sets the combobox to show a certain property as the item caption
l.setItemCaptionPropertyId(ExampleUtil.iso3166_PROPERTY_NAME);
@@ -43,7 +43,7 @@ public class ComboBoxStartsWithExample extends VerticalLayout implements
* Shows a notification when a selection is made.
*/
public void valueChange(ValueChangeEvent event) {
- Property selected = ExampleUtil.getISO3166Container()
+ Property selected = ExampleUtil.getStaticISO3166Container()
.getContainerProperty(event.getProperty().toString(), "name");
getWindow().showNotification("Selected country: " + selected);
}