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