X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.modeling.ui%2Fsrc%2Forg%2Fsimantics%2Fmodeling%2Fui%2Fchart%2Fproperty%2FBooleanPropertyFactory.java;h=8efe2668a6980aa0bb42645597ee364836e343b8;hb=47269fe0acb894f346810417d950a1ab59cdc0ea;hp=7d7fb56fe1b34a7bc0524669fd56de84e975e285;hpb=969bd23cab98a79ca9101af33334000879fb60c5;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/chart/property/BooleanPropertyFactory.java b/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/chart/property/BooleanPropertyFactory.java index 7d7fb56fe..8efe2668a 100644 --- a/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/chart/property/BooleanPropertyFactory.java +++ b/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/chart/property/BooleanPropertyFactory.java @@ -1,42 +1,42 @@ -/******************************************************************************* - * Copyright (c) 2014 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: - * Semantum Oy - initial API and implementation - *******************************************************************************/ -package org.simantics.modeling.ui.chart.property; - -import org.simantics.browsing.ui.swt.widgets.impl.ReadFactoryImpl; -import org.simantics.databoard.Bindings; -import org.simantics.db.ReadGraph; -import org.simantics.db.Resource; -import org.simantics.db.exception.DatabaseException; -import org.simantics.utils.datastructures.Triple; - -/** - * @author Tuukka Lehtonen - */ -public class BooleanPropertyFactory extends ReadFactoryImpl { - - final private String propertyURI; - - public BooleanPropertyFactory(String propertyURI) { - this.propertyURI = propertyURI; - } - - @Override - public Object getIdentity(Object inputContents) { - return new Triple((Resource) inputContents, propertyURI, getClass()); - } - - @Override - public Boolean perform(ReadGraph graph, Resource r) throws DatabaseException { - return graph.getPossibleRelatedValue2(r, graph.getResource(propertyURI), Bindings.BOOLEAN); - } - -} +/******************************************************************************* + * Copyright (c) 2014 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: + * Semantum Oy - initial API and implementation + *******************************************************************************/ +package org.simantics.modeling.ui.chart.property; + +import org.simantics.browsing.ui.swt.widgets.impl.ReadFactoryImpl; +import org.simantics.databoard.Bindings; +import org.simantics.db.ReadGraph; +import org.simantics.db.Resource; +import org.simantics.db.exception.DatabaseException; +import org.simantics.utils.datastructures.Triple; + +/** + * @author Tuukka Lehtonen + */ +public class BooleanPropertyFactory extends ReadFactoryImpl { + + final private String propertyURI; + + public BooleanPropertyFactory(String propertyURI) { + this.propertyURI = propertyURI; + } + + @Override + public Object getIdentity(Object inputContents) { + return new Triple((Resource) inputContents, propertyURI, getClass()); + } + + @Override + public Boolean perform(ReadGraph graph, Resource r) throws DatabaseException { + return Boolean.TRUE.equals( graph.getPossibleRelatedValue2(r, graph.getResource(propertyURI), Bindings.BOOLEAN) ); + } + +}