]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.modeling/src/org/simantics/modeling/ProjectSCLFeature.java
Disable SCL Issue provider by default
[simantics/platform.git] / bundles / org.simantics.modeling / src / org / simantics / modeling / ProjectSCLFeature.java
1 package org.simantics.modeling;
2
3 import java.util.UUID;
4
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;
17
18 public class ProjectSCLFeature extends AbstractProjectFeature {
19
20         @Override
21         public void configure() throws ProjectException {
22                 
23                 try {
24                         
25                 final Session session = getSession();
26                 final VirtualGraphSupport support = session.getService(VirtualGraphSupport.class);
27                 support.getWorkspacePersistent("documentation");
28
29                         Simantics.getSession().syncRequest(new WriteRequest() {
30
31                                 @Override
32                                 public void perform(WriteGraph graph) throws DatabaseException {
33                                         
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);
43                                         }
44                                         
45                                 }
46                                 
47                         });
48                         
49                 } catch (DatabaseException e) {
50                         
51                         throw new ProjectException(e);
52                         
53                 }
54                 
55         }
56
57         @Override
58         public void deconfigure() throws ProjectException {
59                 
60         }
61         
62 }