1 /*******************************************************************************
2 * Copyright (c) 2007, 2011 Association for Decentralized Information Management
4 * All rights reserved. This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License v1.0
6 * which accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
10 * VTT Technical Research Centre of Finland - initial API and implementation
11 *******************************************************************************/
12 package org.simantics.event.view.preference;
14 import org.simantics.databoard.Bindings;
15 import org.simantics.db.ReadGraph;
16 import org.simantics.db.Resource;
17 import org.simantics.db.WriteGraph;
18 import org.simantics.db.exception.DatabaseException;
19 import org.simantics.event.ontology.EventViewResource;
22 * @author Tuukka Lehtonen
24 public final class EventPrefs {
26 public static boolean hideInfoEvents(ReadGraph graph, Resource project) throws DatabaseException {
27 return testBoolean(graph, project, EventViewResource.getInstance(graph).HideInfoEvents);
30 public static boolean hideWarningEvents(ReadGraph graph, Resource project) throws DatabaseException {
31 return testBoolean(graph, project, EventViewResource.getInstance(graph).HideWarningEvents);
34 public static boolean hideReturnEvents(ReadGraph graph, Resource project) throws DatabaseException {
35 return testBoolean(graph, project, EventViewResource.getInstance(graph).HideReturnEvents);
38 public static boolean showHiddenEvents(ReadGraph graph, Resource project) throws DatabaseException {
39 return testBoolean(graph, project, EventViewResource.getInstance(graph).ShowHiddenEvents);
42 public static boolean showOnlyMilestones(ReadGraph graph, Resource project) throws DatabaseException {
43 return testBoolean(graph, project, EventViewResource.getInstance(graph).ShowOnlyMilestones);
46 public static boolean showOnlyActiveEvents(ReadGraph graph, Resource project) throws DatabaseException {
47 return testBoolean(graph, project, EventViewResource.getInstance(graph).ShowOnlyActiveEvents);
50 private static boolean testBoolean(ReadGraph graph, Resource project, Resource property) throws DatabaseException {
53 return Boolean.TRUE.equals(graph.getPossibleRelatedValue(project, property, Bindings.BOOLEAN));
56 public static void setHideInfoEvents(WriteGraph graph, Resource project, boolean show) throws DatabaseException {
57 setBoolean(graph, project, EventViewResource.getInstance(graph).HideInfoEvents, show);
60 public static void setHideWarningEvents(WriteGraph graph, Resource project, boolean show) throws DatabaseException {
61 setBoolean(graph, project, EventViewResource.getInstance(graph).HideWarningEvents, show);
64 public static void setHideReturnEvents(WriteGraph graph, Resource project, boolean show) throws DatabaseException {
65 setBoolean(graph, project, EventViewResource.getInstance(graph).HideReturnEvents, show);
68 public static void setShowHiddenEvents(WriteGraph graph, Resource project, boolean show) throws DatabaseException {
69 setBoolean(graph, project, EventViewResource.getInstance(graph).ShowHiddenEvents, show);
72 public static void setShowOnlyMilestones(WriteGraph graph, Resource project, boolean show) throws DatabaseException {
73 setBoolean(graph, project, EventViewResource.getInstance(graph).ShowOnlyMilestones, show);
76 public static void setShowOnlyActiveEvents(WriteGraph graph, Resource project, boolean show) throws DatabaseException {
77 setBoolean(graph, project, EventViewResource.getInstance(graph).ShowOnlyActiveEvents, show);
80 private static void setBoolean(WriteGraph graph, Resource project, Resource property, boolean value) throws DatabaseException {
81 graph.claimLiteral(project, property, value, Bindings.BOOLEAN);