What is the correct way to allow the user to configure plugin-level settings before initialising the plugin?
已回答
Here is a brief description of my plugin. It is a simple tool window containing two tabs. The content of tabs is just a Tree/List representing the response from an internal API. My plugin needs to make HTTP requests and then create the tool window content using the response.
For this, I require the user to configure hostname & apiKey only once at the beginning to "set up the plugin". From then onwards, the plugin should use them every time. I would also like to allow the user to update these at any point in time. What is the best or right way of achieving this?
请先登录再写评论。
Hi,
My suggestion is to implement an empty state like in the design guide:
https://jetbrains.design/intellij/principles/empty_state/#tool-windows-lists-trees-andtables
Clicking your "Add server..." should open the configuration of the servers.
Karol Lewandowski I see. I like the fact that I can provide instructional text stating that the credentials need to be configured before the plugin can work.
So to actually make this happen, as I understand I will need
1. A class that implements a persistent state
2. A form to collect the info from the user
I think I already have a persistent state class, but I am not sure how/where I would create the input form, and how I can make the form openable from a tool bar action.
Hi,
You can implement a dialog:
https://plugins.jetbrains.com/docs/intellij/dialog-wrapper.html
If you use Kotlin, then you can use Kotlin UI DSL for creating form content:
https://plugins.jetbrains.com/docs/intellij/kotlin-ui-dsl-version-2.html