aboutsummaryrefslogtreecommitdiffstats
path: root/server/src/com/vaadin/ui/UI.java
diff options
context:
space:
mode:
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