]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/diagramEditor/DiagramViewerSelectionProvider.java
Added some enforcement of immutability to structural user component UI's.
[simantics/platform.git] / bundles / org.simantics.modeling.ui / src / org / simantics / modeling / ui / diagramEditor / DiagramViewerSelectionProvider.java
index c3070d9cceb9f60ccd3fde3aef1e7407a14b9957..4317f59799f9c8819bb1459fe76d3997ac56dc90 100644 (file)
@@ -62,6 +62,7 @@ public class DiagramViewerSelectionProvider extends WorkbenchSelectionProvider {
                         public Variable perform(ReadGraph graph) throws DatabaseException {\r
 \r
                             DiagramResource DIA = DiagramResource.getInstance(graph);\r
+                            ModelingResources MOD = ModelingResources.getInstance(graph);\r
 \r
                             String uri = graph.getPossibleRelatedValue(resource, DIA.RuntimeDiagram_HasVariable);\r
                             if (uri == null)\r
@@ -71,9 +72,20 @@ public class DiagramViewerSelectionProvider extends WorkbenchSelectionProvider {
                             if (var == null)\r
                                 return null;\r
 \r
-                            Resource config = graph.getPossibleObject(resource2, ModelingResources.getInstance(graph).ElementToComponent);\r
-                            if (config == null)\r
+                            Resource config = graph.getPossibleObject(resource2, MOD.ElementToComponent);\r
+                            if (config == null) {\r
+                                // Apros #9646: if resource2 is the diagram\r
+                                // itself, return the diagram composite variable\r
+                                // since it is generally more useful than the\r
+                                // variable to the diagram.\r
+                                Resource composite = graph.getPossibleObject(resource2, MOD.DiagramToComposite);\r
+                                if (composite != null && composite.equals(var.getPossibleRepresents(graph))) {\r
+                                    //return Variables.getPossibleVariable(graph, resource2);\r
+                                    return var;\r
+                                }\r
+\r
                                 return null;\r
+                            }\r
 \r
                             return var.browsePossible(graph, config);\r
 \r