using other languages in concept editors

I have an XML file format and I want to implement a WYSIWYG editor with MPS. I know that there are numorous ways to do so. But I have a question about the following approach.

I think it is clear that I have to define my WYSIWYG text snippets as concepts and as concept editors because this is with what the user works. But then I have two ideas:

1. Is it possible to use editor hints so that the reader can also edit the XML version simultanously? Of course this is possible. But is it also possible using the XML language that MPS provides? My question is if I can use other languages than pure text in concept editors?

2. When instead using a generator for producing the XML files, would there be a live preview?

0
7 comments

What is a WYSIWYG editor for an XML file? How is the XML stored? How do you want the file rendered?

It seems to me that the input (XML) is not related to MPS, and the output (some rendering) is also probably not related to MPS. If my impression is correct then you might be better off either editing the file outside of MPS or embedding a custom Swing component in your MPS editor.

0

Oh, sorry that was not clear.

It is something very simple. My XML file looks like this:

<configuration>
<name>EA22-4</name>
  <dimensions>
    <length>32</length>
    <heigth>12</heigth>
  </dimensions>
</configuration>

And in MPS the WYSIWYG editor looks like this:

Configuration EA22-4
     dimension[length x height]: 12x32

This is easy to be implemented with a few concepts. See below an example. But the xml editor does not use the xml langauge. That is not so nice. Hovever, the user experience is very good. Only these parts of the xml file can be changed, that are allowed.

So the question is if it is possible to use the xml language (or other languages) in concept editors. After playing around with everything, I think I must give up the idea of making the xml data editable. Then I can use a generator that produces my xml data.

0

As you saw, it's not possible. But what benefit were you hoping to get from that? Is it being able to add some custom code to the resulting XML? You could allow for that by explicitly embedding a fragment of the XML language into your dimensions concept. Or is it the live preview? In that case, once you write a generator, the users can preview the generated code at any time by invoking an action (right-click, Preview Generated Text). It's not "live" because of the explicit action requirement, but I'd say it's good enough, and experimental solutions exist for live preview as well (shadow models).

0

The benefit would be that I get a transformation to XML for free. I don't have to define a generator.

But I am starting to see some conceptual inconsistencies in my idea. What I tried to achieve is to define how my concepts look in xml. But that is a transformation, and not an editor. So a generator is the better choice for me.

A live preview is not so important. I just read that MPS provides now live html previews and I was wondering how this can be done when there is no live model transformation from my language to html. This was my motivation of the question and I asked for the mssing bolt in my understanding.

0

Yes, you can have your concepts generate to XML while giving them a more user-friendly UI, that's the whole point of MPS, kind of :)

I don't know of any live HTML preview in MPS, where did you read that? It must be some generic IDEA feature that's not related to MPS.

0

The HTML live preview is mentioned in the release announcements of MPS 2021.1 under "What is New?". I would suppose it is a WebStorm feature but wonder why it is listed under MPS.

0
Avatar
Oscar Rodriguez

The HTML live preview was introduced in 2021.1 as a feature from the IDEA platform. For MPS users, if they generate HTML files this feature can be useful. 

0

Please sign in to leave a comment.