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

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

The parent concept should implement this interface:

interface concept Isolatable extends <none> 


properties:
<< ... >>

children:
isolatedNode : BaseConcept[0..1]

references:
<< ... >>
<default> editor <no uniqueName> for concept Isolatable
priority: 100
condition:
(node)->boolean {
true;
}

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;
}
}
}

0

Try this:

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

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

0

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?

0

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

 

 

0

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

0

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.

0

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?
}

0

Please sign in to leave a comment.