diff options
| author | Dirk Fauth | 2022-07-13 12:52:51 +0000 |
|---|---|---|
| committer | Dirk Fauth | 2022-07-13 12:52:51 +0000 |
| commit | f975367b8ffcbeb8d73dc5db29f3ab57d7631c17 (patch) | |
| tree | f1478613e46b8fe27efb9bf4091ebf176452b3cc | |
| parent | fd6cac57efd980627313741c94c4d561e18263d1 (diff) | |
| download | org.eclipse.nebula.widgets.nattable-f975367b8ffcbeb8d73dc5db29f3ab57d7631c17.tar.gz org.eclipse.nebula.widgets.nattable-f975367b8ffcbeb8d73dc5db29f3ab57d7631c17.tar.xz org.eclipse.nebula.widgets.nattable-f975367b8ffcbeb8d73dc5db29f3ab57d7631c17.zip | |
Bug 580376 - Enable initial programmatic freeze operations
Signed-off-by: Dirk Fauth <dirk.fauth@googlemail.com>
Change-Id: I4723f177557aff39ceb4c84fa02bcd2be987e6fc
2 files changed, 33 insertions, 3 deletions
diff --git a/org.eclipse.nebula.widgets.nattable.core.test/src/org/eclipse/nebula/widgets/nattable/freeze/command/FreezeHandlerTest.java b/org.eclipse.nebula.widgets.nattable.core.test/src/org/eclipse/nebula/widgets/nattable/freeze/command/FreezeHandlerTest.java index 2e0926ca..12e61289 100644 --- a/org.eclipse.nebula.widgets.nattable.core.test/src/org/eclipse/nebula/widgets/nattable/freeze/command/FreezeHandlerTest.java +++ b/org.eclipse.nebula.widgets.nattable.core.test/src/org/eclipse/nebula/widgets/nattable/freeze/command/FreezeHandlerTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2012, 2020 Original authors and others. + * Copyright (c) 2012, 2022 Original authors and others. * * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 @@ -367,6 +367,30 @@ public class FreezeHandlerTest { assertEquals(300, this.viewportLayer.getOrigin().getY()); } + @Test + public void shouldFreezeBeforeInitialize() { + DataLayer bodyDataLayer = new DataLayer(new DummyBodyDataProvider(10, 10)); + DefaultBodyLayerStack bodyLayer = new DefaultBodyLayerStack(bodyDataLayer); + SelectionLayer selectionLayer = bodyLayer.getSelectionLayer(); + + FreezeLayer freezeLayer = new FreezeLayer(selectionLayer); + CompositeFreezeLayer compositeFreezeLayer = new CompositeFreezeLayer(freezeLayer, bodyLayer.getViewportLayer(), bodyLayer.getSelectionLayer()); + ViewportLayer viewportLayer = bodyLayer.getViewportLayer(); + FreezeCommandHandler commandHandler = new FreezeCommandHandler(freezeLayer, viewportLayer, selectionLayer); + compositeFreezeLayer.registerCommandHandler(commandHandler); + + // no client area set and no client area resize command triggered + compositeFreezeLayer.doCommand(new FreezeColumnCommand(compositeFreezeLayer, 1)); + assertEquals(0, freezeLayer.getTopLeftPosition().columnPosition); + assertEquals(-1, freezeLayer.getTopLeftPosition().rowPosition); + assertEquals(1, freezeLayer.getBottomRightPosition().columnPosition); + assertEquals(-1, freezeLayer.getBottomRightPosition().rowPosition); + + // Check viewport origin + assertEquals(2, viewportLayer.getMinimumOriginColumnPosition()); + assertEquals(0, viewportLayer.getMinimumOriginRowPosition()); + } + class ReorderListener implements ILayerListener { private ColumnReorderEvent reorderEvent; diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/freeze/command/FreezeCommandHandler.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/freeze/command/FreezeCommandHandler.java index 65ece980..89ab85d8 100644 --- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/freeze/command/FreezeCommandHandler.java +++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/freeze/command/FreezeCommandHandler.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2012, 2020 Original authors and others. + * Copyright (c) 2012, 2022 Original authors and others. * * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 @@ -44,7 +44,13 @@ public class FreezeCommandHandler extends AbstractLayerCommandHandler<IFreezeCom // using ViewportLayer#getScrollableLayer() because the positions in the // further processing are taking from the scrollable layer, which does // not need to be the SelectionLayer in every case - if (command.convertToTargetLayer(this.viewportLayer.getScrollableLayer())) { + // + // The client area check is used to handle the programmatic freeze + // BEFORE the client area was initialized. Without this check a + // programmatic freeze before the rendering completed is not working. + if ((this.viewportLayer.getClientAreaWidth() == 0 + && this.viewportLayer.getClientAreaHeight() == 0) + || command.convertToTargetLayer(this.viewportLayer.getScrollableLayer())) { if (command instanceof FreezeColumnCommand) { // freeze for a whole column FreezeColumnCommand freezeColumnCommand = (FreezeColumnCommand) command; |
