Not showing cells for editor

In my language I have a concept that has a label properties and a reference link to another concept. Both the label and the link are optional.

If the user specifies both the editor will show a cell like this:

label: name(link)

if the label is empty the editor should be:

name(link)

and if the link's list ie empty the editor should be:

name()

With default editing options I produce this

<no label> name1 ( << ... >>)

This is quite ugly because I have a lot of cells and the general view is quite confusing.

I tried to use the show if option in the inspector but then I was not able to edit the label and the link if they were missing because I couldn't find them anymore.

So what is the solution?

I'm using version 1.5.

Thanks

5 comments
Comment actions Permalink

Hi Giampiero,

such things i usually solve by hiding the field via your explained editor-IF, whereas the cell shall be shown if something exists (!= null or whatever) in that field. Then you can show the "hidden" fields in the area "inspected cell layout" of your EditorComponentDeclaration  (will be shown in the inspector-view of your editor).

The user than can initially edit your "hidden" fields via the inspector-view leading to that, that the IF unhides the corresponding field in the main-editor. The user can than edit on in the main-editor and inspector-view (or you may even hide the fields from the "inspected cell layout" if they contain something and vica-versa)

You could also use intentions (f.i. hidden boolean flag switched by intention), side-transform-actions or other cool features of MPS :-)

Regards,

Mirko

0
Comment actions Permalink

Thank's for the answer,

playing with the keymap, I wonder if I could use them to obtain something like this:

the user put the cursor just at the beginning of the name() and start typing, the editor will display the hidden label. I tried to obtain that by doing:

1) create a show if condition to hide the label if it's empty.

2) Create a keymap for the name concept that is fire for a letter with FIRST_POSITION as caret policy. This is applicable when the label is empty and the name concept is defined.

I defined the EXECUTE part like this:

node.label = Character.toString(keyEvent.getKeyChar());

As expected the label is showed but the same character is added to the beginning of name and the cursor is positioned after that. So, is it possible to avoid the change in name and how to put the cursor in the label cell?

0
Comment actions Permalink

Hi Giampiero,

sounds interesting but i didn't play around a lot with keymaps but did you try:

editorContext.select* (f.i. .selectAndSetCaret) ?

Isn't it possible to eliminate the duplicate character as part of the keymap-action?

Regards,

Mirko

0
Comment actions Permalink

Those seem to me good ideas, but I have some problems to implement them:

How can I found documentation for the methods you suggest?

Is there any way to print the content of a node during editing or better to debug it?

Thank's,

Giampiero

0
Comment actions Permalink

Hi Giampiero,

grem schrieb:

How can I found documentation for the methods you suggest?

if it goes into detail (and deeper than the current jetbrains-docs), you need imho the MPS-sources... that is what i do in such cases.

Is there any way to print the content of a node during editing or better to debug it?

Yes, there is: use the MPS-Logging-facility (fatal "", error "", warn "", info "", debug "", trace ""). Normally it is available in every model as they usually import the devkit "general-purpose" which in turn exports the needed language jetbrains.mps.baseLanguage.logging (btw: the devkit "language-design" - which is the usual devkit for models - extends "general-purpose")

(Also see my FAQ at www.compago.de).

Only in the generator it is currently (M3) not working that way, even if these Statements are available. Here you can use: genContext.showError|Warning|Info.

Regards,
Mirko

0

Please sign in to leave a comment.