Embed a ConceptEditor in a JPanel of a plugin Tool?

I created a Tool in a plugin solution and I would like to put inside one of its JPanels the ConceptEditor of one of my root concepts.
The edited Concept don't need to be added to a model or saved.
Is it possible?
I took a look at the generated MyConcept_Editor.java but I don't know where I can get an EditorContext instance.

Thx,
Mar

6 comments
init(project)->void { 
this.makeAvailable();
}

getComponent()->JComponent {
node<YourNode> editedNode = node/YourNode/;
NodeEditorComponent component = new NodeEditorComponent(module/YourNodesModule/.getRepository());
component.editNode(editedNode);
component;
}

If you want to load different nodes you could make an action and open the tool:

execute(event)->void {
tool<YourTool> tool = this.project.tool<YourTool>;
tool.openTool(true);
tool.initializeMyTool(node,repository);
}

The edited node must be part of a model.

1

Thx, I've tried but was not that easy. I got the error below:

java.lang.NullPointerException at jetbrains.mps.nodeEditor.NodeEditorComponent.getInspectorTool(NodeEditorComponent.java:119)

0

Looking at the code this can apparently only happen if the repository passed to the NodeEditorComponent constructor is not a ProjectRepository or isn't associated with a project. Is this the case in your code? Can you provide more details on what you're doing?

0

The Tool I have in mind is similar to the Console: here as you probably know with the editor of ConsoleRoot concept you are able to execute commands. Actually I don't need execution but only define an AST to be red by the Tool logic when the user click somewhere.

I have got the repository as stated above module/..../.getRepository() and it does not work.
What I tried to do, after you hint about project/repository, was to pass the project parameter to getComponent() to take the repository from it, but I finally realize  that getComponent() is executed before init(), this has completely confused myself :-)

Mar

0

Ok... I did it!
I don't know what happens but getComponent() was executed before init(). It looks very strange so I deleted my initial Tool and create a new one with a different name and it works.

Thx for helping.
Mar

0

Hi,

 

Instead of a Tool, I used DialogWrapper to show the conceptEditor. Here the keyboard actions are not working. Do anyone have any idea.?relate post is here

 

Thank you very much in advance.

 

Regards,

Dinesh

0

Please sign in to leave a comment.