]> source.dussan.org Git - vaadin-framework.git/commitdiff
Added RootLayout and implemented rudimentary Root using RootLayout
authorLeif Åstrand <leif@vaadin.com>
Thu, 3 Nov 2011 12:57:26 +0000 (14:57 +0200)
committerLeif Åstrand <leif@vaadin.com>
Thu, 3 Nov 2011 12:57:26 +0000 (14:57 +0200)
src/com/vaadin/RootTestApplication.java
src/com/vaadin/ui/Root.java
src/com/vaadin/ui/RootLayout.java [new file with mode: 0644]

index 8e9bfacfa279e134927fe6872873dde4feca7a2c..2f9cef93e345665f0669d7a163b0dbb52563fcc8 100644 (file)
@@ -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() {
index 0358cba4e8f49ff651e1243192fcb3dafbf7a0e2..75cf6517ddf7d6c4b3fd88e0a2841769cad3c8db 100644 (file)
@@ -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 (file)
index 0000000..8ccd9e6
--- /dev/null
@@ -0,0 +1,5 @@
+package com.vaadin.ui;
+
+public interface RootLayout extends Component {
+    public void init();
+}