]> gerrit.simantics Code Review - simantics/platform.git/blob
e33fa92fb62d8d145f454e8b25f11631a4ca0258
[simantics/platform.git] /
1 package org.simantics.document.linking.report.evaluator;
2
3 import java.util.Map;
4
5 import org.eclipse.jface.resource.ImageDescriptor;
6 import org.simantics.db.ReadGraph;
7 import org.simantics.db.exception.DatabaseException;
8 import org.simantics.db.layer0.variable.Variable;
9 import org.simantics.document.linking.Activator;
10 import org.simantics.document.linking.ontology.DocumentLink;
11 import org.simantics.objmap.graph.annotations.GraphType;
12 import org.simantics.objmap.graph.annotations.RelatedGetValue;
13 import org.simantics.objmap.graph.annotations.RelatedSetValue;
14
15
16 @GraphType(DocumentLink.URIs.EvaluatorTree_Constant)
17 public class Constant extends EvaluatorLeaf implements StringEditableNode{
18         
19         private String string;
20         
21         
22         public Constant() {
23                 string = "text";
24         }
25         
26         public Constant(String text) {
27                 if (text == null)
28                         throw new NullPointerException("Text is null");
29                 string = text;
30         }
31         
32         @Override
33         public String getValue(ReadGraph graph, Variable variable, Map<Object, Object> context) throws DatabaseException {
34                 return string;
35         }
36         
37         @Override
38         public String toString() {
39                 return "\"" + string + "\"";
40         }
41         
42         @RelatedGetValue(DocumentLink.URIs.EvaluatorTree_HasValue)
43         @Override
44         public String getValue() {
45                 return string;
46         }
47         
48         @Override
49         public String setValue(String value) {
50                 string = value;
51                 return null;
52         }
53         
54         @RelatedSetValue(DocumentLink.URIs.EvaluatorTree_HasValue)
55         public void _setValue(String value) {
56                 string = value;
57         }
58         
59         @Override
60         public EvaluatorItem copy() {
61                 return new Constant(string);
62         }
63         
64         
65         @Override
66         public ImageDescriptor getImage() {
67                 return Activator.imageDescriptorFromPlugin("com.famfamfam.silk", "icons/textfield.png");
68         }
69
70 }