--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2011 Association for Decentralized Information Management\r
+ * in Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.event.view.preference;\r
+\r
+import org.simantics.databoard.Bindings;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.WriteGraph;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.event.ontology.EventViewResource;\r
+\r
+/**\r
+ * @author Tuukka Lehtonen\r
+ */\r
+public final class EventPrefs {\r
+\r
+ public static boolean hideInfoEvents(ReadGraph graph, Resource project) throws DatabaseException {\r
+ return testBoolean(graph, project, EventViewResource.getInstance(graph).HideInfoEvents);\r
+ }\r
+\r
+ public static boolean hideWarningEvents(ReadGraph graph, Resource project) throws DatabaseException {\r
+ return testBoolean(graph, project, EventViewResource.getInstance(graph).HideWarningEvents);\r
+ }\r
+\r
+ public static boolean hideReturnEvents(ReadGraph graph, Resource project) throws DatabaseException {\r
+ return testBoolean(graph, project, EventViewResource.getInstance(graph).HideReturnEvents);\r
+ }\r
+\r
+ public static boolean showHiddenEvents(ReadGraph graph, Resource project) throws DatabaseException {\r
+ return testBoolean(graph, project, EventViewResource.getInstance(graph).ShowHiddenEvents);\r
+ }\r
+\r
+ public static boolean showOnlyMilestones(ReadGraph graph, Resource project) throws DatabaseException {\r
+ return testBoolean(graph, project, EventViewResource.getInstance(graph).ShowOnlyMilestones);\r
+ }\r
+\r
+ public static boolean showOnlyActiveEvents(ReadGraph graph, Resource project) throws DatabaseException {\r
+ return testBoolean(graph, project, EventViewResource.getInstance(graph).ShowOnlyActiveEvents);\r
+ }\r
+\r
+ private static boolean testBoolean(ReadGraph graph, Resource project, Resource property) throws DatabaseException {\r
+ if (project == null)\r
+ return false;\r
+ return Boolean.TRUE.equals(graph.getPossibleRelatedValue(project, property, Bindings.BOOLEAN));\r
+ }\r
+\r
+ public static void setHideInfoEvents(WriteGraph graph, Resource project, boolean show) throws DatabaseException {\r
+ setBoolean(graph, project, EventViewResource.getInstance(graph).HideInfoEvents, show);\r
+ }\r
+\r
+ public static void setHideWarningEvents(WriteGraph graph, Resource project, boolean show) throws DatabaseException {\r
+ setBoolean(graph, project, EventViewResource.getInstance(graph).HideWarningEvents, show);\r
+ }\r
+\r
+ public static void setHideReturnEvents(WriteGraph graph, Resource project, boolean show) throws DatabaseException {\r
+ setBoolean(graph, project, EventViewResource.getInstance(graph).HideReturnEvents, show);\r
+ }\r
+\r
+ public static void setShowHiddenEvents(WriteGraph graph, Resource project, boolean show) throws DatabaseException {\r
+ setBoolean(graph, project, EventViewResource.getInstance(graph).ShowHiddenEvents, show);\r
+ }\r
+\r
+ public static void setShowOnlyMilestones(WriteGraph graph, Resource project, boolean show) throws DatabaseException {\r
+ setBoolean(graph, project, EventViewResource.getInstance(graph).ShowOnlyMilestones, show);\r
+ }\r
+\r
+ public static void setShowOnlyActiveEvents(WriteGraph graph, Resource project, boolean show) throws DatabaseException {\r
+ setBoolean(graph, project, EventViewResource.getInstance(graph).ShowOnlyActiveEvents, show);\r
+ }\r
+\r
+ private static void setBoolean(WriteGraph graph, Resource project, Resource property, boolean value) throws DatabaseException {\r
+ graph.claimLiteral(project, property, value, Bindings.BOOLEAN);\r
+ }\r
+\r
+}\r