X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.event%2Fsrc%2Forg%2Fsimantics%2Fevent%2Fview%2Fpreference%2FEventPrefs.java;fp=bundles%2Forg.simantics.event%2Fsrc%2Forg%2Fsimantics%2Fevent%2Fview%2Fpreference%2FEventPrefs.java;h=c7179df932cf73f6146d7a21f29671a86b712c99;hb=969bd23cab98a79ca9101af33334000879fb60c5;hp=0000000000000000000000000000000000000000;hpb=866dba5cd5a3929bbeae85991796acb212338a08;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.event/src/org/simantics/event/view/preference/EventPrefs.java b/bundles/org.simantics.event/src/org/simantics/event/view/preference/EventPrefs.java new file mode 100644 index 000000000..c7179df93 --- /dev/null +++ b/bundles/org.simantics.event/src/org/simantics/event/view/preference/EventPrefs.java @@ -0,0 +1,84 @@ +/******************************************************************************* + * Copyright (c) 2007, 2011 Association for Decentralized Information Management + * in Industry THTH ry. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * VTT Technical Research Centre of Finland - initial API and implementation + *******************************************************************************/ +package org.simantics.event.view.preference; + +import org.simantics.databoard.Bindings; +import org.simantics.db.ReadGraph; +import org.simantics.db.Resource; +import org.simantics.db.WriteGraph; +import org.simantics.db.exception.DatabaseException; +import org.simantics.event.ontology.EventViewResource; + +/** + * @author Tuukka Lehtonen + */ +public final class EventPrefs { + + public static boolean hideInfoEvents(ReadGraph graph, Resource project) throws DatabaseException { + return testBoolean(graph, project, EventViewResource.getInstance(graph).HideInfoEvents); + } + + public static boolean hideWarningEvents(ReadGraph graph, Resource project) throws DatabaseException { + return testBoolean(graph, project, EventViewResource.getInstance(graph).HideWarningEvents); + } + + public static boolean hideReturnEvents(ReadGraph graph, Resource project) throws DatabaseException { + return testBoolean(graph, project, EventViewResource.getInstance(graph).HideReturnEvents); + } + + public static boolean showHiddenEvents(ReadGraph graph, Resource project) throws DatabaseException { + return testBoolean(graph, project, EventViewResource.getInstance(graph).ShowHiddenEvents); + } + + public static boolean showOnlyMilestones(ReadGraph graph, Resource project) throws DatabaseException { + return testBoolean(graph, project, EventViewResource.getInstance(graph).ShowOnlyMilestones); + } + + public static boolean showOnlyActiveEvents(ReadGraph graph, Resource project) throws DatabaseException { + return testBoolean(graph, project, EventViewResource.getInstance(graph).ShowOnlyActiveEvents); + } + + private static boolean testBoolean(ReadGraph graph, Resource project, Resource property) throws DatabaseException { + if (project == null) + return false; + return Boolean.TRUE.equals(graph.getPossibleRelatedValue(project, property, Bindings.BOOLEAN)); + } + + public static void setHideInfoEvents(WriteGraph graph, Resource project, boolean show) throws DatabaseException { + setBoolean(graph, project, EventViewResource.getInstance(graph).HideInfoEvents, show); + } + + public static void setHideWarningEvents(WriteGraph graph, Resource project, boolean show) throws DatabaseException { + setBoolean(graph, project, EventViewResource.getInstance(graph).HideWarningEvents, show); + } + + public static void setHideReturnEvents(WriteGraph graph, Resource project, boolean show) throws DatabaseException { + setBoolean(graph, project, EventViewResource.getInstance(graph).HideReturnEvents, show); + } + + public static void setShowHiddenEvents(WriteGraph graph, Resource project, boolean show) throws DatabaseException { + setBoolean(graph, project, EventViewResource.getInstance(graph).ShowHiddenEvents, show); + } + + public static void setShowOnlyMilestones(WriteGraph graph, Resource project, boolean show) throws DatabaseException { + setBoolean(graph, project, EventViewResource.getInstance(graph).ShowOnlyMilestones, show); + } + + public static void setShowOnlyActiveEvents(WriteGraph graph, Resource project, boolean show) throws DatabaseException { + setBoolean(graph, project, EventViewResource.getInstance(graph).ShowOnlyActiveEvents, show); + } + + private static void setBoolean(WriteGraph graph, Resource project, Resource property, boolean value) throws DatabaseException { + graph.claimLiteral(project, property, value, Bindings.BOOLEAN); + } + +}