How to add a JComponent to pre-existing Run configuration editor
Answered
I am not entirely sure this is possible, but I am trying to add a custom component (JButton, JLabel, etc...) to an existing Run Configuration Editor, so far this is what I have tried.
RunManager instance = RunManager.getInstance(project);
RunnerAndConfigurationSettings nodejsTemplate = instance.createConfiguration("my-config-name", NodeJsRunConfigurationType.getInstance());
(NodeJsRunConfiguration) nodejsTemplate.getConfiguration();
nodejsTemplate.getConfiguration().getConfigurationEditor().getComponent();
However this produce an error:
java.lang.UnsupportedOperationException: This method should never be called!
So I guess that is the wrong direction.
I was thinking to create my own class and extends to the
NodeRunConfigurationEditor
However the class is private and I will have to make a lot of plumbing work.
Is there an easy way to achieve this? Thanks
Please sign in to leave a comment.
Please see com.jetbrains.nodejs.run.NodeJSRunConfigurationExtension, EP: NodeJS.runConfigurationExtension.
It extends generic com.intellij.execution.configuration.RunConfigurationExtensionBase (samples: https://plugins.jetbrains.com/intellij-platform-explorer?extensions=com.intellij.runConfigurationExtension), see its javadoc
Yann Cebron thanks for answer, could you please expand a little bit on this?
I guess the first thing would be to create a class that extends the
Like this
Maybe modify the create editor function and add my custom component?
And maybe add it to my plugin.xml as dependency?
However like this nothing happens, the createEditor won't get called.
Thanks
1) com.intellij.execution.configuration.RunConfigurationExtensionBase#createEditor returns null by default, you need to return your custom instance see com.intellij.execution.coverage.CoverageJavaRunConfigurationExtension from Java plugin as sample
2) Override com.intellij.execution.configuration.RunConfigurationExtensionBase#getEditorTitle
3) return false from com.jetbrains.nodejs.run.NodeJSRunConfigurationExtension#showEditorInMainPage
4) your plugin.xml "implementation" doesn't match the class name (
NodejsExtendedConfigurationEditor vs
NodejsCustomRunConfigurationExtension)
Was `com.jetbrains.nodejs.run.NodeJSRunConfigurationExtension` (that is mentioned a lot in this thread) removed or something? I get `Unresolved reference: NodeJSRunConfigurationExtension` when I try to import it (but not for `com.jetbrains.nodejs.run.NodeJsRunConfiguration`, so I think I do have the JavaScript plugin).
And where is all of this documented actually, or where is the source code if there's no documentation?
How do people know about those classes and their members?
@t4lz The thread above refers to the status of 2021. NodeJS plugin is closed-source and thus cannot be inspected, there is no “official” documentation for it either. The newer variant is
com.intellij.javascript.nodejs.execution.runConfiguration.AbstractNodeRunConfigurationExtension
inJavaScript.nodeRunConfigurationExtension
extension point.Thank you for the clarification, Yann Cebron. Unlike in e.g. `PythonRunConfigurationExtension`, in `AbstractNodeRunConfigurationExtension`, `patchCommandLine` is final. So how can we offer a similar functionality for node?
…which throws
Do not call AbstractNodeRunConfigurationExtension.patchCommandLine. Node.js uses Targets API, not GeneralCommandLine
See
/platform/execution/src/com/intellij/execution/target
in IJ Community sources for Target API + some README