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());
}
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);
}
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());
}
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());
}
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));
}
Aggregations