use of org.eclipse.nebula.widgets.nattable.layer.cell.ILayerCell in project nebula.widgets.nattable by eclipse.
the class EditUtilsTest method testGetLastSelectedCellWithSingleSelection.
@Test
public void testGetLastSelectedCellWithSingleSelection() {
this.selectionLayer.selectCell(1, 1, false, false);
ILayerCell cell = EditUtils.getLastSelectedCell(this.selectionLayer);
assertNotNull(cell);
assertEquals(1, cell.getColumnIndex());
assertEquals(1, cell.getRowIndex());
}
use of org.eclipse.nebula.widgets.nattable.layer.cell.ILayerCell in project nebula.widgets.nattable by eclipse.
the class RowSelectionEditUtilsTest method testGetLastSelectedCellWithMultiSelection.
@Test
public void testGetLastSelectedCellWithMultiSelection() {
this.selectionLayer.selectCell(1, 1, false, true);
this.selectionLayer.selectCell(2, 2, false, true);
this.selectionLayer.selectCell(3, 3, false, true);
ILayerCell cell = EditUtils.getLastSelectedCell(this.selectionLayer);
assertNotNull(cell);
assertEquals(3, cell.getColumnIndex());
assertEquals(3, cell.getRowIndex());
}
use of org.eclipse.nebula.widgets.nattable.layer.cell.ILayerCell in project nebula.widgets.nattable by eclipse.
the class CopyDataCommandHandlerTest method shouldReturnOnlySelectedBodyCells.
@Test
public void shouldReturnOnlySelectedBodyCells() {
this.selectionLayer.doCommand(new SelectCellCommand(this.selectionLayer, 1, 2, false, true));
this.selectionLayer.doCommand(new SelectCellCommand(this.selectionLayer, 3, 7, false, true));
this.selectionLayer.doCommand(new SelectCellCommand(this.selectionLayer, 4, 8, false, true));
this.selectionLayer.doCommand(new SelectCellCommand(this.selectionLayer, 7, 9, false, true));
this.selectionLayer.doCommand(new SelectColumnCommand(this.selectionLayer, 8, 0, false, true));
this.selectionLayer.doCommand(new SelectCellCommand(this.selectionLayer, 9, 9, false, true));
this.selectionLayer.doCommand(new SelectColumnCommand(this.selectionLayer, 5, 0, false, true));
ILayerCell[] bodyCells = this.commandHandler.assembleBody(0);
assertEquals(8, bodyCells.length);
assertEquals("[5,0]", bodyCells[4].getDataValue());
assertEquals("[8,0]", bodyCells[6].getDataValue());
bodyCells = this.commandHandler.assembleBody(9);
assertEquals("[9,9]", bodyCells[7].getDataValue());
}
use of org.eclipse.nebula.widgets.nattable.layer.cell.ILayerCell in project nebula.widgets.nattable by eclipse.
the class CopyDataCommandHandlerTest method checkBodyCells.
private void checkBodyCells(ILayerCell[][] copiedGrid) {
int cellWithDataCounter = 0;
int[] selectedColumns = this.selectionLayer.getSelectedColumnPositions();
Set<Range> selectedRowRanges = this.selectionLayer.getSelectedRowPositions();
Set<Integer> selectedRows = new HashSet<Integer>();
for (Range range : selectedRowRanges) {
selectedRows.addAll(range.getMembers());
}
Iterator<Integer> rowsIterator = selectedRows.iterator();
// Row zero is for column headers
for (int rowPosition = 1; rowPosition < copiedGrid.length; rowPosition++) {
ILayerCell[] cells = copiedGrid[rowPosition];
assertEquals(this.rowHeaderLayer.getDataValueByPosition(0, rowPosition - 1), cells[0].getDataValue());
// Check body data
int selectedRowPosition = rowsIterator.next().intValue();
for (int columnPosition = 1; columnPosition < cells.length; columnPosition++) {
final ILayerCell cell = cells[columnPosition];
if (cell != null) {
cellWithDataCounter++;
assertEquals(this.selectionLayer.getDataValueByPosition(selectedColumns[columnPosition - 1], selectedRowPosition), cell.getDataValue());
}
}
}
assertEquals(this.selectionLayer.getSelectedCellPositions().length, cellWithDataCounter);
}
use of org.eclipse.nebula.widgets.nattable.layer.cell.ILayerCell in project nebula.widgets.nattable by eclipse.
the class HierarchicalTreeLayerTest method testGetCellByPosition.
@Test
public void testGetCellByPosition() {
// test first level header
ILayerCell cell = this.treeLayer.getCellByPosition(0, 0);
assertEquals(0, cell.getOriginRowPosition());
assertEquals(5, cell.getRowSpan());
assertEquals(0, cell.getOriginColumnPosition());
cell = this.treeLayer.getCellByPosition(0, 1);
assertEquals(0, cell.getOriginRowPosition());
assertEquals(5, cell.getRowSpan());
assertEquals(0, cell.getOriginColumnPosition());
cell = this.treeLayer.getCellByPosition(0, 2);
assertEquals(0, cell.getOriginRowPosition());
assertEquals(5, cell.getRowSpan());
assertEquals(0, cell.getOriginColumnPosition());
// test first level column
cell = this.treeLayer.getCellByPosition(1, 0);
assertEquals(0, cell.getOriginRowPosition());
assertEquals(5, cell.getRowSpan());
assertEquals(1, cell.getOriginColumnPosition());
cell = this.treeLayer.getCellByPosition(1, 1);
assertEquals(0, cell.getOriginRowPosition());
assertEquals(5, cell.getRowSpan());
assertEquals(1, cell.getOriginColumnPosition());
cell = this.treeLayer.getCellByPosition(1, 2);
assertEquals(0, cell.getOriginRowPosition());
assertEquals(5, cell.getRowSpan());
assertEquals(1, cell.getOriginColumnPosition());
// test second level header
cell = this.treeLayer.getCellByPosition(3, 0);
assertEquals(0, cell.getOriginRowPosition());
assertEquals(2, cell.getRowSpan());
assertEquals(3, cell.getOriginColumnPosition());
cell = this.treeLayer.getCellByPosition(3, 1);
assertEquals(0, cell.getOriginRowPosition());
assertEquals(2, cell.getRowSpan());
assertEquals(3, cell.getOriginColumnPosition());
cell = this.treeLayer.getCellByPosition(4, 0);
assertEquals(0, cell.getOriginRowPosition());
assertEquals(2, cell.getRowSpan());
assertEquals(4, cell.getOriginColumnPosition());
cell = this.treeLayer.getCellByPosition(4, 1);
assertEquals(0, cell.getOriginRowPosition());
assertEquals(2, cell.getRowSpan());
assertEquals(4, cell.getOriginColumnPosition());
// test for third level header
cell = this.treeLayer.getCellByPosition(7, 0);
assertEquals(0, cell.getOriginRowPosition());
assertEquals(1, cell.getRowSpan());
assertEquals(7, cell.getOriginColumnPosition());
cell = this.treeLayer.getCellByPosition(8, 0);
assertEquals(0, cell.getOriginRowPosition());
assertEquals(1, cell.getRowSpan());
assertEquals(8, cell.getOriginColumnPosition());
}
Aggregations