Ignore multiple modelled tests via context menu action
[simantics/platform.git] / bundles / org.simantics.tests.modelled.ui / src / org / simantics / tests / modelled / ui / TestsUIUtils.java
1 package org.simantics.tests.modelled.ui;
2
3 import java.io.IOException;
4 import java.util.List;
5
6 import org.eclipse.e4.ui.model.application.ui.basic.MPart;
7 import org.simantics.Simantics;
8 import org.simantics.databoard.Bindings;
9 import org.simantics.db.Resource;
10 import org.simantics.db.WriteGraph;
11 import org.simantics.db.exception.DatabaseException;
12 import org.simantics.db.request.Write;
13 import org.simantics.tests.modelled.ontology.TestsResource;
14 import org.simantics.ui.workbench.e4.E4WorkbenchUtils;
15
16 public class TestsUIUtils {
17
18     private TestsUIUtils() {
19     }
20
21     public static void runSTSTestAction(Resource test) throws DatabaseException, IOException {
22         MPart part = E4WorkbenchUtils.getMPartById(STSTestRunnerView.ID);
23         E4WorkbenchUtils.openAndShowPart(part);
24         Object obj = part.getObject();
25         STSTestRunnerView view = (STSTestRunnerView) obj;
26         view.currentTest(test);
27         view.execute();
28     }
29     
30     public static void ignoreSTSTestAction(List<Resource> tests) throws DatabaseException {
31         Simantics.getSession().syncRequest(new Write() {
32             
33             @Override
34             public void perform(WriteGraph graph) throws DatabaseException {
35                 TestsResource TESTS = TestsResource.getInstance(graph);
36                 for (Resource test : tests) {
37                     graph.claimLiteral(test, TESTS.ignore, true, Bindings.BOOLEAN);
38                 }
39             }
40         });
41     }
42 }