How to use CodeStyleSettingsCustomizable.showCustomOption for Drop Down Lists?


I'm able to create check boxes with showCustomOption, but I cannot make drop down lists or radio buttons.

Looking at several other plugins, I tried something like this:

private static final String[] SYNTAX_DESCRS = new String[]{"Strict", "Normal", "Relaxed"};
private static final int[] SYNTAX_VALUES = new int[]{0, 1, 2};

public void customizeSettings(@NotNull CodeStyleSettingsCustomizable consumer, @NotNull SettingsType settingsType) {
consumer.showCustomOption(MyCodeStyleSettings.class, "MY_SYNTAX", "Syntax mode",

where MY_SYNTAX is a public static int attribute in class MyCodeStyleSettings.

This code causes an endless loop when opening the Code Style settings.  The other examples all used null for the group, but when I tried that I got a NPE higher up in the stack.

Is there any kind of documentation on how to do this?  Or would it be easier to use CodeStyleSettingsPanel?

Comment actions Permalink

I gave up on that and use my own panel instead.

Comment actions Permalink

Your code seems to be correct at first glance with one exception: you have to check which settings type the option is added to. For example, if you adding the custom option to "Wrapping and Braces" panel, you should write the following:

public void customizeSettings(@NotNull CodeStyleSettingsCustomizable consumer, @NotNull SettingsType settingsType) {
if (settingsType == SettingsType.WRAPPING_AND_BRACES_SETTINGS) {
consumer.showCustomOption(MyCodeStyleSettings.class, "MY_SYNTAX", "Syntax mode", "Syntax", SYNTAX_DESCRS, SYNTAX_VALUES);

Note: The panel has to be derived from OptionTableWithPreviewPanel in order to handle customizable drop-down lists. Standard "Wrapping and Braces" panel supports them, other standard panels don't. If you don't want to add your option to "Wrapping and Braces", you can create your own panel either from scratch with an arbitrary layout like you probably did or derive it from OptionTableWithPreviewPanel depending on how you want it to look like.


Please sign in to leave a comment.