-/*******************************************************************************\r
- * Copyright (c) 2012 Association for Decentralized Information Management in\r
- * Industry THTH ry.\r
- * All rights reserved. This program and the accompanying materials\r
- * are made available under the terms of the Eclipse Public License v1.0\r
- * which accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- * VTT Technical Research Centre of Finland - initial API and implementation\r
- *******************************************************************************/\r
-package org.simantics.document.function;\r
-\r
-import org.simantics.db.ReadGraph;\r
-import org.simantics.db.Resource;\r
-import org.simantics.db.exception.DatabaseException;\r
-import org.simantics.db.layer0.variable.Variable;\r
-import org.simantics.document.DocumentResource;\r
-import org.simantics.document.DocumentSettings;\r
-import org.simantics.document.DocumentUtils;\r
-import org.simantics.document.Exportable;\r
-import org.simantics.document.node.Composite;\r
-import org.simantics.scenegraph.loader.ScenegraphLoaderProcess;\r
-import org.simantics.scenegraph.loader.ScenegraphLoaderUtils;\r
-import org.simantics.scl.reflection.annotations.SCLValue;\r
-\r
-public class All {\r
- \r
- @SCLValue(type = "ReadGraph -> Resource -> Variable -> Variable")\r
- public static Variable documentationRootVariable(ReadGraph graph, Resource resource, Variable context) throws DatabaseException {\r
- return ScenegraphLoaderUtils.getVariableSelection(graph, context);\r
- }\r
-\r
- @SCLValue(type = "ReadGraph -> Resource -> Variable -> String")\r
- public static String documentationText(ReadGraph graph, Resource resource, Variable context) throws DatabaseException {\r
- \r
- DocumentResource DOC = DocumentResource.getInstance(graph);\r
- Variable sel = ScenegraphLoaderUtils.getVariableSelection(graph, context);\r
- \r
- Resource represents = sel.getPossibleRepresents(graph);\r
- Resource doc = graph.getSingleObject(represents, DOC.HasDocumentation);\r
- Resource scenegraph = graph.getSingleObject(doc, DOC.ScenegraphDocument_scenegraph);\r
- \r
- ScenegraphLoaderProcess loader = new ScenegraphLoaderProcess(new Composite(), "All.documentationText");\r
- WikiDocumentNodeImpl node = loader.load(graph, scenegraph, ScenegraphLoaderUtils.getRuntime(graph, context));\r
- StringBuilder b = new StringBuilder();\r
- node.create(b, false);\r
- loader.dispose();\r
-\r
- DocumentUtils du = new DocumentUtils();\r
- StringBuilder css = new StringBuilder();\r
- du.getDocumentCSSText(graph, represents, css);\r
- DocumentSettings settings = du.getDocumentSettings(graph, represents);\r
- Exportable e = new Exportable(graph, represents, b.toString(), css.toString(), settings, false);\r
- return e.getHTML();\r
- \r
- }\r
- \r
- @SCLValue(type = "ReadGraph -> Resource -> Variable -> String")\r
- public static String standardEditText(ReadGraph graph, Resource resource, Variable context) throws DatabaseException {\r
- Variable location = context.getParent(graph);\r
- StringBuilder result = new StringBuilder();\r
- String path = ScenegraphLoaderUtils.getPath(graph, location);\r
- for(Variable property : location.browseProperties(graph)) {\r
- if(property.getPossibleProperty(graph, "userProperty") != null) {\r
- String name = property.getName(graph);\r
- result.append("[http://variable" + path + "#" + name + " [edit " + name + "]] ");\r
- }\r
- }\r
- return result.toString();\r
- }\r
-\r
-}\r
+/*******************************************************************************
+ * Copyright (c) 2012 Association for Decentralized Information Management in
+ * Industry THTH ry.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * VTT Technical Research Centre of Finland - initial API and implementation
+ *******************************************************************************/
+package org.simantics.document.function;
+
+import org.simantics.db.ReadGraph;
+import org.simantics.db.Resource;
+import org.simantics.db.exception.DatabaseException;
+import org.simantics.db.layer0.variable.Variable;
+import org.simantics.document.DocumentResource;
+import org.simantics.document.DocumentSettings;
+import org.simantics.document.DocumentUtils;
+import org.simantics.document.Exportable;
+import org.simantics.document.node.Composite;
+import org.simantics.scenegraph.loader.ScenegraphLoaderProcess;
+import org.simantics.scenegraph.loader.ScenegraphLoaderUtils;
+import org.simantics.scl.reflection.annotations.SCLValue;
+
+public class All {
+
+ @SCLValue(type = "ReadGraph -> Resource -> Variable -> Variable")
+ public static Variable documentationRootVariable(ReadGraph graph, Resource resource, Variable context) throws DatabaseException {
+ return ScenegraphLoaderUtils.getVariableSelection(graph, context);
+ }
+
+ @SCLValue(type = "ReadGraph -> Resource -> Variable -> String")
+ public static String documentationText(ReadGraph graph, Resource resource, Variable context) throws DatabaseException {
+
+ DocumentResource DOC = DocumentResource.getInstance(graph);
+ Variable sel = ScenegraphLoaderUtils.getVariableSelection(graph, context);
+
+ Resource represents = sel.getPossibleRepresents(graph);
+ Resource doc = graph.getSingleObject(represents, DOC.HasDocumentation);
+ Resource scenegraph = graph.getSingleObject(doc, DOC.ScenegraphDocument_scenegraph);
+
+ ScenegraphLoaderProcess loader = new ScenegraphLoaderProcess(new Composite(), "All.documentationText");
+ WikiDocumentNodeImpl node = loader.load(graph, scenegraph, ScenegraphLoaderUtils.getRuntime(graph, context));
+ StringBuilder b = new StringBuilder();
+ node.create(b, false);
+ loader.dispose();
+
+ DocumentUtils du = new DocumentUtils();
+ StringBuilder css = new StringBuilder();
+ du.getDocumentCSSText(graph, represents, css);
+ DocumentSettings settings = du.getDocumentSettings(graph, represents);
+ Exportable e = new Exportable(graph, represents, b.toString(), css.toString(), settings, false);
+ return e.getHTML();
+
+ }
+
+ @SCLValue(type = "ReadGraph -> Resource -> Variable -> String")
+ public static String standardEditText(ReadGraph graph, Resource resource, Variable context) throws DatabaseException {
+ Variable location = context.getParent(graph);
+ StringBuilder result = new StringBuilder();
+ String path = ScenegraphLoaderUtils.getPath(graph, location);
+ for(Variable property : location.browseProperties(graph)) {
+ if(property.getPossibleProperty(graph, "userProperty") != null) {
+ String name = property.getName(graph);
+ result.append("[http://variable" + path + "#" + name + " [edit " + name + "]] ");
+ }
+ }
+ return result.toString();
+ }
+
+}