Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIvan Furnadjiev2016-04-15 05:53:23 -0400
committerIvan Furnadjiev2016-04-19 10:03:12 -0400
commit6f804432861d6d14510fa49870e4001971f2ef3a (patch)
treed461c3e95ee559248333d2f554b364a369d65b36 /bundles
parent65476668a63bdf1e9586adeb9c6f0bf4e1e57dd8 (diff)
downloadorg.eclipse.rap-6f804432861d6d14510fa49870e4001971f2ef3a.tar.gz
org.eclipse.rap-6f804432861d6d14510fa49870e4001971f2ef3a.tar.xz
org.eclipse.rap-6f804432861d6d14510fa49870e4001971f2ef3a.zip
Add support for website-like scrolling
Native browser page scrolling is useful for website-like RAP applications. To enable it, WebClient#PAGE_OVERFLOW entry point property must be set with one of the values "scroll", "scrollX" or "scrollY". Set blocking overlay and modal shells (dialogs) CSS position to "fixed" to prevent them from scrolling. Bug 355852 - Support website-like scrolling https://bugs.eclipse.org/bugs/show_bug.cgi?id=355852 Change-Id: I9f409e1bbf4bfa100471656b334b201397630eb2
Diffstat (limited to 'bundles')
-rw-r--r--bundles/org.eclipse.rap.rwt/js/rwt/remote/handler/DisplayHandler.js3
-rw-r--r--bundles/org.eclipse.rap.rwt/js/rwt/runtime/ErrorHandler.js4
-rw-r--r--bundles/org.eclipse.rap.rwt/js/rwt/widgets/Display.js8
-rw-r--r--bundles/org.eclipse.rap.rwt/js/rwt/widgets/Shell.js5
-rw-r--r--bundles/org.eclipse.rap.rwt/js/rwt/widgets/base/ClientDocument.js32
-rw-r--r--bundles/org.eclipse.rap.rwt/src/org/eclipse/rap/rwt/client/WebClient.java12
-rw-r--r--bundles/org.eclipse.rap.rwt/widgetkits/org/eclipse/swt/internal/widgets/displaykit/DisplayLCA.java31
7 files changed, 82 insertions, 13 deletions
diff --git a/bundles/org.eclipse.rap.rwt/js/rwt/remote/handler/DisplayHandler.js b/bundles/org.eclipse.rap.rwt/js/rwt/remote/handler/DisplayHandler.js
index a4a96dd5b1..737f8070f7 100644
--- a/bundles/org.eclipse.rap.rwt/js/rwt/remote/handler/DisplayHandler.js
+++ b/bundles/org.eclipse.rap.rwt/js/rwt/remote/handler/DisplayHandler.js
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011, 2013 EclipseSource and others.
+ * Copyright (c) 2011, 2016 EclipseSource and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -18,6 +18,7 @@ rwt.remote.HandlerRegistry.add( "rwt.widgets.Display", {
destructor : null, // destroy is currently not called for display
properties : [
+ "overflow",
"exitConfirmation",
"mnemonicActivator",
"focusControl",
diff --git a/bundles/org.eclipse.rap.rwt/js/rwt/runtime/ErrorHandler.js b/bundles/org.eclipse.rap.rwt/js/rwt/runtime/ErrorHandler.js
index 2a69bd2881..754a25f216 100644
--- a/bundles/org.eclipse.rap.rwt/js/rwt/runtime/ErrorHandler.js
+++ b/bundles/org.eclipse.rap.rwt/js/rwt/runtime/ErrorHandler.js
@@ -174,7 +174,7 @@ rwt.qx.Class.define( "rwt.runtime.ErrorHandler", {
var color = themeStore.getColor( "SystemMessage-DisplayOverlay", {}, "background-color" );
var alpha = themeStore.getAlpha( "SystemMessage-DisplayOverlay", {}, "background-color" );
var style = element.style;
- style.position = "absolute";
+ style.position = "fixed";
style.width = "100%";
style.height = "100%";
style.backgroundColor = color === "undefined" ? "transparent" : color;
@@ -202,7 +202,7 @@ rwt.qx.Class.define( "rwt.runtime.ErrorHandler", {
_createErrorBoxArea : function( width, height ) {
var element = document.createElement( "div" );
var style = element.style;
- style.position = "absolute";
+ style.position = "fixed";
style.width = width + "px";
style.height = height + "px";
var doc = rwt.widgets.base.ClientDocument.getInstance();
diff --git a/bundles/org.eclipse.rap.rwt/js/rwt/widgets/Display.js b/bundles/org.eclipse.rap.rwt/js/rwt/widgets/Display.js
index bc114c2521..4bb6fa60cc 100644
--- a/bundles/org.eclipse.rap.rwt/js/rwt/widgets/Display.js
+++ b/bundles/org.eclipse.rap.rwt/js/rwt/widgets/Display.js
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011, 2015 EclipseSource and others.
+ * Copyright (c) 2011, 2016 EclipseSource and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -68,6 +68,12 @@ rwt.widgets.Display.prototype = {
// do nothing for now, used by native clients
},
+ setOverflow : function( overflow ) {
+ if( overflow === "scroll" || overflow === "scrollX" || overflow === "scrollY" ) {
+ this._document.setOverflow( overflow );
+ }
+ },
+
/**
* An exit confirmation dialog will be displayed if the given message is not
* null. If the message is empty, the dialog will be displayed but without a
diff --git a/bundles/org.eclipse.rap.rwt/js/rwt/widgets/Shell.js b/bundles/org.eclipse.rap.rwt/js/rwt/widgets/Shell.js
index 3b71c4fff4..a89f800e0d 100644
--- a/bundles/org.eclipse.rap.rwt/js/rwt/widgets/Shell.js
+++ b/bundles/org.eclipse.rap.rwt/js/rwt/widgets/Shell.js
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2002, 2015 Innoopract Informationssysteme GmbH and others.
+ * Copyright (c) 2002, 2016 Innoopract Informationssysteme GmbH and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -246,6 +246,9 @@ rwt.qx.Class.define( "rwt.widgets.Shell", {
this._appModal = this.hasState( "rwt_APPLICATION_MODAL" )
|| this.hasState( "rwt_PRIMARY_MODAL" )
|| this.hasState( "rwt_SYSTEM_MODAL" );
+ if( this._appModal ) {
+ this.setStyleProperty( "position", "fixed" );
+ }
},
// TODO [rst] Find a generic solution for state inheritance
diff --git a/bundles/org.eclipse.rap.rwt/js/rwt/widgets/base/ClientDocument.js b/bundles/org.eclipse.rap.rwt/js/rwt/widgets/base/ClientDocument.js
index 6436b40c2e..5c8beb19cd 100644
--- a/bundles/org.eclipse.rap.rwt/js/rwt/widgets/base/ClientDocument.js
+++ b/bundles/org.eclipse.rap.rwt/js/rwt/widgets/base/ClientDocument.js
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2014 1&1 Internet AG, Germany, http://www.1und1.de,
+ * Copyright (c) 2004, 2016 1&1 Internet AG, Germany, http://www.1und1.de,
* EclipseSource, and others.
*
* All rights reserved. This program and the accompanying materials
@@ -61,8 +61,9 @@ rwt.qx.Class.define( "rwt.widgets.base.ClientDocument", {
this.getElement().style.position = "absolute";
this.setSelectable( true );
}
- this._document.documentElement.onscroll = this._resetScrollPosition;
- this.getElement().onscroll = this._resetScrollPosition;
+ var resetScrollPosition = rwt.util.Functions.bind( this._resetScrollPosition, this );
+ this._document.documentElement.onscroll = resetScrollPosition;
+ this.getElement().onscroll = resetScrollPosition;
},
properties : {
@@ -133,6 +134,17 @@ rwt.qx.Class.define( "rwt.widgets.base.ClientDocument", {
_applyParent : rwt.util.Functions.returnTrue,
+ _applyOverflow : function( value ) {
+ var property = "overflow";
+ if( value === "scrollX" ) {
+ property = "overflowX";
+ } else if( value === "scrollY" ) {
+ property = "overflowY";
+ }
+ this._document.documentElement.style[ property ] = value === "hidden" ? value : "auto";
+ this.getElement().style[ property ] = value === "hidden" ? value : "auto";
+ },
+
getTopLevelWidget : function() {
return this;
},
@@ -172,6 +184,7 @@ rwt.qx.Class.define( "rwt.widgets.base.ClientDocument", {
if( !this._blocker ) {
// Create blocker instance
this._blocker = new rwt.widgets.base.ClientDocumentBlocker();
+ this._blocker.setStyleProperty( "position", "fixed" );
// Add blocker to client document
this.add( this._blocker );
}
@@ -206,10 +219,15 @@ rwt.qx.Class.define( "rwt.widgets.base.ClientDocument", {
},
_resetScrollPosition : function() {
- document.documentElement.scrollTop = 0;
- document.documentElement.scrollLeft = 0;
- document.body.scrollTop = 0;
- document.body.scrollLeft = 0;
+ var overflow = this.getOverflow();
+ if( overflow !== "scroll" && overflow !== "scrollX" ) {
+ document.documentElement.scrollLeft = 0;
+ document.body.scrollLeft = 0;
+ }
+ if( overflow !== "scroll" && overflow !== "scrollY" ) {
+ document.documentElement.scrollTop = 0;
+ document.body.scrollTop = 0;
+ }
},
// CSS API
diff --git a/bundles/org.eclipse.rap.rwt/src/org/eclipse/rap/rwt/client/WebClient.java b/bundles/org.eclipse.rap.rwt/src/org/eclipse/rap/rwt/client/WebClient.java
index cbe70f9f65..093f4c28bb 100644
--- a/bundles/org.eclipse.rap.rwt/src/org/eclipse/rap/rwt/client/WebClient.java
+++ b/bundles/org.eclipse.rap.rwt/src/org/eclipse/rap/rwt/client/WebClient.java
@@ -109,6 +109,18 @@ public class WebClient implements Client {
public static final String PAGE_TITLE = PREFIX + ".pageTitle";
/**
+ * Entrypoint property name for the page overflow behavior. The value must be one of the
+ * "scroll", "scrollX", "scrollY". If this property is not set the page overflow is
+ * disabled.
+ *
+ * @see Application#addEntryPoint(String, Class, Map)
+ * @see Application#addEntryPoint(String, EntryPointFactory, Map)
+ *
+ * @since 3.1
+ */
+ public static final String PAGE_OVERFLOW = PREFIX + ".pageOverflow";
+
+ /**
* Entrypoint property name for the website icon (a.k.a favicon or shortcut icon) that will be
* displayed by the web browser. The value must contain a valid path where the image can be
* accessed on the server.
diff --git a/bundles/org.eclipse.rap.rwt/widgetkits/org/eclipse/swt/internal/widgets/displaykit/DisplayLCA.java b/bundles/org.eclipse.rap.rwt/widgetkits/org/eclipse/swt/internal/widgets/displaykit/DisplayLCA.java
index 7d11b079ae..4ace838842 100644
--- a/bundles/org.eclipse.rap.rwt/widgetkits/org/eclipse/swt/internal/widgets/displaykit/DisplayLCA.java
+++ b/bundles/org.eclipse.rap.rwt/widgetkits/org/eclipse/swt/internal/widgets/displaykit/DisplayLCA.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2002, 2015 Innoopract Informationssysteme GmbH and others.
+ * Copyright (c) 2002, 2016 Innoopract Informationssysteme GmbH and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -19,13 +19,20 @@ import static org.eclipse.rap.rwt.internal.lifecycle.WidgetUtil.getLCA;
import static org.eclipse.rap.rwt.internal.protocol.ClientMessageConst.EVENT_RESIZE;
import static org.eclipse.rap.rwt.internal.protocol.ProtocolUtil.handleOperation;
import static org.eclipse.rap.rwt.internal.protocol.RemoteObjectFactory.getRemoteObject;
+import static org.eclipse.rap.rwt.internal.service.ContextProvider.getRequest;
import java.io.IOException;
+import java.util.Collections;
import java.util.List;
+import java.util.Map;
import org.eclipse.rap.rwt.RWT;
+import org.eclipse.rap.rwt.client.WebClient;
import org.eclipse.rap.rwt.client.service.ExitConfirmation;
+import org.eclipse.rap.rwt.internal.application.ApplicationContextImpl;
import org.eclipse.rap.rwt.internal.lifecycle.DisposedWidgets;
+import org.eclipse.rap.rwt.internal.lifecycle.EntryPointManager;
+import org.eclipse.rap.rwt.internal.lifecycle.EntryPointRegistration;
import org.eclipse.rap.rwt.internal.lifecycle.RemoteAdapter;
import org.eclipse.rap.rwt.internal.lifecycle.ReparentedControls;
import org.eclipse.rap.rwt.internal.lifecycle.UITestUtil;
@@ -34,6 +41,7 @@ import org.eclipse.rap.rwt.internal.protocol.Operation;
import org.eclipse.rap.rwt.internal.protocol.ProtocolUtil;
import org.eclipse.rap.rwt.internal.protocol.RemoteObjectFactory;
import org.eclipse.rap.rwt.internal.remote.RemoteObjectLifeCycleAdapter;
+import org.eclipse.rap.rwt.internal.service.ContextProvider;
import org.eclipse.rap.rwt.internal.textsize.MeasurementUtil;
import org.eclipse.rap.rwt.internal.util.ActiveKeysUtil;
import org.eclipse.rap.rwt.remote.OperationHandler;
@@ -85,6 +93,7 @@ public class DisplayLCA {
}
public void render( Display display ) throws IOException {
+ renderOverflow( display );
renderReparentControls();
renderDisposeWidgets();
renderExitConfirmation( display );
@@ -140,6 +149,26 @@ public class DisplayLCA {
}
}
+ private static void renderOverflow( Display display ) {
+ if( !getAdapter( display ).isInitialized() ) {
+ String overflow = getEntryPointProperties().get( WebClient.PAGE_OVERFLOW );
+ if( overflow != null ) {
+ RemoteObjectFactory.getRemoteObject( display ).set( "overflow", overflow );
+ }
+ }
+ }
+
+ private static Map<String, String> getEntryPointProperties() {
+ ApplicationContextImpl applicationContext = ContextProvider.getApplicationContext();
+ EntryPointManager entryPointManager = applicationContext.getEntryPointManager();
+ String servletPath = getRequest().getServletPath();
+ EntryPointRegistration registration = entryPointManager.getRegistrationByPath( servletPath );
+ if( registration != null ) {
+ return registration.getProperties();
+ }
+ return Collections.emptyMap();
+ }
+
private static void renderShells( Display display ) throws IOException {
RenderVisitor visitor = new RenderVisitor();
for( Shell shell : getShells( display ) ) {

Back to the top