X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=org.simantics.district.selection%2Fsrc%2Forg%2Fsimantics%2Fdistrict%2Fselection%2FElementSelector.java;fp=org.simantics.district.selection%2Fsrc%2Forg%2Fsimantics%2Fdistrict%2Fselection%2FElementSelector.java;h=f015bddf0f2ccc0814788c956d59ff05064f90dd;hb=2c1785eb5f5764aa82305c32973705c735f15dfc;hp=4143248214b97786661ae6465bf160dafec42a77;hpb=32e5686b36d517931f014baf6bb3f354a9bd742b;p=simantics%2Fdistrict.git diff --git a/org.simantics.district.selection/src/org/simantics/district/selection/ElementSelector.java b/org.simantics.district.selection/src/org/simantics/district/selection/ElementSelector.java index 41432482..f015bddf 100644 --- a/org.simantics.district.selection/src/org/simantics/district/selection/ElementSelector.java +++ b/org.simantics.district.selection/src/org/simantics/district/selection/ElementSelector.java @@ -170,20 +170,26 @@ public class ElementSelector { return Simantics.getSession().syncRequest(new Read>() { @Override public Map perform(ReadGraph graph) throws DatabaseException { + Layer0 L0 = Layer0.getInstance(graph); + StructuralResource2 STR = StructuralResource2.getInstance(graph); + DistrictNetworkResource DN = DistrictNetworkResource.getInstance(graph); + ModelingResources MOD = ModelingResources.getInstance(graph); + Map result = new HashMap<>(); Resource model = graph.syncRequest(new PossibleActiveModel(Simantics.getProjectResource())); - List composites = QueryIndexUtils.searchByType(graph, model, StructuralResource2.getInstance(graph).Composite); + List composites = QueryIndexUtils.searchByType(graph, model, STR.Composite); for (Resource r : composites) { // Get diagram - Resource diagram = graph.getPossibleObject(r, ModelingResources.getInstance(graph).CompositeToDiagram); - if (diagram == null) continue; + Resource diagram = graph.getPossibleObject(r, MOD.CompositeToDiagram); + if (diagram == null || !graph.isInstanceOf(diagram, DN.Diagram)) + continue; // Filter out user component diagrams - Resource parent = graph.getPossibleObject(r, Layer0.getInstance(graph).PartOf); - if (parent == null || graph.isInheritedFrom(parent, StructuralResource2.getInstance(graph).Component)) + Resource parent = graph.getPossibleObject(r, L0.PartOf); + if (parent == null || graph.isInheritedFrom(parent, STR.Component)) continue; - result.put(r, graph.getRelatedValue(r, Layer0.getInstance(graph).HasName)); + result.put(r, graph.getRelatedValue(r, L0.HasName)); } return result;