]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.modeling.tests/src/org/simantics/modeling/tests/commands/AddDiagram.java
Small but effective HiDPI fixes for platform G2D
[simantics/platform.git] / bundles / org.simantics.modeling.tests / src / org / simantics / modeling / tests / commands / AddDiagram.java
1 package org.simantics.modeling.tests.commands;
2
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;
12
13 public class AddDiagram extends ResourceWriteCommand<CommandSequenceEnvironment> implements SingleResourceTrait {
14
15         private SingleModelTrait model;
16         private Resource compositeType;
17         private String name;
18         
19         public AddDiagram(SingleModelTrait model, Resource compositeType, String name) {
20                 this.model = model;
21                 this.compositeType = compositeType;
22                 this.name = name;
23         }
24         
25         @Override
26         protected Resource run(WriteGraph graph, CommandSequenceEnvironment environment) throws DatabaseException {
27                 
28         SimulationResource SIMU = SimulationResource.getInstance(graph);
29         
30         Resource target = graph.getSingleObject(model.getResource(), SIMU.HasConfiguration);
31
32         Resource composite = StructuralUtils.newComponent(graph, target, name, compositeType);
33         
34                 return graph.getSingleObject(composite, ModelingResources.getInstance(graph).CompositeToDiagram);
35                 
36         }
37         
38         public String getName() {
39                 return name;
40         }
41
42 }