From: lempinen Date: Fri, 20 May 2011 08:40:17 +0000 (+0000) Subject: git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/branches/simantics-1.4... X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=410a4b8f25fa27841f7692cf7afbb33d45f4838a;p=simantics%2Fsysdyn.git git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/branches/simantics-1.4@21051 ac1ea38d-2e2b-0410-8846-a27921b304fc --- 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;