Search in sources :

Example 31 with NatTableFixture

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));
}
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) Test(org.junit.Test)

Example 32 with NatTableFixture

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

Example 33 with NatTableFixture

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));
}
Also used : DataLayer(org.eclipse.nebula.widgets.nattable.layer.DataLayer) DummyGridLayerStack(org.eclipse.nebula.widgets.nattable.layer.stack.DummyGridLayerStack) NatTableFixture(org.eclipse.nebula.widgets.nattable.test.fixture.NatTableFixture) NatTable(org.eclipse.nebula.widgets.nattable.NatTable) Test(org.junit.Test)

Example 34 with NatTableFixture

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);
}
Also used : NatTableFixture(org.eclipse.nebula.widgets.nattable.test.fixture.NatTableFixture) ColumnGroupModelFixture(org.eclipse.nebula.widgets.nattable.test.fixture.group.ColumnGroupModelFixture) DataLayerFixture(org.eclipse.nebula.widgets.nattable.test.fixture.layer.DataLayerFixture) ColumnGroupBodyLayerStack(org.eclipse.nebula.widgets.nattable.layer.stack.ColumnGroupBodyLayerStack) Before(org.junit.Before)

Example 35 with NatTableFixture

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);
}
Also used : CellPainterFixture(org.eclipse.nebula.widgets.nattable.test.fixture.CellPainterFixture) MouseEvent(org.eclipse.swt.events.MouseEvent) NatTableFixture(org.eclipse.nebula.widgets.nattable.test.fixture.NatTableFixture) ILayerCell(org.eclipse.nebula.widgets.nattable.layer.cell.ILayerCell) LayerCell(org.eclipse.nebula.widgets.nattable.layer.cell.LayerCell) GC(org.eclipse.swt.graphics.GC) Before(org.junit.Before)

Aggregations

NatTableFixture (org.eclipse.nebula.widgets.nattable.test.fixture.NatTableFixture)51 Test (org.junit.Test)29 Before (org.junit.Before)22 NatTable (org.eclipse.nebula.widgets.nattable.NatTable)16 DataLayer (org.eclipse.nebula.widgets.nattable.layer.DataLayer)13 DummyGridLayerStack (org.eclipse.nebula.widgets.nattable.layer.stack.DummyGridLayerStack)13 LayerListenerFixture (org.eclipse.nebula.widgets.nattable.test.fixture.layer.LayerListenerFixture)11 RowDataFixture (org.eclipse.nebula.widgets.nattable.dataset.fixture.data.RowDataFixture)8 Properties (java.util.Properties)7 Range (org.eclipse.nebula.widgets.nattable.coordinate.Range)7 GridLayerFixture (org.eclipse.nebula.widgets.nattable.test.fixture.layer.GridLayerFixture)6 ListDataProvider (org.eclipse.nebula.widgets.nattable.data.ListDataProvider)5 SpanningDataLayer (org.eclipse.nebula.widgets.nattable.layer.SpanningDataLayer)5 DataLayerFixture (org.eclipse.nebula.widgets.nattable.test.fixture.layer.DataLayerFixture)5 ViewportLayer (org.eclipse.nebula.widgets.nattable.viewport.ViewportLayer)5 IRowIdAccessor (org.eclipse.nebula.widgets.nattable.data.IRowIdAccessor)4 DefaultEditBindings (org.eclipse.nebula.widgets.nattable.edit.config.DefaultEditBindings)4 DefaultEditConfiguration (org.eclipse.nebula.widgets.nattable.edit.config.DefaultEditConfiguration)4 IUniqueIndexLayer (org.eclipse.nebula.widgets.nattable.layer.IUniqueIndexLayer)4 SelectionLayer (org.eclipse.nebula.widgets.nattable.selection.SelectionLayer)4