1 package org.simantics.document.linking.report.templates.custom;
3 import java.util.Collections;
7 import org.simantics.db.ReadGraph;
8 import org.simantics.db.Resource;
9 import org.simantics.db.exception.DatabaseException;
10 import org.simantics.db.layer0.variable.Variable;
11 import org.simantics.document.linking.report.DocumentLine;
12 import org.simantics.document.linking.report.evaluator.EvaluatorItem;
13 import org.simantics.document.linking.utils.SourceLinkUtil;
16 public class EvaluatorCustomizableContent implements CustomizableContent{
21 boolean supportStyles = false;
22 boolean supportMultiline = true;
24 public EvaluatorCustomizableContent(String description) {
25 this.description = description;
29 public String getCustomizationDescription() {
34 public String getContent(ReadGraph graph, Resource resource, Map<Object, Object> context)
35 throws DatabaseException {
36 if (!SourceLinkUtil.isValidReference(graph, resource))
37 return "Deleted reference";
38 Variable variable = graph.adapt(resource, Variable.class);
39 return item.getValue(graph, variable,context);
43 public List<DocumentLine> getLines(ReadGraph graph, Resource resource, Map<Object, Object> context)
44 throws DatabaseException {
45 if (!SourceLinkUtil.isValidReference(graph, resource))
46 return Collections.singletonList(new DocumentLine("Deleted reference"));
47 Variable variable = graph.adapt(resource, Variable.class);
48 return item.getLines(graph, variable,context);
51 public void setItem(EvaluatorItem item) {
55 public EvaluatorItem getItem() {
59 public boolean isSupportStyles() {
63 public void setSupportStyles(boolean supportStyles) {
64 this.supportStyles = supportStyles;
67 public boolean isSupportMultiline() {
68 return supportMultiline;
70 public void setSupportMultiline(boolean supportMultiline) {
71 this.supportMultiline = supportMultiline;