Search in sources :

Example 1 with PositionCoordinate

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

the class FreezeHandlerTest method shouldFreezeRowsAndColumnsBasedOnMultiSelection.

@Test
public void shouldFreezeRowsAndColumnsBasedOnMultiSelection() {
    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());
    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 2 with PositionCoordinate

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

the class FreezeHandlerTest method shouldFreezeRowsAndColumnsBasedOnSelectionInclude.

@Test
public void shouldFreezeRowsAndColumnsBasedOnSelectionInclude() {
    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(false, false, true));
    assertEquals(0, this.freezeLayer.getTopLeftPosition().columnPosition);
    assertEquals(0, this.freezeLayer.getTopLeftPosition().rowPosition);
    assertNotNull(this.freezeLayer.getBottomRightPosition());
    assertEquals(2, this.freezeLayer.getBottomRightPosition().columnPosition);
    assertEquals(2, this.freezeLayer.getBottomRightPosition().rowPosition);
    // Check viewport origin
    assertEquals(3, this.viewportLayer.getMinimumOriginColumnPosition());
    assertEquals(3, 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 3 with PositionCoordinate

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

the class EditUtilsTest method testIsCellEditableWithoutSelection.

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

Example 4 with PositionCoordinate

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

the class RowSelectionEditUtilsTest 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 5 with PositionCoordinate

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

the class ColumnGroupHeaderLayerSelectionTest method shouldMoveAnchorOnDeselectWithCtrlWithPreserve.

@Test
public void shouldMoveAnchorOnDeselectWithCtrlWithPreserve() {
    this.gridLayer.getBodyLayer().getSelectionLayer().setSelectionModel(new PreserveSelectionModel<>(this.gridLayer.getBodyLayer().getSelectionLayer(), this.dataProvider, new IRowIdAccessor<NumberValues>() {

        @Override
        public Serializable getRowId(NumberValues rowObject) {
            return rowObject.getColumnOneNumber();
        }
    }));
    this.gridLayer.doCommand(new ViewportSelectColumnGroupCommand(this.gridLayer, 2, 0, false, false));
    this.gridLayer.doCommand(new ViewportSelectColumnGroupCommand(this.gridLayer, 6, 0, false, true));
    assertTrue(this.gridLayer.getBodyLayer().getSelectionLayer().isColumnPositionFullySelected(0));
    assertTrue(this.gridLayer.getBodyLayer().getSelectionLayer().isColumnPositionFullySelected(1));
    assertTrue(this.gridLayer.getBodyLayer().getSelectionLayer().isColumnPositionFullySelected(2));
    assertTrue(this.gridLayer.getBodyLayer().getSelectionLayer().isColumnPositionFullySelected(5));
    assertTrue(this.gridLayer.getBodyLayer().getSelectionLayer().isColumnPositionFullySelected(6));
    PositionCoordinate selectionAnchor = this.gridLayer.getBodyLayer().getSelectionLayer().getSelectionAnchor();
    assertEquals(0, selectionAnchor.getRowPosition());
    assertEquals(5, selectionAnchor.getColumnPosition());
    this.gridLayer.doCommand(new ViewportSelectColumnGroupCommand(this.gridLayer, 6, 0, false, true));
    assertTrue(this.gridLayer.getBodyLayer().getSelectionLayer().isColumnPositionFullySelected(0));
    assertTrue(this.gridLayer.getBodyLayer().getSelectionLayer().isColumnPositionFullySelected(1));
    assertTrue(this.gridLayer.getBodyLayer().getSelectionLayer().isColumnPositionFullySelected(2));
    assertFalse(this.gridLayer.getBodyLayer().getSelectionLayer().isColumnPositionFullySelected(5));
    assertFalse(this.gridLayer.getBodyLayer().getSelectionLayer().isColumnPositionFullySelected(6));
    selectionAnchor = this.gridLayer.getBodyLayer().getSelectionLayer().getSelectionAnchor();
    assertEquals(0, selectionAnchor.getRowPosition());
    assertEquals(0, selectionAnchor.getColumnPosition());
}
Also used : IRowIdAccessor(org.eclipse.nebula.widgets.nattable.data.IRowIdAccessor) ViewportSelectColumnGroupCommand(org.eclipse.nebula.widgets.nattable.group.command.ViewportSelectColumnGroupCommand) PositionCoordinate(org.eclipse.nebula.widgets.nattable.coordinate.PositionCoordinate) NumberValues(org.eclipse.nebula.widgets.nattable.dataset.NumberValues) 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