]> gerrit.simantics Code Review - simantics/district.git/blobdiff - org.simantics.district.network.ui/src/org/simantics/district/network/ui/function/Functions.java
Lots of changes to district stuff
[simantics/district.git] / org.simantics.district.network.ui / src / org / simantics / district / network / ui / function / Functions.java
index 7ae651342eca629bd3f33266d90da798fc0a0050..0ea5adf7f7638173ba324b27a610bc931c946c33 100644 (file)
@@ -94,11 +94,19 @@ public class Functions {
     }
 
     public static Map<String, Resource> getVertexMappings(ReadGraph graph, Resource resource) throws DatabaseException {
-        return getNetworkMappingsByType(graph, resource , DistrictNetworkResource.getInstance(graph).Mapping_VertexMapping);
+        Map<String, Resource> second = getNetworkMappingsByType(graph, resource , DistrictNetworkResource.getInstance(graph).Mapping_VertexMapping);
+        return second;
     }
 
     public static Map<String, Resource> getEdgeMappings(ReadGraph graph, Resource resource) throws DatabaseException {
-        return getNetworkMappingsByType(graph, resource , DistrictNetworkResource.getInstance(graph).Mapping_EdgeMapping);
+        Map<String, Resource> second = getNetworkMappingsByType(graph, resource , DistrictNetworkResource.getInstance(graph).Mapping_EdgeMapping);
+        return second;
+    }
+    
+    public static Map<String, Resource> getCRSs(ReadGraph graph, Resource resource) throws DatabaseException {
+        Map<String, Resource> result = getNetworkMappingsByType(graph, resource, DistrictNetworkResource.getInstance(graph).SpatialRefSystem);
+        return result;
+        
     }
 
     public static Map<String, Resource> getNetworkMappingsByType(ReadGraph graph, Resource element, Resource mappingType) throws DatabaseException {
@@ -196,10 +204,13 @@ public class Functions {
         private Map<String, Resource> vertexMappings = new HashMap<>();
         private Map<String, Resource> edgeMappings = new HashMap<>();
         private Map<String, Resource> composites = new HashMap<>();
+        private Map<String, Resource> crss = new HashMap<>();
         private Map<String, Map<String, Resource>> components = new HashMap<>();
         
         private Resource defaultVertexMapping;
         private Resource defaultEdgeMapping;
+        private Resource defaultCRS;
+        
         private Combo compositeMappingCombo;
         private Combo componentMappingCombo;
 
@@ -239,14 +250,21 @@ public class Functions {
                         components = getComponents(graph, composites.get(0));
                     }
                     
+                    crss = getCRSs(graph, configuration);
                     
                     composite.getDisplay().asyncExec(() -> {
                         
                         vertexMappingCombo.setItems(vertexMappings.keySet().toArray(new String[vertexMappings.size()]));
                         edgeMappingCombo.setItems(edgeMappings.keySet().toArray(new String[edgeMappings.size()]));
+                        
+                        crsCombo.setItems(crss.keySet().toArray(new String[crss.size()]));
+                        
                         compositeMappingCombo.setItems(composites.keySet().toArray(new String[composites.size()]));
                         vertexMappingCombo.select(0);
                         edgeMappingCombo.select(0);
+                        
+                        crsCombo.select(0);
+                        
                         if (!composites.isEmpty())
                             compositeMappingCombo.select(0);
                     }); 
@@ -379,6 +397,11 @@ public class Functions {
         protected void computeResult() {
             defaultVertexMapping = vertexMappings.get(vertexMappingCombo.getItem(vertexMappingCombo.getSelectionIndex()));
             defaultEdgeMapping = edgeMappings.get(edgeMappingCombo.getItem(edgeMappingCombo.getSelectionIndex()));
+            defaultCRS = crss.get(crsCombo.getItem(crsCombo.getSelectionIndex()));
+        }
+
+        public Resource getCRS() {
+            return defaultCRS;
         }
         
     }
@@ -404,6 +427,7 @@ public class Functions {
                                 Resource diagram = graph.getSingleObject(composite, ModelingResources.getInstance(graph).CompositeToDiagram);
                                 graph.claim(diagram, DN.EdgeDefaultMapping, dialog.getDefaultEdgeMapping());
                                 graph.claim(diagram, DN.VertexDefaultMapping, dialog.getDefaultVertexMapping());
+                                graph.claim(diagram, DN.HasSpatialRefSystem, dialog.getCRS());
                             }
                         });
                         DefaultActions.asyncPerformDefaultAction(Simantics.getSession(), composite, false, false, true);