]> gerrit.simantics Code Review - simantics/sysdyn.git/blob
f7a5d666fed84dc40c92e9f5e61e4720db79618a
[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(ISessionContext context, String propertyURI) {\r
15         super(context);\r
16         this.propertyURI = propertyURI;\r
17     }\r
18 \r
19     @Override\r
20     public Object getIdentity(Object inputContents) {\r
21         return new Triple<Resource, String, Object>((Resource)inputContents, propertyURI, getClass());\r
22     }\r
23     \r
24     @Override\r
25     public String perform(ReadGraph graph, Resource issue) throws DatabaseException {\r
26         \r
27         Double value = graph.getPossibleRelatedValue(issue, graph.getResource(propertyURI));\r
28         return value.toString();\r
29         \r
30     }\r
31     \r
32 }\r