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() {
@ClientWidget(VView.class)
public class Root extends AbstractComponentContainer {
- private final Component content;
+ private final RootLayout rootLayout;
private Terminal terminal;
private Application application;
*/
private Component scrollIntoView;
- public Root(Component content) {
- this.content = content;
- addComponent(content);
+ public Root(RootLayout rootLayout) {
+ this.rootLayout = rootLayout;
+ addComponent(rootLayout);
+ rootLayout.init();
}
@Override
@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();) {
}
public Iterator<Component> getComponentIterator() {
- return Collections.singleton(content).iterator();
+ return Collections.singleton((Component) rootLayout).iterator();
}
public String getName() {
scrollIntoView = component;
requestRepaint();
}
+
+ public RootLayout getRootLayout() {
+ return rootLayout;
+ }
}