Search in sources :

Example 11 with SelectColumnCommand

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());
}
Also used : SelectColumnCommand(org.eclipse.nebula.widgets.nattable.selection.command.SelectColumnCommand) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) EventList(ca.odell.glazedlists.EventList) List(java.util.List) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) SelectRowsCommand(org.eclipse.nebula.widgets.nattable.selection.command.SelectRowsCommand) Test(org.junit.Test)

Example 12 with SelectColumnCommand

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());
}
Also used : SelectColumnCommand(org.eclipse.nebula.widgets.nattable.selection.command.SelectColumnCommand) SelectCellCommand(org.eclipse.nebula.widgets.nattable.selection.command.SelectCellCommand) ILayerCell(org.eclipse.nebula.widgets.nattable.layer.cell.ILayerCell) Test(org.junit.Test)

Example 13 with SelectColumnCommand

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));
}
Also used : SelectColumnCommand(org.eclipse.nebula.widgets.nattable.selection.command.SelectColumnCommand) Test(org.junit.Test)

Example 14 with SelectColumnCommand

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());
}
Also used : SelectColumnCommand(org.eclipse.nebula.widgets.nattable.selection.command.SelectColumnCommand) ColumnReorderCommand(org.eclipse.nebula.widgets.nattable.reorder.command.ColumnReorderCommand) Test(org.junit.Test)

Example 15 with SelectColumnCommand

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));
}
Also used : SelectColumnCommand(org.eclipse.nebula.widgets.nattable.selection.command.SelectColumnCommand) Test(org.junit.Test)

Aggregations

SelectColumnCommand (org.eclipse.nebula.widgets.nattable.selection.command.SelectColumnCommand)21 Test (org.junit.Test)21 SelectCellCommand (org.eclipse.nebula.widgets.nattable.selection.command.SelectCellCommand)4 GridLayer (org.eclipse.nebula.widgets.nattable.grid.layer.GridLayer)3 AbstractDpiConverter (org.eclipse.nebula.widgets.nattable.layer.AbstractDpiConverter)3 IDpiConverter (org.eclipse.nebula.widgets.nattable.layer.IDpiConverter)3 ConfigureScalingCommand (org.eclipse.nebula.widgets.nattable.layer.command.ConfigureScalingCommand)3 DummyGridLayerStack (org.eclipse.nebula.widgets.nattable.layer.stack.DummyGridLayerStack)3 SelectRowsCommand (org.eclipse.nebula.widgets.nattable.selection.command.SelectRowsCommand)2 EventList (ca.odell.glazedlists.EventList)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)1 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)1 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)1 PositionCoordinate (org.eclipse.nebula.widgets.nattable.coordinate.PositionCoordinate)1 DefaultGridLayer (org.eclipse.nebula.widgets.nattable.grid.layer.DefaultGridLayer)1 ColumnHeaderSelectionEvent (org.eclipse.nebula.widgets.nattable.grid.layer.event.ColumnHeaderSelectionEvent)1 ILayerCell (org.eclipse.nebula.widgets.nattable.layer.cell.ILayerCell)1 DefaultBodyLayerStack (org.eclipse.nebula.widgets.nattable.layer.stack.DefaultBodyLayerStack)1