diff options
author | Dirk Fauth | 2018-05-07 19:28:24 +0000 |
---|---|---|
committer | Dirk Fauth | 2018-05-07 19:28:24 +0000 |
commit | 8e8f70a1a505eb4895bc09046f3231a3cb9e790c (patch) | |
tree | d3dcd444de0b8a1867cc6d58573b58c7aa842279 | |
parent | f5ed7bd3a2577e0581f88c643eb90c810f3840a2 (diff) | |
download | org.eclipse.nebula.widgets.nattable-8e8f70a1a505eb4895bc09046f3231a3cb9e790c.tar.gz org.eclipse.nebula.widgets.nattable-8e8f70a1a505eb4895bc09046f3231a3cb9e790c.tar.xz org.eclipse.nebula.widgets.nattable-8e8f70a1a505eb4895bc09046f3231a3cb9e790c.zip |
Bug 534446 - SelectAllCommand does not trigger repaint
Change-Id: Iee351d6672f5e945e12ec4651ff69eab5054b57c
Signed-off-by: Dirk Fauth <dirk.fauth@googlemail.com>
2 files changed, 51 insertions, 13 deletions
diff --git a/org.eclipse.nebula.widgets.nattable.core.test/src/org/eclipse/nebula/widgets/nattable/selection/SelectAllTest.java b/org.eclipse.nebula.widgets.nattable.core.test/src/org/eclipse/nebula/widgets/nattable/selection/SelectAllTest.java index 2aaba5c0..0ba8779b 100644 --- a/org.eclipse.nebula.widgets.nattable.core.test/src/org/eclipse/nebula/widgets/nattable/selection/SelectAllTest.java +++ b/org.eclipse.nebula.widgets.nattable.core.test/src/org/eclipse/nebula/widgets/nattable/selection/SelectAllTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2012 Original authors and others. + * Copyright (c) 2012, 2018 Original authors and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -10,15 +10,32 @@ ******************************************************************************/ package org.eclipse.nebula.widgets.nattable.selection; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import java.util.List; + +import org.eclipse.nebula.widgets.nattable.NatTable; +import org.eclipse.nebula.widgets.nattable.data.IRowDataProvider; +import org.eclipse.nebula.widgets.nattable.data.ListDataProvider; +import org.eclipse.nebula.widgets.nattable.data.ReflectiveColumnPropertyAccessor; +import org.eclipse.nebula.widgets.nattable.dataset.person.Person; +import org.eclipse.nebula.widgets.nattable.dataset.person.PersonService; import org.eclipse.nebula.widgets.nattable.layer.cell.ILayerCell; +import org.eclipse.nebula.widgets.nattable.selection.command.SelectAllCommand; +import org.eclipse.nebula.widgets.nattable.selection.command.SelectColumnCommand; +import org.eclipse.nebula.widgets.nattable.selection.event.CellSelectionEvent; import org.eclipse.nebula.widgets.nattable.style.DisplayMode; +import org.eclipse.nebula.widgets.nattable.test.fixture.NatTableFixture; import org.eclipse.nebula.widgets.nattable.test.fixture.layer.DataLayerFixture; +import org.eclipse.nebula.widgets.nattable.test.fixture.layer.GridLayerFixture; +import org.eclipse.nebula.widgets.nattable.test.fixture.layer.LayerListenerFixture; import org.junit.After; -import org.junit.Assert; import org.junit.Before; import org.junit.Test; public class SelectAllTest { + private SelectionLayer selectionLayer; @Before @@ -35,14 +52,38 @@ public class SelectAllTest { @Test public void shouldHaveAllCellsSelected() { - for (int columnPosition = 0; columnPosition < this.selectionLayer - .getColumnCount(); columnPosition++) { - for (int rowPosition = 0; rowPosition < this.selectionLayer - .getRowCount(); rowPosition++) { - ILayerCell cell = this.selectionLayer.getCellByPosition( - columnPosition, rowPosition); - Assert.assertEquals(DisplayMode.SELECT, cell.getDisplayMode()); + for (int columnPosition = 0; columnPosition < this.selectionLayer.getColumnCount(); columnPosition++) { + for (int rowPosition = 0; rowPosition < this.selectionLayer.getRowCount(); rowPosition++) { + ILayerCell cell = this.selectionLayer.getCellByPosition(columnPosition, rowPosition); + assertEquals(DisplayMode.SELECT, cell.getDisplayMode()); } } } + + @Test + public void shouldSendEventOnSelectAllWhenHidingLastSelectedColumn() throws Exception { + List<Person> listFixture = PersonService.getPersons(10); + IRowDataProvider<Person> bodyDataProvider = new ListDataProvider<>(listFixture, + new ReflectiveColumnPropertyAccessor<Person>(new String[] { "firstName", "lastName", "gender", "married", "birthday" })); + + GridLayerFixture gridLayer = new GridLayerFixture(bodyDataProvider); + NatTable natTable = new NatTableFixture(gridLayer, false); + + SelectionLayer selectionLayer = gridLayer.getBodyLayer().getSelectionLayer(); + + natTable.doCommand(new SelectColumnCommand(selectionLayer, 4, 0, false, false)); + assertEquals(1, selectionLayer.getFullySelectedColumnPositions().length); + + gridLayer.getBodyLayer().getColumnHideShowLayer().hideColumnPositions(4); + + LayerListenerFixture listener = new LayerListenerFixture(); + natTable.addLayerListener(listener); + + natTable.doCommand(new SelectAllCommand()); + + assertEquals(4, selectionLayer.getFullySelectedColumnPositions().length); + assertEquals(1, listener.getEventsCount()); + assertTrue(listener.getReceivedEvents().get(0) instanceof CellSelectionEvent); + } + } diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/selection/SelectionLayer.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/selection/SelectionLayer.java index e6483d65..df1629e0 100644 --- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/selection/SelectionLayer.java +++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/selection/SelectionLayer.java @@ -226,10 +226,7 @@ public class SelectionLayer extends AbstractIndexLayerTransform { setLastSelectedCell(0, 0); } addSelection(selection); - fireCellSelectionEvent( - getLastSelectedCell().columnPosition, - getLastSelectedCell().rowPosition, - false, false, false); + fireCellSelectionEvent(0, 0, false, false, false); } // Cell features |