diff options
Diffstat (limited to 'compatibility-client')
4 files changed, 45 insertions, 24 deletions
diff --git a/compatibility-client/pom.xml b/compatibility-client/pom.xml index 898326526c..76c06a3755 100644 --- a/compatibility-client/pom.xml +++ b/compatibility-client/pom.xml @@ -75,7 +75,7 @@ <execution> <id>copy-sources</id> <!-- here the phase you need --> - <phase>prepare-package</phase> + <phase>process-resources</phase> <goals> <goal>copy-resources</goal> </goals> diff --git a/compatibility-client/src/main/java/com/vaadin/v7/client/widget/grid/selection/MultiSelectionRenderer.java b/compatibility-client/src/main/java/com/vaadin/v7/client/widget/grid/selection/MultiSelectionRenderer.java index 678d37369f..a7c974aead 100644 --- a/compatibility-client/src/main/java/com/vaadin/v7/client/widget/grid/selection/MultiSelectionRenderer.java +++ b/compatibility-client/src/main/java/com/vaadin/v7/client/widget/grid/selection/MultiSelectionRenderer.java @@ -26,6 +26,7 @@ import com.google.gwt.dom.client.BrowserEvents; import com.google.gwt.dom.client.Element; import com.google.gwt.dom.client.NativeEvent; import com.google.gwt.dom.client.TableElement; +import com.google.gwt.dom.client.TableRowElement; import com.google.gwt.dom.client.TableSectionElement; import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.event.dom.client.ClickHandler; @@ -45,6 +46,7 @@ import com.vaadin.v7.client.widget.grid.RendererCellReference; import com.vaadin.v7.client.widget.grid.events.GridEnabledEvent; import com.vaadin.v7.client.widget.grid.events.GridEnabledHandler; import com.vaadin.v7.client.widget.grid.selection.SelectionModel.Multi.Batched; +import com.vaadin.v7.client.widgets.Escalator.AbstractRowContainer; import com.vaadin.v7.client.widgets.Grid; /** @@ -319,7 +321,7 @@ public class MultiSelectionRenderer<T> int constrainedPageY = Math.max(bodyAbsoluteTop, Math.min(bodyAbsoluteBottom, pageY)); - int logicalRow = getLogicalRowIndex(WidgetUtil + int logicalRow = getLogicalRowIndex(grid, WidgetUtil .getElementFromPoint(initialPageX, constrainedPageY)); int incrementOrDecrement = (logicalRow > lastModifiedLogicalRow) ? 1 @@ -586,8 +588,6 @@ public class MultiSelectionRenderer<T> } } - private static final String LOGICAL_ROW_PROPERTY_INT = "vEscalatorLogicalRow"; - private final Grid<T> grid; private HandlerRegistration nativePreviewHandlerRegistration; @@ -633,8 +633,6 @@ public class MultiSelectionRenderer<T> CheckBox checkBox) { checkBox.setValue(data, false); checkBox.setEnabled(grid.isEnabled() && !grid.isEditorActive()); - checkBox.getElement().setPropertyInt(LOGICAL_ROW_PROPERTY_INT, - cell.getRowIndex()); } @Override @@ -668,7 +666,7 @@ public class MultiSelectionRenderer<T> private void startDragSelect(NativeEvent event, final Element target) { injectNativeHandler(); - int logicalRowIndex = getLogicalRowIndex(target); + int logicalRowIndex = getLogicalRowIndex(grid, target); autoScrollHandler.start(logicalRowIndex); event.preventDefault(); event.stopPropagation(); @@ -687,7 +685,7 @@ public class MultiSelectionRenderer<T> } } - private int getLogicalRowIndex(final Element target) { + private int getLogicalRowIndex(Grid<T> grid, final Element target) { if (target == null) { return -1; } @@ -707,7 +705,8 @@ public class MultiSelectionRenderer<T> final Element checkbox = td.getFirstChildElement(); assert checkbox != null : "Checkbox has disappeared"; - return checkbox.getPropertyInt(LOGICAL_ROW_PROPERTY_INT); + return ((AbstractRowContainer) grid.getEscalator().getBody()) + .getLogicalRowIndex((TableRowElement) tr); } tr = tr.getNextSiblingElement(); } diff --git a/compatibility-client/src/main/java/com/vaadin/v7/client/widgets/Escalator.java b/compatibility-client/src/main/java/com/vaadin/v7/client/widgets/Escalator.java index f343d45f6f..cb2786a4cf 100644 --- a/compatibility-client/src/main/java/com/vaadin/v7/client/widgets/Escalator.java +++ b/compatibility-client/src/main/java/com/vaadin/v7/client/widgets/Escalator.java @@ -673,13 +673,13 @@ public class Escalator extends Widget /*-{ var vScroll = esc.@com.vaadin.v7.client.widgets.Escalator::verticalScrollbar; var vScrollElem = vScroll.@com.vaadin.v7.client.widget.escalator.ScrollbarBundle::getElement()(); - + var hScroll = esc.@com.vaadin.v7.client.widgets.Escalator::horizontalScrollbar; var hScrollElem = hScroll.@com.vaadin.v7.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. @@ -700,29 +700,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.v7.client.widgets.Escalator::body; deltaY *= brc.@com.vaadin.v7.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.v7.client.widgets.Escalator::logWarning(*)(msg); } - + // IE8 has only delta y if (isNaN(deltaY)) { deltaY = -0.5*e.wheelDelta; } - + @com.vaadin.v7.client.widgets.Escalator.JsniUtil::moveScrollFromEvent(*)(esc, deltaX, deltaY, e); }); }-*/; @@ -1044,7 +1044,7 @@ public class Escalator extends Widget } } - protected abstract class AbstractRowContainer implements RowContainer { + public abstract class AbstractRowContainer implements RowContainer { private EscalatorUpdater updater = EscalatorUpdater.NULL; private int rows; @@ -2070,7 +2070,14 @@ public class Escalator extends Widget */ protected abstract double getHeightOfSection(); - protected int getLogicalRowIndex(final TableRowElement tr) { + /** + * Gets the logical row index for the given table row element. + * + * @param tr + * the table row element inside this container + * @return the logical index of the given element + */ + public int getLogicalRowIndex(final TableRowElement tr) { return tr.getSectionRowIndex(); }; @@ -3379,7 +3386,7 @@ public class Escalator extends Widget } @Override - protected int getLogicalRowIndex(final TableRowElement tr) { + public int getLogicalRowIndex(final TableRowElement tr) { assert tr .getParentNode() == root : "The given element isn't a row element in the body"; int internalIndex = visualRowOrder.indexOf(tr); 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 e59fc2213f..5e48188128 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 @@ -4128,6 +4128,8 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>, private GridSpacerUpdater gridSpacerUpdater = new GridSpacerUpdater(); /** A set keeping track of the indices of all currently open details */ private Set<Integer> visibleDetails = new HashSet<>(); + /** A set of indices of details to reopen after detach and on attach */ + private final Set<Integer> reattachVisibleDetails = new HashSet<>(); private boolean columnReorderingAllowed; @@ -6451,8 +6453,14 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>, int columnIndex = columns.indexOf(column); // Remove from column configuration - escalator.getColumnConfiguration() - .removeColumns(getVisibleColumns().indexOf(column), 1); + int visibleColumnIndex = getVisibleColumns().indexOf(column); + if (visibleColumnIndex < 0) { + assert column.isHidden(); + // Hidden columns are not included in Escalator + } else { + getEscalator().getColumnConfiguration() + .removeColumns(visibleColumnIndex, 1); + } updateFrozenColumns(); @@ -6831,7 +6839,12 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>, return editor; } - protected Escalator getEscalator() { + /** + * Gets the {@link Escalator} used by this Grid instnace. + * + * @return the escalator instance, never <code>null</code> + */ + public Escalator getEscalator() { return escalator; } @@ -8766,6 +8779,8 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>, @Override protected void onDetach() { Set<Integer> details = new HashSet<>(visibleDetails); + reattachVisibleDetails.clear(); + reattachVisibleDetails.addAll(details); for (int row : details) { setDetailsVisible(row, false); } |