1 package org.simantics.sysdyn.ui.editor.participant;
\r
3 import org.simantics.db.ReadGraph;
\r
4 import org.simantics.db.Resource;
\r
5 import org.simantics.db.Statement;
\r
6 import org.simantics.db.WriteGraph;
\r
7 import org.simantics.db.exception.DatabaseException;
\r
8 import org.simantics.db.exception.ServiceException;
\r
9 import org.simantics.diagram.synchronization.ISynchronizationContext;
\r
10 import org.simantics.diagram.synchronization.graph.CopyAdvisorUtil;
\r
11 import org.simantics.modeling.mapping.ComponentCopyAdvisor;
\r
12 import org.simantics.sysdyn.SysdynResource;
\r
13 import org.simantics.utils.datastructures.BinaryFunction;
\r
15 public class SysdynComponentCopyAdvisor extends ComponentCopyAdvisor{
\r
18 public Object copy(ISynchronizationContext context, WriteGraph graph, Resource source) throws DatabaseException {
\r
20 BinaryFunction<Boolean, ReadGraph, Statement> tester = new BinaryFunction<Boolean, ReadGraph, Statement>() {
\r
23 public Boolean call(ReadGraph graph, Statement statement) {
\r
24 SysdynResource sr = SysdynResource.getInstance(graph);
\r
26 if(graph.isInstanceOf(statement.getSubject(), sr.IndependentVariable)) {
\r
27 if(statement.getPredicate().equals(sr.HasExpression))
\r
30 } catch (ServiceException e) {
\r
31 e.printStackTrace();
\r
38 Resource copy = CopyAdvisorUtil.copy(graph, source, tester);
\r
39 renameComponent(context, graph, source, copy);
\r