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=7438269aba7071990b2b052cc21c539725d48d3d;hb=669fec715190918badd9d4f90575a6b703aa6b9f;hp=a8db44c789200fb8015596916ade28ed8283e9fa;hpb=b84a03e5c4452c82c718644423373c0d7e2a1e62;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 a8db44c7..7438269a 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 @@ -325,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 @@ -334,14 +334,20 @@ public class TechTypeTable extends Composite { 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>> { @@ -354,6 +360,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();