]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/actions/NewLocalLibrary.java
(refs #7561) Allow extra parameters to the application of type alias
[simantics/platform.git] / bundles / org.simantics.modeling.ui / src / org / simantics / modeling / ui / actions / NewLocalLibrary.java
1 package org.simantics.modeling.ui.actions;
2
3 import org.simantics.Simantics;
4 import org.simantics.db.Resource;
5 import org.simantics.db.WriteGraph;
6 import org.simantics.db.common.request.WriteResultRequest;
7 import org.simantics.db.exception.DatabaseException;
8 import org.simantics.modeling.ModelingResources;
9
10 /**
11  * @author Tuukka Lehtonen
12  */
13 public class NewLocalLibrary extends NewLibrary {
14
15     protected Resource createLocalLibrary(WriteGraph graph, Resource parent)
16             throws DatabaseException {
17         Resource lib = super.createLibrary(graph, parent);
18         ModelingResources MOD = ModelingResources.getInstance(graph);
19         graph.claim(lib, MOD.IsLocalLibraryOf, parent);
20         
21         return lib;
22     }
23     
24     public Resource newLibrary(final Resource model) throws DatabaseException {
25         Resource library = Simantics.getSession().syncRequest(new WriteResultRequest<Resource>() {
26
27                         @Override
28                         public Resource perform(WriteGraph graph) throws DatabaseException {
29                                 Resource library = createLocalLibrary(graph, model);
30                                 return library;
31                         }
32                 });
33         return library;
34     }
35
36 }