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