Search in sources :

Example 1 with SelectCellCommand

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

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

Example 3 with SelectCellCommand

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

Example 4 with SelectCellCommand

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);
}
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 5 with SelectCellCommand

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

Aggregations

SelectCellCommand (org.eclipse.nebula.widgets.nattable.selection.command.SelectCellCommand)54 Test (org.junit.Test)50 PositionCoordinate (org.eclipse.nebula.widgets.nattable.coordinate.PositionCoordinate)15 ILayerCell (org.eclipse.nebula.widgets.nattable.layer.cell.ILayerCell)14 SpanningDataLayer (org.eclipse.nebula.widgets.nattable.layer.SpanningDataLayer)4 SelectColumnCommand (org.eclipse.nebula.widgets.nattable.selection.command.SelectColumnCommand)4 MultiColumnHideCommand (org.eclipse.nebula.widgets.nattable.hideshow.command.MultiColumnHideCommand)3 EditCellCommand (org.eclipse.nebula.widgets.nattable.edit.command.EditCellCommand)2 DefaultEditBindings (org.eclipse.nebula.widgets.nattable.edit.config.DefaultEditBindings)2 DefaultEditConfiguration (org.eclipse.nebula.widgets.nattable.edit.config.DefaultEditConfiguration)2 DummySpanningBodyDataProvider (org.eclipse.nebula.widgets.nattable.grid.data.DummySpanningBodyDataProvider)2 ColumnHideCommand (org.eclipse.nebula.widgets.nattable.hideshow.command.ColumnHideCommand)2 ShowAllColumnsCommand (org.eclipse.nebula.widgets.nattable.hideshow.command.ShowAllColumnsCommand)2 CompositeLayer (org.eclipse.nebula.widgets.nattable.layer.CompositeLayer)2 DataLayer (org.eclipse.nebula.widgets.nattable.layer.DataLayer)2 ILayerListener (org.eclipse.nebula.widgets.nattable.layer.ILayerListener)2 RowDeleteEvent (org.eclipse.nebula.widgets.nattable.layer.event.RowDeleteEvent)2 ColumnReorderCommand (org.eclipse.nebula.widgets.nattable.reorder.command.ColumnReorderCommand)2 SelectionLayer (org.eclipse.nebula.widgets.nattable.selection.SelectionLayer)2 NatTableFixture (org.eclipse.nebula.widgets.nattable.test.fixture.NatTableFixture)2