Assign meaning to text (ValidID) in xtext editor - eclipse-rcp

This might be very basic question but: how to assign meaning to text in xtext editor?
Let's say:
We have an instance of some Java object. Let's name it Data. This data object has several nested fields which contain data.
data.field1.value1,
data.field1.value2,
data.value1,
etc...
Data object is created at runtime by user input and will be available when xtext based editor would try to access it.
If I write in xtext editor text like:
data.field1.value1
how to bind it to that field of data object?
To clarify: "data" object comes from outside of xtext editor but is accessible for the editor but I don't know how and where to pass it and then how to bind "ValidID" rule to its fields.

Related

VSCode ANTLR4 Plugin: Export Call Graph to JSON?

The vscode-antlr4 plugin for VisualStudio Code has a nice call-graph feature which visualizes (as a dendrogram) how grammar (and lexer) rules interact. You can save the graphic as SVG.
Is there a way to export the information as JSON? I wouldn't mind going into the plugin's code to find a way to do it.
My aim is to create reachability graphs for individual rules, i.e. graphs that show from which other rules a particular rule can be reached (transitively). The "calls" and "is-called" information from the call-graph feature would be a nice starting point.
The data for the call graph comes from a source context instance (for each grammar file there's a single source context to manage all details for it). See the function getReferenceGraph, which collects the relations into a map object. You can use that object to generate a JSON object from it. Or you create another function, taking this one as template, to generate the JSON directly, without the overhead required for the UI.

How to explorer properties and methods of an object in Kademi EDM template

I have a question related to Kademi platform. In normal page templating, I can use #docs for exploring properties and methods of an object but in EDM template, I can not. Do you know how to do that?
You can use #docs in theme/emailBase.html
Variables specific to automation are copied into the templating model for the base template, so can be referenced from $page.model.xxx, where xxx is the same variable name as in the automation template
For example, if you're writing an automation template for an event, and you're not sure what the event is and what properties it has, use this;
#docs($page.model.event)

How can I use an existing styles.xml without writing code to recreate it

I'm generating a word document using the Open XML SDK. Right now I have a function which generates my style definitions in code. Since these styles are going to change infrequently and have no real meaning to the code is there any way I can simply include an existing styles.xml in my wordprocessing document? The overload of the Style constructor which accepts a string containing XML throws an exception when I feed it an existing file.

CodeMirror code completion analyzing cursor location

I want to integrate code completion feature to CodeMirror based xml editor. It basically parses the schema of the xml file and provide code completion according to schema and its structure. But there is something i could not manage to do. For example, when the cursor is moved to a location which is inside and xml tag, code completion must behave accordingly. It should aware of that the cursor is inside the tag, etc. How can i do that?
I think XML parser of the code mirror may give a clue about semantic position of the cursor location with some alteration. Is that possible?
Or is there any generic way to analyze cursor location and behave accordingly?
Thanks in advance.
If you use CodeMirror 2, there's a getTokenAt method that allows you to analyse the parser state at a given position. You can see this being used to autocomplete local JavaScript variables in http://codemirror.net/2/demo/complete.html . For the XML parser, you can inspect the context property of the state, which is a linked list of objects, each containing a tagName property and a prev property linking to the context above it.

Create and bind a GUI from xsd file automatically in eclipse rcp app

I want to create GUI components from XSD files. The generated GUIs should be used for concrete xml instances of the corresponding schema with databinding to "interesting" elements or attributes content.
I have considered these solutions:
jaxfront. (commercial tool). This does not generate source code. This is important for me because I want communication between the generated GUIs and other components of the GUI.
Use xsd2emf and try to generate an editor from that. The generated model is to complex, as well as the generated editor and it is buggy.
Do it myself e.g. generate an xml from the xsd, load xml as dom, select the interessting parts and generate data binding using one method described at http://www.vogella.de/eclipse.html.
Has anyone another idea or already successfully solved that problem? I would prefer a free open source solution which generates a SWT GUI.
Have you looked at the Sapphire framework at eclipse?
With it you have to create a model based on a few simple java interface files with some annotations that would model your XSD. Then once you have the model defined, you create the SWT GUI with a single xml file (sdef file) that wires various property editors to your model. The property editors can be simple widgets like label, text, lists, combo boxes but also it can be complex editors like a GEF-based diagram editor. So basically if you have a few interfaces that describe your model, then can have a graphical editor for editing nodes in that model with less than 100 lines of XML.
See lines 22 to 121 of this sample file.