]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.charts/src/org/simantics/charts/query/HideChartItems.java
Statements request is missing dec
[simantics/platform.git] / bundles / org.simantics.charts / src / org / simantics / charts / query / HideChartItems.java
1 package org.simantics.charts.query;
2
3 import java.util.List;
4
5 import org.simantics.Simantics;
6 import org.simantics.charts.ontology.ChartResource;
7 import org.simantics.databoard.Bindings;
8 import org.simantics.db.Resource;
9 import org.simantics.db.Session;
10 import org.simantics.db.WriteGraph;
11 import org.simantics.db.common.request.WriteRequest;
12 import org.simantics.db.exception.DatabaseException;
13
14 /**
15  * @author Tuukka Lehtonen
16  * @since 1.20
17  */
18 public class HideChartItems extends WriteRequest {
19
20     private final Boolean hide;
21     private final List<Resource> items;
22
23     public HideChartItems(boolean hide, List<Resource> items) {
24         this.hide = hide;
25         this.items = items;
26     }
27
28     @Override
29     public void perform(WriteGraph graph) throws DatabaseException {
30         hideChartItems(graph, hide, items);
31     }
32
33     public static void hideChartItems(WriteGraph graph, boolean hide, List<Resource> items) throws DatabaseException {
34         ChartResource CHART = ChartResource.getInstance(graph);
35         for (Resource item : items) {
36             if (graph.isInstanceOf(item, CHART.Chart_Item)) {
37                 graph.claimLiteral(item, CHART.Chart_Item_hidden, hide, Bindings.BOOLEAN);
38             }
39         }
40     }
41
42     public static void hideChartItems(boolean hide, List<Resource> items) throws DatabaseException {
43         Session s = Simantics.getSession();
44         s.markUndoPoint();
45         s.syncRequest(new HideChartItems(hide, items));
46     }
47
48 }