aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLeif Åstrand <leif@vaadin.com>2011-11-03 14:57:26 +0200
committerLeif Åstrand <leif@vaadin.com>2011-11-03 14:57:26 +0200
commitf57881f8d67d9094dba55c04b1ff3e80524e3c15 (patch)
treec6c8dca8cf45abb7d0cfa5227db009e974d7383a /src
parent00a2b867524b21c28d02ad7ee836d33c6b2e12de (diff)
downloadvaadin-framework-f57881f8d67d9094dba55c04b1ff3e80524e3c15.tar.gz
vaadin-framework-f57881f8d67d9094dba55c04b1ff3e80524e3c15.zip
Added RootLayout and implemented rudimentary Root using RootLayout
Diffstat (limited to 'src')
-rw-r--r--src/com/vaadin/RootTestApplication.java24
-rw-r--r--src/com/vaadin/ui/Root.java17
-rw-r--r--src/com/vaadin/ui/RootLayout.java5
3 files changed, 34 insertions, 12 deletions
diff --git a/src/com/vaadin/RootTestApplication.java b/src/com/vaadin/RootTestApplication.java
index 8e9bfacfa2..2f9cef93e3 100644
--- a/src/com/vaadin/RootTestApplication.java
+++ b/src/com/vaadin/RootTestApplication.java
@@ -3,14 +3,26 @@ package com.vaadin;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Root;
+import com.vaadin.ui.RootLayout;
+import com.vaadin.ui.VerticalLayout;
public class RootTestApplication extends Application {
- private final Root root = new Root(new Button("Roots, bloody roots",
- new Button.ClickListener() {
- public void buttonClick(ClickEvent event) {
- root.executeJavaScript("window.alert(\"Here\");");
- }
- }));
+ private static class MyRootLayout extends VerticalLayout implements
+ RootLayout {
+ public void init() {
+ addComponent(new Button("Roots, bloody roots",
+ new Button.ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ event.getButton()
+ .getRoot()
+ .executeJavaScript(
+ "window.alert(\"Here\");");
+ }
+ }));
+ }
+ }
+
+ private final Root root = new Root(new MyRootLayout());
@Override
public void init() {
diff --git a/src/com/vaadin/ui/Root.java b/src/com/vaadin/ui/Root.java
index 0358cba4e8..75cf6517dd 100644
--- a/src/com/vaadin/ui/Root.java
+++ b/src/com/vaadin/ui/Root.java
@@ -18,7 +18,7 @@ import com.vaadin.ui.Window.Notification;
@ClientWidget(VView.class)
public class Root extends AbstractComponentContainer {
- private final Component content;
+ private final RootLayout rootLayout;
private Terminal terminal;
private Application application;
@@ -45,9 +45,10 @@ public class Root extends AbstractComponentContainer {
*/
private Component scrollIntoView;
- public Root(Component content) {
- this.content = content;
- addComponent(content);
+ public Root(RootLayout rootLayout) {
+ this.rootLayout = rootLayout;
+ addComponent(rootLayout);
+ rootLayout.init();
}
@Override
@@ -66,7 +67,7 @@ public class Root extends AbstractComponentContainer {
@Override
public void paintContent(PaintTarget target) throws PaintException {
- content.paint(target);
+ rootLayout.paint(target);
// Paint subwindows
for (final Iterator<Window> i = windows.iterator(); i.hasNext();) {
@@ -132,7 +133,7 @@ public class Root extends AbstractComponentContainer {
}
public Iterator<Component> getComponentIterator() {
- return Collections.singleton(content).iterator();
+ return Collections.singleton((Component) rootLayout).iterator();
}
public String getName() {
@@ -438,4 +439,8 @@ public class Root extends AbstractComponentContainer {
scrollIntoView = component;
requestRepaint();
}
+
+ public RootLayout getRootLayout() {
+ return rootLayout;
+ }
}
diff --git a/src/com/vaadin/ui/RootLayout.java b/src/com/vaadin/ui/RootLayout.java
new file mode 100644
index 0000000000..8ccd9e6c08
--- /dev/null
+++ b/src/com/vaadin/ui/RootLayout.java
@@ -0,0 +1,5 @@
+package com.vaadin.ui;
+
+public interface RootLayout extends Component {
+ public void init();
+}