[menu contributions] openEditor & cursor position

Hi, 

I'm trying to add a menu contribution, say for instance to give the subclasses of a class in "Context Actions". When i click on a subclass, i want it to be opened in the editor. How can i have the cursor positioned at the name of the class which is opened and not where it last was when the class was opened?

So far, i've created a <code>default transformation menu for concept X</code> and in the <code>execute</code> part i have:

<code>{
final EditorPanelManager editorPanelManager = editorContext.getEditorPanelManager();
if (editorPanelManager != null) {
editorPanelManager.openEditor(parameterObject);
}
}</code>

I understood i could use <code>EditorComponent#selectNode</code> but what i don't know is how to get a "pointer" to the component... <code>openEditor</code> returns void... 

Thanks,

lacramioara

 

PS

what's the formatting we could use to put code in a post?

2 comments
Comment actions Permalink

Untested, but give it a try:

execute (editorContext, node, model, pattern)->void { 
Project project = ProjectHelper.getProject(editorContext.getRepository());
node<INamedConcept> root = new node<YourRootThatImplementsINamedConcept>();
model.add root(root);
Editor editor = NavigationSupport.getInstance().openNode(project, root, true, true);
EditorContext editorContext = editor.getEditorContext();
root.select[in: editorContext, cell: {name}];
}

To answer your second question: I usualy paste in my code or write it manually, select it and then select "Code" as formatting by means of the little Pilcrow-Button to the top left:

0
Comment actions Permalink

Thank you Robert, i had something working by adapting your suggestion. 

As for formatting, the hover-text for Pilcrow-Button says "paragraph styles" so i didn't even click on it, not expecting that it would hide code formatting :) (one might want to have also inline code...) 

0

Please sign in to leave a comment.