]> gerrit.simantics Code Review - simantics/district.git/blobdiff - org.simantics.district.selection/src/org/simantics/district/selection/ElementSelector.java
Manage drop-down menu contents by context in district finder dialog
[simantics/district.git] / org.simantics.district.selection / src / org / simantics / district / selection / ElementSelector.java
index 4143248214b97786661ae6465bf160dafec42a77..f015bddf0f2ccc0814788c956d59ff05064f90dd 100644 (file)
@@ -170,20 +170,26 @@ public class ElementSelector {
                        return Simantics.getSession().syncRequest(new Read<Map<Resource, String>>() {
                                @Override
                                public Map<Resource, String> 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<Resource, String> result = new HashMap<>();
                                        Resource model = graph.syncRequest(new PossibleActiveModel(Simantics.getProjectResource()));
-                                       List<Resource> composites = QueryIndexUtils.searchByType(graph, model, StructuralResource2.getInstance(graph).Composite);
+                                       List<Resource> 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;