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:

To use Java-specific components in plugins targeting versions 2019.2+, explicit dependency on the Java plugin is required. See the Modules Specific to Functionality page for details.

See:

In short, you will need to add:

intellij {
  plugins = ['com.intellij.java']
  // ...
}

in your Gradle build script and:

<depends>com.intellij.modules.java</depends>

in your plugin.xml file.

0
评论操作 固定链接

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:

To use these components in plugins targeting versions 2019.2+, explicit dependency on the Java plugin (com.intellij.modules.java or com.intellij.java) is required. See the relevant entry on the Modules Specific to Functionality table for more details about the Java plugin.

If you agree I will make the proposed changes and submit a PR.

0
评论操作 固定链接

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:

To use Java-specific components in plugins targeting versions 2019.2+, explicit dependency on the Java plugin is required. See the Modules Specific to Functionality page for details on how to add a dependency to the Java plugin (com.intellij.modules.java or com.intellij.java).

I believe it should be enough.

1
评论操作 固定链接

Yes, that looks good. Thank you for your help

0

请先登录再写评论。