Search in sources :

Example 1 with MultiRowReorderCommand

use of org.eclipse.nebula.widgets.nattable.reorder.command.MultiRowReorderCommand in project nebula.widgets.nattable by eclipse.

the class ReorderRowEventTest method reorderEventMustPropagateToTheTop.

@Test
public void reorderEventMustPropagateToTheTop() throws Exception {
    DefaultBodyLayerStack underlyingLayer = new DefaultBodyLayerStack(new RowReorderLayer(new DataLayerFixture(10, 10, 100, 20)));
    NatTableFixture natTableFixture = new NatTableFixture(underlyingLayer);
    // Add listener
    LayerListenerFixture listenerFixture = new LayerListenerFixture();
    natTableFixture.addLayerListener(listenerFixture);
    Assert.assertEquals(10, natTableFixture.getRowCount());
    Assert.assertEquals(1, natTableFixture.getRowIndexByPosition(1));
    // Move to outside the visible range
    List<Integer> rowsToMove = Arrays.asList(1, 2, 3);
    int destinationPosition = 10;
    natTableFixture.doCommand(new MultiRowReorderCommand(natTableFixture, rowsToMove, destinationPosition));
    // Ensure that the event propagates to the top
    Assert.assertEquals(1, listenerFixture.getEventsCount());
    Assert.assertNotNull(listenerFixture.getReceivedEvent(RowReorderEvent.class));
    Assert.assertEquals(4, natTableFixture.getRowIndexByPosition(1));
}
Also used : NatTableFixture(org.eclipse.nebula.widgets.nattable.test.fixture.NatTableFixture) MultiRowReorderCommand(org.eclipse.nebula.widgets.nattable.reorder.command.MultiRowReorderCommand) DataLayerFixture(org.eclipse.nebula.widgets.nattable.test.fixture.layer.DataLayerFixture) LayerListenerFixture(org.eclipse.nebula.widgets.nattable.test.fixture.layer.LayerListenerFixture) DefaultBodyLayerStack(org.eclipse.nebula.widgets.nattable.layer.stack.DefaultBodyLayerStack) RowReorderLayer(org.eclipse.nebula.widgets.nattable.reorder.RowReorderLayer) Test(org.junit.Test)

Aggregations

DefaultBodyLayerStack (org.eclipse.nebula.widgets.nattable.layer.stack.DefaultBodyLayerStack)1 RowReorderLayer (org.eclipse.nebula.widgets.nattable.reorder.RowReorderLayer)1 MultiRowReorderCommand (org.eclipse.nebula.widgets.nattable.reorder.command.MultiRowReorderCommand)1 NatTableFixture (org.eclipse.nebula.widgets.nattable.test.fixture.NatTableFixture)1 DataLayerFixture (org.eclipse.nebula.widgets.nattable.test.fixture.layer.DataLayerFixture)1 LayerListenerFixture (org.eclipse.nebula.widgets.nattable.test.fixture.layer.LayerListenerFixture)1 Test (org.junit.Test)1