package org.simantics.district.network.ui.table; import org.eclipse.nebula.widgets.nattable.config.AbstractRegistryConfiguration; import org.eclipse.nebula.widgets.nattable.config.IConfigRegistry; import org.eclipse.nebula.widgets.nattable.config.IEditableRule; import org.eclipse.nebula.widgets.nattable.edit.EditConfigAttributes; import org.eclipse.nebula.widgets.nattable.layer.cell.ILayerCell; public class EditingSupportConfiguration extends AbstractRegistryConfiguration { private TableDataProvider bodyDataProvider; public EditingSupportConfiguration(TableDataProvider bodyDataProvider) { this.bodyDataProvider = bodyDataProvider; } @Override public void configureRegistry(IConfigRegistry configRegistry) { configRegistry.registerConfigAttribute(EditConfigAttributes.CELL_EDITABLE_RULE, new IEditableRule() { @Override public boolean isEditable(ILayerCell cell, IConfigRegistry configRegistry) { return bodyDataProvider.isEditable(cell.getColumnIndex(), cell.getRowIndex()); } @Override public boolean isEditable(int columnIndex, int rowIndex) { return bodyDataProvider.isEditable(columnIndex, rowIndex); } }); } }