Search in sources :

Example 1 with SelectColumnCommand

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

Example 2 with SelectColumnCommand

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

Example 3 with SelectColumnCommand

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

Example 4 with SelectColumnCommand

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

Example 5 with SelectColumnCommand

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));
}
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