aboutsummaryrefslogtreecommitdiffstats
path: root/compatibility-client
diff options
context:
space:
mode:
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;
}