Search in sources :

Example 6 with ILayerCell

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

the class TextRenderingTest method verifyFontAttributes.

private void verifyFontAttributes() {
    // Check cell font attributes
    ILayerCell cell = this.natTable.getCellByPosition(2, 2);
    final FontData expectedFontData = this.defaultFont.getFontData()[0];
    IStyle cellStyle = this.configRegistry.getConfigAttribute(CellConfigAttributes.CELL_STYLE, cell.getDisplayMode(), cell.getConfigLabels().getLabels());
    final FontData actualFontData = cellStyle.getAttributeValue(CellStyleAttributes.FONT).getFontData()[0];
    Assert.assertEquals(actualFontData.getName(), expectedFontData.getName());
    Assert.assertEquals(actualFontData.getHeight(), expectedFontData.getHeight());
    Assert.assertEquals(actualFontData.getStyle(), expectedFontData.getStyle());
    // Draw font
    this.cellPainter.setupGCFromConfig(this.gc, cellStyle);
    final FontData exepectedDrawnFontData = this.gc.getFont().getFontData()[0];
    Assert.assertEquals(actualFontData.getName(), exepectedDrawnFontData.getName());
    Assert.assertEquals(actualFontData.getHeight(), exepectedDrawnFontData.getHeight());
    Assert.assertEquals(actualFontData.getStyle(), exepectedDrawnFontData.getStyle());
}
Also used : IStyle(org.eclipse.nebula.widgets.nattable.style.IStyle) FontData(org.eclipse.swt.graphics.FontData) ILayerCell(org.eclipse.nebula.widgets.nattable.layer.cell.ILayerCell)

Example 7 with ILayerCell

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

the class SelectionUtilsTest method testGetBottomRightSelectDifferentColumns.

@Test
public void testGetBottomRightSelectDifferentColumns() {
    DataLayer dataLayer = new DataLayer(new DataProviderFixture(10, 10));
    SelectionLayer selectionLayer = new SelectionLayer(dataLayer);
    // select cells for same columns in non consecutive rows
    selectionLayer.selectRegion(2, 2, 1, 3);
    selectionLayer.selectRegion(4, 4, 1, 3);
    assertEquals(6, selectionLayer.getSelectedCells().size());
    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 8 with ILayerCell

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

the class SelectionUtilsTest method testGetBottomRightSelectRegion.

@Test
public void testGetBottomRightSelectRegion() {
    DataLayer dataLayer = new DataLayer(new DataProviderFixture(10, 10));
    SelectionLayer selectionLayer = new SelectionLayer(dataLayer);
    // select region
    selectionLayer.selectRegion(2, 2, 3, 3);
    ILayerCell bottomRight = SelectionUtils.getBottomRightCellInSelection(selectionLayer);
    assertEquals(4, bottomRight.getColumnPosition());
    assertEquals(4, 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 9 with ILayerCell

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

the class SelectionUtilsTest method testGetBottomRightSelectRegionDeselectMiddle.

@Test
public void testGetBottomRightSelectRegionDeselectMiddle() {
    DataLayer dataLayer = new DataLayer(new DataProviderFixture(10, 10));
    SelectionLayer selectionLayer = new SelectionLayer(dataLayer);
    // select region
    selectionLayer.selectRegion(2, 2, 3, 3);
    // deselect a cell
    selectionLayer.clearSelection(3, 3);
    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 10 with ILayerCell

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

the class SelectionUtilsTest method testGetBottomRightSelectRegionDeselectMiddleBottomEdge.

@Test
public void testGetBottomRightSelectRegionDeselectMiddleBottomEdge() {
    DataLayer dataLayer = new DataLayer(new DataProviderFixture(10, 10));
    SelectionLayer selectionLayer = new SelectionLayer(dataLayer);
    // select region
    selectionLayer.selectRegion(2, 2, 3, 3);
    // deselect a cell
    selectionLayer.clearSelection(4, 4);
    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)

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