]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.modeling.tests/src/org/simantics/modeling/tests/commands/ActivateProfile.java
Small but effective HiDPI fixes for platform G2D
[simantics/platform.git] / bundles / org.simantics.modeling.tests / src / org / simantics / modeling / tests / commands / ActivateProfile.java
1 package org.simantics.modeling.tests.commands;
2
3 import java.util.Collection;
4 import java.util.Map;
5
6 import org.simantics.Simantics;
7 import org.simantics.db.Resource;
8 import org.simantics.db.exception.DatabaseException;
9 import org.simantics.db.layer0.request.ModelInstances;
10 import org.simantics.db.testing.common.CommandSequenceEnvironment;
11 import org.simantics.db.testing.common.WriteCommand;
12 import org.simantics.diagram.elements.DiagramNodeUtil;
13 import org.simantics.diagram.stubs.DiagramResource;
14 import org.simantics.g2d.canvas.ICanvasContext;
15
16 public class ActivateProfile extends WriteCommand<CommandSequenceEnvironment> {
17
18         private LoadDiagram diagram;
19         private String profileName;
20         private Collection<Resource> entries;
21         
22         public ActivateProfile(LoadDiagram diagram, String profileName, Collection<Resource> entries) {
23                 this.diagram = diagram;
24                 this.profileName = profileName;
25                 this.entries = entries;
26         }
27         
28         @Override
29         public void run(CommandSequenceEnvironment environment) throws DatabaseException {
30                 
31         ICanvasContext ctx = diagram.getContext();
32
33         Resource runtime = DiagramNodeUtil.getRuntime(ctx);
34         
35         DiagramResource DIA = DiagramResource.getInstance(Simantics.getSession());
36
37         Map<String, Resource> profiles = Simantics.getSession().sync(new ModelInstances(diagram.getResource(), DIA.Profile));
38         Resource profile = profiles.get(profileName);
39
40         DiagramNodeUtil.activateProfileWithEntries(runtime, profile, entries);
41                 
42         }
43
44 }