]> gerrit.simantics Code Review - simantics/sysdyn.git/blob
045bf1603011e18475cbe231052552dfbcfe63e0
[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.db.management.ISessionContext;\r
8 import org.simantics.utils.datastructures.Triple;\r
9 \r
10 public class DoublePropertyFactory extends ReadFactoryImpl<Resource, String> {\r
11 \r
12     final private String propertyURI;\r
13     \r
14     public DoublePropertyFactory(String propertyURI) {\r
15         this.propertyURI = propertyURI;\r
16     }\r
17 \r
18     @Override\r
19     public Object getIdentity(Object inputContents) {\r
20         return new Triple<Resource, String, Object>((Resource)inputContents, propertyURI, getClass());\r
21     }\r
22     \r
23     @Override\r
24     public String perform(ReadGraph graph, Resource issue) throws DatabaseException {\r
25         \r
26         Double value = graph.getPossibleRelatedValue(issue, graph.getResource(propertyURI));\r
27         if (value != null)\r
28             return value.toString();\r
29         else\r
30             return "";\r
31     }\r
32     \r
33 }\r