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
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
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
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
\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
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