use of org.eclipse.nebula.widgets.nattable.coordinate.Range 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.coordinate.Range in project nebula.widgets.nattable by eclipse.
the class SelectionModelTest method getSelectedRowsForOverlapingSelections.
@Test
public void getSelectedRowsForOverlapingSelections() {
this.model.addSelection(new Rectangle(10, 3, 5, 2));
this.model.addSelection(new Rectangle(10, 4, 5, 10));
this.model.addSelection(new Rectangle(10, 20, 5, 10));
List<Range> selectedRows = ObjectUtils.asList(this.model.getSelectedRowPositions());
assertEquals(2, selectedRows.size());
assertTrue(selectedRows.contains(new Range(3, 14)));
assertTrue(selectedRows.contains(new Range(20, 30)));
}
use of org.eclipse.nebula.widgets.nattable.coordinate.Range in project nebula.widgets.nattable by eclipse.
the class SelectionModelTest method getSelectedRowsForLargeNumberOfSelections.
@Test
public void getSelectedRowsForLargeNumberOfSelections() {
this.model.addSelection(1, 10);
this.model.addSelection(new Rectangle(5, 1, 1, 100));
List<Range> selectedRows = ObjectUtils.asList(this.model.getSelectedRowPositions());
assertEquals(1, selectedRows.size());
assertTrue(selectedRows.contains(new Range(1, 100)));
}
use of org.eclipse.nebula.widgets.nattable.coordinate.Range in project nebula.widgets.nattable by eclipse.
the class PreserveSelectionModelTest method getSelectedRowPositions.
@Test
public void getSelectedRowPositions() {
this.testee.addSelection(1, 1);
this.testee.addSelection(0, 0);
this.testee.addSelection(2, 2);
HashSet<Range> actualSelectedRowPositions = new HashSet<Range>(this.testee.getSelectedRowPositions());
HashSet<Range> expectedSelectedRowPositions = new HashSet<Range>();
expectedSelectedRowPositions.add(new Range(0, 1));
expectedSelectedRowPositions.add(new Range(1, 2));
expectedSelectedRowPositions.add(new Range(2, 3));
assertEquals(expectedSelectedRowPositions, actualSelectedRowPositions);
}
use of org.eclipse.nebula.widgets.nattable.coordinate.Range in project nebula.widgets.nattable by eclipse.
the class RenameColumnIntegrationTest method shouldRenameColumnHeaderForReorderedColumn.
@Test
public void shouldRenameColumnHeaderForReorderedColumn() {
String originalColumnHeader = this.natTableFixture.getDataValueByPosition(2, 0).toString();
assertEquals("Column 2", originalColumnHeader);
this.natTableFixture.doCommand(new ColumnReorderCommand(this.natTableFixture, 1, 5));
originalColumnHeader = this.natTableFixture.getDataValueByPosition(2, 0).toString();
assertEquals("Column 3", originalColumnHeader);
this.natTableFixture.doCommand(new RenameColumnHeaderCommand(this.natTableFixture, 2, TEST_COLUMN_NAME));
String renamedColumnHeader = this.natTableFixture.getDataValueByPosition(2, 0).toString();
assertEquals(TEST_COLUMN_NAME, renamedColumnHeader);
assertEquals(2, this.listener.getEventsCount());
RenameColumnHeaderEvent event = (RenameColumnHeaderEvent) this.listener.getReceivedEvent(RenameColumnHeaderEvent.class);
assertEquals(new Range(2, 3), event.getColumnPositionRanges().iterator().next());
}
Aggregations