From 89f25e5ddd1039365c886cc239a2f5605343badd Mon Sep 17 00:00:00 2001 From: lempinen Date: Fri, 8 Oct 2010 12:40:19 +0000 Subject: [PATCH] Ungly fix for opening modules from diagrams. Earlier commit broke the opening when opening from the actual configuration, not the module type git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@18348 ac1ea38d-2e2b-0410-8846-a27921b304fc --- .../sysdyn/ui/handlers/ShowModuleHandler.java | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/ShowModuleHandler.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/ShowModuleHandler.java index 90fff3aa..a23fc0c9 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/ShowModuleHandler.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/ShowModuleHandler.java @@ -87,8 +87,20 @@ public class ShowModuleHandler extends AbstractHandler { String finalRvi = currentRVI + "/" + graph.getPossibleRelatedValue(component, l0.HasName, StringBindingDefault.INSTANCE); - Variable rootVariable = graph.adapt(model, Variable.class); - Variable var = rootVariable.browsePossible(graph, finalRvi); + // This is ugly but it has to be done like this because WorkModel example has too PartOfs + Resource rootLibrary = graph.getPossibleObject(model, l0.PartOf); + while(!graph.getObjects(rootLibrary, l0.PartOf).isEmpty()) { + for(Resource possibleLibrary : graph.getObjects(rootLibrary, l0.PartOf)){ + if(graph.isInstanceOf(possibleLibrary, l0.Library)) { + rootLibrary = possibleLibrary; + break; + } + } + } + Variable rootVariable = graph.adapt(rootLibrary, Variable.class); + + String moduleUri = modelURI + "/BaseRealization" + finalRvi; + Variable var = rootVariable.browsePossible(graph, moduleUri.substring(6)); if(var == null) { finalRvi = ""; } -- 2.47.1