]> gerrit.simantics Code Review - simantics/sysdyn.git/commitdiff
Ungly fix for opening modules from diagrams. Earlier commit broke the opening when...
authorlempinen <lempinen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Fri, 8 Oct 2010 12:40:19 +0000 (12:40 +0000)
committerlempinen <lempinen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Fri, 8 Oct 2010 12:40:19 +0000 (12:40 +0000)
git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@18348 ac1ea38d-2e2b-0410-8846-a27921b304fc

org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/ShowModuleHandler.java

index 90fff3aacf9a4260050b18c10117cca1e4cbd670..a23fc0c930cdd5e5881e6a54b815a0a20b9ffc4b 100644 (file)
@@ -87,8 +87,20 @@ public class ShowModuleHandler extends AbstractHandler {
                                        \r
                                        String finalRvi = currentRVI + "/" + graph.getPossibleRelatedValue(component, l0.HasName, StringBindingDefault.INSTANCE);\r
                                        \r
-                                       Variable rootVariable = graph.adapt(model, Variable.class);\r
-                                       Variable var = rootVariable.browsePossible(graph, finalRvi);\r
+                                       // This is ugly but it has to be done like this because WorkModel example has too PartOfs\r
+                                       Resource rootLibrary = graph.getPossibleObject(model, l0.PartOf);\r
+                                       while(!graph.getObjects(rootLibrary, l0.PartOf).isEmpty()) {\r
+                                               for(Resource possibleLibrary : graph.getObjects(rootLibrary, l0.PartOf)){\r
+                                                       if(graph.isInstanceOf(possibleLibrary, l0.Library)) {\r
+                                                               rootLibrary = possibleLibrary;\r
+                                                               break;\r
+                                                       }\r
+                                               }\r
+                                       }\r
+                                       Variable rootVariable = graph.adapt(rootLibrary, Variable.class);\r
+                                       \r
+                                       String moduleUri = modelURI + "/BaseRealization" + finalRvi;\r
+                                       Variable var = rootVariable.browsePossible(graph, moduleUri.substring(6));\r
                                        if(var == null) {\r
                                                finalRvi = "";\r
                                        }\r