use of org.eclipse.nebula.widgets.nattable.edit.editor.TextCellEditor in project nebula.widgets.nattable by eclipse.
the class EditUtilsTest method testGetLastSelectedCellEditorWithMultiSelection.
@Test
public void testGetLastSelectedCellEditorWithMultiSelection() {
this.selectionLayer.selectCell(1, 1, false, true);
this.selectionLayer.selectCell(2, 2, false, true);
this.selectionLayer.selectCell(3, 3, false, true);
ICellEditor editor = EditUtils.getLastSelectedCellEditor(this.selectionLayer, this.natTable.getConfigRegistry());
assertNotNull(editor);
assertTrue(editor instanceof TextCellEditor);
}
use of org.eclipse.nebula.widgets.nattable.edit.editor.TextCellEditor in project nebula.widgets.nattable by eclipse.
the class EditUtilsTest method testGetLastSelectedCellEditorWithSingleSelection.
@Test
public void testGetLastSelectedCellEditorWithSingleSelection() {
this.selectionLayer.selectCell(1, 1, false, false);
ICellEditor editor = EditUtils.getLastSelectedCellEditor(this.selectionLayer, this.natTable.getConfigRegistry());
assertNotNull(editor);
assertTrue(editor instanceof TextCellEditor);
}
use of org.eclipse.nebula.widgets.nattable.edit.editor.TextCellEditor in project nebula.widgets.nattable by eclipse.
the class MultiCellEditDialogRunner method shouldOpenDefaultDialogWithoutIncrementDecrementBox.
public void shouldOpenDefaultDialogWithoutIncrementDecrementBox() {
CellFixture cell = new CellFixture();
cell.setBounds(new Rectangle(100, 100, 100, 20));
cell.setConfigLabels(new LabelStack("Cell_Edit"));
cell.setDataValue("123");
cell.setDisplayMode(DisplayMode.NORMAL);
TextCellEditor cellEditor = new TextCellEditor();
IDisplayConverter dataTypeConverter = new DisplayConverter() {
@Override
public Object canonicalToDisplayValue(Object canonicalValue) {
return canonicalValue;
}
@Override
public Object displayToCanonicalValue(Object displayValue) {
return displayValue;
}
};
final Character newValue = Character.valueOf('4');
IDataValidator dataValidator = new DataValidator() {
@Override
public boolean validate(int columnIndex, int rowIndex, Object newValue) {
Assert.assertEquals(newValue, newValue);
return false;
}
};
Shell shell = new Shell(Display.getDefault(), SWT.H_SCROLL | SWT.V_SCROLL | SWT.RESIZE);
ConfigRegistry configRegistry = new ConfigRegistry();
configRegistry.registerConfigAttribute(CellConfigAttributes.DISPLAY_CONVERTER, dataTypeConverter);
configRegistry.registerConfigAttribute(EditConfigAttributes.DATA_VALIDATOR, dataValidator);
final CellEditDialog dialog = new CellEditDialog(shell, newValue, cell, cellEditor, configRegistry);
if (!this.interactive) {
Display.getDefault().asyncExec(new Runnable() {
@Override
public void run() {
try {
Thread.sleep(100);
} catch (InterruptedException e) {
e.printStackTrace();
} finally {
dialog.close();
}
}
});
}
dialog.open();
}
use of org.eclipse.nebula.widgets.nattable.edit.editor.TextCellEditor in project nebula.widgets.nattable by eclipse.
the class EditTraversalStrategyUpDownTest method setUp.
@Before
public void setUp() {
// only use 10 columns to make the test cases easier
String[] propertyNames = Arrays.copyOfRange(RowDataListFixture.getPropertyNames(), 0, 10);
IRowDataProvider<RowDataFixture> bodyDataProvider = new ListDataProvider<>(RowDataListFixture.getList(10), new ReflectiveColumnPropertyAccessor<RowDataFixture>(propertyNames));
this.dataLayer = new DataLayer(bodyDataProvider, 20, 20);
this.selectionLayer = new SelectionLayer(this.dataLayer);
this.viewportLayer = new ViewportLayer(this.selectionLayer);
this.viewportLayer.setRegionName(GridRegion.BODY);
this.viewportLayer.addConfiguration(new DefaultEditBindings());
this.viewportLayer.addConfiguration(new DefaultEditConfiguration() {
@Override
public void configureRegistry(IConfigRegistry configRegistry) {
configRegistry.registerConfigAttribute(EditConfigAttributes.CELL_EDITOR, new TextCellEditor(true, true));
configRegistry.registerConfigAttribute(EditConfigAttributes.DATA_VALIDATOR, new DefaultDataValidator());
configRegistry.registerConfigAttribute(CellConfigAttributes.DISPLAY_CONVERTER, new DefaultBooleanDisplayConverter(), DisplayMode.NORMAL, ColumnLabelAccumulator.COLUMN_LABEL_PREFIX + 9);
}
});
this.natTable = new NatTableFixture(this.viewportLayer);
this.natTable.enableEditingOnAllCells();
this.natTable.getConfigRegistry().registerConfigAttribute(EditConfigAttributes.CELL_EDITABLE_RULE, IEditableRule.NEVER_EDITABLE, DisplayMode.EDIT, NOT_EDITABLE);
this.natTable.getConfigRegistry().registerConfigAttribute(EditConfigAttributes.OPEN_ADJACENT_EDITOR, Boolean.TRUE);
// register non editable rows
this.overrider = new RowOverrideLabelAccumulator<>(bodyDataProvider, new IRowIdAccessor<RowDataFixture>() {
@Override
public Serializable getRowId(RowDataFixture rowObject) {
return rowObject.getSecurity_id();
}
});
this.overrider.registerRowOverrides(2, NOT_EDITABLE);
this.overrider.registerRowOverrides(5, NOT_EDITABLE);
this.overrider.registerRowOverrides(6, NOT_EDITABLE);
this.overrider.registerRowOverrides(7, NOT_EDITABLE);
this.overrider.registerRowOverrides(8, NOT_EDITABLE);
this.overrider.registerRowOverrides(9, NOT_EDITABLE);
AggregateConfigLabelAccumulator accumulator = new AggregateConfigLabelAccumulator();
accumulator.add(this.overrider);
accumulator.add(new ColumnLabelAccumulator());
this.dataLayer.setConfigLabelAccumulator(accumulator);
}
use of org.eclipse.nebula.widgets.nattable.edit.editor.TextCellEditor in project nebula.widgets.nattable by eclipse.
the class EditIntegrationTest method testEditorActivatedDuringInlineCellEdit.
@Test
public void testEditorActivatedDuringInlineCellEdit() {
this.natTable.enableEditingOnAllCells();
ILayerCell cell = this.natTable.getCellByPosition(4, 4);
this.natTable.doCommand(new EditCellCommand(this.natTable, this.natTable.getConfigRegistry(), cell));
ICellEditor cellEditor = this.natTable.getActiveCellEditor();
assertNotNull(cellEditor);
assertTrue(cellEditor instanceof TextCellEditor);
TextCellEditor textCellEditor = (TextCellEditor) cellEditor;
assertEquals("Col: 4, Row: 4", textCellEditor.getCanonicalValue());
Control control = cellEditor.getEditorControl();
assertNotNull(control);
assertTrue(control instanceof Text);
}
Aggregations