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