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.issues.common.preferences;
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.issues.ui.ontology.IssueUIResource;
22 * @author Tuukka Lehtonen
24 public final class IssuePrefs {
26 public static boolean showHiddenIssues(ReadGraph graph, Resource project) throws DatabaseException {
27 return testBoolean(graph, project, IssueUIResource.getInstance(graph).ShowHiddenIssues, false);
30 public static boolean showNormalIssues(ReadGraph graph, Resource project) throws DatabaseException {
31 return testBoolean(graph, project, IssueUIResource.getInstance(graph).ShowNormalIssues, true);
34 public static boolean showUserIssues(ReadGraph graph, Resource project) throws DatabaseException {
35 return testBoolean(graph, project, IssueUIResource.getInstance(graph).ShowUserIssues, true);
38 private static boolean testBoolean(ReadGraph graph, Resource project, Resource property, boolean defaultValue) throws DatabaseException {
41 Boolean b = graph.getPossibleRelatedValue(project, property, Bindings.BOOLEAN);
42 return b == null ? defaultValue : b;
45 public static void setShowHiddenIssues(WriteGraph graph, Resource project, boolean show) throws DatabaseException {
46 setBoolean(graph, project, IssueUIResource.getInstance(graph).ShowHiddenIssues, show);
49 public static void setShowNormalIssues(WriteGraph graph, Resource project, boolean show) throws DatabaseException {
50 setBoolean(graph, project, IssueUIResource.getInstance(graph).ShowNormalIssues, show);
53 public static void setShowUserIssues(WriteGraph graph, Resource project, boolean show) throws DatabaseException {
54 setBoolean(graph, project, IssueUIResource.getInstance(graph).ShowUserIssues, show);
57 private static void setBoolean(WriteGraph graph, Resource project, Resource property, boolean value)
58 throws DatabaseException {
59 graph.claimLiteral(project, property, value, Bindings.BOOLEAN);