Editor: isolated view on a node that is not root


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,


Comment actions Permalink

The parent concept should implement this interface:

interface concept Isolatable extends <none> 

<< ... >>

isolatedNode : BaseConcept[0..1]

<< ... >>
<default> editor <no uniqueName> for concept Isolatable
priority: 100
(node)->boolean {

node cell layout:
(if true: % isolatedNode % if)
false: [next-editor]

inspected cell layout:
<choose cell model>

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.

intention IsolatedNode for concept BaseConcept {
error intention : false
available in child nodes : true
child filter : <all child nodes>

description(node, editorContext)->string {
node<Isolatable> isolatable = node.ancestor<concept = Isolatable>;
if (isolatable.isolatedNode.isNull) { return "Isolate Node"; }
return "Show Orginal Node";

isApplicable(editorContext, node)->boolean {
node.ancestor<concept = Isolatable>.isNotNull;

execute(node, editorContext)->void {
node<Isolatable> isolatable = node.ancestor<concept = Isolatable>;
if (isolatable.isolatedNode.isNull) {
isolatable.isolatedNode = node.copy;
} else {
isolatable.isolatedNode = null;

Comment actions Permalink

Try this:

Editor editor = NavigationSupport.getInstance().openNode(project, node, true, false);
((NodeEditorComponent) editor.getCurrentEditorComponent()).editNode(node);
Comment actions Permalink

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...

Comment actions Permalink

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.

manager.getCurrentAttributedCellWithRole(AttributeKind.NODE.getClass(), node)

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?

Comment actions Permalink

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

node.refNode.someChild.forEach({~it => enclosingCell.addEditorCell(editorContext.createNodeCell(it.attributedNode.parent)); });

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



Comment actions Permalink
MPSEditorOpener opener = new MPSEditorOpener(((MPSProject) project)); 
Method m = opener.getClass().getDeclaredMethod("openEditor", new Class[]{SNode.class, boolean.class});
m.invoke(opener, node, true);
Comment actions Permalink

Sascha, thanks for the help! Works like a charm! This is much more elegant than my initial workaround ;)

Comment actions Permalink

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.

Comment actions Permalink

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?


Please sign in to leave a comment.