1 package org.simantics.modeling.tests.commands;
3 import org.simantics.db.Resource;
4 import org.simantics.db.WriteGraph;
5 import org.simantics.db.exception.DatabaseException;
6 import org.simantics.db.testing.common.CommandSequenceEnvironment;
7 import org.simantics.modeling.ModelingResources;
8 import org.simantics.modeling.tests.traits.SingleModelTrait;
9 import org.simantics.modeling.tests.traits.SingleResourceTrait;
10 import org.simantics.simulation.ontology.SimulationResource;
11 import org.simantics.structural2.utils.StructuralUtils;
13 public class AddDiagram extends ResourceWriteCommand<CommandSequenceEnvironment> implements SingleResourceTrait {
15 private SingleModelTrait model;
16 private Resource compositeType;
19 public AddDiagram(SingleModelTrait model, Resource compositeType, String name) {
21 this.compositeType = compositeType;
26 protected Resource run(WriteGraph graph, CommandSequenceEnvironment environment) throws DatabaseException {
28 SimulationResource SIMU = SimulationResource.getInstance(graph);
30 Resource target = graph.getSingleObject(model.getResource(), SIMU.HasConfiguration);
32 Resource composite = StructuralUtils.newComponent(graph, target, name, compositeType);
34 return graph.getSingleObject(composite, ModelingResources.getInstance(graph).CompositeToDiagram);
38 public String getName() {