summaryrefslogtreecommitdiffstats
path: root/src/com/vaadin/demo/featurebrowser
diff options
context:
space:
mode:
authorArtur Signell <artur.signell@itmill.com>2009-10-27 07:57:12 +0000
committerArtur Signell <artur.signell@itmill.com>2009-10-27 07:57:12 +0000
commit6a3c715dae922edd723c9423b4308d5d7948b74e (patch)
tree46a007274681a9803afccf135ace5554f3e01e3a /src/com/vaadin/demo/featurebrowser
parent931d75fef69deb9b738fad97001cf5621de9f43e (diff)
downloadvaadin-framework-6a3c715dae922edd723c9423b4308d5d7948b74e.tar.gz
vaadin-framework-6a3c715dae922edd723c9423b4308d5d7948b74e.zip
Split demo and tests files to own source folders, for #3298
svn changeset:9390/svn branch:6.2
Diffstat (limited to 'src/com/vaadin/demo/featurebrowser')
-rw-r--r--src/com/vaadin/demo/featurebrowser/AccordionExample.java39
-rw-r--r--src/com/vaadin/demo/featurebrowser/ButtonExample.java140
-rw-r--r--src/com/vaadin/demo/featurebrowser/ClientCachingExample.java72
-rw-r--r--src/com/vaadin/demo/featurebrowser/ComboBoxExample.java71
-rw-r--r--src/com/vaadin/demo/featurebrowser/EmbeddedBrowserExample.java89
-rw-r--r--src/com/vaadin/demo/featurebrowser/FeatureBrowser.java383
-rw-r--r--src/com/vaadin/demo/featurebrowser/FormExample.java230
-rw-r--r--src/com/vaadin/demo/featurebrowser/GeneratedColumnExample.java559
-rw-r--r--src/com/vaadin/demo/featurebrowser/JavaScriptAPIExample.java98
-rw-r--r--src/com/vaadin/demo/featurebrowser/LabelExample.java78
-rw-r--r--src/com/vaadin/demo/featurebrowser/LayoutExample.java89
-rw-r--r--src/com/vaadin/demo/featurebrowser/NotificationExample.java96
-rw-r--r--src/com/vaadin/demo/featurebrowser/RichTextExample.java64
-rw-r--r--src/com/vaadin/demo/featurebrowser/SelectExample.java103
-rw-r--r--src/com/vaadin/demo/featurebrowser/TableExample.java300
-rw-r--r--src/com/vaadin/demo/featurebrowser/TreeExample.java163
-rw-r--r--src/com/vaadin/demo/featurebrowser/ValueInputExample.java147
-rw-r--r--src/com/vaadin/demo/featurebrowser/WindowingExample.java113
18 files changed, 0 insertions, 2834 deletions
diff --git a/src/com/vaadin/demo/featurebrowser/AccordionExample.java b/src/com/vaadin/demo/featurebrowser/AccordionExample.java
deleted file mode 100644
index 68cd94faf7..0000000000
--- a/src/com/vaadin/demo/featurebrowser/AccordionExample.java
+++ /dev/null
@@ -1,39 +0,0 @@
-package com.vaadin.demo.featurebrowser;
-
-import com.vaadin.ui.Accordion;
-import com.vaadin.ui.CustomComponent;
-import com.vaadin.ui.Label;
-import com.vaadin.ui.TextField;
-import com.vaadin.ui.VerticalLayout;
-
-/**
- * Accordion is a derivative of TabSheet, a vertical tabbed layout that places
- * the tab contents between the vertical tabs.
- */
-@SuppressWarnings("serial")
-public class AccordionExample extends CustomComponent {
- public AccordionExample() {
- // Create a new accordion
- final Accordion accordion = new Accordion();
- setCompositionRoot(accordion);
-
- // Add a few tabs to the accordion.
- for (int i = 0; i < 5; i++) {
- // Create a root component for a accordion tab
- VerticalLayout layout = new VerticalLayout();
- // The accordion tab label is taken from the caption of the root
- // component. Notice that layouts can have a caption too.
- layout.setCaption("Tab " + (i + 1));
-
- accordion.addComponent(layout);
-
- // Add some components in each accordion tab
- Label label = new Label("These are the contents of Tab " + (i + 1)
- + ".");
- layout.addComponent(label);
-
- TextField textfield = new TextField("Some text field");
- layout.addComponent(textfield);
- }
- }
-}
diff --git a/src/com/vaadin/demo/featurebrowser/ButtonExample.java b/src/com/vaadin/demo/featurebrowser/ButtonExample.java
deleted file mode 100644
index f67d6f4c7b..0000000000
--- a/src/com/vaadin/demo/featurebrowser/ButtonExample.java
+++ /dev/null
@@ -1,140 +0,0 @@
-/*
-@ITMillApache2LicenseForJavaFiles@
- */
-
-package com.vaadin.demo.featurebrowser;
-
-import com.vaadin.terminal.ExternalResource;
-import com.vaadin.terminal.ThemeResource;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.CheckBox;
-import com.vaadin.ui.CustomComponent;
-import com.vaadin.ui.HorizontalLayout;
-import com.vaadin.ui.Label;
-import com.vaadin.ui.Link;
-import com.vaadin.ui.Panel;
-import com.vaadin.ui.VerticalLayout;
-import com.vaadin.ui.Button.ClickEvent;
-
-/**
- * Shows a few variations of Buttons and Links.
- *
- * @author IT Mill Ltd.
- */
-@SuppressWarnings("serial")
-public class ButtonExample extends CustomComponent implements
- Button.ClickListener {
-
- public ButtonExample() {
-
- final VerticalLayout main = new VerticalLayout();
- main.setMargin(true);
- setCompositionRoot(main);
-
- final HorizontalLayout horiz = new HorizontalLayout();
- horiz.setWidth("100%");
- main.addComponent(horiz);
- final Panel basic = new Panel("Basic buttons");
- basic.setStyleName(Panel.STYLE_LIGHT);
- horiz.addComponent(basic);
-
- final Panel bells = new Panel("w/ bells & whistles");
- bells.setStyleName(Panel.STYLE_LIGHT);
- horiz.addComponent(bells);
-
- Button b = new Button("Basic button");
- b.addListener(this);
- basic.addComponent(b);
-
- b = new Button("Button w/ icon + tooltip");
- b.addListener(this);
- b.setIcon(new ThemeResource("icons/ok.png"));
- b.setDescription("This button does nothing, fast");
- bells.addComponent(b);
-
- b = new CheckBox("CheckBox - a switch-button");
- b.setImmediate(true); // checkboxes are not immediate by default
- b.addListener(this);
- basic.addComponent(b);
-
- b = new CheckBox("CheckBox w/ icon + tooltip");
- b.setImmediate(true); // checkboxes are not immediate by default
- b.addListener(this);
- b.setIcon(new ThemeResource("icons/ok.png"));
- b.setDescription("This is a CheckBox");
- bells.addComponent(b);
-
- b = new Button("Link-style button");
- b.addListener(this);
- b.setStyleName(Button.STYLE_LINK);
- basic.addComponent(b);
-
- b = new Button("Link button w/ icon + tooltip");
- b.addListener(this);
- b.setStyleName(Button.STYLE_LINK);
- b.setIcon(new ThemeResource("icons/ok.png"));
- b.setDescription("Link-style, icon+tootip, no caption");
- bells.addComponent(b);
-
- b = new Button();
- b.addListener(this);
- b.setStyleName(Button.STYLE_LINK);
- b.setIcon(new ThemeResource("icons/ok.png"));
- b.setDescription("Link-style, icon+tootip, no caption");
- basic.addComponent(b);
-
- final Panel links = new Panel("Links");
- links.setStyleName(Panel.STYLE_LIGHT);
- main.addComponent(links);
- final Label desc = new Label(
- "The main difference between a Link and"
- + " a link-styled Button is that the Link works client-"
- + " side, whereas the Button works server side.<br/> This means"
- + " that the Button triggers some event on the server,"
- + " while the Link is a normal web-link. <br/><br/>Note that for"
- + " opening new windows, the Link might be a safer "
- + " choice, since popup-blockers might interfer with "
- + " server-initiated window opening.");
- desc.setContentMode(Label.CONTENT_XHTML);
- links.addComponent(desc);
- Link l = new Link("Vaadin home", new ExternalResource(
- "http://www.vaadin.com"));
- l.setDescription("Link without target name, opens in this window");
- links.addComponent(l);
-
- l = new Link("Vaadin home (new window)", new ExternalResource(
- "http://www.vaadin.com"));
- l.setTargetName("_blank");
- l.setDescription("Link with target name, opens in new window");
- links.addComponent(l);
-
- l = new Link("Vaadin home (new window, less decor)",
- new ExternalResource("http://www.vaadin.com"));
- l.setTargetName("_blank");
- l.setTargetBorder(Link.TARGET_BORDER_MINIMAL);
- l.setTargetName("_blank");
- l
- .setDescription("Link with target name and BORDER_MINIMAL, opens in new window with less decor");
- links.addComponent(l);
-
- l = new Link("Vaadin home (new 200x200 window, no decor, icon)",
- new ExternalResource("http://www.vaadin.com"), "_blank", 200,
- 200, Link.TARGET_BORDER_NONE);
- l.setTargetName("_blank");
- l
- .setDescription("Link with target name and BORDER_NONE, opens in new window with no decor");
- l.setIcon(new ThemeResource("icons/ok.png"));
- links.addComponent(l);
-
- }
-
- public void buttonClick(ClickEvent event) {
- final Button b = event.getButton();
- getWindow().showNotification(
- "Clicked"
- + (b instanceof CheckBox ? ", value: "
- + event.getButton().getValue() : ""));
-
- }
-
-}
diff --git a/src/com/vaadin/demo/featurebrowser/ClientCachingExample.java b/src/com/vaadin/demo/featurebrowser/ClientCachingExample.java
deleted file mode 100644
index ad840c84c3..0000000000
--- a/src/com/vaadin/demo/featurebrowser/ClientCachingExample.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
-@ITMillApache2LicenseForJavaFiles@
- */
-
-package com.vaadin.demo.featurebrowser;
-
-import com.vaadin.terminal.PaintException;
-import com.vaadin.terminal.PaintTarget;
-import com.vaadin.ui.CustomComponent;
-import com.vaadin.ui.Label;
-import com.vaadin.ui.Layout;
-import com.vaadin.ui.TabSheet;
-import com.vaadin.ui.VerticalLayout;
-
-/**
- * This example is a (simple) demonstration of client-side caching. The content
- * in one tab is intentionally made very slow to produce server-side. When the
- * user changes to this tab for the first time, there will be a 3 second wait
- * before the content shows up, but the second time it shows up immediately
- * since the content has not changed and is cached client-side.
- *
- * @author IT Mill Ltd.
- */
-@SuppressWarnings("serial")
-public class ClientCachingExample extends CustomComponent {
-
- private static final String msg = "This example is a (simple) demonstration of client-side caching."
- + " The content in one tab is intentionally made very slow to"
- + " 'produce' server-side. When you changes to this tab for the"
- + " first time, there will be a 3 second wait before the content"
- + " shows up, but the second time it shows up immediately since the"
- + " content has not changed and is cached client-side.";
-
- public ClientCachingExample() {
-
- final VerticalLayout main = new VerticalLayout();
- main.setMargin(true);
- setCompositionRoot(main);
-
- main.addComponent(new Label(msg));
-
- final TabSheet ts = new TabSheet();
- main.addComponent(ts);
-
- Layout layout = new VerticalLayout();
- layout.setMargin(true);
- Label l = new Label("This is a normal label, quick to render.");
- l.setCaption("A normal label");
- layout.addComponent(l);
-
- ts.addTab(layout, "Normal", null);
-
- layout = new VerticalLayout();
- layout.setMargin(true);
- l = new Label("Slow label - until cached client side.") {
- @Override
- public void paintContent(PaintTarget target) throws PaintException {
- try {
- Thread.sleep(3000);
- } catch (final Exception e) {
- // IGNORED
- }
- super.paintContent(target);
- }
-
- };
- l.setCaption("A slow label");
- layout.addComponent(l);
- ts.addTab(layout, "Slow", null);
-
- }
-}
diff --git a/src/com/vaadin/demo/featurebrowser/ComboBoxExample.java b/src/com/vaadin/demo/featurebrowser/ComboBoxExample.java
deleted file mode 100644
index 60ccd23f27..0000000000
--- a/src/com/vaadin/demo/featurebrowser/ComboBoxExample.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
-@ITMillApache2LicenseForJavaFiles@
- */
-
-package com.vaadin.demo.featurebrowser;
-
-import java.util.Random;
-
-import com.vaadin.ui.ComboBox;
-import com.vaadin.ui.CustomComponent;
-import com.vaadin.ui.VerticalLayout;
-import com.vaadin.ui.AbstractSelect.Filtering;
-
-/**
- *
- */
-@SuppressWarnings("serial")
-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() {
- final VerticalLayout main = new VerticalLayout();
- main.setMargin(true);
- setCompositionRoot(main);
-
- // starts-with filter
- final ComboBox s1 = new ComboBox("Select with starts-with filter");
- s1.setFilteringMode(Filtering.FILTERINGMODE_STARTSWITH);
- s1.setWidth("20em");
- Random r = new Random(5);
- for (int i = 0; i < 105; i++) {
- s1
- .addItem(firstnames[(int) (r.nextDouble() * (firstnames.length - 1))]
- + " "
- + lastnames[(int) (r.nextDouble() * (lastnames.length - 1))]);
- }
- s1.setImmediate(true);
- main.addComponent(s1);
-
- // contains filter
- final ComboBox s2 = new ComboBox("Select with contains filter");
- s2.setFilteringMode(Filtering.FILTERINGMODE_CONTAINS);
- s2.setWidth("20em");
- for (int i = 0; i < 500; i++) {
- s2
- .addItem(firstnames[(int) (r.nextDouble() * (firstnames.length - 1))]
- + " "
- + lastnames[(int) (r.nextDouble() * (lastnames.length - 1))]);
- }
- s2.setImmediate(true);
- main.addComponent(s2);
-
- // initially empty
- final ComboBox s3 = new ComboBox("Initially empty; enter your own");
- s3.setWidth("20em");
- s3.setImmediate(true);
- s3.setNewItemsAllowed(true);
- main.addComponent(s3);
-
- }
-
-}
diff --git a/src/com/vaadin/demo/featurebrowser/EmbeddedBrowserExample.java b/src/com/vaadin/demo/featurebrowser/EmbeddedBrowserExample.java
deleted file mode 100644
index 641838dfdd..0000000000
--- a/src/com/vaadin/demo/featurebrowser/EmbeddedBrowserExample.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
-@ITMillApache2LicenseForJavaFiles@
- */
-
-package com.vaadin.demo.featurebrowser;
-
-import java.net.MalformedURLException;
-import java.net.URL;
-
-import com.vaadin.data.Property.ValueChangeEvent;
-import com.vaadin.terminal.ExternalResource;
-import com.vaadin.ui.Embedded;
-import com.vaadin.ui.Select;
-import com.vaadin.ui.VerticalLayout;
-import com.vaadin.ui.Window.Notification;
-
-/**
- * Demonstrates the use of Embedded and "suggesting" Select by creating a simple
- * web-browser. Note: does not check for recursion.
- *
- * @author IT Mill Ltd.
- * @see com.vaadin.ui.Window
- */
-@SuppressWarnings("serial")
-public class EmbeddedBrowserExample extends VerticalLayout implements
- Select.ValueChangeListener {
-
- // Default URL to open.
- private static final String DEFAULT_URL = "http://www.vaadin.com/";
-
- // The embedded page
- Embedded emb = new Embedded();
-
- public EmbeddedBrowserExample() {
- this(new String[] { DEFAULT_URL, "http://www.vaadin.com/learn",
- "http://www.vaadin.com/api", "http://www.vaadin.com/book" });
- }
-
- public EmbeddedBrowserExample(String[] urls) {
- setSizeFull();
-
- // create the address combobox
- final Select select = new Select();
- // allow input
- select.setNewItemsAllowed(true);
- // no empty selection
- select.setNullSelectionAllowed(false);
- // no 'go' -button clicking necessary
- select.setImmediate(true);
- // add some pre-configured URLs
- for (int i = 0; i < urls.length; i++) {
- select.addItem(urls[i]);
- }
- // add to layout
- addComponent(select);
- // add listener and select initial URL
- select.addListener(this);
- select.setValue(urls[0]);
-
- select.setWidth("100%");
-
- // configure the embedded and add to layout
- emb.setType(Embedded.TYPE_BROWSER);
- emb.setSizeFull();
- addComponent(emb);
- // make the embedded as large as possible
- setExpandRatio(emb, 1);
-
- }
-
- public void valueChange(ValueChangeEvent event) {
- final String url = (String) event.getProperty().getValue();
- if (url != null) {
- try {
- // the selected url has changed, let's go there
- @SuppressWarnings("unused")
- URL u = new URL(url);
- emb.setSource(new ExternalResource(url));
-
- } catch (MalformedURLException e) {
- getWindow().showNotification("Invalid address",
- e.getMessage() + " (example: http://www.vaadin.com)",
- Notification.TYPE_WARNING_MESSAGE);
- }
-
- }
-
- }
-}
diff --git a/src/com/vaadin/demo/featurebrowser/FeatureBrowser.java b/src/com/vaadin/demo/featurebrowser/FeatureBrowser.java
deleted file mode 100644
index 5b9e769015..0000000000
--- a/src/com/vaadin/demo/featurebrowser/FeatureBrowser.java
+++ /dev/null
@@ -1,383 +0,0 @@
-/*
-@ITMillApache2LicenseForJavaFiles@
- */
-
-package com.vaadin.demo.featurebrowser;
-
-import java.util.HashMap;
-import java.util.Iterator;
-
-import com.vaadin.data.Item;
-import com.vaadin.data.Property;
-import com.vaadin.data.Property.ValueChangeEvent;
-import com.vaadin.data.util.HierarchicalContainer;
-import com.vaadin.data.util.IndexedContainer;
-import com.vaadin.terminal.ExternalResource;
-import com.vaadin.terminal.ThemeResource;
-import com.vaadin.ui.AbstractSelect;
-import com.vaadin.ui.Alignment;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Component;
-import com.vaadin.ui.Embedded;
-import com.vaadin.ui.HorizontalLayout;
-import com.vaadin.ui.Label;
-import com.vaadin.ui.Layout;
-import com.vaadin.ui.Select;
-import com.vaadin.ui.SplitPanel;
-import com.vaadin.ui.TabSheet;
-import com.vaadin.ui.Table;
-import com.vaadin.ui.Tree;
-import com.vaadin.ui.VerticalLayout;
-import com.vaadin.ui.Window;
-import com.vaadin.ui.Button.ClickEvent;
-
-/**
- *
- * @author IT Mill Ltd.
- * @see com.vaadin.ui.Window
- */
-@SuppressWarnings("serial")
-public class FeatureBrowser extends com.vaadin.Application implements
- Select.ValueChangeListener {
-
- // Property IDs
- private static final Object PROPERTY_ID_CATEGORY = "Category";
- private static final Object PROPERTY_ID_NAME = "Name";
- private static final Object PROPERTY_ID_DESC = "Description";
- private static final Object PROPERTY_ID_CLASS = "Class";
- private static final Object PROPERTY_ID_VIEWED = "Viewed";
-
- // Global components
- private Tree tree;
- private Table table;
- private TabSheet ts;
-
- // Example "cache"
- private final HashMap<Class<?>, Component> exampleInstances = new HashMap<Class<?>, Component>();
- private String section;
-
- // List of examples
- private static final Object[][] demos = new Object[][] {
- // Category, Name, Desc, Class, Viewed
- // Getting started: Labels
- { "Getting started", "Labels", "Some variations of Labels",
- LabelExample.class },
- // Getting started: Buttons
- { "Getting started", "Buttons and links",
- "Various Buttons and Links", ButtonExample.class },
- // Getting started: Fields
- { "Getting started", "Basic value input",
- "TextFields, DateFields, and such", ValueInputExample.class },
- //
- { "Getting started", "RichText", "Rich text editing",
- RichTextExample.class },
- // Getting started: Selects
- { "Getting started", "Choices, choices",
- "Some variations of simple selects", SelectExample.class },
- // Layouts
- { "Layouts", "Basic layouts", "Laying out components",
- LayoutExample.class },
- // Layouts
- { "Layouts", "Accordion", "Play the Accordion!",
- AccordionExample.class },
- // Wrangling data: ComboBox
- { "Wrangling data", "ComboBox", "ComboBox - the swiss army select",
- ComboBoxExample.class },
- // Wrangling data: Table
- {
- "Wrangling data",
- "Table (\"grid\")",
- "Table with bells, whistles, editmode and actions (contextmenu)",
- TableExample.class },
- // Wrangling data: Form
- { "Wrangling data", "Form", "Every application needs forms",
- FormExample.class },
- // Wrangling data: Tree
- { "Wrangling data", "Tree", "A hierarchy of things",
- TreeExample.class },
- // Misc: Notifications
- { "Misc", "Notifications", "Notifications can improve usability",
- NotificationExample.class },
- // Misc: Caching
- { "Misc", "Client caching", "Demonstrating of client-side caching",
- ClientCachingExample.class },
- // Misc: Embedded
- { "Misc", "Embedding",
- "Embedding resources - another site in this case",
- EmbeddedBrowserExample.class },
- // Windowing
- { "Misc", "Windowing", "About windowing", WindowingExample.class },
- // JavaScript API
- { "Misc", "JavaScript API", "JavaScript to Vaadin communication",
- JavaScriptAPIExample.class },
- // END
- };
-
- @Override
- public void init() {
-
- // Need to set a theme for ThemeResources to work
- setTheme("example");
-
- // Create new window for the application and give the window a visible.
- final Window main = new Window("Vaadin 6");
- // set as main window
- setMainWindow(main);
-
- final SplitPanel split = new SplitPanel(
- SplitPanel.ORIENTATION_HORIZONTAL);
- split.setSplitPosition(200, SplitPanel.UNITS_PIXELS);
- main.setContent(split);
-
- final HashMap<String, Object> sectionIds = new HashMap<String, Object>();
- final HierarchicalContainer container = createContainer();
- final Object rootId = container.addItem();
- Item item = container.getItem(rootId);
- Property p = item.getItemProperty(PROPERTY_ID_NAME);
- p.setValue("All examples");
- for (int i = 0; i < demos.length; i++) {
- final Object[] demo = demos[i];
- final String section = (String) demo[0];
- Object sectionId;
- if (sectionIds.containsKey(section)) {
- sectionId = sectionIds.get(section);
- } else {
- sectionId = container.addItem();
- sectionIds.put(section, sectionId);
- container.setParent(sectionId, rootId);
- item = container.getItem(sectionId);
- p = item.getItemProperty(PROPERTY_ID_NAME);
- p.setValue(section);
- }
- final Object id = container.addItem();
- container.setParent(id, sectionId);
- initItem(container.getItem(id), demo);
-
- }
-
- tree = new Tree();
- tree.setDebugId("FeatureBrowser: Main Tree");
- tree.setSelectable(true);
- tree.setMultiSelect(false);
- tree.setNullSelectionAllowed(false);
- tree.setContainerDataSource(container);
- tree.setItemCaptionMode(AbstractSelect.ITEM_CAPTION_MODE_PROPERTY);
- tree.setItemCaptionPropertyId(PROPERTY_ID_NAME);
- tree.addListener(this);
- tree.setImmediate(true);
- tree.expandItemsRecursively(rootId);
- for (Iterator<?> i = container.getItemIds().iterator(); i.hasNext();) {
- Object id = i.next();
- if (container.getChildren(id) == null) {
- tree.setChildrenAllowed(id, false);
- }
- }
-
- split.addComponent(tree);
-
- final SplitPanel split2 = new SplitPanel();
- split2.setSplitPosition(200, SplitPanel.UNITS_PIXELS);
- split.addComponent(split2);
-
- table = new Table();
- table.setDebugId("FeatureBrowser: Main Table");
- table.setSizeFull();
- table.setColumnReorderingAllowed(true);
- table.setColumnCollapsingAllowed(true);
- table.setSelectable(true);
- table.setMultiSelect(false);
- table.setNullSelectionAllowed(false);
- try {
- table.setContainerDataSource((IndexedContainer) container.clone());
- } catch (final Exception e) {
- e.printStackTrace(System.err);
- }
- // Hide some columns
- table.setVisibleColumns(new Object[] { PROPERTY_ID_CATEGORY,
- PROPERTY_ID_NAME, PROPERTY_ID_DESC, PROPERTY_ID_VIEWED });
- table.addListener(this);
- table.setImmediate(true);
- split2.addComponent(table);
-
- final VerticalLayout exp = new VerticalLayout();
- exp.setSizeFull();
- exp.setMargin(true);
- split2.addComponent(exp);
-
- final HorizontalLayout wbLayout = new HorizontalLayout();
- Button b = new Button("Open in sub-window", new Button.ClickListener() {
- public void buttonClick(ClickEvent event) {
- Component component = (Component) ts.getComponentIterator()
- .next();
- String caption = ts.getTab(component).getCaption();
- try {
- component = component.getClass().newInstance();
- } catch (Exception e) {
- // Could not create
- return;
- }
- Window w = new Window(caption);
- w.setWidth("640px");
- if (Layout.class.isAssignableFrom(component.getClass())) {
- w.setContent((Layout) component);
- } else {
- // w.getLayout().getSize().setSizeFull();
- w.addComponent(component);
- }
- getMainWindow().addWindow(w);
- }
- });
- b.setStyleName(Button.STYLE_LINK);
- wbLayout.addComponent(b);
- b = new Button("Open in native window", new Button.ClickListener() {
- public void buttonClick(ClickEvent event) {
- Component component = (Component) ts.getComponentIterator()
- .next();
- final String caption = ts.getTab(component).getCaption();
- Window w = getWindow(caption);
- if (w == null) {
- try {
- component = component.getClass().newInstance();
- } catch (final Exception e) {
- // Could not create
- return;
- }
- w = new Window(caption);
- w.setName(caption);
- if (Layout.class.isAssignableFrom(component.getClass())) {
- w.setContent((Layout) component);
- } else {
- // w.getLayout().getSize().setSizeFull();
- w.addComponent(component);
- }
- addWindow(w);
- }
- getMainWindow().open(new ExternalResource(w.getURL()), caption);
- }
- });
- b.setStyleName(Button.STYLE_LINK);
- wbLayout.addComponent(b);
-
- exp.addComponent(wbLayout);
- exp.setComponentAlignment(wbLayout, Alignment.TOP_RIGHT);
-
- ts = new TabSheet();
- ts.setSizeFull();
- ts.addTab(new Label(""), "Choose example", null);
- exp.addComponent(ts);
- exp.setExpandRatio(ts, 1);
-
- final Label status = new Label(
- "<a href=\"http://www.vaadin.com/learn\">30 Seconds to Vaadin</a>"
- + " | <a href=\"http://www.vaadin.com/book\">Book of Vaadin</a>");
- status.setContentMode(Label.CONTENT_XHTML);
- exp.addComponent(status);
- exp.setComponentAlignment(status, Alignment.MIDDLE_RIGHT);
-
- // select initial section ("All")
- tree.setValue(rootId);
-
- getMainWindow()
- .showNotification(
- "Welcome",
- "Choose an example to begin.<br/><br/>And remember to experiment!",
- Window.Notification.TYPE_TRAY_NOTIFICATION);
- }
-
- private void initItem(Item item, Object[] data) {
- int p = 0;
- Property prop = item.getItemProperty(PROPERTY_ID_CATEGORY);
- prop.setValue(data[p++]);
- prop = item.getItemProperty(PROPERTY_ID_NAME);
- prop.setValue(data[p++]);
- prop = item.getItemProperty(PROPERTY_ID_DESC);
- prop.setValue(data[p++]);
- prop = item.getItemProperty(PROPERTY_ID_CLASS);
- prop.setValue(data[p++]);
- }
-
- private HierarchicalContainer createContainer() {
- final HierarchicalContainer c = new HierarchicalContainer();
- c.addContainerProperty(PROPERTY_ID_CATEGORY, String.class, null);
- c.addContainerProperty(PROPERTY_ID_NAME, String.class, "");
- c.addContainerProperty(PROPERTY_ID_DESC, String.class, "");
- c.addContainerProperty(PROPERTY_ID_CLASS, Class.class, null);
- c.addContainerProperty(PROPERTY_ID_VIEWED, Embedded.class, null);
- return c;
- }
-
- public void valueChange(ValueChangeEvent event) {
- if (event.getProperty() == tree) {
- final Object id = tree.getValue();
- if (id == null) {
- return;
- }
- final Item item = tree.getItem(id);
- //
- String newSection;
- if (tree.isRoot(id)) {
- newSection = ""; // show all sections
- } else if (tree.hasChildren(id)) {
- newSection = (String) item.getItemProperty(PROPERTY_ID_NAME)
- .getValue();
- } else {
- newSection = (String) item
- .getItemProperty(PROPERTY_ID_CATEGORY).getValue();
- }
-
- table.setValue(null);
- final IndexedContainer c = (IndexedContainer) table
- .getContainerDataSource();
-
- if (newSection != null && !newSection.equals(section)) {
- c.removeAllContainerFilters();
- c.addContainerFilter(PROPERTY_ID_CATEGORY, newSection, false,
- true);
- }
- section = newSection;
- if (!tree.hasChildren(id)) {
- // Example, not section
- // update table selection
- table.setValue(id);
- }
-
- } else if (event.getProperty() == table) {
- if (table.getValue() != null) {
- table.removeListener(this);
- tree.setValue(table.getValue());
- table.addListener(this);
- final Item item = table.getItem(table.getValue());
- final Class<?> c = (Class<?>) item.getItemProperty(
- PROPERTY_ID_CLASS).getValue();
- final Component component = getComponent(c);
- if (component != null) {
- final String caption = (String) item.getItemProperty(
- PROPERTY_ID_NAME).getValue();
- ts.removeAllComponents();
- ts.addTab(component, caption, null);
- }
- // update "viewed" state
- final Property p = item.getItemProperty(PROPERTY_ID_VIEWED);
- if (p.getValue() == null) {
- p.setValue(new Embedded("", new ThemeResource(
- "icons/ok.png")));
- }
- table.requestRepaint();
- }
- }
-
- }
-
- private Component getComponent(Class<?> componentClass) {
- if (!exampleInstances.containsKey(componentClass)) {
- try {
- final Component c = (Component) componentClass.newInstance();
- exampleInstances.put(componentClass, c);
- } catch (final Exception e) {
- return null;
- }
- }
- return exampleInstances.get(componentClass);
- }
-
-}
diff --git a/src/com/vaadin/demo/featurebrowser/FormExample.java b/src/com/vaadin/demo/featurebrowser/FormExample.java
deleted file mode 100644
index 52a2a98d80..0000000000
--- a/src/com/vaadin/demo/featurebrowser/FormExample.java
+++ /dev/null
@@ -1,230 +0,0 @@
-package com.vaadin.demo.featurebrowser;
-
-import com.vaadin.data.Item;
-import com.vaadin.data.Validator;
-import com.vaadin.data.Validator.InvalidValueException;
-import com.vaadin.data.util.BeanItem;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Component;
-import com.vaadin.ui.CustomComponent;
-import com.vaadin.ui.DefaultFieldFactory;
-import com.vaadin.ui.Field;
-import com.vaadin.ui.Form;
-import com.vaadin.ui.HorizontalLayout;
-import com.vaadin.ui.TextField;
-import com.vaadin.ui.VerticalLayout;
-import com.vaadin.ui.Button.ClickEvent;
-import com.vaadin.ui.Button.ClickListener;
-
-/**
- * This example demonstrates the most important features of the Form component:
- * binding Form to a JavaBean so that form fields are automatically generated
- * from the bean properties, creation of custom field editors using a
- * FieldFactory, customizing the form without FieldFactory, buffering
- * (commit/discard) and validation. Please note that the example is quite a bit
- * more complex than real use, as it tries to demonstrate more features than
- * needed in general case.
- */
-@SuppressWarnings("serial")
-public class FormExample extends CustomComponent {
-
- static final String cities[] = { "Amsterdam", "Berlin", "Helsinki",
- "Hong Kong", "London", "Luxemburg", "New York", "Oslo", "Paris",
- "Rome", "Stockholm", "Tokyo", "Turku" };
-
- /** Compose the demo. */
- public FormExample() {
-
- // Example data model
- final Address dataModel = new Address();
- Button peekDataModelState = new Button("Show the data model state",
- new Button.ClickListener() {
-
- public void buttonClick(ClickEvent event) {
- getWindow().showNotification(
- dataModel.getAddressAsText());
- }
- });
-
- // Example form
- final AddressForm form = new AddressForm("Contact Information");
- form.setDataSource(dataModel);
- form
- .setDescription("Please enter valid name and address. Fields marked with * are required. "
- + "If you try to commit with invalid values, a form error message is displayed. "
- + "(Address is required but failing to give it a value does not display an error.)");
-
- // Layout the example
- VerticalLayout root = new VerticalLayout();
- root.setMargin(true);
- root.setSpacing(true);
- root.addComponent(form);
- root.addComponent(peekDataModelState);
- setCompositionRoot(root);
- }
-
- public static class AddressForm extends Form {
- public AddressForm(String caption) {
-
- setCaption(caption);
-
- // Use custom field factory to modify the defaults on how the
- // components are created
- setFormFieldFactory(new MyFieldFactory());
-
- // Add Commit and Discard controls to the form.
-
- Button commit = new Button("Save", new ClickListener() {
-
- public void buttonClick(ClickEvent event) {
- try {
- commit();
- } catch (InvalidValueException e) {
- // Failed to commit. The validation errors are
- // automatically shown to the user.
- }
- }
-
- });
-
- Button discard = new Button("Reset", this, "discard");
- HorizontalLayout footer = new HorizontalLayout();
- footer.addComponent(commit);
- footer.addComponent(discard);
- setFooter(footer);
- }
-
- public void setDataSource(Address dataModel) {
-
- // Set the form to edit given datamodel by converting pojo used as
- // the datamodel to Item
- setItemDataSource(new BeanItem(dataModel));
-
- // Ensure that the fields are shown in correct order as the
- // datamodel does not force any specific order.
- setVisibleItemProperties(new String[] { "name", "streetAddress",
- "postalCode", "city" });
-
- // For examples sake, customize some of the form fields directly
- // here. The alternative way is to use custom field factory as shown
- // above.
- getField("name").setRequired(true);
- getField("name").setDescription("Please enter name");
- getField("name").setRequiredError("Name is missing");
- getField("streetAddress").setRequired(true); // No error message
- getField("streetAddress").setDescription(
- "Please enter street adderss.");
- getField("postalCode").setRequired(true); // No error message
- getField("postalCode").setDescription(
- "Please enter postal code. Example: 12345.");
- replaceWithSelect("city", cities, cities).setNewItemsAllowed(true);
- getField("city")
- .setDescription(
- "Select city from list or type it. City field is not required.");
-
- // Set the form to act immediately on user input. This is
- // automatically transports data between the client and the server
- // to do server-side validation.
- setImmediate(true);
-
- // Enable buffering so that commit() must be called for the form
- // before input is written to the data. (Form input is not written
- // immediately through to the underlying object.)
- setWriteThrough(false);
- }
- }
-
- /**
- * This is example on how to customize field creation. Any kind of field
- * components could be created on the fly.
- */
- static class MyFieldFactory extends DefaultFieldFactory {
-
- @Override
- public Field createField(Item item, Object propertyId,
- Component uiContext) {
-
- Field field = super.createField(item, propertyId, uiContext);
-
- if ("postalCode".equals(propertyId)) {
- ((TextField) field).setColumns(5);
- field.addValidator(new PostalCodeValidator());
- }
-
- return field;
- }
-
- }
-
- /**
- * This is an example of how to create a custom validator for automatic
- * input validation.
- */
- static class PostalCodeValidator implements Validator {
-
- public boolean isValid(Object value) {
- if (value == null || !(value instanceof String)) {
- return false;
- }
-
- return ((String) value).matches("[0-9]{5}");
- }
-
- public void validate(Object value) throws InvalidValueException {
- if (!isValid(value)) {
- throw new InvalidValueException(
- "Postal code must be a five digit number.");
- }
- }
- }
-
- /**
- * Contact information data model created as POJO. Note that in many cases
- * it would be a good idea to implement Item -interface for the datamodel to
- * make it directly bindable to form (without BeanItem wrapper)
- */
- public static class Address {
- String name = "";
- String streetAddress = "";
- String postalCode = "";
- String city;
-
- public String getAddressAsText() {
- return name + "\n" + streetAddress + "\n" + postalCode + " "
- + (city == null ? "" : city);
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public String getName() {
- return name;
- }
-
- public void setStreetAddress(String address) {
- streetAddress = address;
- }
-
- public String getStreetAddress() {
- return streetAddress;
- }
-
- public void setPostalCode(String postalCode) {
- this.postalCode = postalCode;
- }
-
- public String getPostalCode() {
- return postalCode;
- }
-
- public void setCity(String city) {
- this.city = city;
- }
-
- public String getCity() {
- return city;
- }
- }
-
-}
diff --git a/src/com/vaadin/demo/featurebrowser/GeneratedColumnExample.java b/src/com/vaadin/demo/featurebrowser/GeneratedColumnExample.java
deleted file mode 100644
index 0ce1afb511..0000000000
--- a/src/com/vaadin/demo/featurebrowser/GeneratedColumnExample.java
+++ /dev/null
@@ -1,559 +0,0 @@
-/*
-@ITMillApache2LicenseForJavaFiles@
- */
-
-package com.vaadin.demo.featurebrowser;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Date;
-import java.util.GregorianCalendar;
-
-import com.vaadin.data.Container;
-import com.vaadin.data.Item;
-import com.vaadin.data.Property;
-import com.vaadin.data.Container.Indexed;
-import com.vaadin.data.util.BeanItem;
-import com.vaadin.ui.AbstractField;
-import com.vaadin.ui.CheckBox;
-import com.vaadin.ui.Component;
-import com.vaadin.ui.CustomComponent;
-import com.vaadin.ui.DefaultFieldFactory;
-import com.vaadin.ui.Field;
-import com.vaadin.ui.Label;
-import com.vaadin.ui.Table;
-import com.vaadin.ui.VerticalLayout;
-import com.vaadin.ui.Button.ClickEvent;
-import com.vaadin.ui.Button.ClickListener;
-
-/**
- * This example demonstrates the use of generated columns in a table. Generated
- * columns can be used for formatting values or calculating them from other
- * columns (or properties of the items).
- *
- * For the data model, we use POJOs bound to a custom Container with BeanItem
- * items.
- *
- * @author magi
- */
-@SuppressWarnings("serial")
-public class GeneratedColumnExample extends CustomComponent {
- /**
- * The business model: fill-up at a gas station.
- */
- public class FillUp {
- Date date;
- double quantity;
- double total;
-
- public FillUp() {
- }
-
- public FillUp(int day, int month, int year, double quantity,
- double total) {
- date = new GregorianCalendar(year, month - 1, day).getTime();
- this.quantity = quantity;
- this.total = total;
- }
-
- /** Calculates price per unit of quantity (€/l). */
- public double price() {
- if (quantity != 0.0) {
- return total / quantity;
- } else {
- return 0.0;
- }
- }
-
- /** Calculates average daily consumption between two fill-ups. */
- public double dailyConsumption(FillUp other) {
- double difference_ms = date.getTime() - other.date.getTime();
- double days = difference_ms / 1000 / 3600 / 24;
- if (days < 0.5) {
- days = 1.0; // Avoid division by zero if two fill-ups on the
- // same day.
- }
- return quantity / days;
- }
-
- /** Calculates average daily consumption between two fill-ups. */
- public double dailyCost(FillUp other) {
- return price() * dailyConsumption(other);
- }
-
- // Getters and setters
-
- public Date getDate() {
- return date;
- }
-
- public void setDate(Date date) {
- this.date = date;
- }
-
- public double getQuantity() {
- return quantity;
- }
-
- public void setQuantity(double quantity) {
- this.quantity = quantity;
- }
-
- public double getTotal() {
- return total;
- }
-
- public void setTotal(double total) {
- this.total = total;
- }
- };
-
- /**
- * This is a custom container that allows adding BeanItems inside it. The
- * BeanItem objects must be bound to an object. The item ID is an Integer
- * from 0 to 99.
- *
- * Most of the interface methods are implemented with just dummy
- * implementations, as they are not needed in this example.
- */
- public class MySimpleIndexedContainer implements Container, Indexed {
- ArrayList<BeanItem> items;
- Object itemtemplate;
-
- public MySimpleIndexedContainer(Object itemtemplate) {
- this.itemtemplate = itemtemplate;
- items = new ArrayList<BeanItem>(); // Yeah this is just a test
- }
-
- public boolean addContainerProperty(Object propertyId, Class<?> type,
- Object defaultValue) throws UnsupportedOperationException {
- throw new UnsupportedOperationException();
- }
-
- public Item addItem(Object itemId) throws UnsupportedOperationException {
- throw new UnsupportedOperationException();
- }
-
- public Object addItem() throws UnsupportedOperationException {
- throw new UnsupportedOperationException();
- }
-
- /**
- * This addItem method is specific for this container and allows adding
- * BeanItem objects. The BeanItems must be bound to MyBean objects.
- */
- public void addItem(BeanItem item) throws UnsupportedOperationException {
- items.add(item);
- }
-
- public boolean containsId(Object itemId) {
- if (itemId instanceof Integer) {
- int pos = ((Integer) itemId).intValue();
- if (pos >= 0 && pos < items.size()) {
- return items.get(pos) != null;
- }
- }
- return false;
- }
-
- /**
- * The Table will call this method to get the property objects for the
- * columns. It uses the property objects to determine the data types of
- * the columns.
- */
- public Property getContainerProperty(Object itemId, Object propertyId) {
- if (itemId instanceof Integer) {
- int pos = ((Integer) itemId).intValue();
- if (pos >= 0 && pos < items.size()) {
- Item item = items.get(pos);
-
- // The BeanItem provides the property objects for the items.
- return item.getItemProperty(propertyId);
- }
- }
- return null;
- }
-
- /** Table calls this to get the column names. */
- public Collection<?> getContainerPropertyIds() {
- Item item = new BeanItem(itemtemplate);
-
- // The BeanItem knows how to get the property names from the bean.
- return item.getItemPropertyIds();
- }
-
- public Item getItem(Object itemId) {
- if (itemId instanceof Integer) {
- int pos = ((Integer) itemId).intValue();
- if (pos >= 0 && pos < items.size()) {
- return items.get(pos);
- }
- }
- return null;
- }
-
- public Collection<?> getItemIds() {
- ArrayList<Integer> ids = new ArrayList<Integer>(items.size());
- for (int i = 0; i < items.size(); i++) {
- ids.add(Integer.valueOf(i));
- }
- return ids;
- }
-
- public Class<?> getType(Object propertyId) {
- return BeanItem.class;
- }
-
- public boolean removeAllItems() throws UnsupportedOperationException {
- throw new UnsupportedOperationException();
- }
-
- public boolean removeContainerProperty(Object propertyId)
- throws UnsupportedOperationException {
- throw new UnsupportedOperationException();
- }
-
- public boolean removeItem(Object itemId)
- throws UnsupportedOperationException {
- throw new UnsupportedOperationException();
- }
-
- public int size() {
- return items.size();
- }
-
- public Object addItemAt(int index) throws UnsupportedOperationException {
- // TODO Auto-generated method stub
- return null;
- }
-
- public Item addItemAt(int index, Object newItemId)
- throws UnsupportedOperationException {
- // TODO Auto-generated method stub
- return null;
- }
-
- public Object getIdByIndex(int index) {
- return Integer.valueOf(index);
- }
-
- public int indexOfId(Object itemId) {
- return ((Integer) itemId).intValue();
- }
-
- public Object addItemAfter(Object previousItemId)
- throws UnsupportedOperationException {
- // TODO Auto-generated method stub
- return null;
- }
-
- public Item addItemAfter(Object previousItemId, Object newItemId)
- throws UnsupportedOperationException {
- // TODO Auto-generated method stub
- return null;
- }
-
- public Object firstItemId() {
- return new Integer(0);
- }
-
- public boolean isFirstId(Object itemId) {
- return ((Integer) itemId).intValue() == 0;
- }
-
- public boolean isLastId(Object itemId) {
- return ((Integer) itemId).intValue() == (items.size() - 1);
- }
-
- public Object lastItemId() {
- return new Integer(items.size() - 1);
- }
-
- public Object nextItemId(Object itemId) {
- int pos = indexOfId(itemId);
- if (pos >= items.size() - 1) {
- return null;
- }
- return getIdByIndex(pos + 1);
- }
-
- public Object prevItemId(Object itemId) {
- int pos = indexOfId(itemId);
- if (pos <= 0) {
- return null;
- }
- return getIdByIndex(pos - 1);
- }
- }
-
- /** Formats the dates in a column containing Date objects. */
- class DateColumnGenerator implements Table.ColumnGenerator {
- /**
- * Generates the cell containing the Date value. The column is
- * irrelevant in this use case.
- */
- public Component generateCell(Table source, Object itemId,
- Object columnId) {
- Property prop = source.getItem(itemId).getItemProperty(columnId);
- if (prop.getType().equals(Date.class)) {
- Label label = new Label(String.format("%tF",
- new Object[] { (Date) prop.getValue() }));
- label.addStyleName("column-type-date");
- return label;
- }
-
- return null;
- }
- }
-
- /** Formats the value in a column containing Double objects. */
- class ValueColumnGenerator implements Table.ColumnGenerator {
- String format; /* Format string for the Double values. */
-
- /** Creates double value column formatter with the given format string. */
- public ValueColumnGenerator(String format) {
- this.format = format;
- }
-
- /**
- * Generates the cell containing the Double value. The column is
- * irrelevant in this use case.
- */
- public Component generateCell(Table source, Object itemId,
- Object columnId) {
- Property prop = source.getItem(itemId).getItemProperty(columnId);
- if (prop.getType().equals(Double.class)) {
- Label label = new Label(String.format(format,
- new Object[] { (Double) prop.getValue() }));
-
- // Set styles for the column: one indicating that it's a value
- // and a more
- // specific one with the column name in it. This assumes that
- // the column
- // name is proper for CSS.
- label.addStyleName("column-type-value");
- label.addStyleName("column-" + (String) columnId);
- return label;
- }
- return null;
- }
- }
-
- /** Table column generator for calculating price column. */
- class PriceColumnGenerator implements Table.ColumnGenerator {
- public Component generateCell(Table source, Object itemId,
- Object columnId) {
- // Retrieve the item.
- BeanItem item = (BeanItem) source.getItem(itemId);
-
- // Retrieves the underlying POJO from the item.
- FillUp fillup = (FillUp) item.getBean();
-
- // Do the business logic
- double price = fillup.price();
-
- // Create the generated component for displaying the calcucated
- // value.
- Label label = new Label(String.format("%1.2f €",
- new Object[] { new Double(price) }));
-
- // We set the style here. You can't use a CellStyleGenerator for
- // generated columns.
- label.addStyleName("column-price");
- return label;
- }
- }
-
- /** Table column generator for calculating consumption column. */
- class ConsumptionColumnGenerator implements Table.ColumnGenerator {
- /**
- * Generates a cell containing value calculated from the item.
- */
- public Component generateCell(Table source, Object itemId,
- Object columnId) {
- Indexed indexedSource = (Indexed) source.getContainerDataSource();
-
- // Can not calculate consumption for the first item.
- if (indexedSource.isFirstId(itemId)) {
- Label label = new Label("N/A");
- label.addStyleName("column-consumption");
- return label;
- }
-
- // Index of the previous item.
- Object prevItemId = indexedSource.prevItemId(itemId);
-
- // Retrieve the POJOs.
- FillUp fillup = (FillUp) ((BeanItem) indexedSource.getItem(itemId))
- .getBean();
- FillUp prev = (FillUp) ((BeanItem) source.getItem(prevItemId))
- .getBean();
-
- // Do the business logic
- return generateCell(fillup, prev);
- }
-
- public Component generateCell(FillUp fillup, FillUp prev) {
- double consumption = fillup.dailyConsumption(prev);
-
- // Generate the component for displaying the calculated value.
- Label label = new Label(String.format("%3.2f l",
- new Object[] { new Double(consumption) }));
-
- // We set the style here. You can't use a CellStyleGenerator for
- // generated columns.
- label.addStyleName("column-consumption");
- return label;
- }
- }
-
- /** Table column generator for calculating daily cost column. */
- class DailyCostColumnGenerator extends ConsumptionColumnGenerator {
- @Override
- public Component generateCell(FillUp fillup, FillUp prev) {
- double dailycost = fillup.dailyCost(prev);
-
- // Generate the component for displaying the calculated value.
- Label label = new Label(String.format("%3.2f €",
- new Object[] { new Double(dailycost) }));
-
- // We set the style here. You can't use a CellStyleGenerator for
- // generated columns.
- label.addStyleName("column-dailycost");
- return label;
- }
- }
-
- /**
- * Custom field factory that sets the fields as immediate.
- */
- public class ImmediateFieldFactory extends DefaultFieldFactory {
- @Override
- public Field createField(Container container, Object itemId,
- Object propertyId, Component uiContext) {
- // Let the DefaultFieldFactory create the fields
- Field field = super.createField(container, itemId, propertyId,
- uiContext);
-
- // ...and just set them as immediate
- ((AbstractField) field).setImmediate(true);
-
- return field;
- }
- }
-
- public GeneratedColumnExample() {
- final Table table = new Table();
-
- // Define table columns. These include also the column for the generated
- // column, because we want to set the column label to something
- // different than the property ID.
- table
- .addContainerProperty("date", Date.class, null, "Date", null,
- null);
- table.addContainerProperty("quantity", Double.class, null,
- "Quantity (l)", null, null);
- table.addContainerProperty("price", Double.class, null, "Price (€/l)",
- null, null);
- table.addContainerProperty("total", Double.class, null, "Total (€)",
- null, null);
- table.addContainerProperty("consumption", Double.class, null,
- "Consumption (l/day)", null, null);
- table.addContainerProperty("dailycost", Double.class, null,
- "Daily Cost (€/day)", null, null);
-
- // Define the generated columns and their generators.
- table.addGeneratedColumn("date", new DateColumnGenerator());
- table
- .addGeneratedColumn("quantity", new ValueColumnGenerator(
- "%.2f l"));
- table.addGeneratedColumn("price", new PriceColumnGenerator());
- table.addGeneratedColumn("total", new ValueColumnGenerator("%.2f €"));
- table.addGeneratedColumn("consumption",
- new ConsumptionColumnGenerator());
- table.addGeneratedColumn("dailycost", new DailyCostColumnGenerator());
-
- // Create a data source and bind it to the table.
- MySimpleIndexedContainer data = new MySimpleIndexedContainer(
- new FillUp());
- table.setContainerDataSource(data);
-
- // Generated columns are automatically placed after property columns, so
- // we have to set the order of the columns explicitly.
- table.setVisibleColumns(new Object[] { "date", "quantity", "price",
- "total", "consumption", "dailycost" });
-
- // Add some data.
- data.addItem(new BeanItem(new FillUp(19, 2, 2005, 44.96, 51.21)));
- data.addItem(new BeanItem(new FillUp(30, 3, 2005, 44.91, 53.67)));
- data.addItem(new BeanItem(new FillUp(20, 4, 2005, 42.96, 49.06)));
- data.addItem(new BeanItem(new FillUp(23, 5, 2005, 47.37, 55.28)));
- data.addItem(new BeanItem(new FillUp(6, 6, 2005, 35.34, 41.52)));
- data.addItem(new BeanItem(new FillUp(30, 6, 2005, 16.07, 20.00)));
- data.addItem(new BeanItem(new FillUp(2, 7, 2005, 36.40, 36.19)));
- data.addItem(new BeanItem(new FillUp(6, 7, 2005, 39.17, 50.90)));
- data.addItem(new BeanItem(new FillUp(27, 7, 2005, 43.43, 53.03)));
- data.addItem(new BeanItem(new FillUp(17, 8, 2005, 20, 29.18)));
- data.addItem(new BeanItem(new FillUp(30, 8, 2005, 46.06, 59.09)));
- data.addItem(new BeanItem(new FillUp(22, 9, 2005, 46.11, 60.36)));
- data.addItem(new BeanItem(new FillUp(14, 10, 2005, 41.51, 50.19)));
- data.addItem(new BeanItem(new FillUp(12, 11, 2005, 35.24, 40.00)));
- data.addItem(new BeanItem(new FillUp(28, 11, 2005, 45.26, 53.27)));
-
- // Have a check box that allows the user to make the quantity
- // and total columns editable.
- final CheckBox editable = new CheckBox(
- "Edit the input values - calculated columns are regenerated");
- editable.setImmediate(true);
- editable.addListener(new ClickListener() {
- public void buttonClick(ClickEvent event) {
- table.setEditable(editable.booleanValue());
-
- // The columns may not be generated when we want to have them
- // editable.
- if (editable.booleanValue()) {
- table.removeGeneratedColumn("quantity");
- table.removeGeneratedColumn("total");
- } else {
- // In non-editable mode we want to show the formatted
- // values.
- table.addGeneratedColumn("quantity",
- new ValueColumnGenerator("%.2f l"));
- table.addGeneratedColumn("total", new ValueColumnGenerator(
- "%.2f €"));
- }
- // The visible columns are affected by removal and addition of
- // generated columns so we have to redefine them.
- table.setVisibleColumns(new Object[] { "date", "quantity",
- "price", "total", "consumption", "dailycost" });
- }
- });
-
- // Use a custom field factory to set the edit fields as immediate.
- // This is used when the table is in editable mode.
- table.setTableFieldFactory(new ImmediateFieldFactory());
-
- // Setting the table itself as immediate has no relevance in this
- // example,
- // because it is relevant only if the table is selectable and we want to
- // get the selection changes immediately.
- table.setImmediate(true);
-
- table.setHeight("300px");
-
- VerticalLayout layout = new VerticalLayout();
- layout.setMargin(true);
- layout
- .addComponent(new Label(
- "Table with column generators that format and calculate cell values."));
- layout.addComponent(table);
- layout.addComponent(editable);
- layout.addComponent(new Label(
- "Columns displayed in blue are calculated from Quantity and Total. "
- + "Others are simply formatted."));
- layout.setExpandRatio(table, 1);
- layout.setSizeUndefined();
- setCompositionRoot(layout);
- // setSizeFull();
- }
-}
diff --git a/src/com/vaadin/demo/featurebrowser/JavaScriptAPIExample.java b/src/com/vaadin/demo/featurebrowser/JavaScriptAPIExample.java
deleted file mode 100644
index 70ff20daac..0000000000
--- a/src/com/vaadin/demo/featurebrowser/JavaScriptAPIExample.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
-@ITMillApache2LicenseForJavaFiles@
- */
-
-package com.vaadin.demo.featurebrowser;
-
-import java.util.Date;
-
-import com.vaadin.terminal.PaintException;
-import com.vaadin.terminal.PaintTarget;
-import com.vaadin.ui.Alignment;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.CustomComponent;
-import com.vaadin.ui.Label;
-import com.vaadin.ui.TextField;
-import com.vaadin.ui.VerticalLayout;
-import com.vaadin.ui.Button.ClickEvent;
-
-/**
- * An example using a RichTextArea to edit a Label in XHTML-mode.
- *
- */
-@SuppressWarnings("serial")
-public class JavaScriptAPIExample extends CustomComponent {
-
- public static final String txt = "<p>For advanced client side programmers Vaadin offers a simple method which can be used to force sync client with server. This may be needed for example if another part of a mashup changes things on server.</p> (more examples will be added here as the APIs are made public)<br/><br/><A href=\"javascript:vaadin.forceSync();\">javascript:vaadin.forceSync();</A>";
-
- private final VerticalLayout main;
- private final Label l;
- private final TextField editor = new TextField();
-
- public JavaScriptAPIExample() {
- // main layout
- main = new VerticalLayout();
- main.setMargin(true);
- setCompositionRoot(main);
- editor.setRows(7);
- editor.setColumns(50);
- // Add the label
- l = new Label(txt);
- l.setContentMode(Label.CONTENT_XHTML);
- main.addComponent(l);
- // Edit button with inline click-listener
- Button b = new Button("Edit", new Button.ClickListener() {
- public void buttonClick(ClickEvent event) {
- // swap Label <-> RichTextArea
- if (main.getComponentIterator().next() == l) {
- editor.setValue(l.getValue());
- main.replaceComponent(l, editor);
- event.getButton().setCaption("Save");
- } else {
- l.setValue(editor.getValue());
- main.replaceComponent(editor, l);
- event.getButton().setCaption("Edit");
- }
- }
- });
- main.addComponent(b);
- main.setComponentAlignment(b, Alignment.MIDDLE_RIGHT);
-
- //
- Label l = new Label(
- "This label will update it's server-side value AFTER it's rendered to the client-side. "
- + "The client will be synchronized on reload, when you click a button, "
- + "or when vaadin.forceSync() is called.") {
-
- @Override
- public void paintContent(PaintTarget target) throws PaintException {
-
- super.paintContent(target);
- Delay d = new Delay(this);
- d.start();
- }
-
- };
- main.addComponent(l);
-
- }
-
- private class Delay extends Thread {
- Label label;
-
- public Delay(Label l) {
- label = l;
- }
-
- @Override
- public void run() {
- try {
- Thread.sleep(500);
- label.setValue(new Date().toString());
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-
- }
-}
diff --git a/src/com/vaadin/demo/featurebrowser/LabelExample.java b/src/com/vaadin/demo/featurebrowser/LabelExample.java
deleted file mode 100644
index 0e89cbd77d..0000000000
--- a/src/com/vaadin/demo/featurebrowser/LabelExample.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
-@ITMillApache2LicenseForJavaFiles@
- */
-
-package com.vaadin.demo.featurebrowser;
-
-import com.vaadin.ui.CustomComponent;
-import com.vaadin.ui.GridLayout;
-import com.vaadin.ui.Label;
-import com.vaadin.ui.Panel;
-
-/**
- * Shows a few variations of Labels, including the effects of XHTML- and
- * pre-formatted mode.
- *
- * @author IT Mill Ltd.
- */
-@SuppressWarnings("serial")
-public class LabelExample extends CustomComponent {
-
- private static final String xhtml = "This text has <b>HTML</b> formatting.<br/>"
- + "A plain <i>Label</i> will show the markup, while a <u>XHTML-mode</u>"
- + " <i>Label</i> will show the formatted text.";
-
- private static final String pre = "This text has linebreaks.\n\n"
- + "They will show up in a preformatted Label,\n"
- + "but not in a \"plain\" Label.\n\n"
- + " This is an indented row. \n Same indentation here.";
-
- public LabelExample() {
- final GridLayout g = new GridLayout(2, 4);
- g.setMargin(true);
- setCompositionRoot(g);
- g.setWidth("100%");
-
- // plain w/o caption
- Panel p = getExpamplePanel("Plain");
- Label l = new Label("A plain label without caption.");
- p.addComponent(l);
- g.addComponent(p);
- // plain w/ caption
- p = getExpamplePanel("Plain w/ caption + tooltip");
- l = new Label("A plain label with caption.");
- l.setCaption("Label caption");
- l.setDescription("This is a description (tooltip) for the label.");
- p.addComponent(l);
- g.addComponent(p);
- // plain w/ xhtml
- p = getExpamplePanel("Plain w/ XHTML content");
- l = new Label(xhtml);
- p.addComponent(l);
- g.addComponent(p);
- // xhtml w/ xhtml
- p = getExpamplePanel("XHTML-mode w/ XHTML content");
- l = new Label(xhtml);
- l.setContentMode(Label.CONTENT_XHTML);
- p.addComponent(l);
- g.addComponent(p);
- // plain w/ preformatted
- p = getExpamplePanel("Plain w/ preformatted content");
- l = new Label(pre);
- p.addComponent(l);
- g.addComponent(p);
- // preformatted w/ preformatted
- p = getExpamplePanel("Preformatted-mode w/ preformatted content");
- l = new Label(pre);
- l.setContentMode(Label.CONTENT_PREFORMATTED);
- p.addComponent(l);
- g.addComponent(p);
-
- }
-
- private Panel getExpamplePanel(String caption) {
- Panel p = new Panel(caption);
- p.addStyleName(Panel.STYLE_LIGHT);
- return p;
- }
-}
diff --git a/src/com/vaadin/demo/featurebrowser/LayoutExample.java b/src/com/vaadin/demo/featurebrowser/LayoutExample.java
deleted file mode 100644
index 34152c9c86..0000000000
--- a/src/com/vaadin/demo/featurebrowser/LayoutExample.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
-@ITMillApache2LicenseForJavaFiles@
- */
-
-package com.vaadin.demo.featurebrowser;
-
-import com.vaadin.ui.CustomComponent;
-import com.vaadin.ui.GridLayout;
-import com.vaadin.ui.HorizontalLayout;
-import com.vaadin.ui.Label;
-import com.vaadin.ui.Panel;
-import com.vaadin.ui.TabSheet;
-import com.vaadin.ui.VerticalLayout;
-
-/**
- * A few examples of layout possibilities.
- *
- * @author IT Mill Ltd.
- */
-@SuppressWarnings("serial")
-public class LayoutExample extends CustomComponent {
-
- public LayoutExample() {
-
- final VerticalLayout main = new VerticalLayout();
- main.setMargin(true);
- setCompositionRoot(main);
-
- final GridLayout g = new GridLayout(2, 5);
- g.setWidth("100%");
- main.addComponent(g);
-
- // panel
- Panel p = new Panel("This is a normal panel");
- Label l = new Label("A normal panel.");
- p.addComponent(l);
- g.addComponent(p);
- // lightpanel
- p = new Panel("This is a light panel");
- p.setStyleName(Panel.STYLE_LIGHT);
- l = new Label("A light-style panel.");
- p.addComponent(l);
- g.addComponent(p);
-
- TabSheet ts = new TabSheet();
- g.addComponent(ts, 0, 1, 1, 1);
-
- VerticalLayout ol = new VerticalLayout();
- ol.setMargin(true);
- ol.addComponent(new Label("Component 1"));
- ol.addComponent(new Label("Component 2"));
- ol.addComponent(new Label("Component 3"));
- ts.addTab(ol, "Vertical OrderedLayout", null);
-
- HorizontalLayout hl = new HorizontalLayout();
- hl.setMargin(true);
- hl.addComponent(new Label("Component 1"));
- hl.addComponent(new Label("Component 2"));
- hl.addComponent(new Label("Component 3"));
- ts.addTab(hl, "Horizontal OrderedLayout", null);
-
- final GridLayout gl = new GridLayout(3, 3);
- gl.setMargin(true);
- gl.addComponent(new Label("Component 1.1"));
- gl.addComponent(new Label("Component 1.2"));
- gl.addComponent(new Label("Component 1.3"));
- gl.addComponent(new Label("Component 2.2"), 1, 1);
- gl.addComponent(new Label("Component 3.1"), 0, 2);
- gl.addComponent(new Label("Component 3.3"), 2, 2);
- ts.addTab(gl, "GridLayout", null);
-
- /*- TODO spitpanel removed for now - do we need it here?
- ts = new TabSheet();
- ts.setHeight(150);
- g.addComponent(ts, 0, 2, 1, 2);
-
- SplitPanel sp = new SplitPanel();
- sp.addComponent(new Label("Component 1"));
- sp.addComponent(new Label("Component 2"));
- ts.addTab(sp, "Vertical SplitPanel", null);
-
- sp = new SplitPanel(SplitPanel.ORIENTATION_HORIZONTAL);
- sp.addComponent(new Label("Component 1"));
- sp.addComponent(new Label("Component 2"));
- ts.addTab(sp, "Horizontal SplitPanel", null);
- -*/
-
- }
-}
diff --git a/src/com/vaadin/demo/featurebrowser/NotificationExample.java b/src/com/vaadin/demo/featurebrowser/NotificationExample.java
deleted file mode 100644
index 73b94c5577..0000000000
--- a/src/com/vaadin/demo/featurebrowser/NotificationExample.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
-@ITMillApache2LicenseForJavaFiles@
- */
-
-package com.vaadin.demo.featurebrowser;
-
-import com.vaadin.data.Item;
-import com.vaadin.ui.AbstractSelect;
-import com.vaadin.ui.Alignment;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.CustomComponent;
-import com.vaadin.ui.NativeSelect;
-import com.vaadin.ui.RichTextArea;
-import com.vaadin.ui.TextField;
-import com.vaadin.ui.VerticalLayout;
-import com.vaadin.ui.Window;
-import com.vaadin.ui.Button.ClickEvent;
-import com.vaadin.ui.Button.ClickListener;
-
-/**
- * Demonstrates the use of Notifications.
- *
- * @author IT Mill Ltd.
- * @see com.vaadin.ui.Window
- */
-@SuppressWarnings("serial")
-public class NotificationExample extends CustomComponent {
-
- // Dropdown select for notification type, using the native dropdown
- NativeSelect type;
- // Textfield for the notification caption
- TextField caption;
- // Textfield for the notification content
- TextField message;
-
- /**
- * Default constructor; We're subclassing CustomComponent, so we need to
- * choose a root component and set it as composition root.
- */
- public NotificationExample() {
- // Main layout
- final VerticalLayout main = new VerticalLayout();
- main.setSizeUndefined();
- main.setSpacing(true);
- main.setMargin(true); // use theme-specific margin
- setCompositionRoot(main);
-
- // Create the 'type' dropdown select.
- type = new NativeSelect("Notification type");
- main.addComponent(type);
- // no empty selection allowed
- type.setNullSelectionAllowed(false);
- // we want a different caption than the value
- type.addContainerProperty("caption", String.class, null);
- type.setItemCaptionMode(AbstractSelect.ITEM_CAPTION_MODE_PROPERTY);
- type.setItemCaptionPropertyId("caption");
- // add some content (items) using the Container API
- Item i = type.addItem(new Integer(
- Window.Notification.TYPE_HUMANIZED_MESSAGE));
- i.getItemProperty("caption").setValue("Humanized message");
- i = type.addItem(new Integer(Window.Notification.TYPE_WARNING_MESSAGE));
- i.getItemProperty("caption").setValue("Warning message");
- i = type.addItem(new Integer(Window.Notification.TYPE_ERROR_MESSAGE));
- i.getItemProperty("caption").setValue("Error message");
- i = type
- .addItem(new Integer(Window.Notification.TYPE_TRAY_NOTIFICATION));
- i.getItemProperty("caption").setValue("Tray notification");
- // set the initially selected item
- type.setValue(new Integer(Window.Notification.TYPE_HUMANIZED_MESSAGE));
-
- // Notification caption
- caption = new TextField("Caption");
- main.addComponent(caption);
- caption.setColumns(20);
- caption.setValue("Brown Fox!");
-
- // Notification message
- message = new RichTextArea();
- main.addComponent(message);
- message.setCaption("Message");
- message.setValue("A quick one jumped over the lazy dog.");
-
- // Button to show the notification
- final Button b = new Button("Show notification", new ClickListener() {
- // this is an inline ClickListener
- public void buttonClick(ClickEvent event) {
- // show the notification
- getWindow().showNotification((String) caption.getValue(),
- (String) message.getValue(),
- ((Integer) type.getValue()).intValue());
- }
- });
- main.addComponent(b);
- main.setComponentAlignment(b, Alignment.MIDDLE_RIGHT);
- }
-}
diff --git a/src/com/vaadin/demo/featurebrowser/RichTextExample.java b/src/com/vaadin/demo/featurebrowser/RichTextExample.java
deleted file mode 100644
index eb5b2e4279..0000000000
--- a/src/com/vaadin/demo/featurebrowser/RichTextExample.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
-@ITMillApache2LicenseForJavaFiles@
- */
-
-package com.vaadin.demo.featurebrowser;
-
-import com.vaadin.ui.Alignment;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.CustomComponent;
-import com.vaadin.ui.Label;
-import com.vaadin.ui.RichTextArea;
-import com.vaadin.ui.VerticalLayout;
-import com.vaadin.ui.Button.ClickEvent;
-
-/**
- * An example using a RichTextArea to edit a Label in XHTML-mode.
- *
- */
-@SuppressWarnings("serial")
-public class RichTextExample extends CustomComponent {
-
- public static final String txt = "<h1>RichText editor example</h1>"
- + "To edit this text, press the <b>Edit</b> button below."
- + "<br/>"
- + "See the <A href=\"http://www.vaadin.com/book\">Book of Vaadin</a> "
- + "for more information.";
-
- private final VerticalLayout main;
- private final Label l;
- private final RichTextArea editor = new RichTextArea();
- private final Button b;
-
- public RichTextExample() {
- // main layout
- main = new VerticalLayout();
- main.setMargin(true);
- setCompositionRoot(main);
-
- editor.setWidth("100%");
-
- // Add the label
- l = new Label(txt);
- l.setContentMode(Label.CONTENT_XHTML);
- main.addComponent(l);
- // Edit button with inline click-listener
- b = new Button("Edit", new Button.ClickListener() {
- public void buttonClick(ClickEvent event) {
- // swap Label <-> RichTextArea
- if (main.getComponentIterator().next() == l) {
- editor.setValue(l.getValue());
- main.replaceComponent(l, editor);
- b.setCaption("Save");
- } else {
- l.setValue(editor.getValue());
- main.replaceComponent(editor, l);
- b.setCaption("Edit");
- }
- }
- });
- main.addComponent(b);
- main.setComponentAlignment(b, Alignment.MIDDLE_RIGHT);
- }
-
-}
diff --git a/src/com/vaadin/demo/featurebrowser/SelectExample.java b/src/com/vaadin/demo/featurebrowser/SelectExample.java
deleted file mode 100644
index 38183a946b..0000000000
--- a/src/com/vaadin/demo/featurebrowser/SelectExample.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
-@ITMillApache2LicenseForJavaFiles@
- */
-
-package com.vaadin.demo.featurebrowser;
-
-import com.vaadin.data.Property.ValueChangeEvent;
-import com.vaadin.ui.AbstractSelect;
-import com.vaadin.ui.ComboBox;
-import com.vaadin.ui.CustomComponent;
-import com.vaadin.ui.Field;
-import com.vaadin.ui.HorizontalLayout;
-import com.vaadin.ui.ListSelect;
-import com.vaadin.ui.NativeSelect;
-import com.vaadin.ui.OptionGroup;
-import com.vaadin.ui.Panel;
-import com.vaadin.ui.TwinColSelect;
-import com.vaadin.ui.VerticalLayout;
-
-/**
- * Shows some basic fields for value input; TextField, DateField, Slider...
- *
- * @author IT Mill Ltd.
- */
-@SuppressWarnings("serial")
-public class SelectExample extends CustomComponent {
-
- // listener that shows a value change notification
- private final Field.ValueChangeListener listener = new Field.ValueChangeListener() {
- public void valueChange(ValueChangeEvent event) {
- getWindow().showNotification("" + event.getProperty().getValue());
- }
- };
-
- public SelectExample() {
- final VerticalLayout main = new VerticalLayout();
- main.setMargin(true);
- setCompositionRoot(main);
-
- final HorizontalLayout horiz = new HorizontalLayout();
- horiz.setWidth("100%");
- main.addComponent(horiz);
- final Panel single = new Panel("Single selects");
- single.setStyleName(Panel.STYLE_LIGHT);
- horiz.addComponent(single);
- final Panel multi = new Panel("Multi selects");
- multi.setStyleName(Panel.STYLE_LIGHT);
- horiz.addComponent(multi);
-
- // radio button group
- AbstractSelect sel = new OptionGroup("OptionGroup");
- initSelect(sel);
- single.addComponent(sel);
- // checkbox group
- sel = new OptionGroup("OptionGroup");
- sel.setMultiSelect(true); // TODO: throws if set after listener - why?
- initSelect(sel);
- multi.addComponent(sel);
- // single-select list
- sel = new ListSelect("ListSelect");
- ((ListSelect) sel).setColumns(15);
- initSelect(sel);
- single.addComponent(sel);
- // multi-select list
- sel = new ListSelect("ListSelect");
- ((ListSelect) sel).setColumns(15);
- sel.setMultiSelect(true);
- initSelect(sel);
- multi.addComponent(sel);
- // native-style dropdows
- sel = new NativeSelect("NativeSelect");
- ((NativeSelect) sel).setColumns(15);
- initSelect(sel);
- single.addComponent(sel);
- // combobox
- sel = new ComboBox("ComboBox");
- ((ComboBox) sel).setWidth("15em");
- initSelect(sel);
- single.addComponent(sel);
- // "twin column" select
- sel = new TwinColSelect("TwinColSelect");
- sel.setWidth("100%");
- ((TwinColSelect) sel).setColumns(15);
- initSelect(sel);
- multi.addComponent(sel);
- }
-
- /*
- * Initialize select with some values, make immediate and add listener.
- */
- private void initSelect(AbstractSelect sel) {
- for (int i = 1; i <= 5; i++) {
- sel.addItem("Item " + i);
- }
- // select one item
- sel.select("Item 1");
-
- // make immediate, add listener
- sel.setImmediate(true);
- sel.addListener(listener);
- }
-
-}
diff --git a/src/com/vaadin/demo/featurebrowser/TableExample.java b/src/com/vaadin/demo/featurebrowser/TableExample.java
deleted file mode 100644
index 808762724b..0000000000
--- a/src/com/vaadin/demo/featurebrowser/TableExample.java
+++ /dev/null
@@ -1,300 +0,0 @@
-/*
-@ITMillApache2LicenseForJavaFiles@
- */
-
-package com.vaadin.demo.featurebrowser;
-
-import java.util.Iterator;
-import java.util.Random;
-import java.util.Set;
-
-import com.vaadin.data.Item;
-import com.vaadin.data.Property;
-import com.vaadin.event.Action;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.CheckBox;
-import com.vaadin.ui.CustomComponent;
-import com.vaadin.ui.HorizontalLayout;
-import com.vaadin.ui.TabSheet;
-import com.vaadin.ui.Table;
-import com.vaadin.ui.VerticalLayout;
-import com.vaadin.ui.Button.ClickEvent;
-
-/**
- * Table example.
- *
- * @author IT Mill Ltd.
- */
-@SuppressWarnings("serial")
-public class TableExample extends CustomComponent implements Action.Handler,
- Button.ClickListener {
-
- // Actions
- private static final Action ACTION_SAVE = new Action("Save");
- private static final Action ACTION_DELETE = new Action("Delete");
- private static final Action ACTION_HIRE = new Action("Hire");
- // Action sets
- private static final Action[] ACTIONS_NOHIRE = new Action[] { ACTION_SAVE,
- ACTION_DELETE };
- private static final Action[] ACTIONS_HIRE = new Action[] { ACTION_HIRE,
- ACTION_SAVE, ACTION_DELETE };
- // Properties
- private static final Object PROPERTY_SPECIES = "Species";
- private static final Object PROPERTY_TYPE = "Type";
- private static final Object PROPERTY_KIND = "Kind";
- private static final Object PROPERTY_HIRED = "Hired";
-
- // "global" components
- Table source;
- Table saved;
- Button saveSelected;
- Button hireSelected;
- Button deleteSelected;
- Button deselect;
-
- public TableExample() {
- VerticalLayout margin = new VerticalLayout();
- margin.setMargin(true);
-
- TabSheet root = new TabSheet();
- setCompositionRoot(margin);
- margin.addComponent(root);
-
- // main layout
- final VerticalLayout main = new VerticalLayout();
- main.setCaption("Basic Table");
- main.setMargin(true);
- root.addTab(main);
-
- // "source" table with bells & whistlesenabled
- source = new Table("All creatures");
- source.setPageLength(7);
- source.setWidth("550px");
- source.setColumnCollapsingAllowed(true);
- source.setColumnReorderingAllowed(true);
- source.setSelectable(true);
- source.setMultiSelect(true);
- source.setRowHeaderMode(Table.ROW_HEADER_MODE_ID);
- fillTable(source);
- source.addActionHandler(this);
- main.addComponent(source);
-
- // x-selected button row
- final HorizontalLayout horiz = new HorizontalLayout();
-
- horiz.setMargin(false, false, true, false);
- main.addComponent(horiz);
- saveSelected = new Button("Save selected");
- saveSelected.setStyleName(Button.STYLE_LINK);
- saveSelected.addListener(this);
- horiz.addComponent(saveSelected);
- hireSelected = new Button("Hire selected");
- hireSelected.setStyleName(Button.STYLE_LINK);
- hireSelected.addListener(this);
- horiz.addComponent(hireSelected);
- deleteSelected = new Button("Delete selected");
- deleteSelected.setStyleName(Button.STYLE_LINK);
- deleteSelected.addListener(this);
- horiz.addComponent(deleteSelected);
- deselect = new Button("Deselect all");
- deselect.setStyleName(Button.STYLE_LINK);
- deselect.addListener(this);
- horiz.addComponent(deselect);
- final CheckBox editmode = new CheckBox("Editmode ");
- editmode.addListener(new CheckBox.ClickListener() {
- public void buttonClick(ClickEvent event) {
- source.setEditable(((Boolean) event.getButton().getValue())
- .booleanValue());
- }
- });
- editmode.setImmediate(true);
- horiz.addComponent(editmode);
-
- // "saved" table, minimalistic
- saved = new Table("Saved creatures");
- saved.setPageLength(5);
- saved.setWidth("550px");
- saved.setSelectable(false);
- saved.setColumnHeaderMode(Table.COLUMN_HEADER_MODE_HIDDEN);
- saved.setRowHeaderMode(Table.ROW_HEADER_MODE_ID);
- initProperties(saved);
- saved.addActionHandler(this);
- main.addComponent(saved);
-
- final CheckBox b = new CheckBox("Modify saved creatures");
- b.addListener(new CheckBox.ClickListener() {
- public void buttonClick(ClickEvent event) {
- saved.setEditable(((Boolean) event.getButton().getValue())
- .booleanValue());
- }
- });
- b.setImmediate(true);
- main.addComponent(b);
-
- GeneratedColumnExample gencols = new GeneratedColumnExample();
- gencols.setCaption("Generated Columns");
- root.addComponent(gencols);
- }
-
- // set up the properties (columns)
- private void initProperties(Table table) {
- table.addContainerProperty(PROPERTY_SPECIES, String.class, "");
- table.addContainerProperty(PROPERTY_TYPE, String.class, "");
- table.addContainerProperty(PROPERTY_KIND, String.class, "");
- table
- .addContainerProperty(PROPERTY_HIRED, Boolean.class,
- Boolean.FALSE);
- }
-
- // fill the table with some random data
- private void fillTable(Table table) {
- initProperties(table);
-
- final String[] sp = new String[] { "Fox", "Dog", "Cat", "Moose",
- "Penguin", "Cow" };
- final String[] ty = new String[] { "Quick", "Lazy", "Sleepy",
- "Fidgety", "Crazy", "Kewl" };
- final String[] ki = new String[] { "Jumping", "Walking", "Sleeping",
- "Skipping", "Dancing" };
-
- Random r = new Random(5);
-
- for (int i = 0; i < 100; i++) {
- final String s = sp[(int) (r.nextDouble() * sp.length)];
- final String t = ty[(int) (r.nextDouble() * ty.length)];
- final String k = ki[(int) (r.nextDouble() * ki.length)];
- table.addItem(new Object[] { s, t, k, Boolean.FALSE }, new Integer(
- i));
- }
-
- }
-
- // Called for each item (row), returns valid actions for that item
- public Action[] getActions(Object target, Object sender) {
- if (sender == source) {
- final Item item = source.getItem(target);
- // save, delete, and hire if not already hired
- if (item != null
- && item.getItemProperty(PROPERTY_HIRED).getValue() == Boolean.FALSE) {
- return ACTIONS_HIRE;
- } else {
- return ACTIONS_NOHIRE;
- }
- } else {
- // "saved" table only has one action
- return new Action[] { ACTION_DELETE };
- }
- }
-
- // called when an action is invoked on an item (row)
- public void handleAction(Action action, Object sender, Object target) {
- if (sender == source) {
- Item item = source.getItem(target);
- if (action == ACTION_HIRE) {
- // set HIRED property to true
- item.getItemProperty(PROPERTY_HIRED).setValue(Boolean.TRUE);
- if (saved.containsId(target)) {
- item = saved.getItem(target);
- item.getItemProperty(PROPERTY_HIRED).setValue(Boolean.TRUE);
- }
- getWindow().showNotification("Hired", "" + item);
-
- } else if (action == ACTION_SAVE) {
- if (saved.containsId(target)) {
- // let's not save twice
- getWindow().showNotification("Already saved", "" + item);
- return;
- }
- // "manual" copy of the item properties we want
- final Item added = saved.addItem(target);
- Property p = added.getItemProperty(PROPERTY_SPECIES);
- p.setValue(item.getItemProperty(PROPERTY_SPECIES).getValue());
- p = added.getItemProperty(PROPERTY_TYPE);
- p.setValue(item.getItemProperty(PROPERTY_TYPE).getValue());
- p = added.getItemProperty(PROPERTY_KIND);
- p.setValue(item.getItemProperty(PROPERTY_KIND).getValue());
- p = added.getItemProperty(PROPERTY_HIRED);
- p.setValue(item.getItemProperty(PROPERTY_HIRED).getValue());
- getWindow().showNotification("Saved", "" + item);
- } else {
- // ACTION_DELETE
- getWindow().showNotification("Deleted ", "" + item);
- source.removeItem(target);
- }
-
- } else {
- // sender==saved
- if (action == ACTION_DELETE) {
- final Item item = saved.getItem(target);
- getWindow().showNotification("Deleted", "" + item);
- saved.removeItem(target);
- }
- }
- }
-
- @SuppressWarnings("unchecked")
- public void buttonClick(ClickEvent event) {
- final Button b = event.getButton();
- if (b == deselect) {
- source.setValue(null);
- } else if (b == saveSelected) {
- // loop each selected and copy to "saved" table
- final Set selected = (Set) source.getValue();
- int s = 0;
- for (final Iterator it = selected.iterator(); it.hasNext();) {
- final Object id = it.next();
- if (!saved.containsId(id)) {
- final Item item = source.getItem(id);
- final Item added = saved.addItem(id);
- // "manual" copy of the properties we want
- Property p = added.getItemProperty(PROPERTY_SPECIES);
- p.setValue(item.getItemProperty(PROPERTY_SPECIES)
- .getValue());
- p = added.getItemProperty(PROPERTY_TYPE);
- p.setValue(item.getItemProperty(PROPERTY_TYPE).getValue());
- p = added.getItemProperty(PROPERTY_KIND);
- p.setValue(item.getItemProperty(PROPERTY_KIND).getValue());
- p = added.getItemProperty(PROPERTY_HIRED);
- p.setValue(item.getItemProperty(PROPERTY_HIRED).getValue());
- s++;
- }
- }
- getWindow().showNotification("Saved " + s);
-
- } else if (b == hireSelected) {
- // loop each selected and set property HIRED to true
- int s = 0;
- final Set selected = (Set) source.getValue();
- for (final Iterator it = selected.iterator(); it.hasNext();) {
- final Object id = it.next();
- Item item = source.getItem(id);
- final Property p = item.getItemProperty(PROPERTY_HIRED);
- if (p.getValue() == Boolean.FALSE) {
- p.setValue(Boolean.TRUE);
- s++;
- }
- if (saved.containsId(id)) {
- // also update "saved" table
- item = saved.getItem(id);
- item.getItemProperty(PROPERTY_HIRED).setValue(Boolean.TRUE);
- }
- }
- getWindow().showNotification("Hired " + s);
-
- } else {
- // loop trough selected and delete
- int s = 0;
- final Set selected = (Set) source.getValue();
- for (final Iterator it = selected.iterator(); it.hasNext();) {
- final Object id = it.next();
- if (source.containsId(id)) {
- s++;
- source.removeItem(id);
- }
- }
- getWindow().showNotification("Deleted " + s);
- }
-
- }
-
-}
diff --git a/src/com/vaadin/demo/featurebrowser/TreeExample.java b/src/com/vaadin/demo/featurebrowser/TreeExample.java
deleted file mode 100644
index a440cbb25c..0000000000
--- a/src/com/vaadin/demo/featurebrowser/TreeExample.java
+++ /dev/null
@@ -1,163 +0,0 @@
-/*
-@ITMillApache2LicenseForJavaFiles@
- */
-
-package com.vaadin.demo.featurebrowser;
-
-import com.vaadin.data.Item;
-import com.vaadin.data.Property;
-import com.vaadin.data.Property.ValueChangeEvent;
-import com.vaadin.event.Action;
-import com.vaadin.ui.AbstractSelect;
-import com.vaadin.ui.CustomComponent;
-import com.vaadin.ui.HorizontalLayout;
-import com.vaadin.ui.Label;
-import com.vaadin.ui.Panel;
-import com.vaadin.ui.TextField;
-import com.vaadin.ui.Tree;
-
-/**
- * Demonstrates basic Tree -functionality. Actions are used for add/remove item
- * functionality, and a ValueChangeListener reacts to both the Tree and the
- * TextField.
- */
-@SuppressWarnings("serial")
-public class TreeExample extends CustomComponent implements Action.Handler,
- Tree.ValueChangeListener {
-
- private static final Action ADD = new Action("Add item");
- private static final Action DELETE = new Action("Delete item");
- private static final Action[] actions = new Action[] { ADD, DELETE };
-
- // Id for the caption property
- private static final Object CAPTION_PROPERTY = "caption";
-
- private static final String desc = "Try both right- and left-click!";
-
- Tree tree;
- TextField editor;
-
- public TreeExample() {
- final HorizontalLayout main = new HorizontalLayout();
- main.setWidth("100%");
- main.setMargin(true);
- setCompositionRoot(main);
-
- // Panel w/ Tree
- Panel p = new Panel("Select item");
- p.setStyleName(Panel.STYLE_LIGHT);
- p.setWidth("250px");
- // Description
- p.addComponent(new Label(desc));
- // Tree with a few items
- tree = new Tree();
- tree.setImmediate(true);
- // we'll use a property for caption instead of the item id ("value"),
- // so that multiple items can have the same caption
- tree.addContainerProperty(CAPTION_PROPERTY, String.class, "");
- tree.setItemCaptionMode(AbstractSelect.ITEM_CAPTION_MODE_PROPERTY);
- tree.setItemCaptionPropertyId(CAPTION_PROPERTY);
- for (int i = 1; i <= 3; i++) {
- final Object id = addCaptionedItem("Section " + i, null);
- tree.expandItem(id);
- addCaptionedItem("Team A", id);
- addCaptionedItem("Team B", id);
- }
- // listen for selections
- tree.addListener(this);
- // "context menu"
- tree.addActionHandler(this);
- p.addComponent(tree);
- main.addComponent(p);
-
- // Panel w/ TextField ("editor")
- p = new Panel("Edit item caption");
- p.setStyleName(Panel.STYLE_LIGHT);
- editor = new TextField();
- // make immediate, instead of adding an "apply" button
- editor.setImmediate(true);
- editor.setEnabled(false);
- editor.setColumns(15);
- p.addComponent(editor);
- main.addComponent(p);
- main.setExpandRatio(p, 1);
- }
-
- public Action[] getActions(Object target, Object sender) {
- // We can provide different actions for each target (item), but we'll
- // use the same actions all the time.
- return actions;
- }
-
- public void handleAction(Action action, Object sender, Object target) {
- if (action == DELETE) {
- tree.removeItem(target);
- } else {
- // Add
- final Object id = addCaptionedItem("New Item", target);
- tree.expandItem(target);
- tree.setValue(id);
- editor.focus();
- }
- }
-
- public void valueChange(ValueChangeEvent event) {
- final Object id = tree.getValue(); // selected item id
- if (event.getProperty() == tree) {
- // a Tree item was (un) selected
- if (id == null) {
- // no selecteion, disable TextField
- editor.removeListener(this);
- editor.setValue("");
- editor.setEnabled(false);
- } else {
- // item selected
- // first remove previous listener
- editor.removeListener(this);
- // enable TextField and update value
- editor.setEnabled(true);
- final Item item = tree.getItem(id);
- editor.setValue(item.getItemProperty(CAPTION_PROPERTY)
- .getValue());
- // listen for TextField changes
- editor.addListener(this);
- editor.focus();
- }
- } else {
- // TextField
- if (id != null) {
- final Item item = tree.getItem(id);
- final Property p = item.getItemProperty(CAPTION_PROPERTY);
- p.setValue(editor.getValue());
- tree.requestRepaint();
- }
-
- }
- }
-
- /**
- * Helper to add an item with specified caption and (optional) parent.
- *
- * @param caption
- * The item caption
- * @param parent
- * The (optional) parent item id
- * @return the created item's id
- */
- private Object addCaptionedItem(String caption, Object parent) {
- // add item, let tree decide id
- final Object id = tree.addItem();
- // get the created item
- final Item item = tree.getItem(id);
- // set our "caption" property
- final Property p = item.getItemProperty(CAPTION_PROPERTY);
- p.setValue(caption);
- if (parent != null) {
- tree.setChildrenAllowed(parent, true);
- tree.setParent(id, parent);
- tree.setChildrenAllowed(id, false);
- }
- return id;
- }
-
-}
diff --git a/src/com/vaadin/demo/featurebrowser/ValueInputExample.java b/src/com/vaadin/demo/featurebrowser/ValueInputExample.java
deleted file mode 100644
index 81afe67eaf..0000000000
--- a/src/com/vaadin/demo/featurebrowser/ValueInputExample.java
+++ /dev/null
@@ -1,147 +0,0 @@
-/*
-@ITMillApache2LicenseForJavaFiles@
- */
-
-package com.vaadin.demo.featurebrowser;
-
-import com.vaadin.data.Property.ValueChangeEvent;
-import com.vaadin.ui.CustomComponent;
-import com.vaadin.ui.DateField;
-import com.vaadin.ui.Field;
-import com.vaadin.ui.HorizontalLayout;
-import com.vaadin.ui.InlineDateField;
-import com.vaadin.ui.Panel;
-import com.vaadin.ui.Slider;
-import com.vaadin.ui.TextField;
-import com.vaadin.ui.VerticalLayout;
-import com.vaadin.ui.Window.Notification;
-
-/**
- * Shows some basic fields for value input; TextField, DateField, Slider...
- *
- * @author IT Mill Ltd.
- */
-@SuppressWarnings("serial")
-public class ValueInputExample extends CustomComponent {
-
- public ValueInputExample() {
- final VerticalLayout main = new VerticalLayout();
- main.setMargin(true);
- setCompositionRoot(main);
-
- // listener that shows a value change notification
- final Field.ValueChangeListener listener = new Field.ValueChangeListener() {
- public void valueChange(ValueChangeEvent event) {
- getWindow().showNotification("Received",
- "<pre>" + event.getProperty().getValue() + "</pre>",
- Notification.TYPE_WARNING_MESSAGE);
- }
- };
-
- // TextField
- HorizontalLayout horiz = new HorizontalLayout();
- horiz.setWidth("100%");
- main.addComponent(horiz);
- Panel left = new Panel("TextField");
- left.setStyleName(Panel.STYLE_LIGHT);
- horiz.addComponent(left);
- Panel right = new Panel("multiline");
- right.setStyleName(Panel.STYLE_LIGHT);
- horiz.addComponent(right);
- // basic TextField
- TextField tf = new TextField("Basic");
- tf.setColumns(15);
- tf.setImmediate(true);
- tf.addListener(listener);
- left.addComponent(tf);
- // multiline TextField a.k.a TextArea
- tf = new TextField("Area");
- tf.setColumns(15);
- tf.setRows(5);
- tf.setImmediate(true);
- tf.addListener(listener);
- right.addComponent(tf);
-
- // DateFields
- horiz = new HorizontalLayout();
- horiz.setWidth("100%");
- main.addComponent(horiz);
- left = new Panel("DateField");
- left.setStyleName(Panel.STYLE_LIGHT);
- horiz.addComponent(left);
- right = new Panel("inline");
- right.setStyleName(Panel.STYLE_LIGHT);
- horiz.addComponent(right);
- // default
- DateField df = new DateField("Day resolution");
- df.addListener(listener);
- df.setImmediate(true);
- df.setResolution(DateField.RESOLUTION_DAY);
- left.addComponent(df);
- // minute
- df = new DateField("Minute resolution");
- df.addListener(listener);
- df.setImmediate(true);
- df.setResolution(DateField.RESOLUTION_MIN);
- left.addComponent(df);
- // year
- df = new DateField("Year resolution");
- df.addListener(listener);
- df.setImmediate(true);
- df.setResolution(DateField.RESOLUTION_YEAR);
- left.addComponent(df);
- // msec
- df = new DateField("Millisecond resolution");
- df.addListener(listener);
- df.setImmediate(true);
- df.setResolution(DateField.RESOLUTION_MSEC);
- left.addComponent(df);
- // Inline
- df = new InlineDateField();
- df.addListener(listener);
- df.setImmediate(true);
- right.addComponent(df);
-
- // Slider
- left = new Panel("Slider");
- left.setStyleName(Panel.STYLE_LIGHT);
- main.addComponent(left);
- // int slider
- Slider slider = new Slider(0, 100);
- slider.setWidth("300px");
- // slider.setSize(300);
- slider.setImmediate(true);
- slider.addListener(new Slider.ValueChangeListener() {
- public void valueChange(ValueChangeEvent event) {
- // update caption when value changes
- final Slider s = (Slider) event.getProperty();
- s.setCaption("Value: " + s.getValue());
- }
- });
- try {
- slider.setValue(20);
- } catch (final Exception e) {
- e.printStackTrace(System.err);
- }
- left.addComponent(slider);
- // double slider
- slider = new Slider(0.0, 1.0, 1);
- slider.setOrientation(Slider.ORIENTATION_VERTICAL);
- slider.setImmediate(true);
- slider.addListener(new Slider.ValueChangeListener() {
- public void valueChange(ValueChangeEvent event) {
- // update caption when value changes
- final Slider s = (Slider) event.getProperty();
- s.setCaption("Value: " + s.getValue());
- }
- });
- try {
- slider.setValue(0.5);
- } catch (final Exception e) {
- e.printStackTrace(System.err);
- }
- left.addComponent(slider);
-
- }
-
-}
diff --git a/src/com/vaadin/demo/featurebrowser/WindowingExample.java b/src/com/vaadin/demo/featurebrowser/WindowingExample.java
deleted file mode 100644
index db91da6b84..0000000000
--- a/src/com/vaadin/demo/featurebrowser/WindowingExample.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
-@ITMillApache2LicenseForJavaFiles@
- */
-
-package com.vaadin.demo.featurebrowser;
-
-import java.net.URL;
-
-import com.vaadin.terminal.ExternalResource;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.CustomComponent;
-import com.vaadin.ui.Label;
-import com.vaadin.ui.VerticalLayout;
-import com.vaadin.ui.Window;
-import com.vaadin.ui.Button.ClickEvent;
-
-/**
- * @author marc
- *
- */
-@SuppressWarnings("serial")
-public class WindowingExample extends CustomComponent {
-
- public static final String txt = "<p>There are two main types of windows: application-level windows, and "
- + "\"sub windows\".</p><p>A sub window is rendered as a \"inline\" popup window"
- + " within the (native) browser window to which it was added. You can create"
- + " a sub window by creating a new Window and adding it to a application-level window, for instance"
- + " your main window. </p><p> In contrast, you create a application-level window by"
- + " creating a new Window and adding it to the Application. Application-level"
- + " windows are not shown by default - you need to open a browser window for"
- + " the url representing the window. You can think of the application-level"
- + " windows as separate views into your application - and a way to create a"
- + " \"native\" browser window.</p><p>Depending on your needs, it's also"
- + " possible to create a new window instance (with it's own internal state)"
- + " for each new (native) browser window, or you can share the same instance"
- + " (and state) between several browser windows (the latter is most useful"
- + " for read-only views).</p>";
-
- private URL windowUrl = null;
-
- public WindowingExample() {
- final VerticalLayout main = new VerticalLayout();
- main.setMargin(true);
- setCompositionRoot(main);
-
- final Label l = new Label(txt);
- l.setContentMode(Label.CONTENT_XHTML);
- main.addComponent(l);
-
- Button b = new Button("Create a new subwindow",
- new Button.ClickListener() {
- public void buttonClick(ClickEvent event) {
- final Window w = new Window("Subwindow");
- w.setWidth("50%");
- final Label l = new Label(txt);
- l.setContentMode(Label.CONTENT_XHTML);
- w.addComponent(l);
- getApplication().getMainWindow().addWindow(w);
- }
- });
- b.setStyleName(Button.STYLE_LINK);
- main.addComponent(b);
- b = new Button("Create a new modal window", new Button.ClickListener() {
- public void buttonClick(ClickEvent event) {
- final Window w = new Window("Modal window");
- w.setWidth("50%");
- w.setModal(true);
- final Label l = new Label(txt);
- l.setContentMode(Label.CONTENT_XHTML);
- w.addComponent(l);
- getApplication().getMainWindow().addWindow(w);
- }
- });
- b.setStyleName(Button.STYLE_LINK);
- main.addComponent(b);
- b = new Button("Open a application-level window, with shared state",
- new Button.ClickListener() {
- public void buttonClick(ClickEvent event) {
- if (windowUrl == null) {
- final Window w = new Window("Subwindow");
- final Label l = new Label(txt);
- l.setContentMode(Label.CONTENT_XHTML);
- w.addComponent(l);
- getApplication().addWindow(w);
- windowUrl = w.getURL();
- }
- getApplication().getMainWindow().open(
- new ExternalResource(windowUrl), "_new");
- }
- });
- b.setStyleName(Button.STYLE_LINK);
- main.addComponent(b);
- b = new Button(
- "Create a new application-level window, with it's own state",
- new Button.ClickListener() {
- public void buttonClick(ClickEvent event) {
- final Window w = new Window("Subwindow");
- getApplication().addWindow(w);
- final Label l = new Label(
- "Each opened window has its own"
- + " name, and is accessed trough its own uri.");
- l.setCaption("Window " + w.getName());
- w.addComponent(l);
- getApplication().getMainWindow().open(
- new ExternalResource(w.getURL()), "_new");
- }
- });
- b.setStyleName(Button.STYLE_LINK);
- main.addComponent(b);
-
- }
-
-}