use of org.eclipse.nebula.widgets.nattable.selection.command.SelectColumnCommand 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.SelectColumnCommand 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.SelectColumnCommand in project nebula.widgets.nattable by eclipse.
the class ColumnGroupsCommandHandlerTest method shouldRemoveAllColumnsInGroup.
@Test
public void shouldRemoveAllColumnsInGroup() {
this.selectionLayer.doCommand(new SelectColumnCommand(this.selectionLayer, 0, 0, false, true));
this.selectionLayer.doCommand(new SelectColumnCommand(this.selectionLayer, 1, 0, false, true));
this.selectionLayer.doCommand(new SelectColumnCommand(this.selectionLayer, 2, 0, false, true));
final String columnGroupName = "Test Group 3";
this.handler.loadSelectedColumnsIndexesWithPositions();
this.handler.handleGroupColumnsCommand(columnGroupName);
// Test ungrouping first column
this.selectionLayer.doCommand(new SelectColumnCommand(this.selectionLayer, 0, 0, false, true));
this.selectionLayer.doCommand(new SelectColumnCommand(this.selectionLayer, 1, 0, false, true));
this.selectionLayer.doCommand(new SelectColumnCommand(this.selectionLayer, 2, 0, false, true));
this.handler.handleUngroupCommand();
Assert.assertFalse(this.model.isPartOfAGroup(0));
Assert.assertFalse(this.model.isPartOfAGroup(1));
Assert.assertFalse(this.model.isPartOfAGroup(2));
Assert.assertEquals(0, this.selectionLayer.getColumnPositionByIndex(0));
Assert.assertEquals(1, this.selectionLayer.getColumnPositionByIndex(1));
Assert.assertEquals(2, this.selectionLayer.getColumnPositionByIndex(2));
}
use of org.eclipse.nebula.widgets.nattable.selection.command.SelectColumnCommand in project nebula.widgets.nattable by eclipse.
the class ColumnGroupsCommandHandlerTest method shouldCreateColumnGroupFromSelectedColumns.
@Test
public void shouldCreateColumnGroupFromSelectedColumns() {
this.selectionLayer.doCommand(new SelectColumnCommand(this.selectionLayer, 0, 0, false, false));
Assert.assertTrue(this.selectionLayer.isColumnPositionFullySelected(0));
Assert.assertTrue(this.model.isEmpty());
final String columnGroupName = "Test Group";
this.handler.loadSelectedColumnsIndexesWithPositions();
this.handler.handleGroupColumnsCommand(columnGroupName);
Assert.assertEquals(columnGroupName, getColumnGroupNameForIndex(0));
Assert.assertEquals(1, getColumnIndexesInGroup(0).size());
}
use of org.eclipse.nebula.widgets.nattable.selection.command.SelectColumnCommand in project nebula.widgets.nattable by eclipse.
the class ColumnGroupsCommandHandlerTest method shouldNotUngroupColumnsInUnbreakableGroups.
@Test
public void shouldNotUngroupColumnsInUnbreakableGroups() throws Exception {
this.model.addColumnsIndexesToGroup("Test group 1", 0, 1, 2);
this.model.getColumnGroupByIndex(0).setUnbreakable(true);
// Ungroup column in the middle
this.selectionLayer.doCommand(new SelectColumnCommand(this.selectionLayer, 1, 0, false, false));
this.handler.handleUngroupCommand();
Assert.assertEquals(3, getColumnIndexesInGroup(0).size());
Assert.assertTrue(getColumnIndexesInGroup(0).contains(0));
Assert.assertTrue(getColumnIndexesInGroup(0).contains(1));
Assert.assertTrue(getColumnIndexesInGroup(0).contains(2));
// Ungroup first column
this.selectionLayer.doCommand(new SelectColumnCommand(this.selectionLayer, 0, 0, false, false));
this.handler.handleUngroupCommand();
Assert.assertEquals(3, getColumnIndexesInGroup(0).size());
Assert.assertTrue(getColumnIndexesInGroup(0).contains(0));
Assert.assertTrue(getColumnIndexesInGroup(0).contains(1));
Assert.assertTrue(getColumnIndexesInGroup(0).contains(2));
// Assert the columns haven't moved
Assert.assertEquals(0, this.selectionLayer.getColumnPositionByIndex(0));
Assert.assertEquals(1, this.selectionLayer.getColumnPositionByIndex(1));
Assert.assertEquals(2, this.selectionLayer.getColumnPositionByIndex(2));
}
Aggregations