UI in the model aspect

Hello forum!

I've seen some sort of UI (Labels, Button, Textfields etc.) in the model aspect of MPS Jetbrains.
I want to be able to define such a swing component in the editor aspect of my language to make the input more user friendly.
I've also installed the plugin https://plugins.jetbrains.com/plugin/7519?pr=mps from @Fabien Campagne (big thanks to him), which provides different types of buttons.
Anyway, I want to define some UI controls on my own.
How can I apply this to my language editor?

Thanks in advance!

You basically have to add a swing component to your editor, import javax.swing as a dependency and create your component. If you want to interact with nodes you have to use a runWriteActionCommand.
Example: Checkbox
If you are interested in how the button in this plugin works, press Strg/Cmd + N and search for org.campagnelab.ui.code.Swing.Button and org.canpagnelab.ui.structure.Button.
Thanks for your reply, fxlex! It helped a lot.

Somehow my changes in my editor aspect aren't refreshed in my .sandbox. For example if I change the backgroundColor from red to green nothing happens in the .sandbox.
My code is below.
Any ideas?

node cell layout
$swing component$

component provider: (node, editorContext)->JComponent {
  final JPanel panel = new JPanel(); 
  panel.setSize(300, 300); 
  panel.setLayout(new GridLayout(2, 2)); 
  final JLabel label = new JLabel(); 
  label.setText("This is a label text");

I experienced this as well. As a workaround you can either reopen your project or click Menu->Tools->Reload All Classes.
Thanks! Is this behavior expected?

Please sign in to leave a comment.