Editor: isolated view on a node that is not root
Hi,
a short question related to editors: Is there a way to hide/not open the surrounding editor (i.e., the one of the root node), when opening a node that cannot be root? I want to have a "non-root" node isolated and not selected within its context.
My first idea was to have a "helper"-node that keeps a reference to the node which is to edit. However, this would require to attach the node to a model, which results in "polluting" the workspace. So I was wondering if there is an elegant solution?!
Thanks and cheers,
Ben
Please sign in to leave a comment.
The parent concept should implement this interface:
with the condition: node.isolatedNode.isNotNull;
The surrounding editor can be hidden with the following intention. Changes are unfortunately not applied when changing back to the orginal node because the node is copied. Maybe someone can fix this. The Isolatable editor depends on de.slisson.mps.conditionalEditor from the mbeddr platform.
Try this:
Alexander and Sascha, thanks!
I tried your solution Sascha and it nicely isolates the node. However, I want to be able to open multiple editors (one for each node). Moreover, it would be nice to have the current node's name as the title of the tab.
Alexander, thanks for the detailed description. The problem here is that I don't want to work on a copy, but on the original node. I guess it must be a copy, because isolatedNode is a child and not a reference (as nodes cannot have multiple parents)?! If I understood the solution correctly, we cannot have multiple editor tabs open either...
I tried the following:
(1) Create from an action a new root node that is attached to the current model
(2) The new node has a reference to another node (the one that is to be edited in isolation)
(3) The node to be edited in isolation is an attribute and thus we need to display the attributed node
As a result, we should be able to open two editor tabs: (1) an editor of the original root node giving the entire context (containing multiple possibly attributed nodes), and (2) an editor that just shows the attributed node in isolation.
The problem is that the "isolated editor" keeps telling me "<attributed cell not found>". I also tried open the attributed node from a custom cell. Same result.
The code above gives me an EditorCell_Error.
However, when I use a custom cell to open the editor of the isolated node's parent (i.e., node.parent) the content is shown. Yet, information of possibly attributed nodes is lost.
Any ideas why getting the current attributed cell fails?
Managed to get it work, but encountered some strange behavior... When I use a custom cell in the editor of the new root node and add new editor cells like
Then, subsequent editors (including the ones for attributed nodes) are shown correctly.
When I use the editor hierarchy instead, editors are not shown correctly. Even when I use a custom cell in the attributed node as described above...
Any ideas what's the problem here? And why do I get <attributed cell not found>? I don't know what I'm probably missing here, but to me it's pretty strange :D
Sascha, thanks for the help! Works like a charm! This is much more elegant than my initial workaround ;)
Guys, may I suggest you file an issue in YouTrack describing your scenario so that we provide this functionality officially? We may remove or change private methods without notice and your code would then break.
Submitted to YouTrack: https://youtrack.jetbrains.com/issue/MPS-23496.
Is it possible to close the opened editor programmatically?
Object invoke = m.invoke(opener, node, true);
if (invoke instanceof NodeEditor) {
NodeEditor editor = ((NodeEditor) invoke);
edtComponent = editor.getCurrentEditorComponent();
// Is it possible to close the opened editor programmatically?
}
Hi. I tried to implement the below code to isolate node to a new tab. But this gives me NoSuchMethodError. Could anyone help?