Search in sources :

Example 31 with SelectCellCommand

use of org.eclipse.nebula.widgets.nattable.selection.command.SelectCellCommand in project nebula.widgets.nattable by eclipse.

the class FreezeHandlerTest method shouldRestructureFrozenArea.

@Test
public void shouldRestructureFrozenArea() {
    final ReorderListener reorderListener = new ReorderListener();
    this.viewportLayer.addLayerListener(reorderListener);
    // Scroll the viewport to the first column
    this.viewportLayer.resetOrigin(this.viewportLayer.getStartXOfColumnPosition(0), this.viewportLayer.getStartYOfRowPosition(0));
    this.viewportLayer.setOriginX(this.viewportLayer.getStartXOfColumnPosition(1));
    assertEquals(1, this.viewportLayer.getColumnIndexByPosition(0));
    this.selectionLayer.doCommand(new SelectCellCommand(this.selectionLayer, 3, 3, false, false));
    this.compositeFreezeLayer.doCommand(new FreezeSelectionCommand());
    // Move right edge out of frozen area
    assertEquals(2, this.freezeLayer.getColumnCount());
    this.compositeFreezeLayer.doCommand(new ColumnReorderCommand(this.compositeFreezeLayer, 1, 3));
    assertEquals(1, this.freezeLayer.getColumnCount());
}
Also used : SelectCellCommand(org.eclipse.nebula.widgets.nattable.selection.command.SelectCellCommand) ColumnReorderCommand(org.eclipse.nebula.widgets.nattable.reorder.command.ColumnReorderCommand) Test(org.junit.Test)

Example 32 with SelectCellCommand

use of org.eclipse.nebula.widgets.nattable.selection.command.SelectCellCommand 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 33 with SelectCellCommand

use of org.eclipse.nebula.widgets.nattable.selection.command.SelectCellCommand in project nebula.widgets.nattable by eclipse.

the class GridSearchStrategyTest method searchShouldWrapAroundRow.

@Test
public void searchShouldWrapAroundRow() {
    // Select search starting point in composite coordinates
    this.gridLayer.doCommand(new SelectCellCommand(this.gridLayer, 3, 4, false, false));
    GridSearchStrategy gridStrategy = new GridSearchStrategy(this.configRegistry, false, true);
    gridStrategy.setComparator(new CellValueAsStringComparator<>());
    // If we don't specify to wrap the search, it will not find it.
    gridStrategy.setContextLayer(this.selectionLayer);
    PositionCoordinate searchResult = gridStrategy.executeSearch("[1,3]");
    assertNull(searchResult);
    // Should find it when wrap search is enabled.
    gridStrategy.setWrapSearch(true);
    searchResult = gridStrategy.executeSearch("[1,3]");
    assertNotNull(searchResult);
    assertEquals(1, searchResult.columnPosition);
    assertEquals(3, searchResult.rowPosition);
}
Also used : SelectCellCommand(org.eclipse.nebula.widgets.nattable.selection.command.SelectCellCommand) PositionCoordinate(org.eclipse.nebula.widgets.nattable.coordinate.PositionCoordinate) Test(org.junit.Test)

Example 34 with SelectCellCommand

use of org.eclipse.nebula.widgets.nattable.selection.command.SelectCellCommand in project nebula.widgets.nattable by eclipse.

the class GridSearchStrategyTest method searchShouldWrapAroundColumn.

@Test
public void searchShouldWrapAroundColumn() {
    // Select search starting point in composite coordinates
    this.gridLayer.doCommand(new SelectCellCommand(this.gridLayer, 3, 4, false, false));
    GridSearchStrategy gridStrategy = new GridSearchStrategy(this.configRegistry, false, true);
    // If we don't specify to wrap the search, it will not find it.
    gridStrategy.setContextLayer(this.selectionLayer);
    gridStrategy.setCaseSensitive(true);
    gridStrategy.setComparator(new CellValueAsStringComparator<>());
    PositionCoordinate searchResult = gridStrategy.executeSearch("body");
    assertNull(searchResult);
    // Should find it when wrap search is enabled.
    gridStrategy.setWrapSearch(true);
    searchResult = gridStrategy.executeSearch("body");
    assertNotNull(searchResult);
    assertEquals(2, searchResult.columnPosition);
    assertEquals(2, searchResult.rowPosition);
}
Also used : SelectCellCommand(org.eclipse.nebula.widgets.nattable.selection.command.SelectCellCommand) PositionCoordinate(org.eclipse.nebula.widgets.nattable.coordinate.PositionCoordinate) Test(org.junit.Test)

Example 35 with SelectCellCommand

use of org.eclipse.nebula.widgets.nattable.selection.command.SelectCellCommand in project nebula.widgets.nattable by eclipse.

the class GridSearchStrategyTest method searchShouldMoveBackwardsToFindCell.

@Test
public void searchShouldMoveBackwardsToFindCell() {
    // Select search starting point in composite coordinates
    this.gridLayer.doCommand(new SelectCellCommand(this.gridLayer, 3, 4, false, false));
    GridSearchStrategy gridStrategy = new GridSearchStrategy(this.configRegistry, false, ISearchDirection.SEARCH_BACKWARDS, true);
    gridStrategy.setComparator(new CellValueAsStringComparator<>());
    gridStrategy.setContextLayer(this.selectionLayer);
    PositionCoordinate searchResult = gridStrategy.executeSearch("[1,3]");
    assertNotNull(searchResult);
    assertEquals(1, searchResult.columnPosition);
    assertEquals(3, searchResult.rowPosition);
}
Also used : SelectCellCommand(org.eclipse.nebula.widgets.nattable.selection.command.SelectCellCommand) PositionCoordinate(org.eclipse.nebula.widgets.nattable.coordinate.PositionCoordinate) 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