use of org.eclipse.nebula.widgets.nattable.layer.DataLayer in project nebula.widgets.nattable by eclipse.
the class SelectionUtilsTest method testGetSingleItemOnCellSelection.
@Test
public void testGetSingleItemOnCellSelection() {
List<RowDataFixture> listFixture = RowDataListFixture.getList(10);
IRowDataProvider<RowDataFixture> bodyDataProvider = new ListDataProvider<RowDataFixture>(listFixture, new ReflectiveColumnPropertyAccessor<RowDataFixture>(RowDataListFixture.getPropertyNames()));
DataLayer dataLayer = new DataLayer(bodyDataProvider);
SelectionLayer selectionLayer = new SelectionLayer(dataLayer);
selectionLayer.selectCell(1, 3, false, false);
List<RowDataFixture> selected = SelectionUtils.getSelectedRowObjects(selectionLayer, bodyDataProvider, false);
assertNotNull(selected);
assertEquals(1, selected.size());
assertEquals(listFixture.get(3), selected.get(0));
}
use of org.eclipse.nebula.widgets.nattable.layer.DataLayer in project nebula.widgets.nattable by eclipse.
the class SelectionUtilsTest method testGetBottomRightSelectDifferentColumns.
@Test
public void testGetBottomRightSelectDifferentColumns() {
DataLayer dataLayer = new DataLayer(new DataProviderFixture(10, 10));
SelectionLayer selectionLayer = new SelectionLayer(dataLayer);
// select cells for same columns in non consecutive rows
selectionLayer.selectRegion(2, 2, 1, 3);
selectionLayer.selectRegion(4, 4, 1, 3);
assertEquals(6, selectionLayer.getSelectedCells().size());
ILayerCell bottomRight = SelectionUtils.getBottomRightCellInSelection(selectionLayer);
assertNull(bottomRight);
}
use of org.eclipse.nebula.widgets.nattable.layer.DataLayer in project nebula.widgets.nattable by eclipse.
the class SelectionUtilsTest method testGetEmptyListOnNoSelection.
@Test
public void testGetEmptyListOnNoSelection() {
List<RowDataFixture> listFixture = RowDataListFixture.getList(10);
IRowDataProvider<RowDataFixture> bodyDataProvider = new ListDataProvider<RowDataFixture>(listFixture, new ReflectiveColumnPropertyAccessor<RowDataFixture>(RowDataListFixture.getPropertyNames()));
DataLayer dataLayer = new DataLayer(bodyDataProvider);
SelectionLayer selectionLayer = new SelectionLayer(dataLayer);
List<RowDataFixture> selected = SelectionUtils.getSelectedRowObjects(selectionLayer, bodyDataProvider, false);
assertNotNull(selected);
assertEquals(0, selected.size());
}
use of org.eclipse.nebula.widgets.nattable.layer.DataLayer in project nebula.widgets.nattable by eclipse.
the class SelectionUtilsTest method testGetBottomRightSelectRegion.
@Test
public void testGetBottomRightSelectRegion() {
DataLayer dataLayer = new DataLayer(new DataProviderFixture(10, 10));
SelectionLayer selectionLayer = new SelectionLayer(dataLayer);
// select region
selectionLayer.selectRegion(2, 2, 3, 3);
ILayerCell bottomRight = SelectionUtils.getBottomRightCellInSelection(selectionLayer);
assertEquals(4, bottomRight.getColumnPosition());
assertEquals(4, bottomRight.getRowPosition());
}
use of org.eclipse.nebula.widgets.nattable.layer.DataLayer in project nebula.widgets.nattable by eclipse.
the class SelectionUtilsTest method testGetSingleItemsOnFullRowSelection.
@Test
public void testGetSingleItemsOnFullRowSelection() {
List<RowDataFixture> listFixture = RowDataListFixture.getList(10);
IRowDataProvider<RowDataFixture> bodyDataProvider = new ListDataProvider<RowDataFixture>(listFixture, new ReflectiveColumnPropertyAccessor<RowDataFixture>(RowDataListFixture.getPropertyNames()));
DataLayer dataLayer = new DataLayer(bodyDataProvider);
SelectionLayer selectionLayer = new SelectionLayer(dataLayer);
selectionLayer.selectRow(0, 3, false, false);
List<RowDataFixture> selected = SelectionUtils.getSelectedRowObjects(selectionLayer, bodyDataProvider, true);
assertNotNull(selected);
assertEquals(1, selected.size());
assertEquals(listFixture.get(3), selected.get(0));
}
Aggregations