use of org.eclipse.nebula.widgets.nattable.selection.command.SelectCellCommand in project nebula.widgets.nattable by eclipse.
the class SelectionIntegrationTest method movingSelectionWithDownArrow.
@Test
public void movingSelectionWithDownArrow() throws Exception {
this.natTable.doCommand(new SelectCellCommand(this.natTable, 5, 2, NO_SHIFT, NO_CTRL));
// Note: the co-ordinates from this point on are in selection later
// co-ordinates
SWTUtils.pressKey(SWT.ARROW_DOWN, this.natTable);
SWTUtils.pressKey(SWT.ARROW_DOWN, this.natTable);
assertPositionEquals(4, 3, this.selectionLayer.getLastSelectedCellPosition());
assertSelectionAnchorEquals(4, 3);
SWTUtils.pressKey(SWT.ARROW_DOWN, SWT.SHIFT, this.natTable);
SWTUtils.pressKey(SWT.ARROW_DOWN, SWT.SHIFT, this.natTable);
assertSelectCellsCount(2);
assertCellSelected(4, 3);
assertCellSelected(4, 4);
assertSelectionAnchorEquals(4, 3);
SWTUtils.pressKey(SWT.ARROW_DOWN, SWT.MOD1, this.natTable);
assertSelectCellsCount(1);
int lastRow = this.selectionLayer.getRowCount() - 1;
assertPositionEquals(4, lastRow, this.selectionLayer.getSelectedCellPositions()[0]);
assertPositionEquals(4, lastRow, this.selectionLayer.getLastSelectedCellPosition());
assertSelectionAnchorEquals(4, lastRow);
}
use of org.eclipse.nebula.widgets.nattable.selection.command.SelectCellCommand in project nebula.widgets.nattable by eclipse.
the class SelectionIntegrationTest method movingSelectionWithRightArrow.
@Test
public void movingSelectionWithRightArrow() throws Exception {
this.natTable.doCommand(new SelectCellCommand(this.natTable, 5, 2, NO_SHIFT, NO_CTRL));
// Note: the co-ordinates from this point on are in selection later
// co-ordinates
SWTUtils.pressKey(SWT.ARROW_RIGHT, this.natTable);
assertPositionEquals(5, 1, this.selectionLayer.getLastSelectedCellPosition());
assertSelectionAnchorEquals(5, 1);
SWTUtils.pressKey(SWT.ARROW_RIGHT, SWT.SHIFT, this.natTable);
assertSelectCellsCount(2);
assertCellSelected(5, 1);
assertCellSelected(6, 1);
assertSelectionAnchorEquals(5, 1);
SWTUtils.pressKey(SWT.ARROW_RIGHT, SWT.MOD1, this.natTable);
assertSelectCellsCount(1);
assertPositionEquals(9, 1, this.selectionLayer.getSelectedCellPositions()[0]);
assertPositionEquals(9, 1, this.selectionLayer.getLastSelectedCellPosition());
assertSelectionAnchorEquals(9, 1);
}
use of org.eclipse.nebula.widgets.nattable.selection.command.SelectCellCommand in project nebula.widgets.nattable by eclipse.
the class SelectionIntegrationTest method movingSelectionWithLeftArrow.
@Test
public void movingSelectionWithLeftArrow() throws Exception {
this.natTable.doCommand(new SelectCellCommand(this.natTable, 5, 2, NO_SHIFT, NO_CTRL));
// Note: the co-ordinates from this point on are in selection later
// co-ordinates
SWTUtils.pressKey(SWT.ARROW_LEFT, this.natTable);
assertPositionEquals(3, 1, getSelectedCells()[0]);
assertSelectionAnchorEquals(3, 1);
SWTUtils.pressKey(SWT.ARROW_LEFT, SWT.SHIFT, this.natTable);
assertSelectCellsCount(2);
assertPositionEquals(2, 1, getSelectedCells()[0]);
assertPositionEquals(3, 1, getSelectedCells()[1]);
assertSelectionAnchorEquals(3, 1);
SWTUtils.pressKey(SWT.ARROW_LEFT, SWT.MOD1, this.natTable);
assertSelectCellsCount(1);
assertPositionEquals(0, 1, getSelectedCells()[0]);
assertSelectionAnchorEquals(0, 1);
}
use of org.eclipse.nebula.widgets.nattable.selection.command.SelectCellCommand in project nebula.widgets.nattable by eclipse.
the class SearchGridCellsCommandHandler method doCommand.
@Override
public boolean doCommand(ILayer targetLayer, SearchCommand searchCommand) throws PatternSyntaxException {
searchCommand.convertToTargetLayer(targetLayer);
final ILayerListener searchEventListener = searchCommand.getSearchEventListener();
if (searchEventListener != null) {
this.selectionLayer.addLayerListener(searchEventListener);
}
try {
PositionCoordinate anchor = this.selectionLayer.getSelectionAnchor();
if (anchor.columnPosition < 0 || anchor.rowPosition < 0) {
anchor = new PositionCoordinate(this.selectionLayer, 0, 0);
}
Object dataValueToFind = null;
if ((dataValueToFind = searchCommand.getSearchText()) == null) {
dataValueToFind = this.selectionLayer.getDataValueByPosition(anchor.columnPosition, anchor.rowPosition);
}
boolean performActionOnResult = true;
if (searchCommand.getSearchStrategy() instanceof AbstractSearchStrategy) {
AbstractSearchStrategy searchStrategy = (AbstractSearchStrategy) searchCommand.getSearchStrategy();
searchStrategy.setContextLayer(targetLayer);
searchStrategy.setCaseSensitive(searchCommand.isCaseSensitive());
searchStrategy.setWrapSearch(searchCommand.isWrapSearch());
searchStrategy.setWholeWord(searchCommand.isWholeWord());
searchStrategy.setIncremental(searchCommand.isIncremental());
searchStrategy.setRegex(searchCommand.isRegex());
searchStrategy.setIncludeCollapsed(searchCommand.isIncludeCollapsed());
searchStrategy.setSearchDirection(searchCommand.getSearchDirection());
searchStrategy.setComparator(searchCommand.getComparator());
performActionOnResult = !searchStrategy.processResultInternally();
}
this.searchResultCellCoordinate = searchCommand.getSearchStrategy().executeSearch(dataValueToFind);
this.selectionLayer.fireLayerEvent(new SearchEvent(this.searchResultCellCoordinate));
if (performActionOnResult && this.searchResultCellCoordinate != null) {
final SelectCellCommand command = new SelectCellCommand(this.selectionLayer, this.searchResultCellCoordinate.columnPosition, this.searchResultCellCoordinate.rowPosition, false, false);
command.setForcingEntireCellIntoViewport(true);
this.selectionLayer.doCommand(command);
}
} finally {
if (searchEventListener != null) {
this.selectionLayer.removeLayerListener(searchEventListener);
}
}
return true;
}
use of org.eclipse.nebula.widgets.nattable.selection.command.SelectCellCommand in project nebula.widgets.nattable by eclipse.
the class SearchDialog method createSelectCellCommand.
private SelectCellCommand createSelectCellCommand(PositionCoordinate selection) {
SelectCellCommand selectCellCommand = new SelectCellCommand(selection.getLayer(), selection.columnPosition, selection.rowPosition, false, false);
selectCellCommand.setForcingEntireCellIntoViewport(true);
return selectCellCommand;
}
Aggregations