Search in sources :

Example 71 with PositionCoordinate

use of org.eclipse.nebula.widgets.nattable.coordinate.PositionCoordinate in project nebula.widgets.nattable by eclipse.

the class SelectionLayerTest method testGetAnchorDoesNotDelegateToModel.

// Selection Anchor
@Test
public void testGetAnchorDoesNotDelegateToModel() {
    PositionCoordinate existingAnchor = this.selectionLayer.selectionAnchor;
    assertSame(existingAnchor, this.selectionLayer.getSelectionAnchor());
}
Also used : PositionCoordinate(org.eclipse.nebula.widgets.nattable.coordinate.PositionCoordinate) Test(org.junit.Test)

Example 72 with PositionCoordinate

use of org.eclipse.nebula.widgets.nattable.coordinate.PositionCoordinate in project nebula.widgets.nattable by eclipse.

the class SelectionLayerTest method testGetLastSelectedCellDoesNotDelegateToModel.

@Test
public void testGetLastSelectedCellDoesNotDelegateToModel() {
    this.selectionLayer.selectAll();
    PositionCoordinate existingSelectedCell = this.selectionLayer.lastSelectedCell;
    assertSame(existingSelectedCell, this.selectionLayer.getLastSelectedCell());
}
Also used : PositionCoordinate(org.eclipse.nebula.widgets.nattable.coordinate.PositionCoordinate) Test(org.junit.Test)

Example 73 with PositionCoordinate

use of org.eclipse.nebula.widgets.nattable.coordinate.PositionCoordinate in project nebula.widgets.nattable by eclipse.

the class EditIntegrationTest method navigationWithTab.

@Test
public void navigationWithTab() throws Exception {
    this.natTable.enableEditingOnAllCells();
    this.natTable.doCommand(new SelectCellCommand(this.natTable, 1, 1, false, false));
    // Edit cell
    ILayerCell cell = this.natTable.getCellByPosition(1, 1);
    this.natTable.doCommand(new EditCellCommand(this.natTable, this.natTable.getConfigRegistry(), cell));
    // Press tab - 3 times
    Text textControl = ((Text) this.natTable.getActiveCellEditor().getEditorControl());
    textControl.notifyListeners(SWT.Traverse, SWTUtils.keyEvent(SWT.TAB));
    this.natTable.notifyListeners(SWT.KeyDown, SWTUtils.keyEvent(SWT.TAB));
    this.natTable.notifyListeners(SWT.KeyDown, SWTUtils.keyEvent(SWT.TAB));
    this.natTable.notifyListeners(SWT.KeyDown, SWTUtils.keyEvent(SWT.TAB));
    // Verify new cell selection
    PositionCoordinate lastSelectedCellPosition = this.gridLayerStack.getBodyLayer().getSelectionLayer().getSelectionAnchor();
    assertEquals(4, lastSelectedCellPosition.columnPosition);
    assertEquals(0, lastSelectedCellPosition.rowPosition);
    // Verify that no cell is being edited
    assertNull(this.natTable.getActiveCellEditor());
    assertNull(ActiveCellEditorRegistry.getActiveCellEditor());
}
Also used : SelectCellCommand(org.eclipse.nebula.widgets.nattable.selection.command.SelectCellCommand) PositionCoordinate(org.eclipse.nebula.widgets.nattable.coordinate.PositionCoordinate) Text(org.eclipse.swt.widgets.Text) ILayerCell(org.eclipse.nebula.widgets.nattable.layer.cell.ILayerCell) EditCellCommand(org.eclipse.nebula.widgets.nattable.edit.command.EditCellCommand) Test(org.junit.Test)

Example 74 with PositionCoordinate

use of org.eclipse.nebula.widgets.nattable.coordinate.PositionCoordinate in project nebula.widgets.nattable by eclipse.

the class RegionSelectionTest method shouldSelectOtherRegion.

@Test
public void shouldSelectOtherRegion() {
    this.selectionLayer.doCommand(new SelectRegionCommand(this.selectionLayer, 2, 3, 3, 3, false, false));
    this.selectionLayer.doCommand(new SelectRegionCommand(this.selectionLayer, 1, 2, 2, 2, false, false));
    PositionCoordinate[] cellPositions = this.selectionLayer.getSelectedCellPositions();
    assertEquals(4, cellPositions.length);
    Rectangle region = new Rectangle(1, 2, 2, 2);
    assertTrue("not all cells in region selected", this.selectionLayer.allCellsSelectedInRegion(region));
    region = new Rectangle(2, 3, 3, 3);
    assertFalse("all cells selected", this.selectionLayer.allCellsSelectedInRegion(region));
    assertEquals(1, this.selectionLayer.getSelectionAnchor().getColumnPosition());
    assertEquals(2, this.selectionLayer.getSelectionAnchor().getRowPosition());
}
Also used : SelectRegionCommand(org.eclipse.nebula.widgets.nattable.selection.command.SelectRegionCommand) PositionCoordinate(org.eclipse.nebula.widgets.nattable.coordinate.PositionCoordinate) Rectangle(org.eclipse.swt.graphics.Rectangle) Test(org.junit.Test)

Example 75 with PositionCoordinate

use of org.eclipse.nebula.widgets.nattable.coordinate.PositionCoordinate in project nebula.widgets.nattable by eclipse.

the class RegionSelectionTest method shouldExtendSelectedRegionDownWithShift.

@Test
public void shouldExtendSelectedRegionDownWithShift() {
    this.selectionLayer.doCommand(new SelectRegionCommand(this.selectionLayer, 2, 3, 3, 3, false, false));
    this.selectionLayer.doCommand(new SelectRegionCommand(this.selectionLayer, 2, 7, 3, 2, true, false));
    PositionCoordinate[] cellPositions = this.selectionLayer.getSelectedCellPositions();
    assertEquals(18, cellPositions.length);
    Rectangle region = new Rectangle(2, 3, 3, 6);
    assertTrue("not all cells in region selected", this.selectionLayer.allCellsSelectedInRegion(region));
    assertEquals(2, this.selectionLayer.getSelectionAnchor().getColumnPosition());
    assertEquals(3, this.selectionLayer.getSelectionAnchor().getRowPosition());
}
Also used : SelectRegionCommand(org.eclipse.nebula.widgets.nattable.selection.command.SelectRegionCommand) PositionCoordinate(org.eclipse.nebula.widgets.nattable.coordinate.PositionCoordinate) Rectangle(org.eclipse.swt.graphics.Rectangle) Test(org.junit.Test)

Aggregations

PositionCoordinate (org.eclipse.nebula.widgets.nattable.coordinate.PositionCoordinate)97 Test (org.junit.Test)55 SelectCellCommand (org.eclipse.nebula.widgets.nattable.selection.command.SelectCellCommand)15 ILayerCell (org.eclipse.nebula.widgets.nattable.layer.cell.ILayerCell)10 Rectangle (org.eclipse.swt.graphics.Rectangle)9 SelectRegionCommand (org.eclipse.nebula.widgets.nattable.selection.command.SelectRegionCommand)7 ArrayList (java.util.ArrayList)5 ILayer (org.eclipse.nebula.widgets.nattable.layer.ILayer)5 SelectionLayer (org.eclipse.nebula.widgets.nattable.selection.SelectionLayer)5 Range (org.eclipse.nebula.widgets.nattable.coordinate.Range)4 ViewportSelectColumnGroupCommand (org.eclipse.nebula.widgets.nattable.group.command.ViewportSelectColumnGroupCommand)4 SearchEvent (org.eclipse.nebula.widgets.nattable.search.event.SearchEvent)4 SelectAllCommand (org.eclipse.nebula.widgets.nattable.selection.command.SelectAllCommand)4 ILayerListener (org.eclipse.nebula.widgets.nattable.layer.ILayerListener)3 HashSet (java.util.HashSet)2 Pattern (java.util.regex.Pattern)2 IConfigRegistry (org.eclipse.nebula.widgets.nattable.config.IConfigRegistry)2 ColumnPositionCoordinate (org.eclipse.nebula.widgets.nattable.coordinate.ColumnPositionCoordinate)2 RowPositionCoordinate (org.eclipse.nebula.widgets.nattable.coordinate.RowPositionCoordinate)2 UpdateDataCommand (org.eclipse.nebula.widgets.nattable.edit.command.UpdateDataCommand)2