use of org.eclipse.nebula.widgets.nattable.selection.command.SelectCellCommand in project nebula.widgets.nattable by eclipse.
the class CopyDataCommandHandlerTest method shouldReturnGridWithSelectedCellsNoHeaders.
@Test
public void shouldReturnGridWithSelectedCellsNoHeaders() {
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));
this.commandHandler = new CopyDataCommandHandler(this.selectionLayer);
ILayerCell[][] copiedGrid = this.commandHandler.assembleCopiedDataStructure();
// Assert structure of assembled copy grid with headers
assertEquals(10, copiedGrid.length);
assertEquals(7, copiedGrid[0].length);
assertNotNull(copiedGrid[0][5]);
}
use of org.eclipse.nebula.widgets.nattable.selection.command.SelectCellCommand in project nebula.widgets.nattable by eclipse.
the class CopyDataCommandHandlerTest method shouldReturnArrayOfCellsForColumnsInSelectionModel.
@Test
public void shouldReturnArrayOfCellsForColumnsInSelectionModel() {
this.selectionLayer.doCommand(new SelectCellCommand(this.selectionLayer, 2, 3, false, true));
this.selectionLayer.doCommand(new SelectCellCommand(this.selectionLayer, 4, 1, false, true));
this.selectionLayer.doCommand(new SelectCellCommand(this.selectionLayer, 9, 9, false, true));
this.selectionLayer.doCommand(new SelectCellCommand(this.selectionLayer, 1, 0, false, true));
ILayerCell[][] columns = this.commandHandler.assembleColumnHeaders();
assertEquals(5, columns.length);
assertEquals("Column 2", columns[0][1].getDataValue());
assertEquals("Column 3", columns[0][2].getDataValue());
assertEquals("Column 5", columns[0][3].getDataValue());
assertEquals("Column 10", columns[0][4].getDataValue());
}
use of org.eclipse.nebula.widgets.nattable.selection.command.SelectCellCommand in project nebula.widgets.nattable by eclipse.
the class CopyDataCommandHandlerTest method shouldCopySingleCell.
@Test
public void shouldCopySingleCell() {
this.selectionLayer.doCommand(new SelectCellCommand(this.selectionLayer, 3, 7, false, false));
CopyDataCommandHandler commandHandler = new CopyDataCommandHandler(this.selectionLayer);
commandHandler.assembleCopiedDataStructure();
ILayerCell[][] copiedGrid = commandHandler.assembleCopiedDataStructure();
assertNotNull(copiedGrid[0][0]);
}
use of org.eclipse.nebula.widgets.nattable.selection.command.SelectCellCommand in project nebula.widgets.nattable by eclipse.
the class CopyDataCommandHandlerTest method shouldReturnGridWithSelectedCellsAndHeaders.
/**
* Returns a collection representing a 11 x 11 grid. Only selected cells
* will have data, those are (col,row): (2,3),(4,1),(1,0),(9,9)
*
* TODO: Test is ignored since it passes locally and fails on the build.
* Can't figure out why.
*/
@Ignore
@Test
public void shouldReturnGridWithSelectedCellsAndHeaders() {
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[][] copiedGrid = this.commandHandler.assembleCopiedDataStructure();
// Assert structure of assembled copy grid with headers
assertEquals(11, copiedGrid.length);
assertEquals(8, copiedGrid[0].length);
checkColumnHeaderCells(copiedGrid[0]);
checkBodyCells(copiedGrid);
}
use of org.eclipse.nebula.widgets.nattable.selection.command.SelectCellCommand in project nebula.widgets.nattable by eclipse.
the class HierarchicalTreeLayerTest method testGetDisplayModeByPositionWithSelectionLayer.
@Test
public void testGetDisplayModeByPositionWithSelectionLayer() {
this.treeLayer = new HierarchicalTreeLayer(this.selectionLayer, this.data, CarService.PROPERTY_NAMES_COMPACT, this.selectionLayer);
// first test that all cells in a row are NORMAL
for (int i = 0; i < this.treeLayer.getColumnCount(); i++) {
assertEquals(DisplayMode.NORMAL, this.treeLayer.getDisplayModeByPosition(i, 0));
}
// select a cell in first level
this.treeLayer.doCommand(new SelectCellCommand(this.treeLayer, 1, 0, false, false));
// test that the level header column of the first level and the first
// content cell are selected
assertEquals(DisplayMode.SELECT, this.treeLayer.getDisplayModeByPosition(0, 0));
assertEquals(DisplayMode.SELECT, this.treeLayer.getDisplayModeByPosition(1, 0));
// then check that all other cells are NORMAL
for (int i = 2; i < this.treeLayer.getColumnCount(); i++) {
assertEquals(DisplayMode.NORMAL, this.treeLayer.getDisplayModeByPosition(i, 0));
}
// select a cell in second level
this.treeLayer.doCommand(new SelectCellCommand(this.treeLayer, 5, 0, false, false));
// test that only the second level header is SELECT
assertEquals(DisplayMode.NORMAL, this.treeLayer.getDisplayModeByPosition(0, 0));
assertEquals(DisplayMode.SELECT, this.treeLayer.getDisplayModeByPosition(3, 0));
assertEquals(DisplayMode.NORMAL, this.treeLayer.getDisplayModeByPosition(6, 0));
// test the state of the other columns
assertEquals(DisplayMode.NORMAL, this.treeLayer.getDisplayModeByPosition(1, 0));
assertEquals(DisplayMode.NORMAL, this.treeLayer.getDisplayModeByPosition(2, 0));
assertEquals(DisplayMode.NORMAL, this.treeLayer.getDisplayModeByPosition(4, 0));
assertEquals(DisplayMode.SELECT, this.treeLayer.getDisplayModeByPosition(5, 0));
assertEquals(DisplayMode.NORMAL, this.treeLayer.getDisplayModeByPosition(7, 0));
assertEquals(DisplayMode.NORMAL, this.treeLayer.getDisplayModeByPosition(8, 0));
// select a cell in third level
this.treeLayer.doCommand(new SelectCellCommand(this.treeLayer, 7, 0, false, false));
// test that only the third level header is SELECT
assertEquals(DisplayMode.NORMAL, this.treeLayer.getDisplayModeByPosition(0, 0));
assertEquals(DisplayMode.NORMAL, this.treeLayer.getDisplayModeByPosition(3, 0));
assertEquals(DisplayMode.SELECT, this.treeLayer.getDisplayModeByPosition(6, 0));
// test the state of the other columns
assertEquals(DisplayMode.NORMAL, this.treeLayer.getDisplayModeByPosition(1, 0));
assertEquals(DisplayMode.NORMAL, this.treeLayer.getDisplayModeByPosition(2, 0));
assertEquals(DisplayMode.NORMAL, this.treeLayer.getDisplayModeByPosition(4, 0));
assertEquals(DisplayMode.NORMAL, this.treeLayer.getDisplayModeByPosition(5, 0));
assertEquals(DisplayMode.SELECT, this.treeLayer.getDisplayModeByPosition(7, 0));
assertEquals(DisplayMode.NORMAL, this.treeLayer.getDisplayModeByPosition(8, 0));
// clear selection and test that no SELECT is there anymore
this.selectionLayer.clear();
for (int i = 0; i < this.treeLayer.getColumnCount(); i++) {
assertEquals(DisplayMode.NORMAL, this.treeLayer.getDisplayModeByPosition(i, 0));
}
}
Aggregations