use of org.eclipse.nebula.widgets.nattable.test.fixture.NatTableFixture in project nebula.widgets.nattable by eclipse.
the class ReorderColumnEventTest method reorderEventMustPropagateToTheTop.
/**
* Fix for http://nattable.org/jira/browse/NTBL-476
*/
@Test
public void reorderEventMustPropagateToTheTop() throws Exception {
DefaultBodyLayerStack underlyingLayer = new DefaultBodyLayerStack(new DataLayerFixture(20, 10, 100, 20));
NatTableFixture natTableFixture = new NatTableFixture(underlyingLayer);
// Add listener
LayerListenerFixture listenerFixture = new LayerListenerFixture();
natTableFixture.addLayerListener(listenerFixture);
assertEquals(6, natTableFixture.getColumnCount());
assertEquals(1, natTableFixture.getColumnIndexByPosition(1));
// Move to outside the visible range
List<Integer> columnToMove = Arrays.asList(1, 2, 3);
int destinationPosition = 10;
natTableFixture.doCommand(new MultiColumnReorderCommand(natTableFixture, columnToMove, destinationPosition));
// Ensure that the event propagates to the top
assertEquals(1, listenerFixture.getEventsCount());
assertNotNull(listenerFixture.getReceivedEvent(ColumnReorderEvent.class));
assertEquals(4, natTableFixture.getColumnIndexByPosition(1));
}
use of org.eclipse.nebula.widgets.nattable.test.fixture.NatTableFixture 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));
}
use of org.eclipse.nebula.widgets.nattable.test.fixture.NatTableFixture in project nebula.widgets.nattable by eclipse.
the class ColumnSizeResetCommandTest method testResetOnlyBody.
@Test
public void testResetOnlyBody() {
DummyGridLayerStack dummyGridLayerStack = new DummyGridLayerStack();
NatTable natTable = new NatTableFixture(dummyGridLayerStack);
assertEquals(40, dummyGridLayerStack.getRowHeaderDataLayer().getColumnWidthByPosition(0));
assertEquals(100, dummyGridLayerStack.getBodyDataLayer().getColumnWidthByPosition(2));
((DataLayer) dummyGridLayerStack.getRowHeaderDataLayer()).setColumnWidthByPosition(0, 100);
((DataLayer) dummyGridLayerStack.getBodyDataLayer()).setColumnWidthByPosition(2, 50);
assertEquals(100, dummyGridLayerStack.getRowHeaderDataLayer().getColumnWidthByPosition(0));
assertEquals(50, dummyGridLayerStack.getBodyDataLayer().getColumnWidthByPosition(2));
natTable.doCommand(new ColumnWidthResetCommand(GridRegion.BODY));
assertEquals(100, dummyGridLayerStack.getRowHeaderDataLayer().getColumnWidthByPosition(0));
assertEquals(100, dummyGridLayerStack.getBodyDataLayer().getColumnWidthByPosition(2));
}
use of org.eclipse.nebula.widgets.nattable.test.fixture.NatTableFixture in project nebula.widgets.nattable by eclipse.
the class ColumnGroupUtilsTest method setup.
/*
* Test fixture
*
* 0 1 2 3 4 5 6 ... 8 9 10 11 12
* ------------------------------------------------------------------ |<- G1
* ->| |<-- G2 -->| |<- G4 ->|<--- G3 --->|
*/
@Before
public void setup() {
this.model = new ColumnGroupModelFixture();
this.model.addColumnsIndexesToGroup("G4", 8, 9);
this.bodyStack = new ColumnGroupBodyLayerStack(new DataLayerFixture(20, 10, 10, 20), this.model);
// Inits client area
new NatTableFixture(this.bodyStack);
}
use of org.eclipse.nebula.widgets.nattable.test.fixture.NatTableFixture in project nebula.widgets.nattable by eclipse.
the class ButtonCellPainterTest method setup.
@Before
public void setup() {
this.buttonRaisedPainter = new CellPainterFixture();
this.buttonPressedPainter = new CellPainterFixture();
this.buttonCellPainter = new ButtonCellPainter(this.buttonRaisedPainter, this.buttonPressedPainter);
this.buttonCellPainter.setButtonFlashTime(500);
this.natTable = new NatTableFixture();
this.cellFixture = new LayerCell(this.natTable, 1, 5);
this.gcFixture = new GC(this.natTable);
this.mouseClickEvent = new MouseEvent(SWTUtils.getLeftClickEvent(100, 100, 0, this.natTable));
this.mouseClickEvent.data = NatEventData.createInstanceFromEvent(this.mouseClickEvent);
}
Aggregations