Search in sources :

Example 76 with ILayerCell

use of org.eclipse.nebula.widgets.nattable.layer.cell.ILayerCell in project nebula.widgets.nattable by eclipse.

the class SelectionUtilsTest method testGetBottomRightSelectNothing.

@Test
public void testGetBottomRightSelectNothing() {
    DataLayer dataLayer = new DataLayer(new DataProviderFixture(10, 10));
    SelectionLayer selectionLayer = new SelectionLayer(dataLayer);
    ILayerCell bottomRight = SelectionUtils.getBottomRightCellInSelection(selectionLayer);
    assertNull(bottomRight);
}
Also used : DataLayer(org.eclipse.nebula.widgets.nattable.layer.DataLayer) ILayerCell(org.eclipse.nebula.widgets.nattable.layer.cell.ILayerCell) DataProviderFixture(org.eclipse.nebula.widgets.nattable.test.fixture.data.DataProviderFixture) Test(org.junit.Test)

Example 77 with ILayerCell

use of org.eclipse.nebula.widgets.nattable.layer.cell.ILayerCell in project nebula.widgets.nattable by eclipse.

the class SelectionUtilsTest method testGetBottomRightSelectOne.

@Test
public void testGetBottomRightSelectOne() {
    DataLayer dataLayer = new DataLayer(new DataProviderFixture(10, 10));
    SelectionLayer selectionLayer = new SelectionLayer(dataLayer);
    // select one cell
    selectionLayer.selectCell(5, 5, false, false);
    ILayerCell bottomRight = SelectionUtils.getBottomRightCellInSelection(selectionLayer);
    assertEquals(5, bottomRight.getColumnPosition());
    assertEquals(5, bottomRight.getRowPosition());
}
Also used : DataLayer(org.eclipse.nebula.widgets.nattable.layer.DataLayer) ILayerCell(org.eclipse.nebula.widgets.nattable.layer.cell.ILayerCell) DataProviderFixture(org.eclipse.nebula.widgets.nattable.test.fixture.data.DataProviderFixture) Test(org.junit.Test)

Example 78 with ILayerCell

use of org.eclipse.nebula.widgets.nattable.layer.cell.ILayerCell in project nebula.widgets.nattable by eclipse.

the class SelectionUtilsTest method testGetBottomRightSelectAll.

@Test
public void testGetBottomRightSelectAll() {
    DataLayer dataLayer = new DataLayer(new DataProviderFixture(10, 10));
    SelectionLayer selectionLayer = new SelectionLayer(dataLayer);
    // select all cells
    selectionLayer.selectAll();
    ILayerCell bottomRight = SelectionUtils.getBottomRightCellInSelection(selectionLayer);
    assertEquals(9, bottomRight.getColumnPosition());
    assertEquals(9, bottomRight.getRowPosition());
}
Also used : DataLayer(org.eclipse.nebula.widgets.nattable.layer.DataLayer) ILayerCell(org.eclipse.nebula.widgets.nattable.layer.cell.ILayerCell) DataProviderFixture(org.eclipse.nebula.widgets.nattable.test.fixture.data.DataProviderFixture) Test(org.junit.Test)

Example 79 with ILayerCell

use of org.eclipse.nebula.widgets.nattable.layer.cell.ILayerCell in project nebula.widgets.nattable by eclipse.

the class EditIntegrationTest method testDataValidation.

@Test
public void testDataValidation() {
    DummyGridLayerStack gridLayerStack = new DummyGridLayerStack(5, 5);
    this.natTable = new NatTableFixture(gridLayerStack);
    // Register custom validation
    DataLayer bodyDataLayer = (DataLayer) gridLayerStack.getBodyDataLayer();
    this.natTable.registerLabelOnColumn(bodyDataLayer, 0, TEST_LABEL);
    this.natTable.registerLabelOnColumn(bodyDataLayer, 1, TEST_LABEL_2);
    this.natTable.enableEditingOnAllCells();
    this.natTable.getConfigRegistry().registerConfigAttribute(EditConfigAttributes.DATA_VALIDATOR, IDataValidator.NEVER_VALID, DisplayMode.EDIT, TEST_LABEL);
    this.natTable.getConfigRegistry().registerConfigAttribute(EditConfigAttributes.DATA_VALIDATOR, IDataValidator.ALWAYS_VALID, DisplayMode.EDIT, TEST_LABEL_2);
    ILayerCell cell = this.natTable.getCellByPosition(1, 1);
    assertEquals("Col: 1, Row: 1", cell.getDataValue());
    // Column index 0 never valid
    this.natTable.doCommand(new EditCellCommand(this.natTable, this.natTable.getConfigRegistry(), cell));
    assertFalse(this.natTable.getActiveCellEditor().validateCanonicalValue(cell.getDataValue()));
    cell = this.natTable.getCellByPosition(2, 1);
    assertEquals("Col: 2, Row: 1", cell.getDataValue());
    // Column index 1 always valid
    this.natTable.doCommand(new EditCellCommand(this.natTable, this.natTable.getConfigRegistry(), cell));
    assertTrue(this.natTable.getActiveCellEditor().validateCanonicalValue(cell.getDataValue()));
}
Also used : SpanningDataLayer(org.eclipse.nebula.widgets.nattable.layer.SpanningDataLayer) DataLayer(org.eclipse.nebula.widgets.nattable.layer.DataLayer) DummyGridLayerStack(org.eclipse.nebula.widgets.nattable.layer.stack.DummyGridLayerStack) NatTableFixture(org.eclipse.nebula.widgets.nattable.test.fixture.NatTableFixture) ILayerCell(org.eclipse.nebula.widgets.nattable.layer.cell.ILayerCell) EditCellCommand(org.eclipse.nebula.widgets.nattable.edit.command.EditCellCommand) Test(org.junit.Test)

Example 80 with ILayerCell

use of org.eclipse.nebula.widgets.nattable.layer.cell.ILayerCell in project nebula.widgets.nattable by eclipse.

the class EditIntegrationTest method testEditorActivatedDuringInlineCellEdit.

@Test
public void testEditorActivatedDuringInlineCellEdit() {
    this.natTable.enableEditingOnAllCells();
    ILayerCell cell = this.natTable.getCellByPosition(4, 4);
    this.natTable.doCommand(new EditCellCommand(this.natTable, this.natTable.getConfigRegistry(), cell));
    ICellEditor cellEditor = this.natTable.getActiveCellEditor();
    assertNotNull(cellEditor);
    assertTrue(cellEditor instanceof TextCellEditor);
    TextCellEditor textCellEditor = (TextCellEditor) cellEditor;
    assertEquals("Col: 4, Row: 4", textCellEditor.getCanonicalValue());
    Control control = cellEditor.getEditorControl();
    assertNotNull(control);
    assertTrue(control instanceof Text);
}
Also used : Control(org.eclipse.swt.widgets.Control) ICellEditor(org.eclipse.nebula.widgets.nattable.edit.editor.ICellEditor) Text(org.eclipse.swt.widgets.Text) TextCellEditor(org.eclipse.nebula.widgets.nattable.edit.editor.TextCellEditor) ILayerCell(org.eclipse.nebula.widgets.nattable.layer.cell.ILayerCell) EditCellCommand(org.eclipse.nebula.widgets.nattable.edit.command.EditCellCommand) Test(org.junit.Test)

Aggregations

ILayerCell (org.eclipse.nebula.widgets.nattable.layer.cell.ILayerCell)118 Test (org.junit.Test)45 Rectangle (org.eclipse.swt.graphics.Rectangle)23 DataLayer (org.eclipse.nebula.widgets.nattable.layer.DataLayer)14 SelectCellCommand (org.eclipse.nebula.widgets.nattable.selection.command.SelectCellCommand)14 IConfigRegistry (org.eclipse.nebula.widgets.nattable.config.IConfigRegistry)11 PositionCoordinate (org.eclipse.nebula.widgets.nattable.coordinate.PositionCoordinate)10 LabelStack (org.eclipse.nebula.widgets.nattable.layer.LabelStack)10 Color (org.eclipse.swt.graphics.Color)10 EditCellCommand (org.eclipse.nebula.widgets.nattable.edit.command.EditCellCommand)9 ICellPainter (org.eclipse.nebula.widgets.nattable.painter.cell.ICellPainter)9 DataProviderFixture (org.eclipse.nebula.widgets.nattable.test.fixture.data.DataProviderFixture)9 ILayer (org.eclipse.nebula.widgets.nattable.layer.ILayer)8 UpdateDataCommand (org.eclipse.nebula.widgets.nattable.edit.command.UpdateDataCommand)5 Point (org.eclipse.swt.graphics.Point)5 HashSet (java.util.HashSet)4 NatTable (org.eclipse.nebula.widgets.nattable.NatTable)4 DefaultNatTableStyleConfiguration (org.eclipse.nebula.widgets.nattable.config.DefaultNatTableStyleConfiguration)4 IEditableRule (org.eclipse.nebula.widgets.nattable.config.IEditableRule)4 ICellEditor (org.eclipse.nebula.widgets.nattable.edit.editor.ICellEditor)4