X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.browsing.ui.swt%2Fsrc%2Forg%2Fsimantics%2Fbrowsing%2Fui%2Fswt%2Fwidgets%2FStringPropertyFactory.java;h=f675f01042a41a68d61ca08128a8cb77ffe902fe;hb=HEAD;hp=4bc105f85419259de7dca65ad35879a10fe119a9;hpb=969bd23cab98a79ca9101af33334000879fb60c5;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.browsing.ui.swt/src/org/simantics/browsing/ui/swt/widgets/StringPropertyFactory.java b/bundles/org.simantics.browsing.ui.swt/src/org/simantics/browsing/ui/swt/widgets/StringPropertyFactory.java index 4bc105f85..f675f0104 100644 --- a/bundles/org.simantics.browsing.ui.swt/src/org/simantics/browsing/ui/swt/widgets/StringPropertyFactory.java +++ b/bundles/org.simantics.browsing.ui.swt/src/org/simantics/browsing/ui/swt/widgets/StringPropertyFactory.java @@ -1,48 +1,48 @@ -/******************************************************************************* - * Copyright (c) 2007, 2012 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.browsing.ui.swt.widgets; - -import org.simantics.browsing.ui.swt.widgets.impl.ReadFactoryImpl; -import org.simantics.db.ReadGraph; -import org.simantics.db.Resource; -import org.simantics.db.exception.DatabaseException; -import org.simantics.utils.datastructures.Triple; - -/** - * @author Antti Villberg - */ -public class StringPropertyFactory extends ReadFactoryImpl { - - private final String propertyURI; - private final String defaultValue; - - public StringPropertyFactory(String propertyURI) { - this(propertyURI, null); - } - - public StringPropertyFactory(String propertyURI, String defaultValue) { - this.propertyURI = propertyURI; - this.defaultValue = defaultValue; - } - - @Override - public Object getIdentity(Object inputContents) { - return new Triple((Resource) inputContents, propertyURI, getClass()); - } - - @Override - public String perform(ReadGraph graph, Resource resource) throws DatabaseException { - String value = graph.getPossibleRelatedValue(resource, graph.getResource(propertyURI)); - return value != null ? value : defaultValue; - } - -} +/******************************************************************************* + * Copyright (c) 2007, 2012 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.browsing.ui.swt.widgets; + +import org.simantics.browsing.ui.swt.widgets.impl.ReadFactoryImpl; +import org.simantics.db.ReadGraph; +import org.simantics.db.Resource; +import org.simantics.db.exception.DatabaseException; +import org.simantics.utils.datastructures.Triple; + +/** + * @author Antti Villberg + */ +public class StringPropertyFactory extends ReadFactoryImpl { + + private final String propertyURI; + private final String defaultValue; + + public StringPropertyFactory(String propertyURI) { + this(propertyURI, null); + } + + public StringPropertyFactory(String propertyURI, String defaultValue) { + this.propertyURI = propertyURI; + this.defaultValue = defaultValue; + } + + @Override + public Object getIdentity(Object inputContents) { + return new Triple((Resource) inputContents, propertyURI, getClass()); + } + + @Override + public String perform(ReadGraph graph, Resource resource) throws DatabaseException { + String value = graph.getPossibleRelatedValue(resource, graph.getResource(propertyURI)); + return value != null ? value : defaultValue; + } + +}