aboutsummaryrefslogtreecommitdiffstats
path: root/compatibility-client
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 /compatibility-client
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 'compatibility-client')
-rw-r--r--compatibility-client/src/main/java/com/vaadin/v7/client/connectors/RpcDataSourceConnector.java7
-rw-r--r--compatibility-client/src/main/java/com/vaadin/v7/client/widget/escalator/ScrollbarBundle.java71
-rw-r--r--compatibility-client/src/main/java/com/vaadin/v7/client/widget/grid/datasources/ListDataSource.java11
-rw-r--r--compatibility-client/src/main/java/com/vaadin/v7/client/widgets/Grid.java130
4 files changed, 131 insertions, 88 deletions
diff --git a/compatibility-client/src/main/java/com/vaadin/v7/client/connectors/RpcDataSourceConnector.java b/compatibility-client/src/main/java/com/vaadin/v7/client/connectors/RpcDataSourceConnector.java
index 363d3c047d..f800300440 100644
--- a/compatibility-client/src/main/java/com/vaadin/v7/client/connectors/RpcDataSourceConnector.java
+++ b/compatibility-client/src/main/java/com/vaadin/v7/client/connectors/RpcDataSourceConnector.java
@@ -73,7 +73,7 @@ public class RpcDataSourceConnector extends AbstractExtensionConnector {
registerRpc(DataProviderRpc.class, new DataProviderRpc() {
@Override
public void setRowData(int firstRow, JsonArray rowArray) {
- ArrayList<JsonObject> rows = new ArrayList<JsonObject>(
+ ArrayList<JsonObject> rows = new ArrayList<>(
rowArray.length());
for (int i = 0; i < rowArray.length(); i++) {
JsonObject rowObject = rowArray.getObject(i);
@@ -240,6 +240,11 @@ public class RpcDataSourceConnector extends AbstractExtensionConnector {
droppedRowKeys.set(droppedRowKeys.length(), getRowKey(row));
}
}
+
+ @Override
+ protected boolean canFetchData() {
+ return isEnabled();
+ }
}
private final RpcDataSource dataSource = new RpcDataSource();
diff --git a/compatibility-client/src/main/java/com/vaadin/v7/client/widget/escalator/ScrollbarBundle.java b/compatibility-client/src/main/java/com/vaadin/v7/client/widget/escalator/ScrollbarBundle.java
index bdd4240818..20b1e5d1b9 100644
--- a/compatibility-client/src/main/java/com/vaadin/v7/client/widget/escalator/ScrollbarBundle.java
+++ b/compatibility-client/src/main/java/com/vaadin/v7/client/widget/escalator/ScrollbarBundle.java
@@ -16,6 +16,8 @@
package com.vaadin.v7.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.v7.client.widget.grid.events.ScrollEvent;
@@ -47,6 +50,9 @@ import com.vaadin.v7.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/compatibility-client/src/main/java/com/vaadin/v7/client/widget/grid/datasources/ListDataSource.java b/compatibility-client/src/main/java/com/vaadin/v7/client/widget/grid/datasources/ListDataSource.java
index 994e8059eb..d80cdad3c9 100644
--- a/compatibility-client/src/main/java/com/vaadin/v7/client/widget/grid/datasources/ListDataSource.java
+++ b/compatibility-client/src/main/java/com/vaadin/v7/client/widget/grid/datasources/ListDataSource.java
@@ -344,7 +344,7 @@ public class ListDataSource<T> implements DataSource<T> {
if (datasource == null) {
throw new IllegalArgumentException("datasource cannot be null");
}
- ds = new ArrayList<T>(datasource);
+ ds = new ArrayList<>(datasource);
wrapper = new ListWrapper();
}
@@ -358,9 +358,9 @@ public class ListDataSource<T> implements DataSource<T> {
*/
public ListDataSource(T... rows) {
if (rows == null) {
- ds = new ArrayList<T>();
+ ds = new ArrayList<>();
} else {
- ds = new ArrayList<T>(Arrays.asList(rows));
+ ds = new ArrayList<>(Arrays.asList(rows));
}
wrapper = new ListWrapper();
}
@@ -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/compatibility-client/src/main/java/com/vaadin/v7/client/widgets/Grid.java b/compatibility-client/src/main/java/com/vaadin/v7/client/widgets/Grid.java
index e79237702b..afc9cd8a45 100644
--- a/compatibility-client/src/main/java/com/vaadin/v7/client/widgets/Grid.java
+++ b/compatibility-client/src/main/java/com/vaadin/v7/client/widgets/Grid.java
@@ -442,14 +442,14 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
*/
public abstract static class StaticRow<CELLTYPE extends StaticCell> {
- private Map<Column<?, ?>, CELLTYPE> cells = new HashMap<Column<?, ?>, CELLTYPE>();
+ private Map<Column<?, ?>, CELLTYPE> cells = new HashMap<>();
private StaticSection<?> section;
/**
* Map from set of spanned columns to cell meta data.
*/
- private Map<Set<Column<?, ?>>, CELLTYPE> cellGroups = new HashMap<Set<Column<?, ?>>, CELLTYPE>();
+ private Map<Set<Column<?, ?>>, CELLTYPE> cellGroups = new HashMap<>();
/**
* A custom style name for the row or null if none is set.
@@ -497,7 +497,7 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
"You can't merge less than 2 columns together.");
}
- HashSet<Column<?, ?>> columnGroup = new HashSet<Column<?, ?>>();
+ HashSet<Column<?, ?>> columnGroup = new HashSet<>();
// NOTE: this doesn't care about hidden columns, those are
// filtered in calculateColspans()
for (Column<?, ?> column : columns) {
@@ -591,7 +591,7 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
private boolean checkMergedCellIsContinuous(
Set<Column<?, ?>> mergedCell) {
// no matter if hidden or not, just check for continuous order
- final List<Column<?, ?>> columnOrder = new ArrayList<Column<?, ?>>(
+ final List<Column<?, ?>> columnOrder = new ArrayList<>(
section.grid.getColumns());
if (!columnOrder.containsAll(mergedCell)) {
@@ -661,7 +661,7 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
*/
void detach() {
// Avoid calling detach twice for a merged cell
- HashSet<CELLTYPE> cells = new HashSet<CELLTYPE>();
+ HashSet<CELLTYPE> cells = new HashSet<>();
for (Column<?, ?> column : getSection().grid.getColumns()) {
cells.add(getCell(column));
}
@@ -673,7 +673,7 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
private Grid<?> grid;
- private List<ROWTYPE> rows = new ArrayList<ROWTYPE>();
+ private List<ROWTYPE> rows = new ArrayList<>();
private boolean visible = true;
@@ -1337,8 +1337,8 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
// Should only be added to the DOM when there's a message to show
private DivElement message = DivElement.as(DOM.createDiv());
- private Map<Column<?, T>, Widget> columnToWidget = new HashMap<Column<?, T>, Widget>();
- private List<HandlerRegistration> focusHandlers = new ArrayList<HandlerRegistration>();
+ private Map<Column<?, T>, Widget> columnToWidget = new HashMap<>();
+ private List<HandlerRegistration> focusHandlers = new ArrayList<>();
private boolean enabled = false;
private State state = State.INACTIVE;
@@ -1433,7 +1433,7 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
};
/** A set of all the columns that display an error flag. */
- private final Set<Column<?, T>> columnErrors = new HashSet<Grid.Column<?, T>>();
+ private final Set<Column<?, T>> columnErrors = new HashSet<>();
private boolean buffered = true;
/** Original position of editor */
@@ -1629,7 +1629,7 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
throw new IllegalStateException(
"Cannot cancel edit: editor is not in edit mode");
}
- handler.cancel(new EditorRequestImpl<T>(grid, rowIndex,
+ handler.cancel(new EditorRequestImpl<>(grid, rowIndex,
focusedColumnIndex, null));
doCancel();
}
@@ -1675,7 +1675,7 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
state = State.SAVING;
setButtonsEnabled(false);
saveTimeout.schedule(SAVE_TIMEOUT_MS);
- EditorRequest<T> request = new EditorRequestImpl<T>(grid, rowIndex,
+ EditorRequest<T> request = new EditorRequestImpl<>(grid, rowIndex,
focusedColumnIndex, saveRequestCallback);
handler.save(request);
updateSelectionCheckboxesAsNeeded(true);
@@ -1739,7 +1739,7 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
if (state == State.ACTIVATING) {
state = State.BINDING;
bindTimeout.schedule(BIND_TIMEOUT_MS);
- EditorRequest<T> request = new EditorRequestImpl<T>(grid,
+ EditorRequest<T> request = new EditorRequestImpl<>(grid,
rowIndex, columnIndex, bindRequestCallback);
handler.bind(request);
grid.getEscalator().setScrollLocked(Direction.VERTICAL,
@@ -2270,7 +2270,7 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
extends KeyEvent<HANDLER> {
private Grid<?> grid;
- private final Type<HANDLER> associatedType = new Type<HANDLER>(
+ private final Type<HANDLER> associatedType = new Type<>(
getBrowserEventType(), this);
private final CellReference<?> targetCell;
@@ -2330,7 +2330,7 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
private Grid<?> grid;
private final CellReference<?> targetCell;
- private final Type<HANDLER> associatedType = new Type<HANDLER>(
+ private final Type<HANDLER> associatedType = new Type<>(
getBrowserEventType(), this);
public AbstractGridMouseEvent(Grid<?> grid,
@@ -2408,7 +2408,7 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
*/
private static final double DETAILS_ROW_INITIAL_HEIGHT = 50;
- private EventCellReference<T> eventCell = new EventCellReference<T>(this);
+ private EventCellReference<T> eventCell = new EventCellReference<>(this);
private GridKeyDownEvent keyDown = new GridKeyDownEvent(this, eventCell);
private GridKeyUpEvent keyUp = new GridKeyUpEvent(this, eventCell);
private GridKeyPressEvent keyPress = new GridKeyPressEvent(this, eventCell);
@@ -2882,7 +2882,7 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
public void onValueChange(
ValueChangeEvent<Boolean> event) {
if (event.getValue()) {
- fireEvent(new SelectAllEvent<T>(model));
+ fireEvent(new SelectAllEvent<>(model));
selected = true;
} else {
model.deselectAll();
@@ -3167,7 +3167,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();
@@ -3203,7 +3204,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();
@@ -3232,7 +3234,7 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
/* Step 1: Apply all column widths as they are. */
- Map<Integer, Double> selfWidths = new LinkedHashMap<Integer, Double>();
+ Map<Integer, Double> selfWidths = new LinkedHashMap<>();
List<Column<?, T>> columns = getVisibleColumns();
for (int index = 0; index < columns.size(); index++) {
selfWidths.put(index, columns.get(index).getWidth());
@@ -3246,7 +3248,7 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
* violated, fix it.
*/
- Map<Integer, Double> constrainedWidths = new LinkedHashMap<Integer, Double>();
+ Map<Integer, Double> constrainedWidths = new LinkedHashMap<>();
for (int index = 0; index < columns.size(); index++) {
Column<?, T> column = columns.get(index);
@@ -3271,9 +3273,9 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
boolean defaultExpandRatios = true;
int totalRatios = 0;
double reservedPixels = 0;
- final Set<Column<?, T>> columnsToExpand = new HashSet<Column<?, T>>();
- List<Column<?, T>> nonFixedColumns = new ArrayList<Column<?, T>>();
- Map<Integer, Double> columnSizes = new HashMap<Integer, Double>();
+ final Set<Column<?, T>> columnsToExpand = new HashSet<>();
+ List<Column<?, T>> nonFixedColumns = new ArrayList<>();
+ Map<Integer, Double> columnSizes = new HashMap<>();
final List<Column<?, T>> visibleColumns = getVisibleColumns();
/*
@@ -3536,7 +3538,7 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
private static final String STRIPE_CLASSNAME = "stripe";
- private final Map<Element, Widget> elementToWidgetMap = new HashMap<Element, Widget>();
+ private final Map<Element, Widget> elementToWidgetMap = new HashMap<>();
@Override
public void init(Spacer spacer) {
@@ -3918,7 +3920,7 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
private final class ColumnHider {
/** Map from columns to their hiding toggles, component might change */
- private HashMap<Column<?, T>, MenuItem> columnToHidingToggleMap = new HashMap<Grid.Column<?, T>, MenuItem>();
+ private HashMap<Column<?, T>, MenuItem> columnToHidingToggleMap = new HashMap<>();
/**
* When column is being hidden with a toggle, do not refresh toggles for
@@ -4017,7 +4019,7 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
/**
* List of columns in the grid. Order defines the visible order.
*/
- private List<Column<?, T>> columns = new ArrayList<Column<?, T>>();
+ private List<Column<?, T>> columns = new ArrayList<>();
/**
* The datasource currently in use. <em>Note:</em> it is <code>null</code>
@@ -4041,7 +4043,7 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
* Current sort order. The (private) sort() method reads this list to
* determine the order in which to present rows.
*/
- private List<SortOrder> sortOrder = new ArrayList<SortOrder>();
+ private List<SortOrder> sortOrder = new ArrayList<>();
private Renderer<Boolean> selectColumnRenderer = null;
@@ -4064,21 +4066,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>
@@ -4099,7 +4095,7 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
private DetailsGenerator detailsGenerator = DetailsGenerator.NULL;
private GridSpacerUpdater gridSpacerUpdater = new GridSpacerUpdater();
/** A set keeping track of the indices of all currently open details */
- private Set<Integer> visibleDetails = new HashSet<Integer>();
+ private Set<Integer> visibleDetails = new HashSet<>();
private boolean columnReorderingAllowed;
@@ -4149,7 +4145,7 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
* Map of possible drop positions for the column and the corresponding
* column index.
*/
- private final TreeMap<Double, Integer> possibleDropPositions = new TreeMap<Double, Integer>();
+ private final TreeMap<Double, Integer> possibleDropPositions = new TreeMap<>();
/**
* Makes sure that drag cancel doesn't cause anything unwanted like sort
*/
@@ -4348,7 +4344,7 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
&& latestColumnDropIndex != (draggedColumnIndex
+ colspan)) {
List<Column<?, T>> columns = getColumns();
- List<Column<?, T>> reordered = new ArrayList<Column<?, T>>();
+ List<Column<?, T>> reordered = new ArrayList<>();
if (draggedColumnIndex < latestColumnDropIndex) {
reordered.addAll(columns.subList(0, draggedColumnIndex));
reordered.addAll(
@@ -4476,8 +4472,8 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
int leftBound = -1;
int rightBound = getColumnCount() + 1;
- final HashSet<Integer> unavailableColumnDropIndices = new HashSet<Integer>();
- final List<StaticRow<?>> rows = new ArrayList<StaticRow<?>>();
+ final HashSet<Integer> unavailableColumnDropIndices = new HashSet<>();
+ final List<StaticRow<?>> rows = new ArrayList<>();
rows.addAll(header.getRows());
rows.addAll(footer.getRows());
for (StaticRow<?> row : rows) {
@@ -5063,7 +5059,7 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
grid.header.updateColSpans();
grid.footer.updateColSpans();
scheduleColumnWidthRecalculator();
- this.grid.fireEvent(new ColumnVisibilityChangeEvent<T>(this,
+ this.grid.fireEvent(new ColumnVisibilityChangeEvent<>(this,
hidden, userOriginated));
}
}
@@ -5717,7 +5713,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.
@@ -5726,8 +5722,8 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
if (c.getWidth() < 0) {
c.setWidth(c.getWidthActual());
- fireEvent(new ColumnResizeEvent<T>(
- c));
+ fireEvent(
+ new ColumnResizeEvent<>(c));
}
}
@@ -5737,7 +5733,7 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
@Override
public void onComplete() {
- fireEvent(new ColumnResizeEvent<T>(col));
+ fireEvent(new ColumnResizeEvent<>(col));
WidgetUtil.setTextSelectionEnabled(
getElement(), true);
@@ -5819,7 +5815,7 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
escalator.getColumnConfiguration().setColumnWidth(colIndex,
minWidth);
- fireEvent(new ColumnResizeEvent<T>(column));
+ fireEvent(new ColumnResizeEvent<>(column));
}
}
@@ -5937,7 +5933,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());
@@ -5977,12 +5972,6 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
}
});
- addDataAvailableHandler(new DataAvailableHandler() {
- @Override
- public void onDataAvailable(DataAvailableEvent event) {
- dataIsBeingFetched = false;
- }
- });
}
@Override
@@ -6229,7 +6218,7 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
column.reapplyWidth();
// Sink all renderer events
- Set<String> events = new HashSet<String>();
+ Set<String> events = new HashSet<>();
events.addAll(getConsumedEventsForRenderer(column.getRenderer()));
if (column.isHidable()) {
@@ -6321,8 +6310,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<Column<?, T>>(columns));
+ return Collections.unmodifiableList(new ArrayList<>(columns));
}
/**
@@ -6334,7 +6322,7 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
* @return A unmodifiable list of the currently visible columns in the grid
*/
public List<Column<?, T>> getVisibleColumns() {
- ArrayList<Column<?, T>> visible = new ArrayList<Column<?, T>>();
+ ArrayList<Column<?, T>> visible = new ArrayList<>();
for (Column<?, T> c : columns) {
if (!c.isHidden()) {
visible.add(c);
@@ -6749,8 +6737,7 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
int oldSize = body.getRowCount();
// Hide all details.
- Set<Integer> oldDetails = new HashSet<Integer>(
- visibleDetails);
+ Set<Integer> oldDetails = new HashSet<>(visibleDetails);
for (int i : oldDetails) {
setDetailsVisible(i, false);
}
@@ -6766,7 +6753,6 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
}
if (newSize > 0) {
- dataIsBeingFetched = true;
Range visibleRowRange = escalator
.getVisibleRowRange();
dataSource.ensureAvailability(
@@ -7123,7 +7109,7 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
}
private Set<String> getConsumedEventsForRenderer(Renderer<?> renderer) {
- Set<String> events = new HashSet<String>();
+ Set<String> events = new HashSet<>();
if (renderer instanceof ComplexRenderer) {
Collection<String> consumedEvents = ((ComplexRenderer<?>) renderer)
.getConsumedEvents();
@@ -7295,7 +7281,7 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
w = editor.getWidget(getColumn(editor.focusedColumnIndex));
}
- EditorDomEvent<T> editorEvent = new EditorDomEvent<T>(event,
+ EditorDomEvent<T> editorEvent = new EditorDomEvent<>(event,
getEventCell(), w);
return getEditor().getEventHandler().handleEvent(editorEvent);
@@ -7366,8 +7352,8 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
private Point rowEventTouchStartingPoint;
private CellStyleGenerator<T> cellStyleGenerator;
private RowStyleGenerator<T> rowStyleGenerator;
- private RowReference<T> rowReference = new RowReference<T>(this);
- private CellReference<T> cellReference = new CellReference<T>(rowReference);
+ private RowReference<T> rowReference = new RowReference<>(this);
+ private CellReference<T> cellReference = new CellReference<>(rowReference);
private RendererCellReference rendererCellReference = new RendererCellReference(
(RowReference<Object>) rowReference);
@@ -7909,7 +7895,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));
}
@@ -8188,8 +8174,8 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
*/
private void sort(boolean userOriginated) {
refreshHeader();
- fireEvent(new SortEvent<T>(this,
- Collections.unmodifiableList(sortOrder), userOriginated));
+ fireEvent(new SortEvent<>(this, Collections.unmodifiableList(sortOrder),
+ userOriginated));
}
private int getLastVisibleRowIndex() {
@@ -8230,7 +8216,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();
}
@@ -8270,7 +8256,7 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
// Trigger ComplexRenderer.destroy for old content
conf.removeColumns(0, conf.getColumnCount());
- List<Column<?, T>> newOrder = new ArrayList<Column<?, T>>();
+ List<Column<?, T>> newOrder = new ArrayList<>();
if (selectionColumn != null) {
newOrder.add(selectionColumn);
}
@@ -8548,7 +8534,7 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
@Override
protected void onDetach() {
- Set<Integer> details = new HashSet<Integer>(visibleDetails);
+ Set<Integer> details = new HashSet<>(visibleDetails);
for (int row : details) {
setDetailsVisible(row, false);
}
@@ -8958,7 +8944,7 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
if (container != null) {
Cell cell = container.getCell(element);
if (cell != null) {
- EventCellReference<T> cellRef = new EventCellReference<T>(this);
+ EventCellReference<T> cellRef = new EventCellReference<>(this);
cellRef.set(cell, getSectionFromContainer(container));
return cellRef;
}