use of org.eclipse.nebula.widgets.nattable.selection.command.SelectColumnCommand in project nebula.widgets.nattable by eclipse.
the class RowSelectionIntegrationTest method testColumnSelectionProcessing.
@SuppressWarnings("rawtypes")
@Test
public void testColumnSelectionProcessing() {
final List selectedObjects = new ArrayList();
// add a listener to see how many rows are selected
this.selectionProvider.addSelectionChangedListener(new ISelectionChangedListener() {
@SuppressWarnings("unchecked")
@Override
public void selectionChanged(SelectionChangedEvent event) {
IStructuredSelection selection = (IStructuredSelection) event.getSelection();
selectedObjects.addAll(selection.toList());
}
});
// first execute column selection with default configuration to see that
// all rows get selected
this.selectionLayer.doCommand(new SelectColumnCommand(this.selectionLayer, 1, 0, false, false));
assertEquals(10, selectedObjects.size());
// now clear set the flag for column selection processing to false and
// fire the event again
selectedObjects.clear();
this.selectionProvider.setProcessColumnSelection(false);
this.selectionLayer.doCommand(new SelectColumnCommand(this.selectionLayer, 1, 0, false, false));
assertEquals(0, selectedObjects.size());
// now select a cell to verify that other selections are still processed
this.selectionLayer.doCommand(new SelectRowsCommand(this.selectionLayer, 1, 1, false, false));
assertEquals(1, selectedObjects.size());
}
use of org.eclipse.nebula.widgets.nattable.selection.command.SelectColumnCommand 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.selection.command.SelectColumnCommand in project nebula.widgets.nattable by eclipse.
the class ColumnGroupsCommandHandlerTest method shouldUngroupMiddleSelectedColumns.
@Test
public void shouldUngroupMiddleSelectedColumns() {
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);
Assert.assertEquals(3, getColumnIndexesInGroup(0).size());
Assert.assertEquals(0, getColumnIndexesInGroup(0).get(0).intValue());
Assert.assertEquals(1, getColumnIndexesInGroup(0).get(1).intValue());
Assert.assertEquals(2, getColumnIndexesInGroup(0).get(2).intValue());
// Test ungrouping column in middle
this.selectionLayer.doCommand(new SelectColumnCommand(this.selectionLayer, 1, 0, false, false));
this.handler.handleUngroupCommand();
Assert.assertEquals(2, getColumnIndexesInGroup(0).size());
Assert.assertEquals(0, getColumnIndexesInGroup(0).get(0).intValue());
Assert.assertEquals(2, getColumnIndexesInGroup(0).get(1).intValue());
Assert.assertEquals(0, this.selectionLayer.getColumnPositionByIndex(0));
Assert.assertEquals(2, this.selectionLayer.getColumnPositionByIndex(2));
Assert.assertEquals(1, this.selectionLayer.getColumnPositionByIndex(1));
}
use of org.eclipse.nebula.widgets.nattable.selection.command.SelectColumnCommand in project nebula.widgets.nattable by eclipse.
the class ColumnGroupsCommandHandlerTest method shouldCreateColumnGroupAfterReordering.
@Test
public void shouldCreateColumnGroupAfterReordering() {
// Reorder column to first position
this.selectionLayer.doCommand(new ColumnReorderCommand(this.selectionLayer, 9, 0));
// Select first column position
this.selectionLayer.doCommand(new SelectColumnCommand(this.selectionLayer, 0, 0, false, false));
final String columnGroupName = "Test Group";
this.handler.loadSelectedColumnsIndexesWithPositions();
this.handler.handleGroupColumnsCommand(columnGroupName);
Assert.assertEquals(columnGroupName, getColumnGroupNameForIndex(9));
Assert.assertEquals(9, getColumnIndexesInGroup(9).get(0).intValue());
}
use of org.eclipse.nebula.widgets.nattable.selection.command.SelectColumnCommand in project nebula.widgets.nattable by eclipse.
the class ColumnGroupsCommandHandlerTest method shouldUngroupFirstSelectedColumn.
@Test
public void shouldUngroupFirstSelectedColumn() {
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, false));
this.handler.handleUngroupCommand();
Assert.assertEquals(2, getColumnIndexesInGroup(2).size());
Assert.assertEquals(1, getColumnIndexesInGroup(2).get(0).intValue());
Assert.assertEquals(2, getColumnIndexesInGroup(2).get(1).intValue());
Assert.assertEquals(0, this.selectionLayer.getColumnPositionByIndex(0));
Assert.assertEquals(2, this.selectionLayer.getColumnPositionByIndex(2));
Assert.assertEquals(1, this.selectionLayer.getColumnPositionByIndex(1));
}
Aggregations