summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarko Grönroos <magi@iki.fi>2009-05-28 17:03:51 +0000
committerMarko Grönroos <magi@iki.fi>2009-05-28 17:03:51 +0000
commitb62e390cc70840e5b4c9c94a68dcfb51c806ad96 (patch)
tree11cf3947b85fa6ea16b067a81bc4fbd3aeec72d5
parent2a6155bab6eeda7c3cce234e2853b601f8916225 (diff)
downloadvaadin-framework-b62e390cc70840e5b4c9c94a68dcfb51c806ad96.tar.gz
vaadin-framework-b62e390cc70840e5b4c9c94a68dcfb51c806ad96.zip
Book example for layout.
svn changeset:8073/svn branch:6.0
-rw-r--r--WebContent/VAADIN/themes/tests-book/styles.css34
-rw-r--r--src/com/vaadin/tests/book/BookTestApplication.java117
2 files changed, 150 insertions, 1 deletions
diff --git a/WebContent/VAADIN/themes/tests-book/styles.css b/WebContent/VAADIN/themes/tests-book/styles.css
index d24213be67..aef1fb9d29 100644
--- a/WebContent/VAADIN/themes/tests-book/styles.css
+++ b/WebContent/VAADIN/themes/tests-book/styles.css
@@ -172,3 +172,37 @@ table.v-gridlayout-spacingexample {
.v-richtextarea-richtextexample .gwt-ToggleButton .gwt-Image {
background-image: url(img/richtextarea-toolbar-fi.png) !important;
}
+
+/*****************************************************************************/
+/* For example_Layout() */
+/*****************************************************************************/
+.v-verticallayout-layoutexample {
+ background: gray;
+}
+
+.layoutexample .v-verticallayout .v-label {
+ color: white;
+ background: gray;
+}
+
+.layoutexample .v-label-title {
+ font-size: 24pt;
+ color: white;
+ line-height:36pt;
+ background: black;
+}
+
+.layoutexample .v-panel .v-label {
+ font-size: 24pt;
+ color: gray;
+ line-height: 36pt;
+ background: white;
+}
+
+.layoutexample .treecontainer, .layoutexample .v-panel, .layoutexample .v-caption {
+ background: white;
+}
+
+.layoutexample .v-horizontallayout-spacing-on {
+ padding-left: 4px;
+}
diff --git a/src/com/vaadin/tests/book/BookTestApplication.java b/src/com/vaadin/tests/book/BookTestApplication.java
index d80dccb901..a55a0769c1 100644
--- a/src/com/vaadin/tests/book/BookTestApplication.java
+++ b/src/com/vaadin/tests/book/BookTestApplication.java
@@ -31,6 +31,7 @@ import com.vaadin.terminal.UserError;
import com.vaadin.terminal.gwt.server.WebApplicationContext;
import com.vaadin.ui.AbsoluteLayout;
import com.vaadin.ui.AbstractSelect;
+import com.vaadin.ui.Alignment;
import com.vaadin.ui.Button;
import com.vaadin.ui.CheckBox;
import com.vaadin.ui.Component;
@@ -51,6 +52,7 @@ import com.vaadin.ui.PopupDateField;
import com.vaadin.ui.ProgressIndicator;
import com.vaadin.ui.RichTextArea;
import com.vaadin.ui.Select;
+import com.vaadin.ui.SplitPanel;
import com.vaadin.ui.TabSheet;
import com.vaadin.ui.Table;
import com.vaadin.ui.TextField;
@@ -158,7 +160,7 @@ public class BookTestApplication extends com.vaadin.Application {
"customlayout", "spacing", "margin", "clientinfo",
"fillinform/templates", "notification", "print",
"richtextfield", "querycontainer", "menubar",
- "absolutelayout"};
+ "absolutelayout", "layout/intro"};
for (int i = 0; i < examples.length; i++) {
grid.addComponent(new Label("<a href='"
+ context.toString() + examples[i] + "'>"
@@ -245,6 +247,8 @@ public class BookTestApplication extends com.vaadin.Application {
example_MenuBar(main, param);
} else if (example.equals("absolutelayout")) {
example_AbsoluteLayout(main, param);
+ } else if (example.equals("layout")) {
+ example_Layout(main, param);
} else {
; // main.addComponent(new
// Label("Unknown test '"+example+"'."));
@@ -1779,4 +1783,115 @@ public class BookTestApplication extends com.vaadin.Application {
final Button button = new Button ("This could be anywhere");
layout.addComponent(button, "top: 100px; left: 50px;");
}
+
+ void example_Layout(final Window main, String param) {
+ if (param.equals("intro")) {
+ // Set the root layout (VerticalLayout is actually the default).
+ VerticalLayout root = new VerticalLayout();
+ main.setContent(root);
+
+ // Add some components.
+ Label title = new Label("The Ultimate Cat Finder");
+ main.addComponent(title);
+
+ // Horizontal layout with selection tree on the left and
+ // a details panel on the right.
+ HorizontalLayout horlayout = new HorizontalLayout();
+ main.addComponent(horlayout);
+
+ // Layout for the left-hand side
+ VerticalLayout treeContainer = new VerticalLayout();
+ horlayout.addComponent(treeContainer);
+
+ // Add some instructions.
+ treeContainer.addComponent(new Label("The Planets and Major Moons"));
+
+ // A selection tree, fill it later.
+ Tree tree = new Tree();
+ treeContainer.addComponent(tree);
+
+ // A panel for the right size area.
+ Panel detailspanel = new Panel("Details");
+ detailspanel.setSizeFull();
+ horlayout.addComponent(detailspanel);
+
+ // Have a vertical layout in the Details panel.
+ VerticalLayout detailslayout = new VerticalLayout();
+ detailspanel.setContent(detailslayout);
+
+ // Put some stuff in the Details view.
+ detailslayout.addComponent(new Label("Where is the cat?"));
+ detailslayout.addComponent(new Label("I don't know!"));
+
+ // // // // // //
+
+ horlayout.setExpandRatio(detailspanel, 1);
+ horlayout.setExpandRatio(treeContainer, 0);
+ horlayout.setSizeFull();
+ horlayout.setSpacing(true);
+
+ root.addStyleName("layoutexample");
+ root.setSizeFull();
+ root.setExpandRatio(horlayout, 1);
+
+ title.addStyleName("title");
+ tree.setSizeUndefined();
+ tree.setHeight("100%");
+ treeContainer.addStyleName("treecontainer");
+ treeContainer.setSizeUndefined();
+ treeContainer.setHeight("100%");
+ treeContainer.setExpandRatio(tree, 1);
+ detailspanel.addStyleName("light");
+
+ for (Iterator i = detailslayout.getComponentIterator(); i.hasNext();) {
+ Label c = (Label)i.next();
+ detailslayout.setComponentAlignment(c, Alignment.MIDDLE_CENTER);
+ c.setSizeUndefined();
+ }
+
+ final Object[][] planets = new Object[][] {
+ new Object[] { "Mercury" },
+ new Object[] { "Venus" },
+ new Object[] { "Earth", "The Moon" },
+ new Object[] { "Mars", "Phobos", "Deimos" },
+ new Object[] { "Jupiter", "Io", "Europa", "Ganymedes",
+ "Callisto" },
+ new Object[] { "Saturn", "Titan", "Tethys", "Dione", "Rhea",
+ "Iapetus" },
+ new Object[] { "Uranus", "Miranda", "Ariel", "Umbriel",
+ "Titania", "Oberon" },
+ new Object[] { "Neptune", "Triton", "Proteus", "Nereid",
+ "Larissa" } };
+
+ // Add planets as root items in the tree.
+ for (int i = 0; i < planets.length; i++) {
+ final String planet = (String) (planets[i][0]);
+ tree.addItem(planet);
+
+ if (planets[i].length == 1) {
+ // The planet has no moons so make it a leaf.
+ tree.setChildrenAllowed(planet, false);
+ } else {
+ // Add children (moons) under the planets.
+ for (int j = 1; j < planets[i].length; j++) {
+ final String moon = (String) planets[i][j];
+
+ // Add the item as a regular item.
+ tree.addItem(moon);
+
+ // Set it to be a child.
+ tree.setParent(moon, planet);
+
+ // Make the moons look like leaves.
+ tree.setChildrenAllowed(moon, false);
+ }
+
+ // Expand the subtree.
+ tree.expandItemsRecursively(planet);
+ }
+ }
+
+
+ }
+ }
}