diff options
author | Marc Englund <marc.englund@itmill.com> | 2007-11-29 12:45:42 +0000 |
---|---|---|
committer | Marc Englund <marc.englund@itmill.com> | 2007-11-29 12:45:42 +0000 |
commit | 83c5673c3c4965aa36c498a6ef335dc21bf04409 (patch) | |
tree | 5094a2e6a997fccfd5ba58006f1eb5246c9f792f /src | |
parent | a6844333cf52c184eb55f10d58df4bf3b767c1bd (diff) | |
download | vaadin-framework-83c5673c3c4965aa36c498a6ef335dc21bf04409.tar.gz vaadin-framework-83c5673c3c4965aa36c498a6ef335dc21bf04409.zip |
Examples added.
svn changeset:3037/svn branch:trunk
Diffstat (limited to 'src')
4 files changed, 82 insertions, 10 deletions
diff --git a/src/com/itmill/toolkit/demo/featurebrowser/EmbeddedBrowserExample.java b/src/com/itmill/toolkit/demo/featurebrowser/EmbeddedBrowserExample.java index ebbbbce16b..7bebaf38c3 100644 --- a/src/com/itmill/toolkit/demo/featurebrowser/EmbeddedBrowserExample.java +++ b/src/com/itmill/toolkit/demo/featurebrowser/EmbeddedBrowserExample.java @@ -23,6 +23,13 @@ public class EmbeddedBrowserExample extends ExpandLayout implements Embedded emb = new Embedded(); public EmbeddedBrowserExample() { + this(new String[] { DEFAULT_URL, + "http:// www.itmill.com/index_developers.htm", + "http://toolkit.itmill.com/demo/doc/api/", + "http://www.itmill.com/manual/index.html" }); + } + + public EmbeddedBrowserExample(String[] urls) { setSizeFull(); // create the address combobox @@ -34,14 +41,14 @@ public class EmbeddedBrowserExample extends ExpandLayout implements // no 'go' -button clicking necessary select.setImmediate(true); // add some pre-configured URLs - select.addItem(DEFAULT_URL); - select.addItem("http://www.google.com"); - select.addItem("http://toolkit.itmill.com/demo"); + 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(DEFAULT_URL); + select.setValue(urls[0]); // configure the embedded and add to layout emb.setType(Embedded.TYPE_BROWSER); diff --git a/src/com/itmill/toolkit/demo/featurebrowser/FeatureBrowser.java b/src/com/itmill/toolkit/demo/featurebrowser/FeatureBrowser.java index b5dba0ee0c..365b86299b 100644 --- a/src/com/itmill/toolkit/demo/featurebrowser/FeatureBrowser.java +++ b/src/com/itmill/toolkit/demo/featurebrowser/FeatureBrowser.java @@ -49,7 +49,7 @@ public class FeatureBrowser extends com.itmill.toolkit.Application implements // Intro { "Intro", "About", "About this demo", Button.class, Boolean.FALSE }, // Windowing - { "Intro", "Windowing", "About windowing", Button.class, + { "Intro", "Windowing", "About windowing", WindowingExample.class, Boolean.FALSE }, // Basic: Labels { "Basic", "Labels", "Some variations of Labels", Button.class, diff --git a/src/com/itmill/toolkit/demo/featurebrowser/NotificationExample.java b/src/com/itmill/toolkit/demo/featurebrowser/NotificationExample.java index c007df8e74..f0f8e2ac54 100644 --- a/src/com/itmill/toolkit/demo/featurebrowser/NotificationExample.java +++ b/src/com/itmill/toolkit/demo/featurebrowser/NotificationExample.java @@ -86,5 +86,7 @@ public class NotificationExample extends CustomComponent { } }); main.addComponent(b); + main.setComponentAlignment(b, OrderedLayout.ALIGNMENT_RIGHT, + OrderedLayout.ALIGNMENT_VERTICAL_CENTER); } } diff --git a/src/com/itmill/toolkit/demo/featurebrowser/WindowingExample.java b/src/com/itmill/toolkit/demo/featurebrowser/WindowingExample.java index 2871aef769..891e450dbe 100644 --- a/src/com/itmill/toolkit/demo/featurebrowser/WindowingExample.java +++ b/src/com/itmill/toolkit/demo/featurebrowser/WindowingExample.java @@ -3,8 +3,15 @@ */
package com.itmill.toolkit.demo.featurebrowser;
+import java.net.URL;
+
+import com.itmill.toolkit.terminal.ExternalResource;
+import com.itmill.toolkit.ui.Button;
import com.itmill.toolkit.ui.CustomComponent;
+import com.itmill.toolkit.ui.Label;
import com.itmill.toolkit.ui.OrderedLayout;
+import com.itmill.toolkit.ui.Window;
+import com.itmill.toolkit.ui.Button.ClickEvent;
/**
* @author marc
@@ -12,17 +19,73 @@ import com.itmill.toolkit.ui.OrderedLayout; */
public class WindowingExample extends CustomComponent {
- public static final String txt = "There are two main types of windows:";
+ public static final String txt = "<p>There are two main types of windows: application-level windows, and"
+ + "\"subwindows\". </p><p> A subwindow is rendered as a \"inline\" popup window"
+ + " within the (native) browser window to which it was added. You can create"
+ + " a subwindow 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>";
- /*
- * application-level windows, and
- *
- */
+ private URL windowUrl = null;
public WindowingExample() {
OrderedLayout main = new OrderedLayout();
+ main.setMargin(true);
setCompositionRoot(main);
+ Label l = new Label(txt);
+ l.setContentMode(Label.CONTENT_XHTML);
+ main.addComponent(l);
+
+ main.addComponent(new Button("Create a new subwindow",
+ new Button.ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ Window w = new Window("Subwindow");
+ Label l = new Label(txt);
+ l.setContentMode(Label.CONTENT_XHTML);
+ w.addComponent(l);
+ getApplication().getMainWindow().addWindow(w);
+ }
+ }));
+ main.addComponent(new Button(
+ "Open a application-level window, with shared state",
+ new Button.ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ if (windowUrl == null) {
+ Window w = new Window("Subwindow");
+ 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");
+ }
+ }));
+ main.addComponent(new Button(
+ "Create a new application-level window, with it's own state",
+ new Button.ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ Window w = new Window("Subwindow");
+ getApplication().addWindow(w);
+ Label l = new Label(w.getName());
+ l
+ .setCaption("Each opened window has a separate value:");
+ w.addComponent(l);
+ getApplication().getMainWindow().open(
+ new ExternalResource(w.getURL()), "_new");
+ }
+ }));
+
}
}
|