use of org.eclipse.nebula.widgets.nattable.test.fixture.layer.GridLayerFixture in project nebula.widgets.nattable by eclipse.
the class PreserveSelectionModelStructuralChangeEventHandlerTest method setup.
@Before
public void setup() {
this.listFixture = RowDataListFixture.getList(10);
this.bodyDataProvider = new ListDataProvider<RowDataFixture>(this.listFixture, new ReflectiveColumnPropertyAccessor<RowDataFixture>(RowDataListFixture.getPropertyNames()));
GridLayerFixture gridLayer = new GridLayerFixture(this.bodyDataProvider);
this.nattable = new NatTableFixture(gridLayer, false);
this.bodyDataLayer = (DataLayer) gridLayer.getBodyDataLayer();
this.selectionLayer = gridLayer.getBodyLayer().getSelectionLayer();
this.selectionLayer.setSelectionModel(new PreserveSelectionModel<RowDataFixture>(this.selectionLayer, this.bodyDataProvider, new IRowIdAccessor<RowDataFixture>() {
@Override
public Serializable getRowId(RowDataFixture rowObject) {
return rowObject.getSecurity_id();
}
}));
}
use of org.eclipse.nebula.widgets.nattable.test.fixture.layer.GridLayerFixture in project nebula.widgets.nattable by eclipse.
the class SelectionModelStructuralChangeEventHandlerTest method shouldClearSelectionOnDataUpdates.
@Test
public void shouldClearSelectionOnDataUpdates() throws Exception {
List<RowDataFixture> listFixture = RowDataListFixture.getList(10);
IRowDataProvider<RowDataFixture> bodyDataProvider = new ListDataProvider<RowDataFixture>(listFixture, new ReflectiveColumnPropertyAccessor<RowDataFixture>(RowDataListFixture.getPropertyNames()));
GridLayerFixture gridLayer = new GridLayerFixture(bodyDataProvider);
NatTable nattable = new NatTableFixture(gridLayer, false);
DataLayer bodyDataLayer = (DataLayer) gridLayer.getBodyDataLayer();
SelectionLayer selectionLayer = gridLayer.getBodyLayer().getSelectionLayer();
// test SelectionModel updates
assertEquals(0, selectionLayer.getFullySelectedRowPositions().length);
nattable.doCommand(new SelectRowsCommand(nattable, 1, 1, false, false));
assertEquals(1, selectionLayer.getFullySelectedRowPositions().length);
// Ford motor at top and selected
assertEquals("B Ford Motor", nattable.getDataValueByPosition(2, 1).toString());
Range selection = selectionLayer.getSelectedRowPositions().iterator().next();
assertEquals("B Ford Motor", listFixture.get(selection.start).getSecurity_description());
listFixture.add(0, RowDataFixture.getInstance("Tata motors", "A"));
// fire event to trigger structural refresh
bodyDataLayer.fireLayerEvent(new StructuralRefreshEvent(bodyDataLayer));
assertEquals(0, selectionLayer.getFullySelectedRowPositions().length);
}
use of org.eclipse.nebula.widgets.nattable.test.fixture.layer.GridLayerFixture in project nebula.widgets.nattable by eclipse.
the class RowHeaderSelectionTest method setUp.
@Before
public void setUp() {
this.gridLayer = new GridLayerFixture();
this.gridLayer.doCommand(new InitializeClientAreaCommandFixture());
}
Aggregations