2017-10-10 63 views
0

我在學習如何在星雲NatTable中啓用單元格編輯功能。我編輯_301_CustomDataProviderExample :: createExampleControl顯示此功能:在星雲中啓用單元格編輯NatTable

@Override 
public Control createExampleControl(Composite parent) { 
    //... 
    final NatTable natTable = new NatTable(parent, SWT.NO_BACKGROUND 
       | SWT.NO_REDRAW_RESIZE | SWT.DOUBLE_BUFFERED, bodyDataLayer, false); 

    natTable.addConfiguration(new DefaultNatTableStyleConfiguration()); 

    natTable.addConfiguration(new AbstractRegistryConfiguration() { 
     @Override 
     public void configureRegistry(IConfigRegistry configRegistry) { 
      configRegistry.registerConfigAttribute(
        EditConfigAttributes.CELL_EDITABLE_RULE, 
        IEditableRule.ALWAYS_EDITABLE); 
     } 
    }); 

    natTable.configure(); 

    return natTable; 
} 

但運行例子的時候,我不能編輯細胞。我錯過了什麼?謝謝!

更新:我對這種情況下的解決方案是:

bodyDataLayer.addConfiguration(new DefaultEditConfiguration()); 
    bodyDataLayer.addConfiguration(new DefaultEditBindings()); 

注意:沒有這些配置添加到java.lang.ClassCastException的natTable原因:org.eclipse.nebula.widgets。 nattable.NatTable不能轉換爲org.eclipse.nebula.widgets.nattable.layer.AbstractLayer

回答