Search in sources :

Example 16 with LayerListenerFixture

use of org.eclipse.nebula.widgets.nattable.test.fixture.layer.LayerListenerFixture in project nebula.widgets.nattable by eclipse.

the class ReorderColumnEventTest method shouldThrowAReorderColumnEvent.

@Test
public void shouldThrowAReorderColumnEvent() {
    LayerListenerFixture listenerFixture = new LayerListenerFixture();
    this.columnReorderLayer.addLayerListener(listenerFixture);
    this.columnReorderLayer.reorderColumnPosition(3, 1);
    assertEquals(1, listenerFixture.getEventsCount());
    assertNotNull(listenerFixture.getReceivedEvent(ColumnReorderEvent.class));
}
Also used : LayerListenerFixture(org.eclipse.nebula.widgets.nattable.test.fixture.layer.LayerListenerFixture) Test(org.junit.Test)

Example 17 with LayerListenerFixture

use of org.eclipse.nebula.widgets.nattable.test.fixture.layer.LayerListenerFixture in project nebula.widgets.nattable by eclipse.

the class ReorderColumnEventTest method reorderMultipleNotConsecutiveColumnsInHiddenState.

@Test
public void reorderMultipleNotConsecutiveColumnsInHiddenState() {
    DefaultBodyLayerStack underlyingLayer = new DefaultBodyLayerStack(new DataLayerFixture(10, 10, 100, 20));
    NatTableFixture natTableFixture = new NatTableFixture(underlyingLayer, 1000, 400, true);
    // Add listener
    LayerListenerFixture listenerFixture = new LayerListenerFixture();
    natTableFixture.addLayerListener(listenerFixture);
    assertEquals(10, natTableFixture.getColumnCount());
    // hide some columns
    natTableFixture.doCommand(new MultiColumnHideCommand(natTableFixture, new int[] { 2, 5, 8 }));
    assertEquals(7, natTableFixture.getColumnCount());
    List<Integer> columnToMove = Arrays.asList(3, 4, 6, 7);
    int destinationPosition = 0;
    natTableFixture.doCommand(new MultiColumnReorderCommand(underlyingLayer.getColumnReorderLayer(), columnToMove, destinationPosition));
    // verify the event
    ColumnReorderEvent event = (ColumnReorderEvent) listenerFixture.getReceivedEvent(ColumnReorderEvent.class);
    assertNotNull(event);
    assertTrue(StructuralChangeEventHelper.isReorder(event.getColumnDiffs()));
    assertEquals(7, natTableFixture.getColumnCount());
    assertEquals(0, underlyingLayer.getColumnReorderLayer().getColumnPositionByIndex(3));
    assertEquals(1, underlyingLayer.getColumnReorderLayer().getColumnPositionByIndex(4));
    assertEquals(2, underlyingLayer.getColumnReorderLayer().getColumnPositionByIndex(6));
    assertEquals(3, underlyingLayer.getColumnReorderLayer().getColumnPositionByIndex(7));
    assertEquals(4, underlyingLayer.getColumnReorderLayer().getColumnPositionByIndex(0));
    assertEquals(5, underlyingLayer.getColumnReorderLayer().getColumnPositionByIndex(1));
    assertEquals(6, underlyingLayer.getColumnReorderLayer().getColumnPositionByIndex(2));
    assertEquals(7, underlyingLayer.getColumnReorderLayer().getColumnPositionByIndex(5));
    assertEquals(8, underlyingLayer.getColumnReorderLayer().getColumnPositionByIndex(8));
    assertEquals(9, underlyingLayer.getColumnReorderLayer().getColumnPositionByIndex(9));
}
Also used : MultiColumnReorderCommand(org.eclipse.nebula.widgets.nattable.reorder.command.MultiColumnReorderCommand) NatTableFixture(org.eclipse.nebula.widgets.nattable.test.fixture.NatTableFixture) 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) MultiColumnHideCommand(org.eclipse.nebula.widgets.nattable.hideshow.command.MultiColumnHideCommand) Test(org.junit.Test)

Example 18 with LayerListenerFixture

use of org.eclipse.nebula.widgets.nattable.test.fixture.layer.LayerListenerFixture in project nebula.widgets.nattable by eclipse.

the class ReorderRowEventTest method shouldThrowAReorderRowEvent.

@Test
public void shouldThrowAReorderRowEvent() {
    LayerListenerFixture listenerFixture = new LayerListenerFixture();
    this.rowReorderLayer.addLayerListener(listenerFixture);
    this.rowReorderLayer.reorderRowPosition(3, 1);
    Assert.assertEquals(1, listenerFixture.getEventsCount());
    Assert.assertNotNull(listenerFixture.getReceivedEvent(RowReorderEvent.class));
}
Also used : LayerListenerFixture(org.eclipse.nebula.widgets.nattable.test.fixture.layer.LayerListenerFixture) Test(org.junit.Test)

Example 19 with LayerListenerFixture

use of org.eclipse.nebula.widgets.nattable.test.fixture.layer.LayerListenerFixture in project nebula.widgets.nattable by eclipse.

the class ColumnReorderLayerTest2 method shouldLoadstateFromProperties.

@Test
public void shouldLoadstateFromProperties() throws Exception {
    LayerListenerFixture listener = new LayerListenerFixture();
    this.reorderLayer.addLayerListener(listener);
    Properties testProperties = new Properties();
    testProperties.put(ColumnReorderLayer.PERSISTENCE_KEY_COLUMN_INDEX_ORDER, "0,1,3,2,");
    this.reorderLayer.loadState("", testProperties);
    Assert.assertEquals(0, this.reorderLayer.getColumnIndexByPosition(0));
    Assert.assertEquals(1, this.reorderLayer.getColumnIndexByPosition(1));
    Assert.assertEquals(3, this.reorderLayer.getColumnIndexByPosition(2));
    Assert.assertEquals(2, this.reorderLayer.getColumnIndexByPosition(3));
    Assert.assertTrue(listener.containsInstanceOf(ColumnStructuralRefreshEvent.class));
}
Also used : ColumnStructuralRefreshEvent(org.eclipse.nebula.widgets.nattable.layer.event.ColumnStructuralRefreshEvent) LayerListenerFixture(org.eclipse.nebula.widgets.nattable.test.fixture.layer.LayerListenerFixture) Properties(java.util.Properties) Test(org.junit.Test)

Example 20 with LayerListenerFixture

use of org.eclipse.nebula.widgets.nattable.test.fixture.layer.LayerListenerFixture in project nebula.widgets.nattable by eclipse.

the class RowReorderLayerTest2 method shouldLoadstateFromProperties.

@Test
public void shouldLoadstateFromProperties() throws Exception {
    LayerListenerFixture listener = new LayerListenerFixture();
    this.reorderLayer.addLayerListener(listener);
    Properties testProperties = new Properties();
    testProperties.put(RowReorderLayer.PERSISTENCE_KEY_ROW_INDEX_ORDER, "0,1,3,2,");
    this.reorderLayer.loadState("", testProperties);
    Assert.assertEquals(0, this.reorderLayer.getRowIndexByPosition(0));
    Assert.assertEquals(1, this.reorderLayer.getRowIndexByPosition(1));
    Assert.assertEquals(3, this.reorderLayer.getRowIndexByPosition(2));
    Assert.assertEquals(2, this.reorderLayer.getRowIndexByPosition(3));
    Assert.assertTrue(listener.containsInstanceOf(RowStructuralRefreshEvent.class));
}
Also used : RowStructuralRefreshEvent(org.eclipse.nebula.widgets.nattable.layer.event.RowStructuralRefreshEvent) LayerListenerFixture(org.eclipse.nebula.widgets.nattable.test.fixture.layer.LayerListenerFixture) Properties(java.util.Properties) Test(org.junit.Test)

Aggregations

LayerListenerFixture (org.eclipse.nebula.widgets.nattable.test.fixture.layer.LayerListenerFixture)37 Test (org.junit.Test)21 Before (org.junit.Before)16 NatTableFixture (org.eclipse.nebula.widgets.nattable.test.fixture.NatTableFixture)11 DataLayerFixture (org.eclipse.nebula.widgets.nattable.test.fixture.layer.DataLayerFixture)7 Range (org.eclipse.nebula.widgets.nattable.coordinate.Range)4 Rectangle (org.eclipse.swt.graphics.Rectangle)4 Shell (org.eclipse.swt.widgets.Shell)4 Properties (java.util.Properties)3 NatTable (org.eclipse.nebula.widgets.nattable.NatTable)3 DataLayer (org.eclipse.nebula.widgets.nattable.layer.DataLayer)3 CellVisualChangeEvent (org.eclipse.nebula.widgets.nattable.layer.event.CellVisualChangeEvent)3 DefaultBodyLayerStack (org.eclipse.nebula.widgets.nattable.layer.stack.DefaultBodyLayerStack)3 DummyGridLayerStack (org.eclipse.nebula.widgets.nattable.layer.stack.DummyGridLayerStack)3 ReflectiveColumnPropertyAccessor (org.eclipse.nebula.widgets.nattable.data.ReflectiveColumnPropertyAccessor)2 DummyBodyDataProvider (org.eclipse.nebula.widgets.nattable.grid.data.DummyBodyDataProvider)2 ColumnHideCommand (org.eclipse.nebula.widgets.nattable.hideshow.command.ColumnHideCommand)2 RowHideCommand (org.eclipse.nebula.widgets.nattable.hideshow.command.RowHideCommand)2 HideColumnPositionsEvent (org.eclipse.nebula.widgets.nattable.hideshow.event.HideColumnPositionsEvent)2 HideRowPositionsEvent (org.eclipse.nebula.widgets.nattable.hideshow.event.HideRowPositionsEvent)2