From 15fa971e4183666529fc717531b6be08aa782672 Mon Sep 17 00:00:00 2001 From: lempinen Date: Fri, 20 May 2011 08:39:17 +0000 Subject: [PATCH] Use copy4 to copy variables on diagram. This fixes copy for expressions but not for array indexes. git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@21050 ac1ea38d-2e2b-0410-8846-a27921b304fc --- .../SysdynComponentCopyAdvisor.java | 24 +++++++++++++++---- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/editor/participant/SysdynComponentCopyAdvisor.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/editor/participant/SysdynComponentCopyAdvisor.java index 5b3c122c..a689a252 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/editor/participant/SysdynComponentCopyAdvisor.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/editor/participant/SysdynComponentCopyAdvisor.java @@ -16,15 +16,16 @@ import org.simantics.db.ReadGraph; import org.simantics.db.Resource; import org.simantics.db.Statement; import org.simantics.db.WriteGraph; +import org.simantics.db.common.request.PossibleTypedParent; import org.simantics.db.common.utils.NameUtils; import org.simantics.db.exception.DatabaseException; -import org.simantics.db.exception.ServiceException; import org.simantics.diagram.synchronization.ISynchronizationContext; import org.simantics.diagram.synchronization.graph.CopyAdvisorUtil; import org.simantics.layer0.Layer0; import org.simantics.modeling.ComponentUtils; import org.simantics.modeling.mapping.ComponentCopyAdvisor; -import org.simantics.sysdyn.SysdynResource; +import org.simantics.simulation.ontology.SimulationResource; +import org.simantics.structural.stubs.StructuralResource2; import org.simantics.utils.datastructures.BinaryFunction; public class SysdynComponentCopyAdvisor extends ComponentCopyAdvisor{ @@ -36,21 +37,34 @@ public class SysdynComponentCopyAdvisor extends ComponentCopyAdvisor{ @Override public Boolean call(ReadGraph graph, Statement statement) { + /* SysdynResource sr = SysdynResource.getInstance(graph); try { if(graph.isInstanceOf(statement.getSubject(), sr.IndependentVariable)) { - if(statement.getPredicate().equals(sr.HasExpressions)) - return true; + if(statement.getPredicate().equals(sr.HasExpressions) || + statement.getPredicate().equals(sr.HasArrayIndexes) ) + return false; } } catch (ServiceException e) { e.printStackTrace(); } + */ return false; } }; - Resource copy = CopyAdvisorUtil.copy(graph, source, tester); + Resource copy; + + StructuralResource2 sr2 = StructuralResource2.getInstance(graph); + SimulationResource SIMU = SimulationResource.getInstance(graph); + Resource model = graph.syncRequest(new PossibleTypedParent(targetContainer, SIMU.Model)); + if(graph.isInstanceOf(source, sr2.Connection)) { + copy = CopyAdvisorUtil.copy(graph, source, tester); + } else { + copy = CopyAdvisorUtil.copy4(graph, source, model); + } + renameComponent(context, graph, source, copy, sourceContainer, targetContainer); return copy; -- 2.47.1