From 3f8144b7194617913fb0c149a1fe89033ad16e7b Mon Sep 17 00:00:00 2001 From: lempinen Date: Tue, 27 Jul 2010 11:14:12 +0000 Subject: [PATCH] git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@16843 ac1ea38d-2e2b-0410-8846-a27921b304fc --- .../sysdyn/ui/elements2/InputFactory.java | 40 ++++++++++++++++--- .../sysdyn/ui/project/SysdynProject.java | 6 ++- sysdyn_ontologies/sysdyn.graph | 1 - 3 files changed, 40 insertions(+), 7 deletions(-) diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements2/InputFactory.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements2/InputFactory.java index 7bb49b3d..7a0b0eb1 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements2/InputFactory.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements2/InputFactory.java @@ -14,6 +14,8 @@ import org.simantics.db.Resource; import org.simantics.db.exception.DatabaseException; import org.simantics.diagram.elements.TextElementNoBounds; import org.simantics.diagram.elements.TextNode; +import org.simantics.diagram.stubs.DiagramResource; +import org.simantics.diagram.ui.DiagramModelHints; import org.simantics.g2d.canvas.ICanvasContext; import org.simantics.g2d.diagram.IDiagram; import org.simantics.g2d.element.ElementClass; @@ -89,26 +91,54 @@ public class InputFactory extends SysdynElementFactory { Resource dependency = null; Resource refersTo = null; Resource module = null; + String moduleName = ""; + String referenceName = ""; component = graph.getPossibleObject(element, mr.ElementToComponent); if(component != null) dependency = graph.getPossibleObject(component, sr.IsHeadOf); if(dependency != null) { refersTo = graph.getPossibleObject(dependency, sr.RefersTo); + referenceName = (String) graph.getPossibleRelatedValue(refersTo, b.HasName); module = graph.getPossibleObject(dependency, sr.HasTail); + moduleName = (String) graph.getPossibleRelatedValue(module, b.HasName); + } else { + Resource runtime = diagram.getHint((DiagramModelHints.KEY_DIAGRAM_RUNTIME_RESOURCE)); + DiagramResource dr = DiagramResource.getInstance(graph); + String variable = (String)graph.getRelatedValue(runtime, dr.HasVariable); + Resource moduleRepresentation = graph.getPossibleResource(variable); + if(moduleRepresentation != null) + module = graph.getSingleObject(moduleRepresentation, b.Represents); + if(module != null) + for(Resource dep : graph.getObjects(module, sr.IsHeadOf)) { + Resource reference = graph.getPossibleObject(dep, sr.RefersTo); + if(reference!= null && reference.equals(component)) { + refersTo = graph.getSingleObject(dep, sr.HasTail); + referenceName = (String) graph.getPossibleRelatedValue(refersTo, b.HasName); + moduleRepresentation = graph.getPossibleResource(variable.substring(0, variable.lastIndexOf("/"))); + Resource parent = graph.getSingleObject(moduleRepresentation, b.PartOf); + module = graph.getSingleObject(moduleRepresentation, b.Represents); + String parentURI = graph.getURI(parent); + String modelURI = diagram.getHint((DiagramModelHints.KEY_DIAGRAM_MODEL_URI)); + System.out.println(parentURI + " < -- > " + modelURI); + if(parentURI.equals(modelURI)) + moduleName = ""; + else { + moduleName = (String) graph.getPossibleRelatedValue(module, b.HasName); + } + break; + } + } } - + String inputReference = null; if (module != null && refersTo != null) { - inputReference = (String) graph.getPossibleRelatedValue(module, b.HasName); - inputReference += "."; - inputReference += (String) graph.getPossibleRelatedValue(refersTo, b.HasName); + inputReference = moduleName + "." + referenceName; } if (inputReference == null) { inputReference = ""; } SysdynElementUtils.setInputReference(e, inputReference); - } diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/project/SysdynProject.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/project/SysdynProject.java index 2b371a0d..2b18c8d7 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/project/SysdynProject.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/project/SysdynProject.java @@ -31,6 +31,7 @@ import org.simantics.modeling.ModelingResources; import org.simantics.modeling.ModelingUtils; import org.simantics.modeling.services.CaseInsensitiveComponentNamingStrategy2; import org.simantics.modeling.services.ComponentNamingStrategy; +import org.simantics.modeling.ui.features.EditorNamingService2; import org.simantics.project.ProjectElementType; import org.simantics.project.ProjectElements; import org.simantics.project.ProjectKeys; @@ -40,6 +41,7 @@ import org.simantics.project.features.UIModelManager; import org.simantics.project.features.UIModelManagerBase; import org.simantics.project.features.UIModelManagerBase.WriteRunnable; import org.simantics.sysdyn.SysdynResource; +import org.simantics.ui.workbench.IEditorNamingService; import org.simantics.ui.workbench.action.ChooseActionRequest; import org.simantics.utils.datastructures.Callback; import org.simantics.utils.ui.workbench.WorkbenchUtils; @@ -116,7 +118,7 @@ public class SysdynProject extends AbstractProjectFeature { Resource report = GraphUtils.create2(g, mu.b.Report, mu.b.HasDocumentation, "===Report==="); - Resource experiment = GraphUtils.create2(g, mu.b.Experiment, + GraphUtils.create2(g, mu.b.Experiment, mu.b.HasName, "Experiment", mu.b.HasLabel, "Experiment", mu.b.HasReportFactory, report, @@ -136,6 +138,8 @@ public class SysdynProject extends AbstractProjectFeature { addToCollectionHint(ProjectKeys.PERSPECTIVES, DEFAULT_PERSPECTIVE); addToCollectionHint(ProjectKeys.OPEN_PERSPECTIVES, DEFAULT_PERSPECTIVE); getProjectElement().setHint(ProjectKeys.DEFAULT_PERSPECTIVE, DEFAULT_PERSPECTIVE); + + getProjectElement().setHint(IEditorNamingService.KEY_EDITOR_NAMING_SERVICE, new EditorNamingService2()); mm = new ModelManager(); getProjectElement().setHint(UIModelManager.KEY_MODEL_MANAGER, mm); diff --git a/sysdyn_ontologies/sysdyn.graph b/sysdyn_ontologies/sysdyn.graph index 3869fac1..22793451 100644 --- a/sysdyn_ontologies/sysdyn.graph +++ b/sysdyn_ontologies/sysdyn.graph @@ -66,7 +66,6 @@ SysdynProject : PROJ.Feature L0.PartOf Sysdyn L0.HasLabel "Sysdyn Model Manager" : L0.String L0.HasDescription "Sysdyn Model Manager." : L0.String - PROJ.RequiresFeature MOD.ModelingProject PROJ.RequiresFeature PROJ.ExperimentControl -- 2.47.1