1 package org.simantics.document.linking.report.evaluator;
\r
3 import java.util.Map;
\r
5 import org.eclipse.jface.resource.ImageDescriptor;
\r
6 import org.simantics.db.ReadGraph;
\r
7 import org.simantics.db.exception.DatabaseException;
\r
8 import org.simantics.document.linking.Activator;
\r
9 import org.simantics.document.linking.ontology.DocumentLink;
\r
10 import org.simantics.document.linking.utils.SourceLinkUtil;
\r
11 import org.simantics.objmap.graph.annotations.GraphType;
\r
12 import org.simantics.objmap.graph.annotations.RelatedGetValue;
\r
13 import org.simantics.objmap.graph.annotations.RelatedSetValue;
\r
16 @GraphType(DocumentLink.URIs.EvaluatorTree_Variable)
\r
17 public class Variable extends EvaluatorLeaf implements StringEditableNode{
\r
19 String variableRef = "#HasName";
\r
25 public Variable(String variableRef) {
\r
26 this.variableRef = variableRef;
\r
29 public void setVariableRef(String variableRef) {
\r
30 this.variableRef = variableRef;
\r
33 public String getVariableRef() {
\r
38 public String getValue(ReadGraph graph, org.simantics.db.layer0.variable.Variable variable, Map<Object, Object> context) throws DatabaseException {
\r
39 if (context.containsKey(variableRef))
\r
40 return SourceLinkUtil.getValueString(context.get(variableRef));
\r
42 org.simantics.db.layer0.variable.Variable propertyVar = PredefinedVariables.getInstance().getVariable(graph, variableRef, null, variable);
\r
43 if (propertyVar.getRepresents(graph) == null)
\r
45 return SourceLinkUtil.getValueString(propertyVar.getValue(graph));
\r
46 } catch (Exception e) {
\r
55 public String toString() {
\r
59 @RelatedGetValue(DocumentLink.URIs.EvaluatorTree_HasValue)
\r
61 public String getValue() {
\r
67 public String setValue(String value) {
\r
68 if (value.length() == 0)
\r
69 return "Variable reference cannot be empty";
\r
70 variableRef = value;
\r
74 @RelatedSetValue(DocumentLink.URIs.EvaluatorTree_HasValue)
\r
75 public void _setValue(String value) {
\r
76 variableRef = value;
\r
81 public EvaluatorItem copy() {
\r
82 return new Variable(variableRef);
\r
86 public ImageDescriptor getImage() {
\r
87 return Activator.imageDescriptorFromPlugin("com.famfamfam.silk", "icons/database_go.png");
\r