How to use UI components (PackageChooserDialog) within ToolWindow? 关注
I am trying to write my first IntelliJ plugin, and I'm finding it a very confusing process.
I have found and cloned a sample project with a tool window (https://github.com/JetBrains/intellij-sdk-code-samples/tree/main/tool_window), and I am now trying to add a Java class/package chooser (https://plugins.jetbrains.com/docs/intellij/file-and-class-choosers.html#class-and-package-choosers) to that window.
However, the class I want (PackageChooserDialog) is not resolved when I try to add it. According to https://plugins.jetbrains.com/docs/intellij/plugin-compatibility.html#modules-available-in-all-products it should be included in the 'com.intellij.modules.platform' dependency, which is already included in the <depends> tag in plugin.xml.
Why can't I access the PackageChooserDialog in my project?
请先登录再写评论。
Hi Chris,
I guess you need to add Java support to your plugin, as PackageChooserDialog is a part of the Java plugin.
It is mentioned in the information box at the bottom of the File and Class Choosers page:
In short, you will need to add:
in your Gradle build script and:
in your plugin.xml file.
Hi Karol, thanks for your reply, that all makes sense now.
I would suggest that the documentation could be improved because in the box that you mention, the attention is drawn to the Modules Specific to Functionality link, and to the first-time plugin creator the thought process is that we are writing a plugin in Java, therefore the plugins in the link are all Java plugins and that we need to find the Java plugin related to UI components, because we have come from the docs page relating to UI components. So, searching for "UI components" within that page leads us to the 'com.intellij.modules.platform', which is already included in the sample project. Plus as we are already writing in Java, the developer does not naturally assume that there would be a missing dependency on a plugin simply called Java.
A less ambiguous wording would be:
If you agree I will make the proposed changes and submit a PR.
Hi Chris,
Thanks for the suggestions. I agree it may be confusing to find the required information on this page for new plugin developers.
We've rephrased it (it will be published soon) a bit to:
I believe it should be enough.
Yes, that looks good. Thank you for your help