Search in sources :

Example 46 with PositionCoordinate

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

the class RowSelectionIntegrationTest method onlyOneRowSelectedAtAnyTime.

@Test
public void onlyOneRowSelectedAtAnyTime() {
    this.selectionLayer.getSelectionModel().setMultipleSelectionAllowed(false);
    this.selectionLayer.clear();
    this.selectionLayer.doCommand(new SelectCellCommand(this.selectionLayer, 1, 0, false, true));
    Collection<PositionCoordinate> cells = ArrayUtil.asCollection(this.selectionLayer.getSelectedCellPositions());
    Assert.assertEquals(this.selectionLayer.getColumnCount(), cells.size());
    Assert.assertEquals(1, this.selectionLayer.getSelectedRowCount());
    // select another cell with control mask
    this.selectionLayer.doCommand(new SelectCellCommand(this.selectionLayer, 2, 1, false, true));
    cells = ArrayUtil.asCollection(this.selectionLayer.getSelectedCellPositions());
    Assert.assertEquals(this.selectionLayer.getColumnCount(), cells.size());
    Assert.assertEquals(1, this.selectionLayer.getSelectedRowCount());
    // select additional cells with shift mask
    this.selectionLayer.doCommand(new SelectCellCommand(this.selectionLayer, 2, 10, true, false));
    cells = ArrayUtil.asCollection(this.selectionLayer.getSelectedCellPositions());
    Assert.assertEquals(this.selectionLayer.getColumnCount(), cells.size());
    Assert.assertEquals(1, this.selectionLayer.getSelectedRowCount());
    // select additional cells with shift mask
    this.selectionLayer.doCommand(new SelectCellCommand(this.selectionLayer, 10, 0, true, false));
    cells = ArrayUtil.asCollection(this.selectionLayer.getSelectedCellPositions());
    Assert.assertEquals(this.selectionLayer.getColumnCount(), cells.size());
    Assert.assertEquals(1, this.selectionLayer.getSelectedRowCount());
}
Also used : SelectCellCommand(org.eclipse.nebula.widgets.nattable.selection.command.SelectCellCommand) PositionCoordinate(org.eclipse.nebula.widgets.nattable.coordinate.PositionCoordinate) Test(org.junit.Test)

Example 47 with PositionCoordinate

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

the class FreezeHandlerTest method shouldFreezeRowsAndColumnsBasedOnMultiSelectionInclude.

@Test
public void shouldFreezeRowsAndColumnsBasedOnMultiSelectionInclude() {
    this.compositeFreezeLayer.doCommand(new SelectCellCommand(this.compositeFreezeLayer, 2, 2, false, false));
    this.compositeFreezeLayer.doCommand(new SelectCellCommand(this.compositeFreezeLayer, 3, 3, true, false));
    // Make sure selection layer processed command
    assertEquals(4, this.selectionLayer.getSelectedCellPositions().length);
    PositionCoordinate lastSelectedCell = this.selectionLayer.getLastSelectedCellPosition();
    assertEquals(3, lastSelectedCell.columnPosition);
    assertEquals(3, lastSelectedCell.rowPosition);
    // This is what would happen if we selected to freeze from a selected
    // cell
    this.compositeFreezeLayer.doCommand(new FreezeSelectionCommand(false, false, true));
    assertEquals(0, this.freezeLayer.getTopLeftPosition().columnPosition);
    assertEquals(0, this.freezeLayer.getTopLeftPosition().rowPosition);
    assertNotNull(this.freezeLayer.getBottomRightPosition());
    assertEquals(3, this.freezeLayer.getBottomRightPosition().columnPosition);
    assertEquals(3, this.freezeLayer.getBottomRightPosition().rowPosition);
    // Check viewport origin
    assertEquals(4, this.viewportLayer.getMinimumOriginColumnPosition());
    assertEquals(4, this.viewportLayer.getMinimumOriginRowPosition());
}
Also used : SelectCellCommand(org.eclipse.nebula.widgets.nattable.selection.command.SelectCellCommand) PositionCoordinate(org.eclipse.nebula.widgets.nattable.coordinate.PositionCoordinate) Test(org.junit.Test)

Example 48 with PositionCoordinate

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

the class FreezeHandlerTest method shouldFreezeRowsAndColumnsBasedOnSelection.

@Test
public void shouldFreezeRowsAndColumnsBasedOnSelection() {
    this.compositeFreezeLayer.doCommand(new SelectCellCommand(this.compositeFreezeLayer, 2, 2, false, false));
    // Make sure selection layer processed command
    final PositionCoordinate lastSelectedCell = this.selectionLayer.getLastSelectedCellPosition();
    assertEquals(2, lastSelectedCell.columnPosition);
    assertEquals(2, lastSelectedCell.rowPosition);
    // This is what would happen if we selected to freeze from a selected
    // cell
    this.compositeFreezeLayer.doCommand(new FreezeSelectionCommand());
    assertEquals(0, this.freezeLayer.getTopLeftPosition().columnPosition);
    assertEquals(0, this.freezeLayer.getTopLeftPosition().rowPosition);
    assertNotNull(this.freezeLayer.getBottomRightPosition());
    assertEquals(1, this.freezeLayer.getBottomRightPosition().columnPosition);
    assertEquals(1, this.freezeLayer.getBottomRightPosition().rowPosition);
    // Check viewport origin
    assertEquals(2, this.viewportLayer.getMinimumOriginColumnPosition());
    assertEquals(2, this.viewportLayer.getMinimumOriginRowPosition());
}
Also used : SelectCellCommand(org.eclipse.nebula.widgets.nattable.selection.command.SelectCellCommand) PositionCoordinate(org.eclipse.nebula.widgets.nattable.coordinate.PositionCoordinate) Test(org.junit.Test)

Example 49 with PositionCoordinate

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

the class EditUtilsTest method testIsCellEditableWithoutSelectionEnableEditing.

@Test
public void testIsCellEditableWithoutSelectionEnableEditing() {
    this.natTable.enableEditingOnAllCells();
    PositionCoordinate coord = new PositionCoordinate(this.selectionLayer, 0, 0);
    assertTrue(EditUtils.isCellEditable(this.selectionLayer, this.natTable.getConfigRegistry(), coord));
}
Also used : PositionCoordinate(org.eclipse.nebula.widgets.nattable.coordinate.PositionCoordinate) Test(org.junit.Test)

Example 50 with PositionCoordinate

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

the class EditUtilsTest method testIsCellEditableWithSingleSelection.

@Test
public void testIsCellEditableWithSingleSelection() {
    this.selectionLayer.selectCell(1, 1, false, false);
    PositionCoordinate coord = new PositionCoordinate(this.selectionLayer, 1, 1);
    assertFalse(EditUtils.isCellEditable(this.selectionLayer, this.natTable.getConfigRegistry(), coord));
}
Also used : PositionCoordinate(org.eclipse.nebula.widgets.nattable.coordinate.PositionCoordinate) 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