]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.event/src/org/simantics/event/view/preference/EventPrefs.java
Migrated source code from Simantics SVN
[simantics/platform.git] / bundles / org.simantics.event / src / org / simantics / event / view / preference / EventPrefs.java
1 /*******************************************************************************\r
2  * Copyright (c) 2007, 2011 Association for Decentralized Information Management\r
3  * in Industry THTH ry.\r
4  * All rights reserved. This program and the accompanying materials\r
5  * are made available under the terms of the Eclipse Public License v1.0\r
6  * which accompanies this distribution, and is available at\r
7  * http://www.eclipse.org/legal/epl-v10.html\r
8  *\r
9  * Contributors:\r
10  *     VTT Technical Research Centre of Finland - initial API and implementation\r
11  *******************************************************************************/\r
12 package org.simantics.event.view.preference;\r
13 \r
14 import org.simantics.databoard.Bindings;\r
15 import org.simantics.db.ReadGraph;\r
16 import org.simantics.db.Resource;\r
17 import org.simantics.db.WriteGraph;\r
18 import org.simantics.db.exception.DatabaseException;\r
19 import org.simantics.event.ontology.EventViewResource;\r
20 \r
21 /**\r
22  * @author Tuukka Lehtonen\r
23  */\r
24 public final class EventPrefs {\r
25 \r
26     public static boolean hideInfoEvents(ReadGraph graph, Resource project) throws DatabaseException {\r
27         return testBoolean(graph, project, EventViewResource.getInstance(graph).HideInfoEvents);\r
28     }\r
29 \r
30     public static boolean hideWarningEvents(ReadGraph graph, Resource project) throws DatabaseException {\r
31         return testBoolean(graph, project, EventViewResource.getInstance(graph).HideWarningEvents);\r
32     }\r
33 \r
34     public static boolean hideReturnEvents(ReadGraph graph, Resource project) throws DatabaseException {\r
35         return testBoolean(graph, project, EventViewResource.getInstance(graph).HideReturnEvents);\r
36     }\r
37 \r
38     public static boolean showHiddenEvents(ReadGraph graph, Resource project) throws DatabaseException {\r
39         return testBoolean(graph, project, EventViewResource.getInstance(graph).ShowHiddenEvents);\r
40     }\r
41 \r
42     public static boolean showOnlyMilestones(ReadGraph graph, Resource project) throws DatabaseException {\r
43         return testBoolean(graph, project, EventViewResource.getInstance(graph).ShowOnlyMilestones);\r
44     }\r
45 \r
46     public static boolean showOnlyActiveEvents(ReadGraph graph, Resource project) throws DatabaseException {\r
47         return testBoolean(graph, project, EventViewResource.getInstance(graph).ShowOnlyActiveEvents);\r
48     }\r
49 \r
50     private static boolean testBoolean(ReadGraph graph, Resource project, Resource property) throws DatabaseException {\r
51         if (project == null)\r
52             return false;\r
53         return Boolean.TRUE.equals(graph.getPossibleRelatedValue(project, property, Bindings.BOOLEAN));\r
54     }\r
55 \r
56     public static void setHideInfoEvents(WriteGraph graph, Resource project, boolean show) throws DatabaseException {\r
57         setBoolean(graph, project, EventViewResource.getInstance(graph).HideInfoEvents, show);\r
58     }\r
59 \r
60     public static void setHideWarningEvents(WriteGraph graph, Resource project, boolean show) throws DatabaseException {\r
61         setBoolean(graph, project, EventViewResource.getInstance(graph).HideWarningEvents, show);\r
62     }\r
63 \r
64     public static void setHideReturnEvents(WriteGraph graph, Resource project, boolean show) throws DatabaseException {\r
65         setBoolean(graph, project, EventViewResource.getInstance(graph).HideReturnEvents, show);\r
66     }\r
67 \r
68     public static void setShowHiddenEvents(WriteGraph graph, Resource project, boolean show) throws DatabaseException {\r
69         setBoolean(graph, project, EventViewResource.getInstance(graph).ShowHiddenEvents, show);\r
70     }\r
71 \r
72     public static void setShowOnlyMilestones(WriteGraph graph, Resource project, boolean show) throws DatabaseException {\r
73         setBoolean(graph, project, EventViewResource.getInstance(graph).ShowOnlyMilestones, show);\r
74     }\r
75 \r
76     public static void setShowOnlyActiveEvents(WriteGraph graph, Resource project, boolean show) throws DatabaseException {\r
77         setBoolean(graph, project, EventViewResource.getInstance(graph).ShowOnlyActiveEvents, show);\r
78     }\r
79 \r
80     private static void setBoolean(WriteGraph graph, Resource project, Resource property, boolean value) throws DatabaseException {\r
81         graph.claimLiteral(project, property, value, Bindings.BOOLEAN);\r
82     }\r
83 \r
84 }\r