using push editor hints through code
Hi,
I have implemented "Push Editor Hints" option from the IDE. However, I would like to add a drop down button and push editor hints thought that.
It will be great if anyone gives any hint.
Please sign in to leave a comment.
You can use the actions and action-groups to achieve that. Moreover you need to get and push the editor hints from the code in your action. For instance:
string[] editorHints = {concept editor hint/your_hint/};this.editorComponent.getUpdater().setInitialEditorHints(editorHints);
this.editorComponent.rebuildEditorContent();
If you want to preserve your previously pushed hints, you can use:
if (this.editorComponent.getUpdater().getInitialEditorHints() != null) {sequence<string> editorHints = this.editorComponent.getUpdater().getInitialEditorHints().asSequence;
...
}
Hope it helps.
Hello Benjamin,
Thanks a lot you reply, it works you said, however, I have two issues -
1. I need to press F5 button to refresh the screen for the new editor.
2. I implemented for my editor hint, I would also like to revert back to my default editor with button push but the default editor option is not visible when selecting editor hints.
3. I did not find drop down menu as swing component, so i used radio button for now, but I would like to implement it using drop down button.
My code is,
string[]editorHints={concept editor hint/<myhint>/};
editorContext.getEditorComponent().getUpdater().setInitialEditorHints(editorHints);
editorContext.getEditorComponent().rebuildEditorContent();
editorContext.getEditorComponent().update();
Hi,
Where did you implement your action? Your solution should look like follows:
You can add your action to the MPS menus using an action group as follows:
Your action should look like follows:
action My_Action_To_Push_The_Editor_Hint {
mnemonic: <no mnemonic>
execute outside command: false
also available in: everywhere
caption: Activate My Hint
description: <no description>
icon: <no icon>
construction parameters
<< ... >>
action context parameters ( always visible = true )
EditorComponent editorComponent key: EDITOR_COMPONENT required
execute(event)->void {
string[] editorHints = {concept editor hint/myhint/};
this.editorComponent.getUpdater().setInitialEditorHints(editorHints);
this.editorComponent.rebuildEditorContent();
}
additional methods
<< ... >>
}
Did you do it this way? You can also push the hint from an intention like you may have done.
to 1) Hm, actually rebuildEditorContent should do the job.
to 2) You can go back to default by just pushing an empty set.
to 3) I don't quite get what you'd like to do.
Cheers,
Ben
Dear Ben,
Thanks for your help a lot! My 3rd point was about implementing a clickable drop down button which i could not find in MPS. I was wondering if it is possible.
Sure. Yet, you must use standard Java Swing to do so, I'm not aware of any DSL that would ease the job for you.
Cheers, Ben
thanks a lot Ben:)