Search in sources :

Example 1 with ColumnResizeEvent

use of org.eclipse.nebula.widgets.nattable.resize.event.ColumnResizeEvent in project nebula.widgets.nattable by eclipse.

the class AbstractLayerTest method testFireOriginalEventIfOnlyOneListener.

@Test
public void testFireOriginalEventIfOnlyOneListener() {
    ILayerEvent event = new ColumnResizeEvent(this.dataLayer, 2);
    this.dataLayer.fireLayerEvent(event);
    List<ILayerEvent> receivedEvents = this.firstListener.getReceivedEvents();
    assertNotNull(receivedEvents);
    assertEquals(1, receivedEvents.size());
    assertSame(event, receivedEvents.get(0));
}
Also used : ILayerEvent(org.eclipse.nebula.widgets.nattable.layer.event.ILayerEvent) ColumnResizeEvent(org.eclipse.nebula.widgets.nattable.resize.event.ColumnResizeEvent) Test(org.junit.Test)

Example 2 with ColumnResizeEvent

use of org.eclipse.nebula.widgets.nattable.resize.event.ColumnResizeEvent in project nebula.widgets.nattable by eclipse.

the class AbstractLayerTest method testFireClonedEventIfMultipleListeners.

@Test
public void testFireClonedEventIfMultipleListeners() {
    LayerListenerFixture secondListener = new LayerListenerFixture();
    this.dataLayer.addLayerListener(secondListener);
    ILayerEvent event = new ColumnResizeEvent(this.dataLayer, 2);
    this.dataLayer.fireLayerEvent(event);
    List<ILayerEvent> receivedEvents = this.firstListener.getReceivedEvents();
    assertNotNull(receivedEvents);
    assertEquals(1, receivedEvents.size());
    assertNotSame(event, receivedEvents.get(0));
    receivedEvents = secondListener.getReceivedEvents();
    assertNotNull(receivedEvents);
    assertEquals(1, receivedEvents.size());
    assertSame(event, receivedEvents.get(0));
}
Also used : ILayerEvent(org.eclipse.nebula.widgets.nattable.layer.event.ILayerEvent) ColumnResizeEvent(org.eclipse.nebula.widgets.nattable.resize.event.ColumnResizeEvent) LayerListenerFixture(org.eclipse.nebula.widgets.nattable.test.fixture.layer.LayerListenerFixture) Test(org.junit.Test)

Example 3 with ColumnResizeEvent

use of org.eclipse.nebula.widgets.nattable.resize.event.ColumnResizeEvent in project nebula.widgets.nattable by eclipse.

the class ResizeColumnHideShowLayerTest method testHideShowDefaultSizedColumns.

// test hide with default only set columns
@Test
public void testHideShowDefaultSizedColumns() {
    assertEquals(500, this.hideShowLayer.getWidth());
    assertTrue(this.bodyDataLayer.isColumnPositionResizable(1));
    assertTrue(this.bodyDataLayer.isColumnPositionResizable(4));
    this.hideShowLayer.hideColumnPositions(1, 4);
    assertEquals(2, this.listener.getReceivedEvents().size());
    assertEquals(new Range(1, 2), ((ColumnResizeEvent) this.listener.getReceivedEvents().get(0)).getColumnDiffs().iterator().next().getAfterPositionRange());
    assertEquals(new Range(4, 5), ((ColumnResizeEvent) this.listener.getReceivedEvents().get(1)).getColumnDiffs().iterator().next().getAfterPositionRange());
    assertEquals(300, this.hideShowLayer.getWidth());
    assertEquals(0, this.hideShowLayer.getColumnWidthByPosition(1));
    assertEquals(0, this.hideShowLayer.getColumnWidthByPosition(4));
    assertEquals(2, this.hideShowLayer.getHiddenColumnIndexes().size());
    assertTrue("1 is not contained in hidden column indexes", this.hideShowLayer.getHiddenColumnIndexes().contains(Integer.valueOf(1)));
    assertTrue("4 is not contained in hidden column indexes", this.hideShowLayer.getHiddenColumnIndexes().contains(Integer.valueOf(4)));
    assertFalse(this.bodyDataLayer.isColumnPositionResizable(1));
    assertFalse(this.bodyDataLayer.isColumnPositionResizable(4));
    this.hideShowLayer.showAllColumns();
    assertEquals(4, this.listener.getReceivedEvents().size());
    assertEquals(new Range(1, 2), ((ColumnResizeEvent) this.listener.getReceivedEvents().get(2)).getColumnDiffs().iterator().next().getAfterPositionRange());
    assertEquals(new Range(4, 5), ((ColumnResizeEvent) this.listener.getReceivedEvents().get(3)).getColumnDiffs().iterator().next().getAfterPositionRange());
    assertEquals(500, this.hideShowLayer.getWidth());
    assertEquals(100, this.hideShowLayer.getColumnWidthByPosition(1));
    assertEquals(100, this.hideShowLayer.getColumnWidthByPosition(4));
    assertTrue("hidden column indexes are not empty", this.hideShowLayer.getHiddenColumnIndexes().isEmpty());
    assertTrue(this.bodyDataLayer.isColumnPositionResizable(1));
    assertTrue(this.bodyDataLayer.isColumnPositionResizable(4));
}
Also used : ColumnResizeEvent(org.eclipse.nebula.widgets.nattable.resize.event.ColumnResizeEvent) Range(org.eclipse.nebula.widgets.nattable.coordinate.Range) Test(org.junit.Test)

Example 4 with ColumnResizeEvent

use of org.eclipse.nebula.widgets.nattable.resize.event.ColumnResizeEvent in project nebula.widgets.nattable by eclipse.

the class ResizeColumnHideShowLayerTest method testShowSpecificColumnsFixedWidth.

// test showing specific columns again
@Test
public void testShowSpecificColumnsFixedWidth() {
    assertEquals(500, this.hideShowLayer.getWidth());
    assertTrue(this.bodyDataLayer.isColumnPositionResizable(1));
    assertTrue(this.bodyDataLayer.isColumnPositionResizable(4));
    this.hideShowLayer.hideColumnPositions(1, 4);
    assertEquals(2, this.listener.getReceivedEvents().size());
    assertEquals(new Range(1, 2), ((ColumnResizeEvent) this.listener.getReceivedEvents().get(0)).getColumnDiffs().iterator().next().getAfterPositionRange());
    assertEquals(new Range(4, 5), ((ColumnResizeEvent) this.listener.getReceivedEvents().get(1)).getColumnDiffs().iterator().next().getAfterPositionRange());
    assertEquals(300, this.hideShowLayer.getWidth());
    assertEquals(0, this.hideShowLayer.getColumnWidthByPosition(1));
    assertEquals(0, this.hideShowLayer.getColumnWidthByPosition(4));
    assertFalse(this.bodyDataLayer.isColumnPositionResizable(1));
    assertFalse(this.bodyDataLayer.isColumnPositionResizable(4));
    this.hideShowLayer.showColumnIndexes(1);
    assertEquals(3, this.listener.getReceivedEvents().size());
    assertEquals(new Range(1, 2), ((ColumnResizeEvent) this.listener.getReceivedEvents().get(2)).getColumnDiffs().iterator().next().getAfterPositionRange());
    assertEquals(400, this.hideShowLayer.getWidth());
    assertEquals(100, this.hideShowLayer.getColumnWidthByPosition(1));
    assertEquals(0, this.hideShowLayer.getColumnWidthByPosition(4));
    assertTrue(this.bodyDataLayer.isColumnPositionResizable(1));
    assertFalse(this.bodyDataLayer.isColumnPositionResizable(4));
}
Also used : ColumnResizeEvent(org.eclipse.nebula.widgets.nattable.resize.event.ColumnResizeEvent) Range(org.eclipse.nebula.widgets.nattable.coordinate.Range) Test(org.junit.Test)

Example 5 with ColumnResizeEvent

use of org.eclipse.nebula.widgets.nattable.resize.event.ColumnResizeEvent in project nebula.widgets.nattable by eclipse.

the class ResizeEventDiffTest method before.

@Before
public void before() {
    DataLayerFixture dataLayer = new DataLayerFixture(20, 20, 100, 40);
    this.viewportLayer = new ViewportLayer(dataLayer);
    this.viewportLayer.setClientAreaProvider(new IClientAreaProvider() {

        @Override
        public Rectangle getClientArea() {
            return new Rectangle(0, 0, 400, 400);
        }
    });
    this.viewportLayer.setOriginX(this.viewportLayer.getStartXOfColumnPosition(2));
    this.viewportLayer.setOriginY(this.viewportLayer.getStartYOfRowPosition(2));
    this.event = new ColumnResizeEvent(dataLayer, 2);
}
Also used : IClientAreaProvider(org.eclipse.nebula.widgets.nattable.util.IClientAreaProvider) DataLayerFixture(org.eclipse.nebula.widgets.nattable.test.fixture.layer.DataLayerFixture) Rectangle(org.eclipse.swt.graphics.Rectangle) ColumnResizeEvent(org.eclipse.nebula.widgets.nattable.resize.event.ColumnResizeEvent) ViewportLayer(org.eclipse.nebula.widgets.nattable.viewport.ViewportLayer) Before(org.junit.Before)

Aggregations

ColumnResizeEvent (org.eclipse.nebula.widgets.nattable.resize.event.ColumnResizeEvent)15 Test (org.junit.Test)8 Range (org.eclipse.nebula.widgets.nattable.coordinate.Range)6 Rectangle (org.eclipse.swt.graphics.Rectangle)5 TreeMap (java.util.TreeMap)2 ILayerEvent (org.eclipse.nebula.widgets.nattable.layer.event.ILayerEvent)2 LayerListenerFixture (org.eclipse.nebula.widgets.nattable.test.fixture.layer.LayerListenerFixture)2 ArrayList (java.util.ArrayList)1 Map (java.util.Map)1 DataLayerFixture (org.eclipse.nebula.widgets.nattable.test.fixture.layer.DataLayerFixture)1 IClientAreaProvider (org.eclipse.nebula.widgets.nattable.util.IClientAreaProvider)1 ViewportLayer (org.eclipse.nebula.widgets.nattable.viewport.ViewportLayer)1 Before (org.junit.Before)1