1 /*******************************************************************************
\r
2 * Copyright (c) 2012 Association for Decentralized Information Management in
\r
4 * All rights reserved. This program and the accompanying materials
\r
5 * are made available under the terms of the Eclipse Public License v1.0
\r
6 * which accompanies this distribution, and is available at
\r
7 * http://www.eclipse.org/legal/epl-v10.html
\r
10 * VTT Technical Research Centre of Finland - initial API and implementation
\r
11 *******************************************************************************/
\r
12 package org.simantics.document.ui.function;
\r
14 import java.util.TreeMap;
\r
16 import org.eclipse.jface.viewers.ISelectionProvider;
\r
17 import org.eclipse.jface.viewers.StructuredSelection;
\r
18 import org.eclipse.swt.graphics.FontData;
\r
19 import org.eclipse.swt.graphics.Point;
\r
20 import org.eclipse.swt.graphics.RGB;
\r
21 import org.eclipse.swt.widgets.Display;
\r
22 import org.eclipse.swt.widgets.Event;
\r
23 import org.eclipse.swt.widgets.FontDialog;
\r
24 import org.eclipse.swt.widgets.TreeItem;
\r
25 import org.eclipse.ui.PartInitException;
\r
26 import org.eclipse.ui.PlatformUI;
\r
27 import org.simantics.Simantics;
\r
28 import org.simantics.browsing.ui.BuiltinKeys;
\r
29 import org.simantics.browsing.ui.NodeContext;
\r
30 import org.simantics.databoard.Bindings;
\r
31 import org.simantics.db.ReadGraph;
\r
32 import org.simantics.db.Resource;
\r
33 import org.simantics.db.WriteGraph;
\r
34 import org.simantics.db.common.request.ReadRequest;
\r
35 import org.simantics.db.common.request.WriteRequest;
\r
36 import org.simantics.db.common.utils.Logger;
\r
37 import org.simantics.db.common.utils.NameUtils;
\r
38 import org.simantics.db.exception.DatabaseException;
\r
39 import org.simantics.db.layer0.adapter.Instances;
\r
40 import org.simantics.db.layer0.request.PossibleModel;
\r
41 import org.simantics.db.layer0.util.RemoverUtil;
\r
42 import org.simantics.db.layer0.variable.RVI;
\r
43 import org.simantics.db.layer0.variable.Variable;
\r
44 import org.simantics.document.DocumentResource;
\r
45 import org.simantics.document.DocumentUtils;
\r
46 import org.simantics.document.ui.CSSEditor;
\r
47 import org.simantics.layer0.Layer0;
\r
48 import org.simantics.scenegraph.INode;
\r
49 import org.simantics.scenegraph.loader.ScenegraphLoaderProcess;
\r
50 import org.simantics.scenegraph.loader.ScenegraphLoaderUtils;
\r
51 import org.simantics.scenegraph.loader.ScenegraphLoaderUtils.ScenegraphPropertyReference;
\r
52 import org.simantics.scl.reflection.annotations.SCLValue;
\r
53 import org.simantics.scl.runtime.function.FunctionImpl1;
\r
54 import org.simantics.scl.runtime.function.FunctionImpl3;
\r
55 import org.simantics.ui.workbench.ResourceEditorInput2;
\r
56 import org.simantics.utils.threads.SWTThread;
\r
57 import org.simantics.utils.ui.workbench.WorkbenchUtils;
\r
62 private static boolean createDocument(WriteGraph graph, Resource resource, Resource model) throws DatabaseException {
\r
64 Layer0 L0 = Layer0.getInstance(graph);
\r
65 DocumentResource DOC = DocumentResource.getInstance(graph);
\r
67 if(graph.hasStatement(resource, DOC.HasDocumentation)) return true;
\r
69 Instances query = graph.adapt(DOC.DocumentTypeBinding, Instances.class);
\r
71 TreeMap<Double, Resource> bindings = new TreeMap<Double, Resource>();
\r
72 for(Resource binding : query.find(graph, model)) {
\r
73 double priority = graph.getRelatedValue2(binding, DOC.DocumentTypeBinding_priority, Bindings.DOUBLE);
\r
74 Resource type = graph.getSingleObject(binding, DOC.DocumentTypeBinding_HasType);
\r
75 if(graph.isInstanceOf(resource, type)) {
\r
76 bindings.put(priority, binding);
\r
80 if(bindings.isEmpty()) return false;
\r
82 Resource binding = bindings.lastEntry().getValue();
\r
84 Resource documentType = graph.getSingleObject(binding, DOC.DocumentTypeBinding_HasDocumentType);
\r
85 Resource document = graph.newResource();
\r
86 graph.claim(document, L0.InstanceOf, null, DOC.ScenegraphDocument);
\r
87 graph.claimLiteral(document, L0.HasName, "Documentation");
\r
88 graph.claim(resource, DOC.HasDocumentation, document);
\r
89 graph.claim(document, L0.PartOf, resource);
\r
91 Resource scenegraph = graph.newResource();
\r
92 graph.claim(scenegraph, L0.InstanceOf, null, documentType);
\r
93 graph.claimLiteral(scenegraph, L0.HasName, "Scenegraph");
\r
94 graph.claim(scenegraph, L0.PartOf, document);
\r
95 graph.claim(document, DOC.ScenegraphDocument_scenegraph, scenegraph);
\r
101 @SCLValue(type = "ReadGraph -> Resource -> Variable -> b")
\r
102 public static Object onCreateDocumentButton(ReadGraph graph, Resource resource, final Variable context) throws DatabaseException {
\r
104 return new FunctionImpl1<Object, Object>() {
\r
107 public Object apply(Object _o) {
\r
109 Simantics.async(new ReadRequest() {
\r
112 public void run(ReadGraph graph) throws DatabaseException {
\r
114 Variable selection = ScenegraphLoaderUtils.getPossibleVariableSelection(graph, context);
\r
115 if(selection == null) return;
\r
117 final Resource input = selection.getRepresents(graph);
\r
118 if(input == null) return;
\r
120 graph.async(new WriteRequest() {
\r
123 public void perform(WriteGraph graph) throws DatabaseException {
\r
125 Resource model = graph.sync(new PossibleModel(input));
\r
126 if(model == null) return;
\r
127 createDocument(graph, input, model);
\r
145 @SCLValue(type = "ReadGraph -> Resource -> Variable -> b")
\r
146 public static Object onDeleteDocumentButton(ReadGraph graph, Resource resource, final Variable context) throws DatabaseException {
\r
148 return new FunctionImpl1<Object, Object>() {
\r
151 public Object apply(Object _o) {
\r
153 Simantics.async(new ReadRequest() {
\r
156 public void run(ReadGraph graph) throws DatabaseException {
\r
158 Variable selection = ScenegraphLoaderUtils.getPossibleVariableSelection(graph, context);
\r
159 if(selection == null) return;
\r
161 final Resource input = selection.getRepresents(graph);
\r
162 if(input == null) return;
\r
164 DocumentResource DOC = DocumentResource.getInstance(graph);
\r
165 if(!graph.hasStatement(input, DOC.HasDocumentation)) return;
\r
167 graph.async(new WriteRequest() {
\r
170 public void perform(WriteGraph graph) throws DatabaseException {
\r
172 DocumentResource DOC = DocumentResource.getInstance(graph);
\r
173 Resource document = graph.getPossibleObject(input, DOC.HasDocumentation);
\r
174 if(document == null) return;
\r
176 RemoverUtil.remove(graph, document);
\r
194 @SCLValue(type = "ReadGraph -> Resource -> Variable -> a")
\r
195 public static Object editorLoaded(ReadGraph graph, final Resource resource, final Variable context) throws DatabaseException {
\r
197 return new FunctionImpl3<WriteGraph, Variable, Variable, Boolean>() {
\r
200 public Boolean apply(WriteGraph graph, Variable editor, Variable input) {
\r
203 // return createDocument(graph, input);
\r
204 // } catch (DatabaseException e) {
\r
205 // Logger.defaultLogError(e);
\r
216 @SCLValue(type = "ReadGraph -> Resource -> Variable -> Boolean")
\r
217 public static Boolean hasDocument(ReadGraph graph, final Resource resource, final Variable context) throws DatabaseException {
\r
219 DocumentResource DOC = DocumentResource.getInstance(graph);
\r
221 Variable selection = ScenegraphLoaderUtils.getPossibleVariableSelection(graph, context);
\r
222 if(selection == null) return false;
\r
224 Resource input = selection.getRepresents(graph);
\r
225 if(input == null) return null;
\r
227 return graph.hasStatement(input, DOC.HasDocumentation);
\r
231 @SCLValue(type = "ReadGraph -> Resource -> Variable -> a")
\r
232 public static Object viewInputChanged(ReadGraph graph, final Resource resource, final Variable context) throws DatabaseException {
\r
234 return new FunctionImpl1<Variable, Boolean>() {
\r
237 public Boolean apply(final Variable viewVariable) {
\r
246 @SCLValue(type = "ReadGraph -> Variable -> Boolean")
\r
247 public static Boolean isWikitext(ReadGraph graph, Variable context) throws DatabaseException {
\r
248 Layer0 L0 = Layer0.getInstance(graph);
\r
249 DocumentResource DOC = DocumentResource.getInstance(graph);
\r
250 Resource p = context.getPossiblePredicateResource(graph);
\r
252 return Boolean.FALSE;
\r
253 Resource range = graph.getPossibleObject(p, L0.HasRange);
\r
254 return DOC.WikiDocument_WikiText.equals(range);
\r
257 private static Variable getDefaultSelection(ReadGraph graph, Variable context) throws DatabaseException {
\r
259 DocumentResource DOC = DocumentResource.getInstance(graph);
\r
260 Variable sel = ScenegraphLoaderUtils.getVariableSelection(graph, context);
\r
262 Resource represents = sel.getRepresents(graph);
\r
263 Resource doc = graph.getSingleObject(represents, DOC.HasDocument);
\r
264 Resource scenegraph = graph.getSingleObject(doc, DOC.ScenegraphDocument_scenegraph);
\r
266 Variable runtime = ScenegraphLoaderUtils.getRuntimeVariable(graph, context);
\r
267 INode root = runtime.adapt(graph, INode.class);
\r
269 Variable result = ScenegraphLoaderProcess.getVariable(graph, null, scenegraph, ScenegraphLoaderUtils.getRuntime(graph, context), root);
\r
270 if(result != null) {
\r
271 Variable userDoc = result.getPossibleProperty(graph, "UserDocumentation");
\r
272 if(userDoc != null) return userDoc;
\r
279 private static Variable resolveEditSelection(ReadGraph graph, Variable context, String path) throws DatabaseException {
\r
281 final ScenegraphPropertyReference<Variable> selectionReference =
\r
282 ScenegraphLoaderUtils.getRelativePropertyReference(SWTThread.getThreadAccess(), graph, context, path);
\r
284 Variable editSelection = selectionReference.getExternalValue(graph);
\r
285 if(editSelection == null) editSelection = getDefaultSelection(graph, context);
\r
287 return editSelection;
\r
291 @SCLValue(type = "ReadGraph -> Resource -> Variable -> a")
\r
292 public static Object wikitextModifier(ReadGraph graph, final Resource resource, final Variable context) throws DatabaseException {
\r
294 final ScenegraphPropertyReference<String> textReference = ScenegraphLoaderUtils.getRelativePropertyReference(SWTThread.getThreadAccess(), graph, context, ".../TextContainer/Text#text");
\r
296 return new FunctionImpl1<Object, Object>() {
\r
299 public Object apply(final Object event) {
\r
301 final String value = textReference.getValue();
\r
304 Simantics.getSession().sync(new WriteRequest() {
\r
307 public void perform(WriteGraph graph) throws DatabaseException {
\r
309 Variable selection = resolveEditSelection(graph, context, "..../Scroll/Browser#edited");
\r
310 if (selection != null)
\r
311 selection.setValue(graph, (String)value, Bindings.STRING);
\r
313 System.err.println("no selection for resource : " + resource + ", Variable context : " + context + ", value : " + value);
\r
318 } catch (DatabaseException e) {
\r
319 e.printStackTrace();
\r
327 @SCLValue(type = "ReadGraph -> Resource -> Variable -> String")
\r
328 public static String wikitext(ReadGraph graph, Resource resource, Variable context) throws DatabaseException {
\r
329 Variable selection = ScenegraphLoaderUtils.getVariableSelection(graph, context);
\r
330 return selection.getValue(graph);
\r
333 @SCLValue(type = "ReadGraph -> Resource -> Variable -> String")
\r
334 public static String selectedDocumentPart(ReadGraph graph, Resource resource, Variable context) throws DatabaseException {
\r
336 Variable selection = resolveEditSelection(graph, context, ".../Scroll/Browser#edited");
\r
337 if(selection == null) return null;
\r
339 return selection.getValue(graph);
\r
343 @SCLValue(type = "ReadGraph -> Resource -> Variable -> b")
\r
344 public static Object documentStructureSelected(ReadGraph graph, Resource resource, Variable context) throws DatabaseException {
\r
346 return new FunctionImpl1<Object, Boolean>() {
\r
349 public Boolean apply(Object _event) {
\r
351 Event event = (Event)_event;
\r
353 final TreeItem item = (TreeItem)event.item;
\r
354 NodeContext context = (NodeContext)item.getData();
\r
355 final Variable entry = (Variable)context.getConstant(BuiltinKeys.INPUT);
\r
357 ISelectionProvider provider = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActivePart().getSite().getSelectionProvider();
\r
358 provider.setSelection(new StructuredSelection(entry));
\r
368 abstract static class WikiButtonModifier extends FunctionImpl1<Object, Object> {
\r
370 final ScenegraphPropertyReference<String> textReference;
\r
371 final ScenegraphPropertyReference<Point> selectionReference;
\r
373 public WikiButtonModifier(ReadGraph graph, Variable context) throws DatabaseException {
\r
374 textReference = ScenegraphLoaderUtils.getRelativePropertyReference(SWTThread.getThreadAccess(), graph, context, ".../TextContainer/Text#text");
\r
375 selectionReference = ScenegraphLoaderUtils.getRelativePropertyReference(SWTThread.getThreadAccess(), graph, context, ".../TextContainer/Text#selection");
\r
378 abstract void perform(String before, String selected, String after, Point selection);
\r
381 public Object apply(Object _event) {
\r
382 String text = textReference.getValue();
\r
383 Point selection = selectionReference.getValue();
\r
384 String before = text.substring(0, selection.x);
\r
385 String selected = text.substring(selection.x, selection.y);
\r
386 String after = text.substring(selection.y);
\r
387 perform(before, selected, after, selection);
\r
393 @SCLValue(type = "ReadGraph -> Resource -> Variable -> b")
\r
394 public static Object boldModifier(ReadGraph graph, Resource resource, final Variable context) throws DatabaseException {
\r
396 return new WikiButtonModifier(graph, context) {
\r
399 void perform(String before, String selected, String after, Point selection) {
\r
401 if(selected.isEmpty()) {
\r
402 textReference.setValue(before + "'''bold text'''" + after);
\r
404 textReference.setValue(before + "'''" + selected + "'''" + after);
\r
413 @SCLValue(type = "ReadGraph -> Resource -> Variable -> b")
\r
414 public static Object italicModifier(ReadGraph graph, Resource resource, final Variable context) throws DatabaseException {
\r
416 return new WikiButtonModifier(graph, context) {
\r
419 void perform(String before, String selected, String after, Point selection) {
\r
421 if(selected.isEmpty()) {
\r
422 textReference.setValue(before + "''italic text''" + after);
\r
424 textReference.setValue(before + "''" + selected + "''" + after);
\r
433 @SCLValue(type = "ReadGraph -> Resource -> Variable -> b")
\r
434 public static Object strikethroughModifier(ReadGraph graph, Resource resource, final Variable context) throws DatabaseException {
\r
436 return new WikiButtonModifier(graph, context) {
\r
439 void perform(String before, String selected, String after, Point selection) {
\r
441 if(selected.isEmpty()) {
\r
442 textReference.setValue(before + "<span style=\"text-decoration:line-through;\">strikethrough text</span>" + after);
\r
444 textReference.setValue(before + "<span style=\"text-decoration:line-through;\">" + selected + "</span>" + after);
\r
453 @SCLValue(type = "ReadGraph -> Resource -> Variable -> b")
\r
454 public static Object underlineModifier(ReadGraph graph, Resource resource, final Variable context) throws DatabaseException {
\r
456 return new WikiButtonModifier(graph, context) {
\r
459 void perform(String before, String selected, String after, Point selection) {
\r
461 if(selected.isEmpty()) {
\r
462 textReference.setValue(before + "<span style=\"text-decoration:underline;\">strikethrough text</span>" + after);
\r
464 textReference.setValue(before + "<span style=\"text-decoration:underline;\">" + selected + "</span>" + after);
\r
473 @SCLValue(type = "ReadGraph -> Resource -> Variable -> b")
\r
474 public static Object horizontalRulerModifier(ReadGraph graph, Resource resource, final Variable context) throws DatabaseException {
\r
476 return new WikiButtonModifier(graph, context) {
\r
479 void perform(String before, String selected, String after, Point selection) {
\r
481 textReference.setValue(before + "\r\n<hr/>\r\n" + selected + after);
\r
489 @SCLValue(type = "ReadGraph -> Resource -> Variable -> b")
\r
490 public static Object indentModifier(ReadGraph graph, Resource resource, final Variable context) throws DatabaseException {
\r
492 return new WikiButtonModifier(graph, context) {
\r
495 void perform(String before, String selected, String after, Point selection) {
\r
497 textReference.setValue(before + ":" + selected + after);
\r
505 @SCLValue(type = "ReadGraph -> Resource -> Variable -> b")
\r
506 public static Object fontModifier(ReadGraph graph, Resource resource, final Variable context) throws DatabaseException {
\r
508 return new WikiButtonModifier(graph, context) {
\r
510 private String hex2(int value) {
\r
511 String result = Integer.toHexString(value);
\r
512 if(result.length() == 1) result = "0" + result;
\r
517 void perform(String before, String selected, String after, Point selection) {
\r
519 FontDialog dialog = new FontDialog(Display.getCurrent().getActiveShell());
\r
520 FontData data = dialog.open();
\r
521 if(data == null) return;
\r
523 String family = data.getName();
\r
524 int size = data.getHeight();
\r
526 RGB rgb = dialog.getRGB();
\r
527 String hex = hex2(rgb.red) + hex2(rgb.green) + hex2(rgb.blue);
\r
529 if(selected.isEmpty()) {
\r
530 textReference.setValue(before + "<font style=\"font-size:" + size + ";color: #" + hex + ";font-family:" + family + ";\" >formatted text</font>" + selected + after);
\r
532 textReference.setValue(before + "<font style=\"font-size:" + size + ";color: #" + hex + ";font-family:" + family + ";\" >" + selected + "</font>" + after);
\r
541 @SCLValue(type = "ReadGraph -> Resource -> Variable -> b")
\r
542 public static Object imageModifier(ReadGraph graph, Resource resource, final Variable context) throws DatabaseException {
\r
544 return new WikiButtonModifier(graph, context) {
\r
547 void perform(String before, String selected, String after, Point selection) {
\r
549 textReference.setValue(before + "[[Image:root://Library/image.png|100px]]" + selected + after);
\r
557 @SCLValue(type = "ReadGraph -> Resource -> Variable -> b")
\r
558 public static Object header1Modifier(ReadGraph graph, Resource resource, final Variable context) throws DatabaseException {
\r
560 return new WikiButtonModifier(graph, context) {
\r
563 void perform(String before, String selected, String after, Point selection) {
\r
565 textReference.setValue(before + "\r\n= Header 1 =\r\n" + selected + after);
\r
573 @SCLValue(type = "ReadGraph -> Resource -> Variable -> b")
\r
574 public static Object header2Modifier(ReadGraph graph, Resource resource, final Variable context) throws DatabaseException {
\r
576 return new WikiButtonModifier(graph, context) {
\r
579 void perform(String before, String selected, String after, Point selection) {
\r
581 textReference.setValue(before + "\r\n== Header 2 ==\r\n" + selected + after);
\r
589 @SCLValue(type = "ReadGraph -> Resource -> Variable -> b")
\r
590 public static Object header3Modifier(ReadGraph graph, Resource resource, final Variable context) throws DatabaseException {
\r
592 return new WikiButtonModifier(graph, context) {
\r
595 void perform(String before, String selected, String after, Point selection) {
\r
597 textReference.setValue(before + "\r\n=== Header 3 ===\r\n" + selected + after);
\r
605 @SCLValue(type = "ReadGraph -> Resource -> Variable -> b")
\r
606 public static Object header4Modifier(ReadGraph graph, Resource resource, final Variable context) throws DatabaseException {
\r
608 return new WikiButtonModifier(graph, context) {
\r
611 void perform(String before, String selected, String after, Point selection) {
\r
613 textReference.setValue(before + "\r\n==== Header 4 ====\r\n" + selected + after);
\r
621 @SCLValue(type = "ReadGraph -> Resource -> Variable -> b")
\r
622 public static Object numberedListModifier(ReadGraph graph, Resource resource, final Variable context) throws DatabaseException {
\r
624 return new WikiButtonModifier(graph, context) {
\r
627 void perform(String before, String selected, String after, Point selection) {
\r
629 textReference.setValue(before + "\r\n" +
\r
632 "## Item2.1\r\n" +
\r
633 "# Item3\r\n" + selected + after);
\r
641 @SCLValue(type = "ReadGraph -> Resource -> Variable -> b")
\r
642 public static Object bulletListModifier(ReadGraph graph, Resource resource, final Variable context) throws DatabaseException {
\r
644 return new WikiButtonModifier(graph, context) {
\r
647 void perform(String before, String selected, String after, Point selection) {
\r
649 textReference.setValue(before + "\r\n" +
\r
652 "** Item2.1\r\n" +
\r
653 "* Item3\r\n" + selected + after);
\r
661 @SCLValue(type = "ReadGraph -> Resource -> Variable -> b")
\r
662 public static Object tableModifier(ReadGraph graph, Resource resource, final Variable context) throws DatabaseException {
\r
664 return new WikiButtonModifier(graph, context) {
\r
667 void perform(String before, String selected, String after, Point selection) {
\r
669 textReference.setValue(before + "\r\n" +
\r
670 "{| border=\"1\"\r\n" +
\r
674 "| cell || cell2\r\n" +
\r
678 "|}\r\n" + selected + after);
\r
686 @SCLValue(type = "ReadGraph -> Resource -> Variable -> b")
\r
687 public static Object linkModifier(ReadGraph graph, Resource resource, final Variable context) throws DatabaseException {
\r
689 return new WikiButtonModifier(graph, context) {
\r
692 void perform(String before, String selected, String after, Point selection) {
\r
694 textReference.setValue(before + "\r\n" +
\r
695 "[http://www.simantics.org External Website Link]\r\n" + selected + after);
\r
703 @SCLValue(type = "ReadGraph -> Resource -> Variable -> b")
\r
704 public static Object styleModifier(ReadGraph graph, Resource resource, final Variable context) throws DatabaseException {
\r
706 return new WikiButtonModifier(graph, context) {
\r
709 void perform(String before, String selected, String after, Point selection) {
\r
711 Simantics.getSession().asyncRequest(new ReadRequest() {
\r
714 public void run(ReadGraph graph) throws DatabaseException {
\r
716 Variable sel = ScenegraphLoaderUtils.getVariableSelection(graph, context);
\r
717 Resource root = sel.getIndexRoot(graph);
\r
718 String editorId = CSSEditor.EDITOR_ID;
\r
721 PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {
\r
724 public void run() {
\r
727 WorkbenchUtils.openEditor(editorId, new ResourceEditorInput2(editorId, root, root, rvi));
\r
728 } catch (PartInitException e) {
\r
729 Logger.defaultLogError(e);
\r
747 // @SCLValue(type = "ReadGraph -> Resource -> Variable -> a")
\r
748 // public static Object navigate(ReadGraph graph, Resource resource, final Variable context) throws DatabaseException {
\r
750 // return new FunctionImpl1<String, Boolean>() {
\r
753 // public Boolean apply(final String path) {
\r
755 // Simantics.getSession().asyncRequest(new ReadRequest() {
\r
758 // public void run(ReadGraph graph) throws DatabaseException {
\r
760 // DocumentResource DOC = DocumentResource.getInstance(graph);
\r
761 // Variable sel = ScenegraphLoaderUtils.getVariableSelection(graph, context);
\r
763 // Resource represents = sel.getRepresents(graph);
\r
764 // Resource doc = graph.getSingleObject(represents, DOC.HasDocument);
\r
765 // Resource scenegraph = graph.getSingleObject(doc, DOC.ScenegraphDocument_scenegraph);
\r
767 // Variable runtime = ScenegraphLoaderUtils.getRuntimeVariable(graph, context);
\r
768 // INode root = runtime.adapt(graph, INode.class);
\r
770 // Variable result = ScenegraphLoaderProcess.getVariable(graph, null, scenegraph, ScenegraphLoaderUtils.getRuntime(graph, context), root);
\r
771 // Variable location = result.browse(graph, path);
\r
773 // ScenegraphPropertyReference<Variable> editReference = ScenegraphLoaderUtils.getRelativePropertyReference(SWTThread.getThreadAccess(), graph, context, ".#edited");
\r
774 // editReference.setValue(location);
\r
788 @SCLValue(type = "ReadGraph -> Resource -> Variable -> String")
\r
789 public static String noDocumentText(ReadGraph graph, final Resource resource, final Variable context) throws DatabaseException {
\r
791 Variable selection = ScenegraphLoaderUtils.getPossibleVariableSelection(graph, context);
\r
792 if(selection == null) return "<no input>";
\r
794 Resource input = selection.getRepresents(graph);
\r
795 if(input == null) return "<no input>";
\r
797 String path = DocumentUtils.indexRootPath(graph, selection);
\r
798 if(!path.isEmpty()) {
\r
799 return "for " + path + selection.getName(graph);
\r
802 return "for " + NameUtils.getSafeLabel(graph, input);
\r
806 @SCLValue(type = "ReadGraph -> Resource -> Variable -> Boolean")
\r
807 public static Boolean canCreateDocument(ReadGraph graph, final Resource resource, final Variable context) throws DatabaseException {
\r
809 Variable selection = ScenegraphLoaderUtils.getPossibleVariableSelection(graph, context);
\r
810 if(selection == null) return false;
\r
812 Resource input = selection.getRepresents(graph);
\r
813 if(input == null) return false;
\r