Search in sources :

Example 11 with EditCellCommand

use of org.eclipse.nebula.widgets.nattable.edit.command.EditCellCommand 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 12 with EditCellCommand

use of org.eclipse.nebula.widgets.nattable.edit.command.EditCellCommand in project nebula.widgets.nattable by eclipse.

the class MouseEditAction method run.

@Override
public void run(NatTable natTable, MouseEvent event) {
    int columnPosition = natTable.getColumnPositionByX(event.x);
    int rowPosition = natTable.getRowPositionByY(event.y);
    natTable.doCommand(new EditCellCommand(natTable, natTable.getConfigRegistry(), natTable.getCellByPosition(columnPosition, rowPosition)));
}
Also used : EditCellCommand(org.eclipse.nebula.widgets.nattable.edit.command.EditCellCommand)

Aggregations

EditCellCommand (org.eclipse.nebula.widgets.nattable.edit.command.EditCellCommand)12 Test (org.junit.Test)10 ILayerCell (org.eclipse.nebula.widgets.nattable.layer.cell.ILayerCell)9 Text (org.eclipse.swt.widgets.Text)4 DataLayer (org.eclipse.nebula.widgets.nattable.layer.DataLayer)2 SpanningDataLayer (org.eclipse.nebula.widgets.nattable.layer.SpanningDataLayer)2 SelectCellCommand (org.eclipse.nebula.widgets.nattable.selection.command.SelectCellCommand)2 PositionCoordinate (org.eclipse.nebula.widgets.nattable.coordinate.PositionCoordinate)1 ICellEditor (org.eclipse.nebula.widgets.nattable.edit.editor.ICellEditor)1 TextCellEditor (org.eclipse.nebula.widgets.nattable.edit.editor.TextCellEditor)1 DummyGridLayerStack (org.eclipse.nebula.widgets.nattable.layer.stack.DummyGridLayerStack)1 ColumnResizeCommand (org.eclipse.nebula.widgets.nattable.resize.command.ColumnResizeCommand)1 NatTableFixture (org.eclipse.nebula.widgets.nattable.test.fixture.NatTableFixture)1 Rectangle (org.eclipse.swt.graphics.Rectangle)1 Control (org.eclipse.swt.widgets.Control)1