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));
}
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));
}
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));
}
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));
}
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));
}
Aggregations