use of org.eclipse.nebula.widgets.nattable.edit.command.EditCellCommand 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.edit.command.EditCellCommand in project nebula.widgets.nattable by eclipse.
the class EditIntegrationTest method testEditorClosesWhenANewEditCommandIsFired.
@Test
public void testEditorClosesWhenANewEditCommandIsFired() {
// Even rows are editable, Odd rows are not
this.natTable.getConfigRegistry().registerConfigAttribute(EditConfigAttributes.CELL_EDITABLE_RULE, IEditableRule.ALWAYS_EDITABLE, DisplayMode.NORMAL, AlternatingRowConfigLabelAccumulator.EVEN_ROW_CONFIG_TYPE);
this.natTable.getConfigRegistry().registerConfigAttribute(EditConfigAttributes.CELL_EDITABLE_RULE, IEditableRule.NEVER_EDITABLE, DisplayMode.NORMAL, AlternatingRowConfigLabelAccumulator.ODD_ROW_CONFIG_TYPE);
this.natTable.doCommand(new EditCellCommand(this.natTable, this.natTable.getConfigRegistry(), this.natTable.getCellByPosition(4, COLUMN_HEADER_ROW_COUNT + 2)));
assertNotNull(this.natTable.getActiveCellEditor());
assertNotNull(ActiveCellEditorRegistry.getActiveCellEditor());
this.natTable.doCommand(new EditCellCommand(this.natTable, this.natTable.getConfigRegistry(), this.natTable.getCellByPosition(4, COLUMN_HEADER_ROW_COUNT + 3)));
assertNotNull(this.natTable.getActiveCellEditor());
assertFalse(this.natTable.getActiveCellEditor().isClosed());
assertNotNull(ActiveCellEditorRegistry.getActiveCellEditor());
assertFalse(ActiveCellEditorRegistry.getActiveCellEditor().isClosed());
}
use of org.eclipse.nebula.widgets.nattable.edit.command.EditCellCommand 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());
}
use of org.eclipse.nebula.widgets.nattable.edit.command.EditCellCommand in project nebula.widgets.nattable by eclipse.
the class EditIntegrationTest method testEditorRegisteredInActiveCellEditorRegistry.
/**
* Test case that ensures that the active editor is also available via the
* {@linkplain ActiveCellEditorRegistry}.
* <p>
* Ensures that the backward compatibility is not broken.
* </p>
*/
@Test
public void testEditorRegisteredInActiveCellEditorRegistry() {
this.natTable.enableEditingOnAllCells();
ILayerCell cell = this.natTable.getCellByPosition(4, 4);
this.natTable.doCommand(new EditCellCommand(this.natTable, this.natTable.getConfigRegistry(), cell));
assertNotNull(this.natTable.getActiveCellEditor());
assertNotNull(ActiveCellEditorRegistry.getActiveCellEditor());
assertEquals(this.natTable.getActiveCellEditor(), ActiveCellEditorRegistry.getActiveCellEditor());
// Close the editor again
this.natTable.getActiveCellEditor().getEditorControl().notifyListeners(SWT.KeyDown, SWTUtils.keyEvent(SWT.CR));
assertNull(this.natTable.getActiveCellEditor());
assertNull(ActiveCellEditorRegistry.getActiveCellEditor());
}
use of org.eclipse.nebula.widgets.nattable.edit.command.EditCellCommand in project nebula.widgets.nattable by eclipse.
the class CellEditDragMode method mouseUp.
@Override
public void mouseUp(NatTable natTable, MouseEvent event) {
super.mouseUp(natTable, event);
int columnPosition = natTable.getColumnPositionByX(event.x);
int rowPosition = natTable.getRowPositionByY(event.y);
if (columnPosition == this.originalColumnPosition && rowPosition == this.originalRowPosition) {
natTable.doCommand(new EditCellCommand(natTable, natTable.getConfigRegistry(), natTable.getCellByPosition(columnPosition, rowPosition)));
}
}
Aggregations