]> gerrit.simantics Code Review - simantics/sysdyn.git/blob
7727d14ee8b29da4d769f13bda3f4828c8045530
[simantics/sysdyn.git] /
1 package org.simantics.sysdyn.ui.properties.widgets.factories;\r
2 \r
3 import org.simantics.browsing.ui.swt.widgets.impl.ReadFactoryImpl;\r
4 import org.simantics.db.ReadGraph;\r
5 import org.simantics.db.Resource;\r
6 import org.simantics.db.exception.DatabaseException;\r
7 import org.simantics.utils.datastructures.Triple;\r
8 \r
9 public class DoublePropertyFactory extends ReadFactoryImpl<Resource, String> {\r
10 \r
11     final private String propertyURI;\r
12     \r
13     public DoublePropertyFactory(String propertyURI) {\r
14         this.propertyURI = propertyURI;\r
15     }\r
16 \r
17     @Override\r
18     public Object getIdentity(Object inputContents) {\r
19         return new Triple<Resource, String, Object>((Resource)inputContents, propertyURI, getClass());\r
20     }\r
21     \r
22     @Override\r
23     public String perform(ReadGraph graph, Resource issue) throws DatabaseException {\r
24         \r
25         Double value = graph.getPossibleRelatedValue(issue, graph.getResource(propertyURI));\r
26         if (value != null)\r
27             return value.toString();\r
28         else\r
29             return "";\r
30     }\r
31     \r
32 }\r