Search in sources :

Example 26 with LayerListenerFixture

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

the class ResizeEventPropagationTest method shouldReturnARectangleStartingFromResizedColumnToEndOfGrid.

@Test
public void shouldReturnARectangleStartingFromResizedColumnToEndOfGrid() {
    // Mimics resizing the second column
    this.layerListener = new LayerListenerFixture();
    this.dataLayer.addLayerListener(this.layerListener);
    this.dataLayer.setColumnWidthByPosition(2, 200);
    // This is the propagated event
    ColumnResizeEvent columnResizeEvent = (ColumnResizeEvent) this.layerListener.getReceivedEvents().get(0);
    Collection<Rectangle> actualRectangles = columnResizeEvent.getChangedPositionRectangles();
    // The affected region should have the following size
    Rectangle expectedRectangle = new Rectangle(2, 0, 3, 7);
    Assert.assertEquals(expectedRectangle, actualRectangles.iterator().next());
}
Also used : Rectangle(org.eclipse.swt.graphics.Rectangle) ColumnResizeEvent(org.eclipse.nebula.widgets.nattable.resize.event.ColumnResizeEvent) LayerListenerFixture(org.eclipse.nebula.widgets.nattable.test.fixture.layer.LayerListenerFixture) Test(org.junit.Test)

Example 27 with LayerListenerFixture

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

the class AbstractLayerTest method setup.

@Before
public void setup() {
    this.dataLayer = new DataLayerFixture();
    this.firstListener = new LayerListenerFixture();
    this.dataLayer.addLayerListener(this.firstListener);
}
Also used : DataLayerFixture(org.eclipse.nebula.widgets.nattable.test.fixture.layer.DataLayerFixture) LayerListenerFixture(org.eclipse.nebula.widgets.nattable.test.fixture.layer.LayerListenerFixture) Before(org.junit.Before)

Example 28 with LayerListenerFixture

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

the class DataLayerCommandHandlingTest method handleUpdateDataCommandRaisesEvents.

@Test
public void handleUpdateDataCommandRaisesEvents() throws Exception {
    LayerListenerFixture listener = new LayerListenerFixture();
    this.dataLayer.addLayerListener(listener);
    this.dataLayer.doCommand(this.command);
    Assert.assertTrue(listener.getReceivedEvents().get(0) instanceof CellVisualChangeEvent);
}
Also used : LayerListenerFixture(org.eclipse.nebula.widgets.nattable.test.fixture.layer.LayerListenerFixture) CellVisualChangeEvent(org.eclipse.nebula.widgets.nattable.layer.event.CellVisualChangeEvent) Test(org.junit.Test)

Example 29 with LayerListenerFixture

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

the class ColumnHideShowLayerTest2 method scrollAndHideTheLastColumn.

/**
 * Integration test
 */
@Test
public void scrollAndHideTheLastColumn() throws Exception {
    // Total columns in fixture - 20 (index 0 - 19)
    NatTableFixture natTable = new NatTableFixture();
    LayerListenerFixture natTableListener = new LayerListenerFixture();
    natTable.addLayerListener(natTableListener);
    // Scroll to position 14 in grid/14 in body
    natTable.scrollToColumn(14);
    assertEquals(14, natTable.getColumnIndexByPosition(1));
    // Hide last column - position 6/index 19
    assertEquals(19, natTable.getColumnIndexByPosition(6));
    natTable.doCommand(new ColumnHideCommand(natTable, 6));
    // Assert event received
    assertNotNull(natTableListener.getReceivedEvent(HideColumnPositionsEvent.class));
    HideColumnPositionsEvent hideEvent = (HideColumnPositionsEvent) natTableListener.getReceivedEvent(HideColumnPositionsEvent.class);
    // When last column is hidden it is not carrying the following info
    assertEquals(1, hideEvent.getColumnPositionRanges().size());
    // View port adjusted origin to move an extra column in
    Range hiddenRange = hideEvent.getColumnPositionRanges().iterator().next();
    assertEquals(7, hiddenRange.start);
    assertEquals(8, hiddenRange.end);
}
Also used : ColumnHideCommand(org.eclipse.nebula.widgets.nattable.hideshow.command.ColumnHideCommand) HideColumnPositionsEvent(org.eclipse.nebula.widgets.nattable.hideshow.event.HideColumnPositionsEvent) NatTableFixture(org.eclipse.nebula.widgets.nattable.test.fixture.NatTableFixture) LayerListenerFixture(org.eclipse.nebula.widgets.nattable.test.fixture.layer.LayerListenerFixture) Range(org.eclipse.nebula.widgets.nattable.coordinate.Range) Test(org.junit.Test)

Example 30 with LayerListenerFixture

use of org.eclipse.nebula.widgets.nattable.test.fixture.layer.LayerListenerFixture 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)

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