import java.util.List;
import java.util.Objects;
import java.util.Set;
-import java.util.function.Consumer;
import java.util.stream.Collectors;
import org.eclipse.jface.layout.GridDataFactory;
import org.eclipse.nebula.widgets.nattable.config.AbstractRegistryConfiguration;
import org.eclipse.nebula.widgets.nattable.config.CellConfigAttributes;
import org.eclipse.nebula.widgets.nattable.config.DefaultNatTableStyleConfiguration;
+import org.eclipse.nebula.widgets.nattable.config.EditableRule;
import org.eclipse.nebula.widgets.nattable.config.IConfigRegistry;
-import org.eclipse.nebula.widgets.nattable.config.IEditableRule;
import org.eclipse.nebula.widgets.nattable.copy.command.CopyDataCommandHandler;
import org.eclipse.nebula.widgets.nattable.data.IDataProvider;
import org.eclipse.nebula.widgets.nattable.edit.EditConfigAttributes;
bodyDataLayer.setConfigLabelAccumulator(new IConfigLabelAccumulator() {
@Override
public void accumulateConfigLabels(LabelStack configLabels, int columnPosition, int rowPosition) {
- if (columnPosition == 0) {
+ if (bodyDataProvider.isCheckBoxColumn(columnPosition)) {
configLabels.addLabel(CHECK_BOX_LABEL);
} else if (validationResult != null && keyName != null) {
int keyColumn = bodyDataProvider.getVariableIndex(keyName);
cellStyle.setAttributeValue(CellStyleAttributes.BACKGROUND_COLOR, GUIHelper.COLOR_RED);
configRegistry.registerConfigAttribute(EditConfigAttributes.CELL_EDITABLE_RULE,
- IEditableRule.ALWAYS_EDITABLE);
+ new EditableRule() {
+ @Override
+ public boolean isEditable(int columnIndex, int rowIndex) {
+ return bodyDataProvider.isEditable(columnIndex, rowIndex);
+ }
+ });
configRegistry.registerConfigAttribute(
CellConfigAttributes.CELL_STYLE,
LOGGER.error("Failed to read possible tech type key name for {}", componentType, e);
}
}
- return keyName.startsWith("_") ? keyName.substring(1) : keyName;
+ return keyName != null && keyName.startsWith("_") ? keyName.substring(1) : keyName;
}
@Override
super.dispose();
}
+ public Resource getComponentType() {
+ return this.componentType;
+ }
+
public void setComponentType(Resource componentType) {
if (Objects.equals(this.componentType, componentType))
return;
this.componentType = componentType;
this.keyName = getKeyColumnName(componentType);
-
- Simantics.getSession().asyncRequest(new TableDataRequest(componentType), new TableDataListener(componentType));
+
+ if (componentType != null) {
+ Simantics.getSession().asyncRequest(new TableDataRequest(componentType), new TableDataListener(componentType));
+ }
}
private final class TableDataListener implements Listener<Triple<Resource, String, List<Integer>>> {
@Override
public void execute(Triple<Resource, String, List<Integer>> result) {
TechTypeTable.this.getDisplay().asyncExec(() -> {
+ if (isDisposed() || result == null)
+ return;
+
TechTypeTable.this.tableResource = result.first;
String data = result.second;
int[] enabled = result.third.stream().mapToInt(Integer::intValue).toArray();