Search in sources :

Example 16 with ILayerCell

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

the class ColumnHeaderLayerSelectionTest method willSelectBodyCellAndShouldHaveColumnHeaderSelected.

@Test
public void willSelectBodyCellAndShouldHaveColumnHeaderSelected() {
    // Select body cell
    // The column position is a grid layer position
    this.gridLayer.doCommand(new SelectCellCommand(this.gridLayer, 2, 2, false, false));
    // Get column header cell corresponding to the selected body cell
    ColumnHeaderLayer columnHeaderLayer = (ColumnHeaderLayer) this.gridLayer.getChildLayerByLayoutCoordinate(1, 0);
    // The column position is 1 because it takes into account the offset of
    // the row header
    ILayerCell cell = columnHeaderLayer.getCellByPosition(1, 0);
    // Assert the cell is in selected state
    assertEquals(DisplayMode.SELECT, cell.getDisplayMode());
}
Also used : ColumnHeaderLayer(org.eclipse.nebula.widgets.nattable.grid.layer.ColumnHeaderLayer) SelectCellCommand(org.eclipse.nebula.widgets.nattable.selection.command.SelectCellCommand) ILayerCell(org.eclipse.nebula.widgets.nattable.layer.cell.ILayerCell) Test(org.junit.Test)

Example 17 with ILayerCell

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

the class RowHeaderSelectionTest method willSelectBodyCellAndShouldHaveColumnHeaderSelected.

@Test
public void willSelectBodyCellAndShouldHaveColumnHeaderSelected() {
    // Select body cell
    // The row position is a grid layer position
    this.gridLayer.doCommand(new SelectCellCommand(this.gridLayer, 2, 2, false, false));
    // Get row header cell corresponding to the selected body cell
    RowHeaderLayer rowHeaderLayer = (RowHeaderLayer) this.gridLayer.getChildLayerByLayoutCoordinate(0, 1);
    // The column position is 0 because it takes into account the offset of
    // the row header
    ILayerCell cell = rowHeaderLayer.getCellByPosition(0, 1);
    // Assert the cell is in selected state
    Assert.assertEquals(DisplayMode.SELECT, cell.getDisplayMode());
}
Also used : RowHeaderLayer(org.eclipse.nebula.widgets.nattable.grid.layer.RowHeaderLayer) SelectCellCommand(org.eclipse.nebula.widgets.nattable.selection.command.SelectCellCommand) ILayerCell(org.eclipse.nebula.widgets.nattable.layer.cell.ILayerCell) Test(org.junit.Test)

Example 18 with ILayerCell

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

the class StyleInheritanceTest method shouldFallBackToSuperTypeAttributesForEvenCell.

@Test
public void shouldFallBackToSuperTypeAttributesForEvenCell() {
    ILayerCell cell = this.natTable.getCellByPosition(2, 2);
    // Test cell even attributes
    final IStyle cellInstanceStyle = this.configRegistry.getConfigAttribute(CellConfigAttributes.CELL_STYLE, cell.getDisplayMode(), cell.getConfigLabels().getLabels());
    Assert.assertEquals(Display.getDefault().getSystemColor(SWT.COLOR_BLACK), cellInstanceStyle.getAttributeValue(CellStyleAttributes.FOREGROUND_COLOR));
    Assert.assertEquals(Display.getDefault().getSystemColor(SWT.COLOR_GRAY), cellInstanceStyle.getAttributeValue(CellStyleAttributes.BACKGROUND_COLOR));
    // Test super cell attributes
    StyleProxy cellProxy = new CellStyleProxy(this.configRegistry, cell.getDisplayMode(), cell.getConfigLabels().getLabels());
    final Font fontAttribute = cellProxy.getAttributeValue(CellStyleAttributes.FONT);
    Assert.assertEquals(FONT_DATA.getName(), fontAttribute.getFontData()[0].getName());
    Assert.assertEquals(FONT_DATA.getStyle(), fontAttribute.getFontData()[0].getStyle());
}
Also used : ILayerCell(org.eclipse.nebula.widgets.nattable.layer.cell.ILayerCell) Font(org.eclipse.swt.graphics.Font) Test(org.junit.Test)

Example 19 with ILayerCell

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

the class EditIntegrationTest method testNotEditableByDefault.

@Test
public void testNotEditableByDefault() {
    ILayerCell cell = this.natTable.getCellByPosition(4, 4);
    this.natTable.doCommand(new EditCellCommand(this.natTable, this.natTable.getConfigRegistry(), cell));
    assertNull(this.natTable.getActiveCellEditor());
    assertNull(ActiveCellEditorRegistry.getActiveCellEditor());
}
Also used : ILayerCell(org.eclipse.nebula.widgets.nattable.layer.cell.ILayerCell) EditCellCommand(org.eclipse.nebula.widgets.nattable.edit.command.EditCellCommand) Test(org.junit.Test)

Example 20 with ILayerCell

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

the class EditIntegrationTest method testNavigationUsingTabButtonWhenAnInvalidValueIsEntered.

@Test
public void testNavigationUsingTabButtonWhenAnInvalidValueIsEntered() throws InterruptedException {
    this.natTable.enableEditingOnAllCells();
    DataLayer bodyDataLayer = (DataLayer) this.gridLayerStack.getBodyDataLayer();
    this.natTable.registerLabelOnColumn(bodyDataLayer, 0, TEST_LABEL);
    this.natTable.getConfigRegistry().registerConfigAttribute(EditConfigAttributes.DATA_VALIDATOR, getStartingWithCValidator(), DisplayMode.EDIT, TEST_LABEL);
    // Start editing 1,1
    ILayerCell cell = this.natTable.getCellByPosition(1, 1);
    assertEquals("Col: 1, Row: 1", cell.getDataValue());
    this.natTable.doCommand(new SelectCellCommand(this.natTable, 1, 1, false, false));
    // Column position 1 - originally valid
    this.natTable.doCommand(new EditCellCommand(this.natTable, this.natTable.getConfigRegistry(), cell));
    assertTrue(this.natTable.getActiveCellEditor().validateCanonicalValue(cell.getDataValue()));
    // Set an invalid value in cell - AA
    Text textControl = ((Text) this.natTable.getActiveCellEditor().getEditorControl());
    textControl.setText("AA");
    assertEquals("AA", this.natTable.getActiveCellEditor().getCanonicalValue());
    assertFalse(this.natTable.getActiveCellEditor().validateCanonicalValue(this.natTable.getActiveCellEditor().getCanonicalValue()));
    // Press tab
    textControl.notifyListeners(SWT.Traverse, SWTUtils.keyEvent(SWT.TAB));
    assertEquals(textControl, this.natTable.getActiveCellEditor().getEditorControl());
    assertEquals("AA", this.natTable.getActiveCellEditor().getCanonicalValue());
    assertEquals(textControl, ActiveCellEditorRegistry.getActiveCellEditor().getEditorControl());
    assertEquals("AA", ActiveCellEditorRegistry.getActiveCellEditor().getCanonicalValue());
}
Also used : SpanningDataLayer(org.eclipse.nebula.widgets.nattable.layer.SpanningDataLayer) DataLayer(org.eclipse.nebula.widgets.nattable.layer.DataLayer) SelectCellCommand(org.eclipse.nebula.widgets.nattable.selection.command.SelectCellCommand) 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)

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