]> source.dussan.org Git - vaadin-framework.git/commitdiff
Examples added.
authorMarc Englund <marc.englund@itmill.com>
Thu, 29 Nov 2007 12:45:42 +0000 (12:45 +0000)
committerMarc Englund <marc.englund@itmill.com>
Thu, 29 Nov 2007 12:45:42 +0000 (12:45 +0000)
svn changeset:3037/svn branch:trunk

src/com/itmill/toolkit/demo/featurebrowser/EmbeddedBrowserExample.java
src/com/itmill/toolkit/demo/featurebrowser/FeatureBrowser.java
src/com/itmill/toolkit/demo/featurebrowser/NotificationExample.java
src/com/itmill/toolkit/demo/featurebrowser/WindowingExample.java

index ebbbbce16b6316af4ea62c5a597e003fce540049..7bebaf38c38a7ab605d314aeb7b91967fa66150d 100644 (file)
@@ -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);
index b5dba0ee0c427cb2d53f511c99b248b6786c99af..365b86299b6945d9218c33010398e860ea12853b 100644 (file)
@@ -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,
index c007df8e74852c6d821c49151f5cb146f368d76a..f0f8e2ac548d4457544eb6ee86df5fc5e9b10f71 100644 (file)
@@ -86,5 +86,7 @@ public class NotificationExample extends CustomComponent {
             }
         });
         main.addComponent(b);
+        main.setComponentAlignment(b, OrderedLayout.ALIGNMENT_RIGHT,
+                OrderedLayout.ALIGNMENT_VERTICAL_CENTER);
     }
 }
index 2871aef7697054e1a6f5b6e7d33385551328ce96..891e450dbea32d3b03a2bab650197889d6f5e50e 100644 (file)
@@ -3,8 +3,15 @@
  */\r
 package com.itmill.toolkit.demo.featurebrowser;\r
 \r
+import java.net.URL;\r
+\r
+import com.itmill.toolkit.terminal.ExternalResource;\r
+import com.itmill.toolkit.ui.Button;\r
 import com.itmill.toolkit.ui.CustomComponent;\r
+import com.itmill.toolkit.ui.Label;\r
 import com.itmill.toolkit.ui.OrderedLayout;\r
+import com.itmill.toolkit.ui.Window;\r
+import com.itmill.toolkit.ui.Button.ClickEvent;\r
 \r
 /**\r
  * @author marc\r
@@ -12,17 +19,73 @@ import com.itmill.toolkit.ui.OrderedLayout;
  */\r
 public class WindowingExample extends CustomComponent {\r
 \r
-    public static final String txt = "There are two main types of windows:";\r
+    public static final String txt = "<p>There are two main types of windows: application-level windows, and"\r
+            + "\"subwindows\". </p><p> A subwindow is rendered as a \"inline\" popup window"\r
+            + " within the (native) browser window to which it was added. You can create"\r
+            + " a subwindow by creating a new Window and adding it to a application-level window, for instance"\r
+            + " your main window. </p><p> In contrast, you create a application-level window by"\r
+            + " creating a new Window and adding it to the Application. Application-level"\r
+            + " windows are not shown by default - you need to open a browser window for"\r
+            + " the url representing the window. You can think of the application-level"\r
+            + " windows as separate views into your application - and a way to create a"\r
+            + " \"native\" browser window. </p><p> Depending on your needs, it's also"\r
+            + " possible to create a new window instance (with it's own internal state)"\r
+            + " for each new (native) browser window, or you can share the same instance"\r
+            + " (and state) between several browser windows (the latter is most useful"\r
+            + " for read-only views).</p>";\r
 \r
-    /*\r
-     * application-level windows, and\r
-     * \r
-     */\r
+    private URL windowUrl = null;\r
 \r
     public WindowingExample() {\r
         OrderedLayout main = new OrderedLayout();\r
+        main.setMargin(true);\r
         setCompositionRoot(main);\r
 \r
+        Label l = new Label(txt);\r
+        l.setContentMode(Label.CONTENT_XHTML);\r
+        main.addComponent(l);\r
+\r
+        main.addComponent(new Button("Create a new subwindow",\r
+                new Button.ClickListener() {\r
+                    public void buttonClick(ClickEvent event) {\r
+                        Window w = new Window("Subwindow");\r
+                        Label l = new Label(txt);\r
+                        l.setContentMode(Label.CONTENT_XHTML);\r
+                        w.addComponent(l);\r
+                        getApplication().getMainWindow().addWindow(w);\r
+                    }\r
+                }));\r
+        main.addComponent(new Button(\r
+                "Open a application-level window, with shared state",\r
+                new Button.ClickListener() {\r
+                    public void buttonClick(ClickEvent event) {\r
+                        if (windowUrl == null) {\r
+                            Window w = new Window("Subwindow");\r
+                            Label l = new Label(txt);\r
+                            l.setContentMode(Label.CONTENT_XHTML);\r
+                            w.addComponent(l);\r
+                            getApplication().addWindow(w);\r
+                            windowUrl = w.getURL();\r
+                        }\r
+                        getApplication().getMainWindow().open(\r
+                                new ExternalResource(windowUrl), "_new");\r
+                    }\r
+                }));\r
+        main.addComponent(new Button(\r
+                "Create a new application-level window, with it's own state",\r
+                new Button.ClickListener() {\r
+                    public void buttonClick(ClickEvent event) {\r
+                        Window w = new Window("Subwindow");\r
+                        getApplication().addWindow(w);\r
+                        Label l = new Label(w.getName());\r
+                        l\r
+                                .setCaption("Each opened window has a separate value:");\r
+                        w.addComponent(l);\r
+                        getApplication().getMainWindow().open(\r
+                                new ExternalResource(w.getURL()), "_new");\r
+                    }\r
+                }));\r
+\r
     }\r
 \r
 }\r