+ Resource pipe = null;
+ try {
+ List<NamedResource> componentTypes = DistrictNetworkUtil.getDistrictComponents();
+
+ pipe = componentTypes.stream()
+ .filter(r -> r.getName().toLowerCase().contains("pipe"))
+ .map(r -> r.getResource())
+ .findFirst().orElse(null);
+ } catch (DatabaseException e) {
+ LOGGER.error("Failed to read district component types for active model", e);
+ }
+
+ LOGGER.debug("Pipe component type is {}", pipe);
+
+ String data = null;
+ Resource tableResource = null;
+ if (pipe != null) {
+ try {
+ Resource model = Simantics.getSession().syncRequest(new PossibleActiveModel(Simantics.getProjectResource()));
+ if (model != null) {
+ tableResource = Simantics.getSession().syncRequest(new PossibleTechTypeTable(model, pipe), TransientCacheListener.instance());
+ data = Simantics.getSession().syncRequest(new PossibleTechTypeTableData(model, pipe), TransientCacheListener.instance());
+ }
+ } catch (DatabaseException e) {
+ LOGGER.error("Failed to read tech type table data for {}", pipe, e);
+ }
+ }
+
+ table = new TechTypeTable(parent, 0, pipe, tableResource, data);