summaryrefslogtreecommitdiffstats
path: root/client/src
diff options
context:
space:
mode:
authorDenis Anisimov <denis@vaadin.com>2016-09-28 13:24:42 +0300
committerDenis Anisimov <denis@vaadin.com>2016-10-03 09:00:48 +0300
commit43bb825f0e7fbaa3a1382f85c9b2f6f6c4fe3ac4 (patch)
tree6ba789759db22c0d8042c4ede8d91593b648ed7e /client/src
parentd6967afcbc87836464b39b22b2d424a336403952 (diff)
downloadvaadin-framework-43bb825f0e7fbaa3a1382f85c9b2f6f6c4fe3ac4.tar.gz
vaadin-framework-43bb825f0e7fbaa3a1382f85c9b2f6f6c4fe3ac4.zip
Migrating 7.7.1, 7.7.2, 7.7.3 to V8.
commit 11c3f8bd9ea65f7a7b8da9a282c31a127bd475a6 - Test and its UI class are added (both V8 and V7). Required functionality should be available via modern GWT version. commit 729dbf96fe76e7627168ab2c9d1d71c4eb7214c8 - About update release notes. No need to be included. commit 675f38349c43ac45dae40cf33a7b1fd0f8f261ca - V8 already contains correct Import-Packages section which uses osgi.javax.servlet.version variable whise version is 3.0.0 at the moment. commit 5da7c052f55cb4703b74f38f5bb19fc3f3fa2a76 - Use Vaadin plugin 7.7.0 from 7.7.0.alpha1. Is not applicable. commit 1df80001ab6c916effa917781dba652d09d01056 - Updated tutorial to Vaadin 7.7.0. Is not applicable. The tutorial already contains correct links and updated source code snippets. commit 8b4f0ed8a894b04902a5d4258119dcdc8e76d1e0 - set-property-fallback name="user.agent" value="safari". Is already there. commit 28ed04e827669cc4dd329331dac9699bd93f70bc - Fix animation end listeners so they are always removed. Is already there. commit 408253bc3f8bd3975f0525ce6832be214a3552e9 - Use servlet context classloader when finding servlet class for websockets. Is already there. commit 7a6f250d89474849648ed2ee96a6bfb78c3b9ca8 - Fire actions before removing menu from the DOM. Is already there. commit 9b66c6eb9bebf657d3f2def8c767e0e9d51cc92c - Do not run test on IE8 as IE8 is broken. Transplanted. commit 3faa43ff39ecda56587b93f0c5e262a2907871a7 - Discard for DateField when the data source contains null. It is not applicable for V8 (There is no anymore discard method in DateField (and no datasource suport in field)). Transplanted for DateField in compatibility. commit e0c1f91a3d6d1884e07ce8d1ba957aff6a9bf29a - Fix ComboBox paging when number of items equals page length. It's already done by another fix which replaced ComboBox in compatibility package to the V7 version. commit 83a1b8a0961cc9b2d43e01757530cefd035b0a22 - Update DOM and update escalator row count in the correct order. Transplanted. commit 45f2fba8ff7a4b62680618a325d4afcebfb7a1e9 - Prevent editor from being canceled while it is being saved. Transplanted to compatibility package. Is not applicable to modern Grid. commit ad67f7f43afb0feec5e029aea90297f2abe4f2c1 - Delete broken stylesheet and revert to default style until a new stylesheet is created. Is already there. commit c970a78d42a2d8f1745df7a11a74f3731f8be9a5 - Always show loading indicator for JavaScript RPC. Transplanted. commit 2aad3416061586f7e2649160bd832eefe03702ad - Make test independent of any converters present in the factory. It's already there. commit c9ad48430be135d18fe9f30868e091dd51c57b94 - Do not include yuicompressor for Sass compiler. Transplanted. Exclusion is added into vaadin/pom.xml commit 52d01a68e91ce73306b3a1747af97e928048ecdf - Test for Firefox download disconnecting push channel. Transplanted. commit 4bc375d1d21f468e6433da3a183150e0bfe0cae4 - Handle encoded URL characters correctly when constructing widget set name. Transplanted. commit 17ba88eaf87e15e6f3c729e5c7f8e875d5f86d8d - Update version to 7.7-SNAPSHOT. Is not applicable. commit 47b7b13e5c959de3bd925693b074d85e7625a87e - Ensure Firefox always updates the grid scrollbar. Transplanted. Made changes in the logic to the test for modern Grid component. commit 4d851ba21d1b8f35685b631d2845731f8fb33252 - Calculate column widths immediately if there is data. Transplanted to both client side modules. commit 8f0b1a1dd026a756912c9f21bd2b34ea46897c7f - Skip Maven enforcer plugin during demo validation. Transplanted (one build file is affected). commit 62815353e1b9d3cd126809f5c818ad35bf913807 - Build demos from 7.7 branch (now for master branch). FW8 demos are added (one build file is affected). commit 815d72115d5aaf3676daefd5642115577e4151ef - Make test pass on all browsers. Transplanted to both V7 and V8 version tests. commit 516c428ca127e3c31b7b4d74220e4b7eed4571be - Use widget set specified by init parameter. Transplanted to the one UIProvider class. commit b00c580ed70f682a42afbfa91f978921bb86c2cd - Use correct column index when calculating min width during resize. Transplanted into both client side classes (main and compatibility) as is. Test for V7 is transplanted as is. Test for V8 is written from scratch based on V7 version. commit 7dd91cf057eb06a09009096a8278f34aad9bd8d9 - Fix regression that broke widget set compilation in 7.7.1. It's already there. commit c665731b0b97b697e80c47955d3558c19f0c81cb - Ensure temporary layout manager state is cleared at the end of a layout phase. Transplanted to the one LayoutManager class. commit 57a965251afdb5ee9ac1913a0101d854d8215aa6 - Fix assertion error when column widths are calculated. Transplanted to both versions of the client Grid widget. commit c5c52684eb30d924cb75a632b526a0f879d5a33c - Format Java files using Eclipse Neon and Vaadin settings. Only formatting changes. Is not transplanted. f5d06d877165bf413ec71c4fc88cf46c8c57a372 - Change javadoc to a style Eclipse formatter can handle. Transplanted to both versions of the client Grid widget. commit 6033e13c20b3d6e8b6f5add0f786d5ab2e1bb3fe - Make initially disabled grid work when enabled. Transplanted to both client side modules. commit a2d6e4fb4b1fd13e9a1b88f2ab1b78d14d8b64a9 - Use requestAnimationFrame when scrolling in Grid. Transplanted to both client side modules. commit fe9438e7b77c606855cfd739dd7e30b3f8cd4165 - Specify branch also for Sampler. Is not applicable for master branch. commit 1ec5d8ef7cb8bbd82bae1c9b79a376a5dca28f48 - Update to Chrome 53. Is already there. commit 961851bfbc4844474299433c34af6c9e4323d891 - Updated link to new step 1 video in tutorial. Is already there. commit 41dc2fe1611adc70d00e6f77debb2a6d4dcdefb0 - Revert "Use widget set specified by init parameter. Transplanted to the one UIProvider class. commit 092b4f7f3192555fe3ae22ac03a89ac2ada2a2dd - Use widget set specified by init parameter. Transplanted to the common server side classes. commit 977cec7e3107c2da306d46449dbf32f6544313be - Fix widget set builder to create widget set in correct location. Transplanted to the one ClassPathExplorer class file. commit 6c12ad89ea1064cd4cc0456baca5ee00ae76d032 - Format project pom files using correct settings. Is not transplanted: only formatting changes for POM files. commit 0aad93ecc1ce743dffc093ce7ae2ef88831f6073 - Add tests for widgetset compilation in different modes. Transplanted. New test projects. commit 0a3a1ef8321ed421be2337034fdb1cae2c434c3d - Use versions-maven-plugin 2.3 to avoid NPE while setting project version. Is already there. Change-Id: Ie3a5088f25de1772f01ea30c4a5eba0b169ee0ab
Diffstat (limited to 'client/src')
-rw-r--r--client/src/main/java/com/vaadin/client/AnimationUtil.java25
-rw-r--r--client/src/main/java/com/vaadin/client/LayoutManager.java8
-rw-r--r--client/src/main/java/com/vaadin/client/communication/ServerRpcQueue.java5
-rw-r--r--client/src/main/java/com/vaadin/client/data/AbstractRemoteDataSource.java15
-rw-r--r--client/src/main/java/com/vaadin/client/data/DataSource.java10
-rw-r--r--client/src/main/java/com/vaadin/client/widget/escalator/ScrollbarBundle.java71
-rw-r--r--client/src/main/java/com/vaadin/client/widget/grid/datasources/ListDataSource.java5
-rw-r--r--client/src/main/java/com/vaadin/client/widgets/Escalator.java31
-rw-r--r--client/src/main/java/com/vaadin/client/widgets/Grid.java46
9 files changed, 144 insertions, 72 deletions
diff --git a/client/src/main/java/com/vaadin/client/AnimationUtil.java b/client/src/main/java/com/vaadin/client/AnimationUtil.java
index bbefcffbdd..e2cf9e690a 100644
--- a/client/src/main/java/com/vaadin/client/AnimationUtil.java
+++ b/client/src/main/java/com/vaadin/client/AnimationUtil.java
@@ -19,7 +19,6 @@ import com.google.gwt.core.client.JavaScriptObject;
import com.google.gwt.dom.client.Element;
import com.google.gwt.dom.client.NativeEvent;
import com.google.gwt.dom.client.Style;
-import com.vaadin.client.AnimationUtil.AnimationEndListener;
/**
* Utility methods for working with CSS transitions and animations.
@@ -67,15 +66,15 @@ public class AnimationUtil {
listener.@com.vaadin.client.AnimationUtil.AnimationEndListener::onAnimationEnd(Lcom/google/gwt/dom/client/NativeEvent;)(e);
});
callbackFunc.listener = listener;
-
+
elem.addEventListener(@com.vaadin.client.AnimationUtil::ANIMATION_END_EVENT_NAME, callbackFunc, false);
-
+
// Store function reference for later removal
if(!elem._vaadin_animationend_callbacks) {
elem._vaadin_animationend_callbacks = [];
}
elem._vaadin_animationend_callbacks.push(callbackFunc);
-
+
return callbackFunc;
}-*/;
@@ -138,7 +137,7 @@ public class AnimationUtil {
return event.mozAnimationName;
else if(event.oAnimationName)
return event.oAnimationName;
-
+
return "";
}-*/;
@@ -146,22 +145,22 @@ public class AnimationUtil {
public static native String getAnimationName(ComputedStyle cstyle)
/*-{
var cs = cstyle.@com.vaadin.client.ComputedStyle::computedStyle;
-
+
if(!cs.getPropertyValue)
return "";
-
+
if(cs.getPropertyValue("-webkit-animation-name"))
return cs.getPropertyValue("-webkit-animation-name");
-
+
else if(cs.getPropertyValue("animation-name"))
return cs.getPropertyValue("animation-name");
-
+
else if(cs.getPropertyValue("-moz-animation-name"))
return cs.getPropertyValue("-moz-animation-name");
-
+
else if(cs.getPropertyValue("-o-animation-name"))
return cs.getPropertyValue("-o-animation-name");
-
+
return "";
}-*/;
@@ -176,7 +175,7 @@ public class AnimationUtil {
'MozAnimation': 'animationend',
'WebkitAnimation': 'webkitAnimationEnd'
}
-
+
for(var a in anims){
if( el.style[a] !== undefined ){
return anims[a];
@@ -195,7 +194,7 @@ public class AnimationUtil {
'mozAnimation',
'webkitAnimation'
]
-
+
for(var i=0; i < anims.length; i++) {
if( el.style[anims[i]] !== undefined ){
return anims[i];
diff --git a/client/src/main/java/com/vaadin/client/LayoutManager.java b/client/src/main/java/com/vaadin/client/LayoutManager.java
index 841eead561..ad0a3f8c38 100644
--- a/client/src/main/java/com/vaadin/client/LayoutManager.java
+++ b/client/src/main/java/com/vaadin/client/LayoutManager.java
@@ -600,6 +600,14 @@ public class LayoutManager {
}
Profiler.leave("layout PostLayoutListener");
+ // Ensure temporary variables are cleaned
+ if (!pendingOverflowFixes.isEmpty()) {
+ getLogger().warning(
+ "pendingOverflowFixes is not empty at the end of doLayout: "
+ + pendingOverflowFixes.dump());
+ pendingOverflowFixes = FastStringSet.create();
+ }
+
getLogger().info("Total layout phase time: "
+ totalDuration.elapsedMillis() + "ms");
}
diff --git a/client/src/main/java/com/vaadin/client/communication/ServerRpcQueue.java b/client/src/main/java/com/vaadin/client/communication/ServerRpcQueue.java
index 35d6f48565..ce07fc0baf 100644
--- a/client/src/main/java/com/vaadin/client/communication/ServerRpcQueue.java
+++ b/client/src/main/java/com/vaadin/client/communication/ServerRpcQueue.java
@@ -226,10 +226,11 @@ public class ServerRpcQueue {
*/
public boolean showLoadingIndicator() {
for (MethodInvocation invocation : getAll()) {
- if (isLegacyVariableChange(invocation)) {
+ if (isLegacyVariableChange(invocation)
+ || isJavascriptRpc(invocation)) {
// Always show loading indicator for legacy requests
return true;
- } else if (!isJavascriptRpc(invocation)) {
+ } else {
Type type = new Type(invocation.getInterfaceName(), null);
Method method = type.getMethod(invocation.getMethodName());
if (!TypeDataStore.isNoLoadingIndicator(method)) {
diff --git a/client/src/main/java/com/vaadin/client/data/AbstractRemoteDataSource.java b/client/src/main/java/com/vaadin/client/data/AbstractRemoteDataSource.java
index 33f96e009c..9dd1a504ab 100644
--- a/client/src/main/java/com/vaadin/client/data/AbstractRemoteDataSource.java
+++ b/client/src/main/java/com/vaadin/client/data/AbstractRemoteDataSource.java
@@ -378,7 +378,7 @@ public abstract class AbstractRemoteDataSource<T> implements DataSource<T> {
}
private void handleMissingRows(Range range) {
- if (range.isEmpty()) {
+ if (range.isEmpty() || !canFetchData()) {
return;
}
currentRequestCallback = new RequestRowsCallback<>(this, range);
@@ -794,4 +794,17 @@ public abstract class AbstractRemoteDataSource<T> implements DataSource<T> {
protected boolean isPinned(T row) {
return pinnedRows.containsKey(getRowKey(row));
}
+
+ /**
+ * Checks if it is possible to currently fetch data from the remote data
+ * source.
+ *
+ * @return <code>true</code> if it is ok to try to fetch data,
+ * <code>false</code> if it is known that fetching data will fail
+ * and should not be tried right now.
+ * @since 7.7.2
+ */
+ protected boolean canFetchData() {
+ return true;
+ }
}
diff --git a/client/src/main/java/com/vaadin/client/data/DataSource.java b/client/src/main/java/com/vaadin/client/data/DataSource.java
index fdec4b9a38..4645957111 100644
--- a/client/src/main/java/com/vaadin/client/data/DataSource.java
+++ b/client/src/main/java/com/vaadin/client/data/DataSource.java
@@ -217,4 +217,14 @@ public interface DataSource<T> {
* means that the row is not currently in this data source's cache.
*/
public RowHandle<T> getHandle(T row);
+
+ /**
+ * Checks whether this data source is currently waiting for more rows to
+ * become available.
+ *
+ * @return <code>true</code> if waiting for data; otherwise
+ * <code>false</code>
+ * @since 7.7.2
+ */
+ public boolean isWaitingForData();
}
diff --git a/client/src/main/java/com/vaadin/client/widget/escalator/ScrollbarBundle.java b/client/src/main/java/com/vaadin/client/widget/escalator/ScrollbarBundle.java
index 7e11c6c0d9..c62c5f032f 100644
--- a/client/src/main/java/com/vaadin/client/widget/escalator/ScrollbarBundle.java
+++ b/client/src/main/java/com/vaadin/client/widget/escalator/ScrollbarBundle.java
@@ -16,6 +16,8 @@
package com.vaadin.client.widget.escalator;
+import com.google.gwt.animation.client.AnimationScheduler;
+import com.google.gwt.animation.client.AnimationScheduler.AnimationSupportDetector;
import com.google.gwt.core.client.Scheduler;
import com.google.gwt.core.client.Scheduler.ScheduledCommand;
import com.google.gwt.dom.client.Element;
@@ -31,6 +33,7 @@ import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.Event;
import com.google.gwt.user.client.EventListener;
import com.google.gwt.user.client.Timer;
+import com.vaadin.client.BrowserInfo;
import com.vaadin.client.DeferredWorker;
import com.vaadin.client.WidgetUtil;
import com.vaadin.client.widget.grid.events.ScrollEvent;
@@ -47,6 +50,9 @@ import com.vaadin.client.widget.grid.events.ScrollHandler;
*/
public abstract class ScrollbarBundle implements DeferredWorker {
+ private static final boolean supportsRequestAnimationFrame = new AnimationSupportDetector()
+ .isNativelySupported();
+
private class ScrollEventFirer {
private final ScheduledCommand fireEventCommand = new ScheduledCommand() {
@Override
@@ -91,7 +97,17 @@ public abstract class ScrollbarBundle implements DeferredWorker {
* We'll gather all the scroll events, and only fire once, once
* everything has calmed down.
*/
- Scheduler.get().scheduleDeferred(fireEventCommand);
+ if (supportsRequestAnimationFrame) {
+ // Chrome MUST use this as deferred commands will sometimes
+ // be run with a 300+ ms delay when scrolling.
+ AnimationScheduler.get().requestAnimationFrame(
+ timestamp -> fireEventCommand.execute());
+ } else {
+ // Does not support requestAnimationFrame and the fallback
+ // uses a delay of 16ms, we stick to the old deferred
+ // command which uses a delay of 0ms
+ Scheduler.get().scheduleDeferred(fireEventCommand);
+ }
isBeingFired = true;
}
}
@@ -449,13 +465,25 @@ public abstract class ScrollbarBundle implements DeferredWorker {
* set either <code>overflow-x</code> or <code>overflow-y</code> to "
* <code>scroll</code>" in the scrollbar's direction.
* <p>
- * This is an IE8 workaround, since it doesn't always show scrollbars with
- * <code>overflow: auto</code> enabled.
+ * This method is an IE8 workaround, since it doesn't always show scrollbars
+ * with <code>overflow: auto</code> enabled.
+ * <p>
+ * Firefox on the other hand loses pending scroll events when the scrollbar
+ * is hidden, so the event must be fired manually.
+ * <p>
+ * When IE8 support is dropped, this should really be simplified.
*/
protected void forceScrollbar(boolean enable) {
if (enable) {
root.getStyle().clearDisplay();
} else {
+ if (BrowserInfo.get().isFirefox()) {
+ /*
+ * This is related to the Firefox workaround in setScrollSize
+ * for setScrollPos(0)
+ */
+ scrollEventFirer.scheduleEvent();
+ }
root.getStyle().setDisplay(Display.NONE);
}
internalForceScrollbar(enable);
@@ -603,21 +631,37 @@ public abstract class ScrollbarBundle implements DeferredWorker {
* This needs to be made step-by-step because IE8 flat-out refuses to
* fire a scroll event when the scroll size becomes smaller than the
* offset size. All other browser need to suffer alongside.
+ *
+ * This really should be changed to not use any temporary scroll
+ * handlers at all once IE8 support is dropped, like now done only for
+ * Firefox.
*/
boolean newScrollSizeIsSmallerThanOffsetSize = px <= getOffsetSize();
boolean scrollSizeBecomesSmallerThanOffsetSize = showsScrollHandle()
&& newScrollSizeIsSmallerThanOffsetSize;
if (scrollSizeBecomesSmallerThanOffsetSize && getScrollPos() != 0) {
- // must be a field because Java insists.
- scrollSizeTemporaryScrollHandler = addScrollHandler(
- new ScrollHandler() {
- @Override
- public void onScroll(ScrollEvent event) {
- setScrollSizeNow(px);
- }
- });
+ /*
+ * For whatever reason, Firefox loses the scroll event in this case
+ * and the onscroll handler is never called (happens when reducing
+ * size from 1000 items to 1 while being scrolled a bit down, see
+ * #19802). Based on the comment above, only IE8 should really use
+ * 'delayedSizeSet'
+ */
+ boolean delayedSizeSet = !BrowserInfo.get().isFirefox();
+ if (delayedSizeSet) {
+ scrollSizeTemporaryScrollHandler = addScrollHandler(
+ new ScrollHandler() {
+ @Override
+ public void onScroll(ScrollEvent event) {
+ setScrollSizeNow(px);
+ }
+ });
+ }
setScrollPos(0);
+ if (!delayedSizeSet) {
+ setScrollSizeNow(px);
+ }
} else {
setScrollSizeNow(px);
}
@@ -863,7 +907,10 @@ public abstract class ScrollbarBundle implements DeferredWorker {
@Override
public boolean isWorkPending() {
+ // Need to include scrollEventFirer.isBeingFired as it might use
+ // requestAnimationFrame - which is not automatically checked
return scrollSizeTemporaryScrollHandler != null
- || offsetSizeTemporaryScrollHandler != null;
+ || offsetSizeTemporaryScrollHandler != null
+ || scrollEventFirer.isBeingFired;
}
}
diff --git a/client/src/main/java/com/vaadin/client/widget/grid/datasources/ListDataSource.java b/client/src/main/java/com/vaadin/client/widget/grid/datasources/ListDataSource.java
index 9767a230bb..355840d4ce 100644
--- a/client/src/main/java/com/vaadin/client/widget/grid/datasources/ListDataSource.java
+++ b/client/src/main/java/com/vaadin/client/widget/grid/datasources/ListDataSource.java
@@ -457,6 +457,11 @@ public class ListDataSource<T> implements DataSource<T> {
};
}
+ @Override
+ public boolean isWaitingForData() {
+ return false;
+ }
+
private Stream<DataChangeHandler> getHandlers() {
Set<DataChangeHandler> copy = new LinkedHashSet<>(changeHandlers);
return copy.stream();
diff --git a/client/src/main/java/com/vaadin/client/widgets/Escalator.java b/client/src/main/java/com/vaadin/client/widgets/Escalator.java
index 77afccdb30..fdd4c22645 100644
--- a/client/src/main/java/com/vaadin/client/widgets/Escalator.java
+++ b/client/src/main/java/com/vaadin/client/widgets/Escalator.java
@@ -672,13 +672,13 @@ public class Escalator extends Widget
/*-{
var vScroll = esc.@com.vaadin.client.widgets.Escalator::verticalScrollbar;
var vScrollElem = vScroll.@com.vaadin.client.widget.escalator.ScrollbarBundle::getElement()();
-
+
var hScroll = esc.@com.vaadin.client.widgets.Escalator::horizontalScrollbar;
var hScrollElem = hScroll.@com.vaadin.client.widget.escalator.ScrollbarBundle::getElement()();
-
+
return $entry(function(e) {
var target = e.target;
-
+
// in case the scroll event was native (i.e. scrollbars were dragged, or
// the scrollTop/Left was manually modified), the bundles have old cache
// values. We need to make sure that the caches are kept up to date.
@@ -699,29 +699,29 @@ public class Escalator extends Widget
return $entry(function(e) {
var deltaX = e.deltaX ? e.deltaX : -0.5*e.wheelDeltaX;
var deltaY = e.deltaY ? e.deltaY : -0.5*e.wheelDeltaY;
-
+
// Delta mode 0 is in pixels; we don't need to do anything...
-
+
// A delta mode of 1 means we're scrolling by lines instead of pixels
// We need to scale the number of lines by the default line height
if(e.deltaMode === 1) {
var brc = esc.@com.vaadin.client.widgets.Escalator::body;
deltaY *= brc.@com.vaadin.client.widgets.Escalator.AbstractRowContainer::getDefaultRowHeight()();
}
-
+
// Other delta modes aren't supported
if((e.deltaMode !== undefined) && (e.deltaMode >= 2 || e.deltaMode < 0)) {
var msg = "Unsupported wheel delta mode \"" + e.deltaMode + "\"";
-
+
// Print warning message
esc.@com.vaadin.client.widgets.Escalator::logWarning(*)(msg);
}
-
+
// IE8 has only delta y
if (isNaN(deltaY)) {
deltaY = -0.5*e.wheelDelta;
}
-
+
@com.vaadin.client.widgets.Escalator.JsniUtil::moveScrollFromEvent(*)(esc, deltaX, deltaY, e);
});
}-*/;
@@ -4170,6 +4170,11 @@ public class Escalator extends Widget
frozenColumns += numberOfColumns;
}
+ // Add to DOM
+ header.paintInsertColumns(index, numberOfColumns, frozen);
+ body.paintInsertColumns(index, numberOfColumns, frozen);
+ footer.paintInsertColumns(index, numberOfColumns, frozen);
+
// this needs to be before the scrollbar adjustment.
boolean scrollbarWasNeeded = horizontalScrollbar
.getOffsetSize() < horizontalScrollbar.getScrollSize();
@@ -4177,14 +4182,12 @@ public class Escalator extends Widget
boolean scrollbarIsNowNeeded = horizontalScrollbar
.getOffsetSize() < horizontalScrollbar.getScrollSize();
if (!scrollbarWasNeeded && scrollbarIsNowNeeded) {
+ // This might as a side effect move rows around (when scrolled
+ // all the way down) and require the DOM to be up to date, i.e.
+ // the column to be added
body.verifyEscalatorCount();
}
- // Add to DOM
- header.paintInsertColumns(index, numberOfColumns, frozen);
- body.paintInsertColumns(index, numberOfColumns, frozen);
- footer.paintInsertColumns(index, numberOfColumns, frozen);
-
// fix initial width
if (header.getRowCount() > 0 || body.getRowCount() > 0
|| footer.getRowCount() > 0) {
diff --git a/client/src/main/java/com/vaadin/client/widgets/Grid.java b/client/src/main/java/com/vaadin/client/widgets/Grid.java
index 9a87d82363..eac958fdce 100644
--- a/client/src/main/java/com/vaadin/client/widgets/Grid.java
+++ b/client/src/main/java/com/vaadin/client/widgets/Grid.java
@@ -3163,7 +3163,8 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
rescheduleCount = 0;
Scheduler.get().scheduleDeferred(this);
}
- } else if (dataIsBeingFetched) {
+ } else if (currentDataAvailable.isEmpty()
+ && dataSource.isWaitingForData()) {
Scheduler.get().scheduleDeferred(this);
} else {
calculate();
@@ -3199,7 +3200,8 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
isScheduled = false;
rescheduleCount = 0;
- assert !dataIsBeingFetched : "Trying to calculate column widths even though data is still being fetched.";
+ assert !(currentDataAvailable.isEmpty() && dataSource
+ .isWaitingForData()) : "Trying to calculate column widths without data while data is still being fetched.";
if (columnsAreGuaranteedToBeWiderThanGrid()) {
applyColumnWidths();
@@ -4060,21 +4062,15 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
private final Editor<T> editor = GWT.create(Editor.class);
- private boolean dataIsBeingFetched = false;
-
/**
* The cell a click event originated from
* <p>
* This is a workaround to make Chrome work like Firefox. In Chrome,
* normally if you start a drag on one cell and release on:
* <ul>
- * <li>that same cell, the click event is that {@code
- *
- <td>}.
- * <li>a cell on that same row, the click event is the parent {@code
- *
- <tr>
- * }.
+ * <li>that same cell, the click event is that <code>&lt;td></code>.
+ * <li>a cell on that same row, the click event is the parent
+ * <code>&lt;tr></code>.
* <li>a cell on another row, the click event is the table section ancestor
* ({@code <thead>}, {@code <tbody>} or {@code <tfoot>}).
* </ul>
@@ -5672,7 +5668,7 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
initialWidth = col.getWidthActual();
minCellWidth = escalator.getMinCellWidth(
- getColumns().indexOf(col));
+ getVisibleColumns().indexOf(col));
for (Column<?, T> c : getVisibleColumns()) {
if (selectionColumn == c) {
// Don't modify selection column.
@@ -5681,8 +5677,8 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
if (c.getWidth() < 0) {
c.setWidth(c.getWidthActual());
- fireEvent(new ColumnResizeEvent<>(
- c));
+ fireEvent(
+ new ColumnResizeEvent<>(c));
}
}
@@ -5907,7 +5903,6 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
public void onRowVisibilityChange(
RowVisibilityChangeEvent event) {
if (dataSource != null && dataSource.size() != 0) {
- dataIsBeingFetched = true;
dataSource.ensureAvailability(
event.getFirstVisibleRow(),
event.getVisibleRowCount());
@@ -5947,12 +5942,6 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
}
});
- addDataAvailableHandler(new DataAvailableHandler() {
- @Override
- public void onDataAvailable(DataAvailableEvent event) {
- dataIsBeingFetched = false;
- }
- });
}
@Override
@@ -6291,8 +6280,7 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
* @return A unmodifiable list of the columns in the grid
*/
public List<Column<?, T>> getColumns() {
- return Collections
- .unmodifiableList(new ArrayList<>(columns));
+ return Collections.unmodifiableList(new ArrayList<>(columns));
}
/**
@@ -6717,8 +6705,7 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
int oldSize = body.getRowCount();
// Hide all details.
- Set<Integer> oldDetails = new HashSet<>(
- visibleDetails);
+ Set<Integer> oldDetails = new HashSet<>(visibleDetails);
for (int i : oldDetails) {
setDetailsVisible(i, false);
}
@@ -6734,7 +6721,6 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
}
if (newSize > 0) {
- dataIsBeingFetched = true;
Range visibleRowRange = escalator
.getVisibleRowRange();
dataSource.ensureAvailability(
@@ -7829,7 +7815,7 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
Scheduler.get().scheduleFinally(new ScheduledCommand() {
@Override
public void execute() {
- if (!dataIsBeingFetched) {
+ if (!dataSource.isWaitingForData()) {
handler.onDataAvailable(
new DataAvailableEvent(currentDataAvailable));
}
@@ -8108,8 +8094,8 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
*/
private void sort(boolean userOriginated) {
refreshHeader();
- fireEvent(new SortEvent<>(this,
- Collections.unmodifiableList(sortOrder), userOriginated));
+ fireEvent(new SortEvent<>(this, Collections.unmodifiableList(sortOrder),
+ userOriginated));
}
private int getLastVisibleRowIndex() {
@@ -8150,7 +8136,7 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
@Override
public boolean isWorkPending() {
- return escalator.isWorkPending() || dataIsBeingFetched
+ return escalator.isWorkPending() || dataSource.isWaitingForData()
|| autoColumnWidthsRecalculator.isScheduled()
|| editor.isWorkPending();
}