Hello,
Please let me know if this is the wrong forum for this.
I suspect there may be an issue with Messages#showCheckboxOkCancelDialog (see code for it below).
The issue I am experiencing is that when the checkbox in the dialog is unchecked and Cancel is clicked, the resulting exit code is 1 rather than 2 (CANCEL).
I think the issue is with the lambda being passed to showMessageCheckboxDialog in that the condition exitCode == -1 is never true because the Cancel actions in MessageDialog and DialogWrapper (as far as I can tell) use 1 for the cancel exit code and not -1.
I have verified this behaviour. I get the following behaviour when I use this message dialog:
[OK] + checked = 1
[OK] + unchecked = 0
[CANCEL] + checked = 2
[CANCEL] + unchecked = 1
Sincerely,
Alex
p.s. The code below is from: https://github.com/JetBrains/intellij-community/blob/master/platform/platform-api/src/com/intellij/openapi/ui/Messages.java lines 583 - 594.
public static int showCheckboxOkCancelDialog(@DialogMessage String message,
@DialogTitle String title,
@NlsContexts.Checkbox String checkboxText,
final boolean checked,
final int defaultOptionIndex,
final int focusedOptionIndex,
Icon icon) {
return showCheckboxMessageDialog(message, title, new String[]{getOkButton(), getCancelButton()}, checkboxText, checked, defaultOptionIndex,
focusedOptionIndex, icon,
(BiFunction<? super Integer, ? super JCheckBox, Integer>)
(exitCode, cb) -> exitCode == -1 ? CANCEL : exitCode + (cb.isSelected() ? 1 : 0));
}