-package org.simantics.document.linking.report.evaluator;\r
-\r
-import java.util.ArrayList;\r
-import java.util.HashMap;\r
-import java.util.List;\r
-import java.util.Map;\r
-\r
-import org.eclipse.jface.resource.ImageDescriptor;\r
-import org.simantics.db.ReadGraph;\r
-import org.simantics.db.exception.DatabaseException;\r
-import org.simantics.db.layer0.variable.Variable;\r
-import org.simantics.document.linking.Activator;\r
-import org.simantics.document.linking.ontology.DocumentLink;\r
-import org.simantics.document.linking.report.DocumentLine;\r
-import org.simantics.objmap.graph.annotations.OrderedSetType;\r
-import org.simantics.objmap.graph.annotations.RelatedGetValue;\r
-import org.simantics.objmap.graph.annotations.RelatedSetValue;\r
-\r
-/**\r
- * And node combines contents of the child nodes with configurable separator (default " ")\r
- * \r
- * If all children return null, the return value is null.\r
- * \r
- * @author Marko Luukkainen <marko.luukkainen@vtt.fi>\r
- *\r
- */\r
-@OrderedSetType(DocumentLink.URIs.EvaluatorTree_And)\r
-public class And extends EvaluatorNode implements StringEditableNode{\r
- \r
- String separator;\r
- \r
- \r
- public And() {\r
- separator = " ";\r
- }\r
- \r
- public And(String separator) {\r
- this.separator = separator;\r
- }\r
- \r
- public void setSeparator(String separator) {\r
- this.separator = separator;\r
- }\r
- \r
- public String getSeparator() {\r
- return separator;\r
- }\r
- \r
- \r
- @Override\r
- public String getValue(ReadGraph graph, Variable variable, Map<Object, Object> context) throws DatabaseException {\r
- String s = "";\r
- for (int i = 0 ; i < children.size(); i++) {\r
- String s2 = children.get(i).getValue(graph, variable, context);\r
- if (s2 != null) {\r
- s+= s2;\r
- if (i < children.size()-1)\r
- s+=separator;\r
- }\r
- }\r
- if (s.length() == 0)\r
- return null;\r
- return s;\r
- }\r
- \r
- @Override\r
- public List<DocumentLine> getLines(ReadGraph graph, Variable variable, Map<Object, Object> context) throws DatabaseException {\r
- List<DocumentLine> result = new ArrayList<DocumentLine>();\r
- for (int i = 0 ; i < children.size(); i++) {\r
- List<DocumentLine> list = children.get(i).getLines(graph, variable, context);\r
- for (int j = 0; j < list.size(); j++) {\r
- DocumentLine line = list.get(j); \r
- if (j <= result.size()) {\r
- result.add(line);\r
- } else {\r
- DocumentLine extLine = result.get(j);\r
- String combined = extLine.getLine() + separator + line.getLine();\r
- Map<Object,Object> combinedSet = new HashMap<Object, Object>();\r
- combinedSet.putAll(extLine.getHints());\r
- combinedSet.putAll(line.getHints());\r
- \r
- result.set(j, new DocumentLine(combined,combinedSet));\r
- }\r
- }\r
- }\r
- return result;\r
- }\r
- \r
-\r
- @Override\r
- public String toString() {\r
- return "and " + "(" + separator +")" ;\r
- }\r
- \r
- @RelatedGetValue(DocumentLink.URIs.EvaluatorTree_HasValue)\r
- @Override\r
- public String getValue() {\r
- return separator;\r
- }\r
- \r
- @Override\r
- public String setValue(String value) {\r
- separator = value;\r
- return null;\r
- }\r
- \r
- @RelatedSetValue(DocumentLink.URIs.EvaluatorTree_HasValue)\r
- public void _setValue(String value) {\r
- separator = value;\r
- }\r
- \r
- @Override\r
- public EvaluatorItem copy() {\r
- And a = new And(separator);\r
- copyChildren(a);\r
- return a;\r
- }\r
- \r
- @Override\r
- public ImageDescriptor getImage() {\r
- return Activator.imageDescriptorFromPlugin("com.famfamfam.silk", "icons/text_columns.png");\r
- }\r
-\r
-}\r
+package org.simantics.document.linking.report.evaluator;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.simantics.db.ReadGraph;
+import org.simantics.db.exception.DatabaseException;
+import org.simantics.db.layer0.variable.Variable;
+import org.simantics.document.linking.Activator;
+import org.simantics.document.linking.ontology.DocumentLink;
+import org.simantics.document.linking.report.DocumentLine;
+import org.simantics.objmap.graph.annotations.OrderedSetType;
+import org.simantics.objmap.graph.annotations.RelatedGetValue;
+import org.simantics.objmap.graph.annotations.RelatedSetValue;
+
+/**
+ * And node combines contents of the child nodes with configurable separator (default " ")
+ *
+ * If all children return null, the return value is null.
+ *
+ * @author Marko Luukkainen <marko.luukkainen@vtt.fi>
+ *
+ */
+@OrderedSetType(DocumentLink.URIs.EvaluatorTree_And)
+public class And extends EvaluatorNode implements StringEditableNode{
+
+ String separator;
+
+
+ public And() {
+ separator = " ";
+ }
+
+ public And(String separator) {
+ this.separator = separator;
+ }
+
+ public void setSeparator(String separator) {
+ this.separator = separator;
+ }
+
+ public String getSeparator() {
+ return separator;
+ }
+
+
+ @Override
+ public String getValue(ReadGraph graph, Variable variable, Map<Object, Object> context) throws DatabaseException {
+ String s = "";
+ for (int i = 0 ; i < children.size(); i++) {
+ String s2 = children.get(i).getValue(graph, variable, context);
+ if (s2 != null) {
+ s+= s2;
+ if (i < children.size()-1)
+ s+=separator;
+ }
+ }
+ if (s.length() == 0)
+ return null;
+ return s;
+ }
+
+ @Override
+ public List<DocumentLine> getLines(ReadGraph graph, Variable variable, Map<Object, Object> context) throws DatabaseException {
+ List<DocumentLine> result = new ArrayList<DocumentLine>();
+ for (int i = 0 ; i < children.size(); i++) {
+ List<DocumentLine> list = children.get(i).getLines(graph, variable, context);
+ for (int j = 0; j < list.size(); j++) {
+ DocumentLine line = list.get(j);
+ if (j <= result.size()) {
+ result.add(line);
+ } else {
+ DocumentLine extLine = result.get(j);
+ String combined = extLine.getLine() + separator + line.getLine();
+ Map<Object,Object> combinedSet = new HashMap<Object, Object>();
+ combinedSet.putAll(extLine.getHints());
+ combinedSet.putAll(line.getHints());
+
+ result.set(j, new DocumentLine(combined,combinedSet));
+ }
+ }
+ }
+ return result;
+ }
+
+
+ @Override
+ public String toString() {
+ return "and " + "(" + separator +")" ;
+ }
+
+ @RelatedGetValue(DocumentLink.URIs.EvaluatorTree_HasValue)
+ @Override
+ public String getValue() {
+ return separator;
+ }
+
+ @Override
+ public String setValue(String value) {
+ separator = value;
+ return null;
+ }
+
+ @RelatedSetValue(DocumentLink.URIs.EvaluatorTree_HasValue)
+ public void _setValue(String value) {
+ separator = value;
+ }
+
+ @Override
+ public EvaluatorItem copy() {
+ And a = new And(separator);
+ copyChildren(a);
+ return a;
+ }
+
+ @Override
+ public ImageDescriptor getImage() {
+ return Activator.imageDescriptorFromPlugin("com.famfamfam.silk", "icons/text_columns.png");
+ }
+
+}