]> gerrit.simantics Code Review - simantics/district.git/blob - org.simantics.district.network.ui/src/org/simantics/district/network/ui/table/EditingSupportConfiguration.java
Fixed District diagram viewer to allow moving of vertices again.
[simantics/district.git] / org.simantics.district.network.ui / src / org / simantics / district / network / ui / table / EditingSupportConfiguration.java
1 package org.simantics.district.network.ui.table;
2
3 import org.eclipse.nebula.widgets.nattable.config.AbstractRegistryConfiguration;
4 import org.eclipse.nebula.widgets.nattable.config.IConfigRegistry;
5 import org.eclipse.nebula.widgets.nattable.config.IEditableRule;
6 import org.eclipse.nebula.widgets.nattable.edit.EditConfigAttributes;
7 import org.eclipse.nebula.widgets.nattable.layer.cell.ILayerCell;
8
9 public class EditingSupportConfiguration extends AbstractRegistryConfiguration {
10
11     private TableDataProvider bodyDataProvider;
12
13     public EditingSupportConfiguration(TableDataProvider bodyDataProvider) {
14         this.bodyDataProvider = bodyDataProvider;
15     }
16
17     @Override
18     public void configureRegistry(IConfigRegistry configRegistry) {
19         configRegistry.registerConfigAttribute(EditConfigAttributes.CELL_EDITABLE_RULE, new IEditableRule() {
20             @Override
21             public boolean isEditable(ILayerCell cell, IConfigRegistry configRegistry) {
22                 return bodyDataProvider.isEditable(cell.getColumnIndex(), cell.getRowIndex());
23             }
24
25             @Override
26             public boolean isEditable(int columnIndex, int rowIndex) {
27                 return bodyDataProvider.isEditable(columnIndex, rowIndex);
28             }
29         });
30     }
31
32 }