summaryrefslogtreecommitdiffstats
path: root/server/src/com/vaadin/ui/UI.java
diff options
context:
space:
mode:
authorLeif Åstrand <leif@vaadin.com>2012-11-29 16:36:27 +0200
committerVaadin Code Review <review@vaadin.com>2012-11-30 07:42:46 +0000
commit9dd665b56eb4166d2af92a4825c37d20d15ed413 (patch)
treecb49de0aa15e6e8a29464e928c4653dd6ba19dad /server/src/com/vaadin/ui/UI.java
parentcfb2513cd2049d6cae90b6d2c725a03e75194ce9 (diff)
downloadvaadin-framework-9dd665b56eb4166d2af92a4825c37d20d15ed413.tar.gz
vaadin-framework-9dd665b56eb4166d2af92a4825c37d20d15ed413.zip
UI scroll position can be given programmatically (#9952)
Change-Id: Icef0858ee495abcacab7823f7f8fc6044abd64dc
Diffstat (limited to 'server/src/com/vaadin/ui/UI.java')
-rw-r--r--server/src/com/vaadin/ui/UI.java55
1 files changed, 54 insertions, 1 deletions
diff --git a/server/src/com/vaadin/ui/UI.java b/server/src/com/vaadin/ui/UI.java
index 55f756010e..b45aedb8e1 100644
--- a/server/src/com/vaadin/ui/UI.java
+++ b/server/src/com/vaadin/ui/UI.java
@@ -39,6 +39,7 @@ import com.vaadin.server.VaadinServlet;
import com.vaadin.server.VaadinSession;
import com.vaadin.shared.EventId;
import com.vaadin.shared.MouseEventDetails;
+import com.vaadin.shared.ui.ui.ScrollClientRpc;
import com.vaadin.shared.ui.ui.UIConstants;
import com.vaadin.shared.ui.ui.UIServerRpc;
import com.vaadin.shared.ui.ui.UIState;
@@ -114,6 +115,16 @@ public abstract class UI extends AbstractSingleComponentContainer implements
private Page page = new Page(this);
+ /**
+ * Scroll Y position.
+ */
+ private int scrollTop = 0;
+
+ /**
+ * Scroll X position
+ */
+ private int scrollLeft = 0;
+
private UIServerRpc rpc = new UIServerRpc() {
@Override
public void click(MouseEventDetails mouseDetails) {
@@ -126,6 +137,12 @@ public abstract class UI extends AbstractSingleComponentContainer implements
// TODO We're not doing anything with the view dimensions
getPage().updateBrowserWindowSize(windowWidth, windowHeight);
}
+
+ @Override
+ public void scroll(int scrollTop, int scrollLeft) {
+ UI.this.scrollTop = scrollTop;
+ UI.this.scrollLeft = scrollLeft;
+ }
};
/**
@@ -560,8 +577,44 @@ public abstract class UI extends AbstractSingleComponentContainer implements
return CurrentInstance.get(UI.class);
}
+ /**
+ * Set top offset to which the UI should scroll to.
+ *
+ * @param scrollTop
+ */
public void setScrollTop(int scrollTop) {
- throw new RuntimeException("Not yet implemented");
+ if (scrollTop < 0) {
+ throw new IllegalArgumentException(
+ "Scroll offset must be at least 0");
+ }
+ if (this.scrollTop != scrollTop) {
+ this.scrollTop = scrollTop;
+ getRpcProxy(ScrollClientRpc.class).setScrollTop(scrollTop);
+ }
+ }
+
+ public int getScrollTop() {
+ return scrollTop;
+ }
+
+ /**
+ * Set left offset to which the UI should scroll to.
+ *
+ * @param scrollLeft
+ */
+ public void setScrollLeft(int scrollLeft) {
+ if (scrollLeft < 0) {
+ throw new IllegalArgumentException(
+ "Scroll offset must be at least 0");
+ }
+ if (this.scrollLeft != scrollLeft) {
+ this.scrollLeft = scrollLeft;
+ getRpcProxy(ScrollClientRpc.class).setScrollLeft(scrollLeft);
+ }
+ }
+
+ public int getScrollLeft() {
+ return scrollLeft;
}
@Override