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
10 * VTT Technical Research Centre of Finland - initial API and implementation
\r
11 *******************************************************************************/
\r
12 package org.simantics.event.view.preference;
\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
22 * @author Tuukka Lehtonen
\r
24 public final class EventPrefs {
\r
26 public static boolean hideInfoEvents(ReadGraph graph, Resource project) throws DatabaseException {
\r
27 return testBoolean(graph, project, EventViewResource.getInstance(graph).HideInfoEvents);
\r
30 public static boolean hideWarningEvents(ReadGraph graph, Resource project) throws DatabaseException {
\r
31 return testBoolean(graph, project, EventViewResource.getInstance(graph).HideWarningEvents);
\r
34 public static boolean hideReturnEvents(ReadGraph graph, Resource project) throws DatabaseException {
\r
35 return testBoolean(graph, project, EventViewResource.getInstance(graph).HideReturnEvents);
\r
38 public static boolean showHiddenEvents(ReadGraph graph, Resource project) throws DatabaseException {
\r
39 return testBoolean(graph, project, EventViewResource.getInstance(graph).ShowHiddenEvents);
\r
42 public static boolean showOnlyMilestones(ReadGraph graph, Resource project) throws DatabaseException {
\r
43 return testBoolean(graph, project, EventViewResource.getInstance(graph).ShowOnlyMilestones);
\r
46 public static boolean showOnlyActiveEvents(ReadGraph graph, Resource project) throws DatabaseException {
\r
47 return testBoolean(graph, project, EventViewResource.getInstance(graph).ShowOnlyActiveEvents);
\r
50 private static boolean testBoolean(ReadGraph graph, Resource project, Resource property) throws DatabaseException {
\r
51 if (project == null)
\r
53 return Boolean.TRUE.equals(graph.getPossibleRelatedValue(project, property, Bindings.BOOLEAN));
\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
60 public static void setHideWarningEvents(WriteGraph graph, Resource project, boolean show) throws DatabaseException {
\r
61 setBoolean(graph, project, EventViewResource.getInstance(graph).HideWarningEvents, show);
\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
68 public static void setShowHiddenEvents(WriteGraph graph, Resource project, boolean show) throws DatabaseException {
\r
69 setBoolean(graph, project, EventViewResource.getInstance(graph).ShowHiddenEvents, show);
\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
76 public static void setShowOnlyActiveEvents(WriteGraph graph, Resource project, boolean show) throws DatabaseException {
\r
77 setBoolean(graph, project, EventViewResource.getInstance(graph).ShowOnlyActiveEvents, show);
\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