]> gerrit.simantics Code Review - simantics/sysdyn.git/commitdiff
git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@16843 ac1ea38d-2e2b...
authorlempinen <lempinen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Tue, 27 Jul 2010 11:14:12 +0000 (11:14 +0000)
committerlempinen <lempinen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Tue, 27 Jul 2010 11:14:12 +0000 (11:14 +0000)
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements2/InputFactory.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/project/SysdynProject.java
sysdyn_ontologies/sysdyn.graph

index 7bb49b3d20dee3926413d6387264a4a7ad19da02..7a0b0eb1bfe1b56843cbbcd3b0592fb0fea0b456 100644 (file)
@@ -14,6 +14,8 @@ import org.simantics.db.Resource;
 import org.simantics.db.exception.DatabaseException;\r
 import org.simantics.diagram.elements.TextElementNoBounds;\r
 import org.simantics.diagram.elements.TextNode;\r
+import org.simantics.diagram.stubs.DiagramResource;\r
+import org.simantics.diagram.ui.DiagramModelHints;\r
 import org.simantics.g2d.canvas.ICanvasContext;\r
 import org.simantics.g2d.diagram.IDiagram;\r
 import org.simantics.g2d.element.ElementClass;\r
@@ -89,26 +91,54 @@ public class InputFactory extends SysdynElementFactory {
         Resource dependency = null;\r
         Resource refersTo = null;\r
         Resource module = null;\r
+        String moduleName = "";\r
+        String referenceName = "";\r
         component = graph.getPossibleObject(element, mr.ElementToComponent);\r
         if(component != null) \r
             dependency = graph.getPossibleObject(component, sr.IsHeadOf);\r
         if(dependency != null) {\r
             refersTo = graph.getPossibleObject(dependency, sr.RefersTo);\r
+            referenceName = (String) graph.getPossibleRelatedValue(refersTo, b.HasName);\r
             module = graph.getPossibleObject(dependency, sr.HasTail);\r
+            moduleName = (String) graph.getPossibleRelatedValue(module, b.HasName);\r
+        } else {\r
+            Resource runtime = diagram.getHint((DiagramModelHints.KEY_DIAGRAM_RUNTIME_RESOURCE));\r
+            DiagramResource dr = DiagramResource.getInstance(graph);\r
+            String variable = (String)graph.getRelatedValue(runtime, dr.HasVariable);\r
+            Resource moduleRepresentation = graph.getPossibleResource(variable);\r
+            if(moduleRepresentation != null)\r
+                module = graph.getSingleObject(moduleRepresentation, b.Represents);\r
+            if(module != null)\r
+                for(Resource dep : graph.getObjects(module, sr.IsHeadOf)) {\r
+                    Resource reference = graph.getPossibleObject(dep, sr.RefersTo);\r
+                    if(reference!= null && reference.equals(component)) {\r
+                        refersTo = graph.getSingleObject(dep, sr.HasTail);\r
+                        referenceName = (String) graph.getPossibleRelatedValue(refersTo, b.HasName);\r
+                        moduleRepresentation = graph.getPossibleResource(variable.substring(0, variable.lastIndexOf("/")));\r
+                        Resource parent = graph.getSingleObject(moduleRepresentation, b.PartOf);\r
+                        module = graph.getSingleObject(moduleRepresentation, b.Represents);\r
+                        String parentURI = graph.getURI(parent);\r
+                        String modelURI =  diagram.getHint((DiagramModelHints.KEY_DIAGRAM_MODEL_URI));\r
+                        System.out.println(parentURI + " < -- > " + modelURI);\r
+                        if(parentURI.equals(modelURI))\r
+                            moduleName = "";\r
+                        else {\r
+                            moduleName = (String) graph.getPossibleRelatedValue(module, b.HasName);\r
+                        }\r
+                        break;\r
+                    }\r
+                }\r
         }\r
-        \r
+\r
         String inputReference = null;\r
         if (module != null && refersTo != null) {\r
-            inputReference = (String) graph.getPossibleRelatedValue(module, b.HasName);\r
-            inputReference += ".";\r
-            inputReference += (String) graph.getPossibleRelatedValue(refersTo, b.HasName);\r
+            inputReference = moduleName + "." + referenceName;\r
         }\r
         if (inputReference == null) {\r
             inputReference = "";\r
         }\r
 \r
         SysdynElementUtils.setInputReference(e, inputReference);\r
-\r
     }\r
 \r
 \r
index 2b371a0d1dceb9d5d82e7ad3d63922df10646759..2b18c8d7a8236551a5484d6ae230b2fb0ab0ef02 100644 (file)
@@ -31,6 +31,7 @@ import org.simantics.modeling.ModelingResources;
 import org.simantics.modeling.ModelingUtils;\r
 import org.simantics.modeling.services.CaseInsensitiveComponentNamingStrategy2;\r
 import org.simantics.modeling.services.ComponentNamingStrategy;\r
+import org.simantics.modeling.ui.features.EditorNamingService2;\r
 import org.simantics.project.ProjectElementType;\r
 import org.simantics.project.ProjectElements;\r
 import org.simantics.project.ProjectKeys;\r
@@ -40,6 +41,7 @@ import org.simantics.project.features.UIModelManager;
 import org.simantics.project.features.UIModelManagerBase;\r
 import org.simantics.project.features.UIModelManagerBase.WriteRunnable;\r
 import org.simantics.sysdyn.SysdynResource;\r
+import org.simantics.ui.workbench.IEditorNamingService;\r
 import org.simantics.ui.workbench.action.ChooseActionRequest;\r
 import org.simantics.utils.datastructures.Callback;\r
 import org.simantics.utils.ui.workbench.WorkbenchUtils;\r
@@ -116,7 +118,7 @@ public class SysdynProject extends AbstractProjectFeature {
 \r
                 Resource report = GraphUtils.create2(g, mu.b.Report,  mu.b.HasDocumentation, "===Report===");\r
 \r
-                Resource experiment = GraphUtils.create2(g, mu.b.Experiment,\r
+                GraphUtils.create2(g, mu.b.Experiment,\r
                         mu.b.HasName, "Experiment",\r
                         mu.b.HasLabel, "Experiment",\r
                         mu.b.HasReportFactory, report,\r
@@ -136,6 +138,8 @@ public class SysdynProject extends AbstractProjectFeature {
         addToCollectionHint(ProjectKeys.PERSPECTIVES, DEFAULT_PERSPECTIVE);\r
         addToCollectionHint(ProjectKeys.OPEN_PERSPECTIVES, DEFAULT_PERSPECTIVE);\r
         getProjectElement().setHint(ProjectKeys.DEFAULT_PERSPECTIVE, DEFAULT_PERSPECTIVE);\r
+        \r
+        getProjectElement().setHint(IEditorNamingService.KEY_EDITOR_NAMING_SERVICE, new EditorNamingService2());\r
 \r
         mm = new ModelManager();\r
         getProjectElement().setHint(UIModelManager.KEY_MODEL_MANAGER, mm);\r
index 3869fac17d5c20ddf83a6957a26f80278100344a..22793451bc677fb95147fffc205e2ee40cd9e9bf 100644 (file)
@@ -66,7 +66,6 @@ SysdynProject : PROJ.Feature
         L0.PartOf Sysdyn\r
         L0.HasLabel "Sysdyn Model Manager" : L0.String\r
         L0.HasDescription "Sysdyn Model Manager." : L0.String\r
-        PROJ.RequiresFeature MOD.ModelingProject\r
         PROJ.RequiresFeature PROJ.ExperimentControl\r
 \r
 \r