Search in sources :

Example 1 with IEditor

use of org.eclipse.nebula.widgets.nattable.extension.builder.model.IEditor in project nebula.widgets.nattable by eclipse.

the class NatTableBuilder method configureEditing.

protected void configureEditing() {
    for (int colIndex = 0; colIndex < columns.length; colIndex++) {
        TableColumn column = columns[colIndex];
        if (column.isEditable) {
            IEditor editor = column.editor;
            // Column label has been registered already
            String columnLabel = BODY_COLUMN_LABEL_PREFIX + colIndex;
            configRegistry.registerConfigAttribute(EditConfigAttributes.CELL_EDITABLE_RULE, editor.getEditableRule(), DisplayMode.EDIT, columnLabel);
            configRegistry.registerConfigAttribute(EditConfigAttributes.DATA_VALIDATOR, editor.getValidator(), DisplayMode.EDIT, columnLabel);
            switch(editor.getType()) {
                case CHECKBOX:
                    configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_PAINTER, new CheckBoxPainter(), DisplayMode.NORMAL, columnLabel);
                    configRegistry.registerConfigAttribute(CellConfigAttributes.DISPLAY_CONVERTER, new DefaultBooleanDisplayConverter(), DisplayMode.NORMAL, columnLabel);
                    configRegistry.registerConfigAttribute(EditConfigAttributes.CELL_EDITOR, editor.getCellEditor(), DisplayMode.NORMAL, columnLabel);
                    break;
                case COMBO:
                    configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_PAINTER, new ComboBoxPainter(), DisplayMode.NORMAL, columnLabel);
                    configRegistry.registerConfigAttribute(EditConfigAttributes.CELL_EDITOR, editor.getCellEditor(), DisplayMode.NORMAL, columnLabel);
                    configRegistry.registerConfigAttribute(EditConfigAttributes.CELL_EDITOR, editor.getCellEditor(), DisplayMode.EDIT, columnLabel);
                    break;
                case TEXT:
                    configRegistry.registerConfigAttribute(EditConfigAttributes.CELL_EDITOR, new TextCellEditor());
                    break;
                default:
                    break;
            }
        }
    }
}
Also used : IEditor(org.eclipse.nebula.widgets.nattable.extension.builder.model.IEditor) DefaultBooleanDisplayConverter(org.eclipse.nebula.widgets.nattable.data.convert.DefaultBooleanDisplayConverter) CheckBoxPainter(org.eclipse.nebula.widgets.nattable.painter.cell.CheckBoxPainter) ComboBoxPainter(org.eclipse.nebula.widgets.nattable.painter.cell.ComboBoxPainter) TextCellEditor(org.eclipse.nebula.widgets.nattable.edit.editor.TextCellEditor) TableColumn(org.eclipse.nebula.widgets.nattable.extension.builder.model.TableColumn)

Aggregations

DefaultBooleanDisplayConverter (org.eclipse.nebula.widgets.nattable.data.convert.DefaultBooleanDisplayConverter)1 TextCellEditor (org.eclipse.nebula.widgets.nattable.edit.editor.TextCellEditor)1 IEditor (org.eclipse.nebula.widgets.nattable.extension.builder.model.IEditor)1 TableColumn (org.eclipse.nebula.widgets.nattable.extension.builder.model.TableColumn)1 CheckBoxPainter (org.eclipse.nebula.widgets.nattable.painter.cell.CheckBoxPainter)1 ComboBoxPainter (org.eclipse.nebula.widgets.nattable.painter.cell.ComboBoxPainter)1