1 package org.simantics.modeling;
5 import org.simantics.Simantics;
6 import org.simantics.databoard.Bindings;
7 import org.simantics.db.Resource;
8 import org.simantics.db.Session;
9 import org.simantics.db.WriteGraph;
10 import org.simantics.db.common.request.WriteRequest;
11 import org.simantics.db.exception.DatabaseException;
12 import org.simantics.db.layer0.util.Layer0Utils;
13 import org.simantics.db.service.VirtualGraphSupport;
14 import org.simantics.layer0.Layer0;
15 import org.simantics.project.exception.ProjectException;
16 import org.simantics.project.features.AbstractProjectFeature;
18 public class ProjectSCLFeature extends AbstractProjectFeature {
21 public void configure() throws ProjectException {
25 final Session session = getSession();
26 final VirtualGraphSupport support = session.getService(VirtualGraphSupport.class);
27 support.getWorkspacePersistent("documentation");
29 Simantics.getSession().syncRequest(new WriteRequest() {
32 public void perform(WriteGraph graph) throws DatabaseException {
34 Resource project = Simantics.getProjectResource();
35 Resource commandSession = Layer0Utils.getPossibleChild(graph, project, "__scl__");
36 if(commandSession == null) {
37 Layer0 L0 = Layer0.getInstance(graph);
38 ModelingResources MOD = ModelingResources.getInstance(graph);
39 commandSession = graph.newResource();
40 graph.claim(commandSession, L0.InstanceOf, MOD.SCLCommandSession);
41 graph.claimLiteral(commandSession, L0.HasName, L0.NameOf, L0.String, "__scl__", Bindings.STRING);
42 graph.claim(project, L0.ConsistsOf, commandSession);
49 } catch (DatabaseException e) {
51 throw new ProjectException(e);
58 public void deconfigure() throws ProjectException {