Need help implementing add, remove, edit, and reset functionality for a list data configuration in my plugin.
Answered
Hello! I am currently working on implementing a plugin that includes list data settings with add, remove, edit, and reset functionality. You can see an example of this in the image below:
This type of setting is common in IntelliJ IDEA. I have searched for a standard API that can be used for this purpose, but so far, I have not found anything related to listing settings in com.intellij.openapi.vfs.encoding.FileEncodingConfigurable
. Can you suggest any resources or classes that I should refer to? Any help would be greatly appreciated. Thank you!
Please sign in to leave a comment.
Hi,
To create a table, you can use
JBTable
class with the proper model for storing data. There are a lot of examples in the https://github.com/JetBrains/intellij-community code.If you want to display a table of something backed by a class, e.g., every row represents
MyCustomItem
, take a look atcom.intellij.ui.table.TableView
andcom.intellij.util.ui.ListTableModel
.ListTableModel
allows creating column definitions by extendingcom.intellij.util.ui.ColumnInfo
in a very simple and expressive way.To add “Add”, “Delete”, and “Edit” actions, use
com.intellij.ui.ToolbarDecorator#createDecorator(javax.swing.JTable)
that decorates a table in a panel with these buttons. Example:Reset is not directly related to the table. It is a part of reset/apply/isModified mechanism for the configurable. I suggest implementing the whole table in a separate panel that exposes the
reset()
,apply()
, andisModified()
methods that will be called from the actual configurable. See com.intellij.openapi.options.UnnamedConfigurable methods for the details.Thank you for your reply, it helped me a lot!