From 9a307e04b855af49673d8cebc24dcd7846097d6e Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Wed, 14 Mar 2012 15:34:53 +0200 Subject: [PATCH] Get scroll position from state, where it is available --- .../terminal/gwt/client/ui/WindowConnector.java | 16 ++++++++++++---- src/com/vaadin/ui/Window.java | 15 ++++++++++----- 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/src/com/vaadin/terminal/gwt/client/ui/WindowConnector.java b/src/com/vaadin/terminal/gwt/client/ui/WindowConnector.java index 7e9f7c9580..f1b7232de6 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/WindowConnector.java +++ b/src/com/vaadin/terminal/gwt/client/ui/WindowConnector.java @@ -21,12 +21,17 @@ import com.vaadin.terminal.gwt.client.ComponentConnector; import com.vaadin.terminal.gwt.client.LayoutManager; import com.vaadin.terminal.gwt.client.UIDL; import com.vaadin.terminal.gwt.client.Util; +import com.vaadin.terminal.gwt.client.ui.PanelConnector.PanelState; import com.vaadin.terminal.gwt.client.ui.ShortcutActionHandler.BeforeShortcutActionListener; public class WindowConnector extends AbstractComponentContainerConnector implements BeforeShortcutActionListener, SimpleManagedLayout, PostLayoutListener { + public static class WindowState extends PanelState { + + } + private static final String CLICK_EVENT_IDENTIFIER = PanelConnector.CLICK_EVENT_IDENTIFIER; private ClickEventHandler clickEventHandler = new ClickEventHandler(this, @@ -178,10 +183,9 @@ public class WindowConnector extends AbstractComponentContainerConnector } // setting scrollposition must happen after children is rendered - getWidget().contentPanel.setScrollPosition(uidl - .getIntVariable("scrollTop")); - getWidget().contentPanel.setHorizontalScrollPosition(uidl - .getIntVariable("scrollLeft")); + getWidget().contentPanel.setScrollPosition(getState().getScrollTop()); + getWidget().contentPanel.setHorizontalScrollPosition(getState() + .getScrollLeft()); // Center this window on screen if requested // This had to be here because we might not know the content size before @@ -306,4 +310,8 @@ public class WindowConnector extends AbstractComponentContainerConnector window.updateShadowSizeAndPosition(); } + @Override + public WindowState getState() { + return (WindowState) super.getState(); + } } diff --git a/src/com/vaadin/ui/Window.java b/src/com/vaadin/ui/Window.java index 57ed11f3ba..41bef54fe2 100644 --- a/src/com/vaadin/ui/Window.java +++ b/src/com/vaadin/ui/Window.java @@ -21,9 +21,9 @@ import com.vaadin.event.ShortcutAction.ModifierKey; import com.vaadin.event.ShortcutListener; import com.vaadin.terminal.PaintException; import com.vaadin.terminal.PaintTarget; -import com.vaadin.terminal.gwt.client.ui.PanelConnector.PanelState; import com.vaadin.terminal.gwt.client.ui.VView; import com.vaadin.terminal.gwt.client.ui.WindowConnector; +import com.vaadin.terminal.gwt.client.ui.WindowConnector.WindowState; /** * A component that represents an application (browser native) window or a sub @@ -74,10 +74,6 @@ import com.vaadin.terminal.gwt.client.ui.WindowConnector; @ClientWidget(WindowConnector.class) public class Window extends Panel implements FocusNotifier, BlurNotifier { - public class WindowState extends PanelState { - - } - /** * Sub window only. Top offset in pixels for the sub window (relative * to the parent application window) or -1 if unspecified. @@ -892,4 +888,13 @@ public class Window extends Panel implements FocusNotifier, BlurNotifier { bringToFront(); } + @Override + public WindowState getState() { + return (WindowState) super.getState(); + } + + @Override + protected WindowState createState() { + return new WindowState(); + } } -- 2.39.5