]> gerrit.simantics Code Review - simantics/platform.git/blob
2c0f0e766a74f40190217ddab4aba227f80e0a88
[simantics/platform.git] /
1 package org.simantics.document.linking.report.evaluator;
2
3 import java.util.Collections;
4 import java.util.List;
5 import java.util.Map;
6
7 import org.eclipse.jface.resource.ImageDescriptor;
8 import org.simantics.db.ReadGraph;
9 import org.simantics.db.exception.DatabaseException;
10 import org.simantics.db.layer0.variable.Variable;
11 import org.simantics.document.linking.ontology.DocumentLink;
12 import org.simantics.document.linking.report.DocumentLine;
13 import org.simantics.objmap.graph.annotations.OrderedSetType;
14
15
16 @OrderedSetType(DocumentLink.URIs.EvaluatorTree_Root)
17 public class EvaluatorRoot extends EvaluatorNode{
18         
19         boolean supportMultiline = true;
20         boolean supportStyles = false;
21         
22         public boolean isSupportMultiline() {
23                 return supportMultiline;
24         }
25         
26         public void setSupportMultiline(boolean multilineSupport) {
27                 this.supportMultiline = multilineSupport;
28         }
29         
30         public void setSupportStyles(boolean allowStyles) {
31                 this.supportStyles = allowStyles;
32         }
33         
34         public boolean isSupportStyles() {
35                 return supportStyles;
36         }
37         
38         @Override
39         public String getValue(ReadGraph graph, Variable variable, Map<Object, Object> context) throws DatabaseException {
40                 if (children.size() > 0 )
41                         return children.get(0).getValue(graph, variable, context);
42                 return null;
43         }
44         
45         @Override
46         public List<DocumentLine> getLines(ReadGraph graph,     Variable variable, Map<Object, Object> context) throws DatabaseException {
47                 if (children.size() > 0 )
48                         return children.get(0).getLines(graph, variable, context);
49                 return null;
50         }
51         
52         @Override
53         public List<Class<? extends EvaluatorItem>> getPossibleChildren(boolean add) {
54                 if (add && children.size() > 0)
55                         return Collections.emptyList();
56                 List<Class<? extends EvaluatorItem>> classes = super.getPossibleChildren(add);
57                 if (supportMultiline) {
58                         if (!(children.size() == 1 && children.get(0) instanceof Lines))
59                                 classes.add(Lines.class);
60                 }
61                 return classes;
62         }
63         
64         @Override
65         public String toString() {
66                 return "root";
67         }
68         
69         @Override
70         public EvaluatorRoot getRoot() {
71                 return this;
72         }
73         
74         @Override
75         public EvaluatorItem copy() {
76                 EvaluatorRoot root = new EvaluatorRoot();
77                 root.supportMultiline = supportMultiline;
78                 root.supportStyles = supportStyles;
79                 copyChildren(root);
80                 return root;
81         }
82         
83         @Override
84         public ImageDescriptor getImage() {
85                 return null;
86         }
87
88 }