X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=org.simantics.district.network.ui%2Fsrc%2Forg%2Fsimantics%2Fdistrict%2Fnetwork%2Fui%2Ftechtype%2Ftable%2FTechTypeTable.java;h=b18e10c8d63f50c8971ef2fd90150ae783b37e69;hb=85f9ed92b6332c3e539d9736d1536d5714444d69;hp=fa0a1acb4632957bd329bcc6f4e4d11ca9beedbb;hpb=29af77f249a4842bfd3f9280755121c9c98b32a1;p=simantics%2Fdistrict.git diff --git a/org.simantics.district.network.ui/src/org/simantics/district/network/ui/techtype/table/TechTypeTable.java b/org.simantics.district.network.ui/src/org/simantics/district/network/ui/techtype/table/TechTypeTable.java index fa0a1acb..b18e10c8 100644 --- a/org.simantics.district.network.ui/src/org/simantics/district/network/ui/techtype/table/TechTypeTable.java +++ b/org.simantics.district.network.ui/src/org/simantics/district/network/ui/techtype/table/TechTypeTable.java @@ -8,7 +8,6 @@ import java.util.Arrays; 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; @@ -17,8 +16,8 @@ import org.eclipse.nebula.widgets.nattable.NatTable; 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; @@ -268,7 +267,12 @@ public class TechTypeTable extends Composite { 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 columnIndex == 0; + } + }); configRegistry.registerConfigAttribute( CellConfigAttributes.CELL_STYLE, @@ -321,7 +325,7 @@ public class TechTypeTable extends Composite { 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 @@ -336,8 +340,10 @@ public class TechTypeTable extends Composite { 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>> { @@ -350,6 +356,9 @@ public class TechTypeTable extends Composite { @Override public void execute(Triple> 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();