Search in sources :

Example 81 with ILayerCell

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

the class EditIntegrationTest method navigationWithTab.

@Test
public void navigationWithTab() throws Exception {
    this.natTable.enableEditingOnAllCells();
    this.natTable.doCommand(new SelectCellCommand(this.natTable, 1, 1, false, false));
    // Edit cell
    ILayerCell cell = this.natTable.getCellByPosition(1, 1);
    this.natTable.doCommand(new EditCellCommand(this.natTable, this.natTable.getConfigRegistry(), cell));
    // Press tab - 3 times
    Text textControl = ((Text) this.natTable.getActiveCellEditor().getEditorControl());
    textControl.notifyListeners(SWT.Traverse, SWTUtils.keyEvent(SWT.TAB));
    this.natTable.notifyListeners(SWT.KeyDown, SWTUtils.keyEvent(SWT.TAB));
    this.natTable.notifyListeners(SWT.KeyDown, SWTUtils.keyEvent(SWT.TAB));
    this.natTable.notifyListeners(SWT.KeyDown, SWTUtils.keyEvent(SWT.TAB));
    // Verify new cell selection
    PositionCoordinate lastSelectedCellPosition = this.gridLayerStack.getBodyLayer().getSelectionLayer().getSelectionAnchor();
    assertEquals(4, lastSelectedCellPosition.columnPosition);
    assertEquals(0, lastSelectedCellPosition.rowPosition);
    // Verify that no cell is being edited
    assertNull(this.natTable.getActiveCellEditor());
    assertNull(ActiveCellEditorRegistry.getActiveCellEditor());
}
Also used : SelectCellCommand(org.eclipse.nebula.widgets.nattable.selection.command.SelectCellCommand) PositionCoordinate(org.eclipse.nebula.widgets.nattable.coordinate.PositionCoordinate) Text(org.eclipse.swt.widgets.Text) ILayerCell(org.eclipse.nebula.widgets.nattable.layer.cell.ILayerCell) EditCellCommand(org.eclipse.nebula.widgets.nattable.edit.command.EditCellCommand) Test(org.junit.Test)

Example 82 with ILayerCell

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

the class EditIntegrationTest method testEditorRemovedWhenCommitted.

/**
 * Test case that ensures that an editor, which is committed through the
 * {@linkplain EditUtils}, is also removed from the table.
 * <p>
 * Ensures that the backward compatibility is not broken.
 * </p>
 */
@Test
public void testEditorRemovedWhenCommitted() {
    this.natTable.enableEditingOnAllCells();
    ILayerCell cell = this.natTable.getCellByPosition(4, 4);
    this.natTable.doCommand(new EditCellCommand(this.natTable, this.natTable.getConfigRegistry(), cell));
    Text editor = (Text) this.natTable.getActiveCellEditor().getEditorControl();
    editor.setText("A");
    // Close the again
    EditUtils.commitAndCloseActiveEditor();
    // check if value is saved and editor is gone
    assertEquals("A", this.natTable.getCellByPosition(4, 4).getDataValue());
    assertNull(this.natTable.getActiveCellEditor());
    assertNull(ActiveCellEditorRegistry.getActiveCellEditor());
}
Also used : Text(org.eclipse.swt.widgets.Text) ILayerCell(org.eclipse.nebula.widgets.nattable.layer.cell.ILayerCell) EditCellCommand(org.eclipse.nebula.widgets.nattable.edit.command.EditCellCommand) Test(org.junit.Test)

Example 83 with ILayerCell

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

the class EditIntegrationTest method testEditorRemovedWhenClosed.

/**
 * Test case that ensures that an editor, which is closed via API, is also
 * removed from the table.
 * <p>
 * Ensures that the backward compatibility is not broken.
 * </p>
 */
@Test
public void testEditorRemovedWhenClosed() {
    this.natTable.enableEditingOnAllCells();
    ILayerCell cell = this.natTable.getCellByPosition(4, 4);
    this.natTable.doCommand(new EditCellCommand(this.natTable, this.natTable.getConfigRegistry(), cell));
    // close the editor
    ActiveCellEditorRegistry.getActiveCellEditor().close();
    // check if editor is gone
    assertNull(this.natTable.getActiveCellEditor());
    assertNull(ActiveCellEditorRegistry.getActiveCellEditor());
}
Also used : ILayerCell(org.eclipse.nebula.widgets.nattable.layer.cell.ILayerCell) EditCellCommand(org.eclipse.nebula.widgets.nattable.edit.command.EditCellCommand) Test(org.junit.Test)

Example 84 with ILayerCell

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

the class EditIntegrationTest method testEditorResize.

@Test
public void testEditorResize() {
    this.natTable.enableEditingOnAllCells();
    ILayerCell cell = this.natTable.getCellByPosition(4, 4);
    this.natTable.doCommand(new EditCellCommand(this.natTable, this.natTable.getConfigRegistry(), cell));
    assertEquals(new Rectangle(340, 80, 99, 19), this.natTable.getActiveCellEditor().getEditorControl().getBounds());
    this.natTable.doCommand(new ColumnResizeCommand(this.natTable, 2, 110));
    assertEquals(new Rectangle(340, 80, 99, 19), this.natTable.getActiveCellEditor().getEditorControl().getBounds());
    this.natTable.getActiveCellEditor().getEditorControl().notifyListeners(SWT.FocusOut, null);
    // ActiveCellEditor should be closed if a ColumnResizeCommand is
    // executed and the editor loses focus
    assertNull(this.natTable.getActiveCellEditor());
    assertNull(ActiveCellEditorRegistry.getActiveCellEditor());
}
Also used : ColumnResizeCommand(org.eclipse.nebula.widgets.nattable.resize.command.ColumnResizeCommand) Rectangle(org.eclipse.swt.graphics.Rectangle) ILayerCell(org.eclipse.nebula.widgets.nattable.layer.cell.ILayerCell) EditCellCommand(org.eclipse.nebula.widgets.nattable.edit.command.EditCellCommand) Test(org.junit.Test)

Example 85 with ILayerCell

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

the class SelectAllTest method shouldHaveAllCellsSelected.

@Test
public void shouldHaveAllCellsSelected() {
    for (int columnPosition = 0; columnPosition < this.selectionLayer.getColumnCount(); columnPosition++) {
        for (int rowPosition = 0; rowPosition < this.selectionLayer.getRowCount(); rowPosition++) {
            ILayerCell cell = this.selectionLayer.getCellByPosition(columnPosition, rowPosition);
            Assert.assertEquals(DisplayMode.SELECT, cell.getDisplayMode());
        }
    }
}
Also used : 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