]> gerrit.simantics Code Review - simantics/district.git/blobdiff - org.simantics.district.network.ui/src/org/simantics/district/network/ui/techtype/adapters/TechTypeEditorAdapter.java
Handle tech type tables with no component type
[simantics/district.git] / org.simantics.district.network.ui / src / org / simantics / district / network / ui / techtype / adapters / TechTypeEditorAdapter.java
index 6ab176ede84979537a7b1dc303cbcfcf8984afd7..fcd6a7e259075f81894f1613ee4d9699071e97b5 100644 (file)
@@ -64,10 +64,18 @@ public class TechTypeEditorAdapter extends AbstractResourceEditorAdapter impleme
                                public void run(ReadGraph graph) throws DatabaseException {
                                        DistrictNetworkResource DN = DistrictNetworkResource.getInstance(graph);
                                        Resource componentType = graph.getPossibleObject(table, DN.TechType_TechTypeTable_HasComponentType);
-
-                                       TechTypeTableView.table.getDisplay().asyncExec(() -> {
-                                               TechTypeTableView.table.setComponentType(componentType);
-                                       });
+                                       if (componentType != null) {
+                                               TechTypeTableView.table.getDisplay().asyncExec(() -> {
+                                                       TechTypeTableView.table.setComponentType(componentType);
+                                               });
+                                       } else {
+                                               String data = graph.getRelatedValue2(table, DN.TechType_TechTypeTable_HasData);
+                                               int[] enabled = graph.getPossibleRelatedValue2(table, DN.TechType_TechTypeTable_HasEnabledItems);
+                                               TechTypeTableView.table.getDisplay().asyncExec(() -> {
+                                                       TechTypeTableView.table.setComponentType(null);
+                                                       TechTypeTableView.table.setTechTypeData(data, enabled);
+                                               });
+                                       }
                                }
                        });
                } catch (DatabaseException e) {