]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/actions/NewSCLQuery.java
Improved usability of shared library export wizard
[simantics/platform.git] / bundles / org.simantics.modeling.ui / src / org / simantics / modeling / ui / actions / NewSCLQuery.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.common.request.PossibleIndexRoot;
6 import org.simantics.db.exception.DatabaseException;
7 import org.simantics.db.layer0.adapter.ActionFactory;
8 import org.simantics.modeling.ui.ModelingUIUtils;
9 import org.simantics.utils.ui.ErrorLogger;
10
11 /**
12  * @author Antti Villberg
13  */
14 public class NewSCLQuery implements ActionFactory {
15
16     @Override
17     public Runnable create(Object target) {
18         if(!(target instanceof Resource))
19             return null;
20         final Resource parent = (Resource)target;
21
22         return new Runnable() {
23             @Override
24             public void run() {
25                 try {
26                     Resource indexRoot = Simantics.getSession().syncRequest(new PossibleIndexRoot(parent));
27                     if(indexRoot == null) return;
28                     Simantics.getSession().markUndoPoint();
29                     ModelingUIUtils.newSCLQuery(parent, indexRoot);
30                 } catch (DatabaseException e) {
31                     ErrorLogger.defaultLogError(e);
32                 }
33             }
34         };
35     }
36
37 }