Search in sources :

Example 66 with ILayerCell

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

the class CompositeLayerTest method getCellByPosition.

@Test
public void getCellByPosition() throws Exception {
    ILayerCell cell = this.layerFixture.getCellByPosition(3, 2);
    assertIsCorner(cell.getLayer());
    assertEquals("[3, 2]", cell.getDataValue());
    // pixel
    assertEquals(new Rectangle(15, 10, 5, 5), cell.getBounds());
    // values
    assertEquals(DisplayMode.NORMAL, cell.getDisplayMode());
    // Get a cell from the body
    cell = this.layerFixture.getCellByPosition(8, 8);
    assertTrue(cell.getLayer() instanceof CompositeLayer);
    assertEquals("[3, 1]", cell.getDataValue());
    assertEquals(new Rectangle(310, 75, 100, 70), cell.getBounds());
    assertEquals(DisplayMode.NORMAL, cell.getDisplayMode());
    assertEquals(8, cell.getOriginColumnPosition());
    assertEquals(8, cell.getOriginRowPosition());
}
Also used : Rectangle(org.eclipse.swt.graphics.Rectangle) ILayerCell(org.eclipse.nebula.widgets.nattable.layer.cell.ILayerCell) Test(org.junit.Test)

Example 67 with ILayerCell

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

the class ColumnGroupHeaderLayerTest method getCellForACellInAColumnGroup.

@Test
public void getCellForACellInAColumnGroup() {
    ILayerCell cell = this.columnGroupLayer.getCellByPosition(0, 0);
    assertEquals(TEST_GROUP_NAME_1, cell.getDataValue());
    assertEquals(0, cell.getBounds().x);
    assertEquals(0, cell.getBounds().y);
    assertEquals(200, cell.getBounds().width);
    assertEquals(20, cell.getBounds().height);
    cell = this.columnGroupLayer.getCellByPosition(1, 0);
    assertEquals(TEST_GROUP_NAME_1, cell.getDataValue());
    assertEquals(0, 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 68 with ILayerCell

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

the class BoxingStyleTest method retreivedCellShouldHaveTopAlignment.

// Vertical alignment
@Test
public void retreivedCellShouldHaveTopAlignment() {
    // Register vertical alignment
    final VerticalAlignmentEnum vAlignment = VerticalAlignmentEnum.TOP;
    this.cellStyle.setAttributeValue(CellStyleAttributes.VERTICAL_ALIGNMENT, vAlignment);
    this.configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_STYLE, this.cellStyle, DisplayMode.NORMAL, AlternatingRowConfigLabelAccumulator.EVEN_ROW_CONFIG_TYPE);
    // Check cell vertical alignment
    ILayerCell cell = this.natTable.getCellByPosition(2, 3);
    Assert.assertEquals(vAlignment.name(), this.configRegistry.getConfigAttribute(CellConfigAttributes.CELL_STYLE, cell.getDisplayMode(), cell.getConfigLabels().getLabels()).getAttributeValue(CellStyleAttributes.VERTICAL_ALIGNMENT).name());
}
Also used : VerticalAlignmentEnum(org.eclipse.nebula.widgets.nattable.style.VerticalAlignmentEnum) ILayerCell(org.eclipse.nebula.widgets.nattable.layer.cell.ILayerCell) Test(org.junit.Test)

Example 69 with ILayerCell

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

the class BoxingStyleTest method retrievedCellShouldHaveConfiguredBackground.

// Background color
@Test
public void retrievedCellShouldHaveConfiguredBackground() {
    // Register background color for body cells in normal mode
    final Color backgroundColor = Display.getDefault().getSystemColor(SWT.COLOR_GRAY);
    this.cellStyle.setAttributeValue(CellStyleAttributes.BACKGROUND_COLOR, backgroundColor);
    this.configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_STYLE, this.cellStyle, DisplayMode.NORMAL, AlternatingRowConfigLabelAccumulator.ODD_ROW_CONFIG_TYPE);
    // Check for background color styling
    ILayerCell cell = this.natTable.getCellByPosition(2, 2);
    IStyle cellStyle = this.configRegistry.getConfigAttribute(CellConfigAttributes.CELL_STYLE, cell.getDisplayMode(), cell.getConfigLabels().getLabels());
    Assert.assertEquals(backgroundColor, cellStyle.getAttributeValue(CellStyleAttributes.BACKGROUND_COLOR));
    // set up painter
    this.cellPainter.setupGCFromConfig(this.gc, cellStyle);
    Assert.assertEquals(backgroundColor, this.gc.getBackground());
}
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 70 with ILayerCell

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

the class ConfigurableCellBorderTest method shouldReturnASelectedCellWithDottedLineStyling.

@Test
public void shouldReturnASelectedCellWithDottedLineStyling() {
    Style cellStyle = new Style();
    final BorderStyle defaultBorderStyle = new BorderStyle(13, GUIHelper.COLOR_YELLOW, LineStyleEnum.DOTTED);
    cellStyle.setAttributeValue(CellStyleAttributes.BORDER_STYLE, defaultBorderStyle);
    // Register line styling for body cells in selection mode
    this.configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_STYLE, cellStyle, DisplayMode.SELECT, SelectionStyleLabels.SELECTION_ANCHOR_STYLE);
    // Select and access cell
    this.natTable.doCommand(new SelectCellCommand(this.natTable, 2, 2, false, false));
    ILayerCell cell = this.natTable.getCellByPosition(2, 2);
    Assert.assertEquals(DisplayMode.SELECT, cell.getDisplayMode());
    // Check for line styling
    Assert.assertEquals(defaultBorderStyle, this.configRegistry.getConfigAttribute(CellConfigAttributes.CELL_STYLE, cell.getDisplayMode(), cell.getConfigLabels().getLabels()).getAttributeValue(CellStyleAttributes.BORDER_STYLE));
}
Also used : BorderStyle(org.eclipse.nebula.widgets.nattable.style.BorderStyle) SelectCellCommand(org.eclipse.nebula.widgets.nattable.selection.command.SelectCellCommand) Style(org.eclipse.nebula.widgets.nattable.style.Style) BorderStyle(org.eclipse.nebula.widgets.nattable.style.BorderStyle) 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