]> gerrit.simantics Code Review - simantics/sysdyn.git/commitdiff
Use copy4 to copy variables on diagram. This fixes copy for expressions but not for...
authorlempinen <lempinen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Fri, 20 May 2011 08:39:17 +0000 (08:39 +0000)
committerlempinen <lempinen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Fri, 20 May 2011 08:39:17 +0000 (08:39 +0000)
git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@21050 ac1ea38d-2e2b-0410-8846-a27921b304fc

org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/editor/participant/SysdynComponentCopyAdvisor.java

index 5b3c122c0c7397a9df40d14feba907d7d12be91c..a689a25234db80da2b3ace018419ced1f84db189 100644 (file)
@@ -16,15 +16,16 @@ import org.simantics.db.ReadGraph;
 import org.simantics.db.Resource;\r
 import org.simantics.db.Statement;\r
 import org.simantics.db.WriteGraph;\r
+import org.simantics.db.common.request.PossibleTypedParent;\r
 import org.simantics.db.common.utils.NameUtils;\r
 import org.simantics.db.exception.DatabaseException;\r
-import org.simantics.db.exception.ServiceException;\r
 import org.simantics.diagram.synchronization.ISynchronizationContext;\r
 import org.simantics.diagram.synchronization.graph.CopyAdvisorUtil;\r
 import org.simantics.layer0.Layer0;\r
 import org.simantics.modeling.ComponentUtils;\r
 import org.simantics.modeling.mapping.ComponentCopyAdvisor;\r
-import org.simantics.sysdyn.SysdynResource;\r
+import org.simantics.simulation.ontology.SimulationResource;\r
+import org.simantics.structural.stubs.StructuralResource2;\r
 import org.simantics.utils.datastructures.BinaryFunction;\r
 \r
 public class SysdynComponentCopyAdvisor extends ComponentCopyAdvisor{\r
@@ -36,21 +37,34 @@ public class SysdynComponentCopyAdvisor extends ComponentCopyAdvisor{
 \r
                        @Override\r
                        public Boolean call(ReadGraph graph, Statement statement) {\r
+                               /*\r
                                SysdynResource sr = SysdynResource.getInstance(graph);\r
                                try {\r
                                        if(graph.isInstanceOf(statement.getSubject(), sr.IndependentVariable)) {\r
-                                               if(statement.getPredicate().equals(sr.HasExpressions))\r
-                                                       return true;\r
+                                               if(statement.getPredicate().equals(sr.HasExpressions) ||\r
+                                                               statement.getPredicate().equals(sr.HasArrayIndexes) )\r
+                                                       return false;\r
                                        }\r
                                } catch (ServiceException e) {\r
                                        e.printStackTrace();\r
                                }\r
+                               */\r
                                return false;\r
                        }\r
                \r
        };\r
        \r
-        Resource copy = CopyAdvisorUtil.copy(graph, source, tester);\r
+       Resource copy;\r
+       \r
+       StructuralResource2 sr2 = StructuralResource2.getInstance(graph);\r
+       SimulationResource SIMU = SimulationResource.getInstance(graph);\r
+       Resource model = graph.syncRequest(new PossibleTypedParent(targetContainer, SIMU.Model));\r
+       if(graph.isInstanceOf(source, sr2.Connection)) {\r
+                copy = CopyAdvisorUtil.copy(graph, source, tester);\r
+       } else {\r
+            copy = CopyAdvisorUtil.copy4(graph, source, model);\r
+       }\r
+\r
         \r
         renameComponent(context, graph, source, copy, sourceContainer, targetContainer);\r
         return copy;\r