Search in sources :

Example 1 with ILayerCell

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

the class CopyDataCommandHandlerTest method checkColumnHeaderCells.

private void checkColumnHeaderCells(ILayerCell[] cells) {
    // First cell should be blank, this is the corner
    assertNull(cells[0]);
    // Should only have Column headers
    int[] selectedColumns = this.gridLayer.getBodyLayer().getSelectionLayer().getSelectedColumnPositions();
    for (int columnPosition = 1; columnPosition < cells.length; columnPosition++) {
        ILayerCell cell = cells[columnPosition];
        // Remember to substract offset from columnPosition
        assertEquals(this.columnHeaderLayer.getDataValueByPosition(selectedColumns[columnPosition - 1], 0), cell.getDataValue());
    }
}
Also used : ILayerCell(org.eclipse.nebula.widgets.nattable.layer.cell.ILayerCell)

Example 2 with ILayerCell

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

the class RowSelectionEditUtilsTest method testGetLastSelectedCellWithSingleSelection.

@Test
public void testGetLastSelectedCellWithSingleSelection() {
    this.selectionLayer.selectCell(1, 1, false, false);
    ILayerCell cell = EditUtils.getLastSelectedCell(this.selectionLayer);
    assertNotNull(cell);
    assertEquals(1, cell.getColumnIndex());
    assertEquals(1, cell.getRowIndex());
}
Also used : ILayerCell(org.eclipse.nebula.widgets.nattable.layer.cell.ILayerCell) Test(org.junit.Test)

Example 3 with ILayerCell

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

the class ColumnGroupHeaderLayerTest method getCellForACellNotInAColumnGroup.

@Test
public void getCellForACellNotInAColumnGroup() {
    ILayerCell cell = this.columnGroupLayer.getCellByPosition(5, 0);
    assertEquals(500, cell.getBounds().x);
    assertEquals(0, cell.getBounds().y);
    assertEquals(200, cell.getBounds().width);
    assertEquals(20, cell.getBounds().height);
}
Also used : ILayerCell(org.eclipse.nebula.widgets.nattable.layer.cell.ILayerCell) Test(org.junit.Test)

Example 4 with ILayerCell

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

the class BoxingStyleTest method retrievedCellShouldHaveConfiguredForegroundColor.

// Foreground color
@Test
public void retrievedCellShouldHaveConfiguredForegroundColor() {
    // Register foreground color for body cells in normal mode
    final Color foregroundColor = Display.getDefault().getSystemColor(SWT.COLOR_BLACK);
    this.cellStyle.setAttributeValue(CellStyleAttributes.FOREGROUND_COLOR, foregroundColor);
    this.configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_STYLE, this.cellStyle, DisplayMode.NORMAL, AlternatingRowConfigLabelAccumulator.ODD_ROW_CONFIG_TYPE);
    // Check cell foreground color
    ILayerCell cell = this.natTable.getCellByPosition(2, 2);
    IStyle cellStyle = this.configRegistry.getConfigAttribute(CellConfigAttributes.CELL_STYLE, cell.getDisplayMode(), cell.getConfigLabels().getLabels());
    Assert.assertEquals(foregroundColor, cellStyle.getAttributeValue(CellStyleAttributes.FOREGROUND_COLOR));
    // set up painter
    this.cellPainter.setupGCFromConfig(this.gc, cellStyle);
    Assert.assertEquals(foregroundColor, this.gc.getForeground());
}
Also used : IStyle(org.eclipse.nebula.widgets.nattable.style.IStyle) Color(org.eclipse.swt.graphics.Color) ILayerCell(org.eclipse.nebula.widgets.nattable.layer.cell.ILayerCell) Test(org.junit.Test)

Example 5 with ILayerCell

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

the class BoxingStyleTest method retreivedCellShouldHaveRightAlignment.

// Horizontal alignment
@Test
public void retreivedCellShouldHaveRightAlignment() {
    // Register horizontal alignment
    final HorizontalAlignmentEnum hAlignment = HorizontalAlignmentEnum.RIGHT;
    this.cellStyle.setAttributeValue(CellStyleAttributes.HORIZONTAL_ALIGNMENT, hAlignment);
    this.configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_STYLE, this.cellStyle, DisplayMode.NORMAL, AlternatingRowConfigLabelAccumulator.ODD_ROW_CONFIG_TYPE);
    // Check cell horizontal alignment
    ILayerCell cell = this.natTable.getCellByPosition(2, 2);
    Assert.assertEquals(hAlignment.name(), this.configRegistry.getConfigAttribute(CellConfigAttributes.CELL_STYLE, cell.getDisplayMode(), cell.getConfigLabels().getLabels()).getAttributeValue(CellStyleAttributes.HORIZONTAL_ALIGNMENT).name());
}
Also used : HorizontalAlignmentEnum(org.eclipse.nebula.widgets.nattable.style.HorizontalAlignmentEnum) ILayerCell(org.eclipse.nebula.widgets.nattable.layer.cell.ILayerCell) 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