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
// 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);
*/\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
*/\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