IJ-CR-155115 IJPL-172387 [FUS] provide additional attribute in statistics to define the action type for simple dialogs

Implemented for dialogs with yes/no/cancel, yes/no, ok/cancel actions. Any other dialogs with custom actions will return undefined exitActionType

(cherry picked from commit dd030c0a4a98c385d30c3710b3a063f500bb400e)

GitOrigin-RevId: f95022c182218f0172c7aa9a70aea38c2e44c420
This commit is contained in:
Vera Petrenkova
2025-02-13 14:10:04 +01:00
committed by intellij-monorepo-bot
parent 21d689f17c
commit 04f625af66
18 changed files with 100 additions and 42 deletions

View File

@@ -1943,6 +1943,16 @@ a:com.intellij.openapi.ui.DoNotAskOption$Adapter
- a:rememberChoice(Z,I):V
- f:setToBeShown(Z,I):V
- shouldSaveOptionsOnCancel():Z
e:com.intellij.openapi.ui.ExitActionType
- java.lang.Enum
- sf:CANCEL:com.intellij.openapi.ui.ExitActionType
- sf:NO:com.intellij.openapi.ui.ExitActionType
- sf:OK:com.intellij.openapi.ui.ExitActionType
- sf:UNDEFINED:com.intellij.openapi.ui.ExitActionType
- sf:YES:com.intellij.openapi.ui.ExitActionType
- s:getEntries():kotlin.enums.EnumEntries
- s:valueOf(java.lang.String):com.intellij.openapi.ui.ExitActionType
- s:values():com.intellij.openapi.ui.ExitActionType[]
f:com.intellij.openapi.ui.MessageConstants
- sf:CANCEL:I
- sf:NO:I

View File

@@ -0,0 +1,6 @@
// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.openapi.ui
enum class ExitActionType {
YES, NO, CANCEL, OK, UNDEFINED
}

View File

@@ -120,6 +120,7 @@ sealed class MessageDialogBuilder<T : MessageDialogBuilder<T>>(protected val tit
return MessagesService.getInstance().showMessageDialog(
project = project, parentComponent = parentComponent, message = message, title = title, options = arrayOf(yesText, noText),
icon = icon, doNotAskOption = doNotAskOption, alwaysUseIdeaUI = true, helpId = helpId, invocationPlace = invocationPlace,
exitActionTypes = arrayOf(ExitActionType.YES, ExitActionType.NO)
) == YES
}
}
@@ -152,7 +153,8 @@ sealed class MessageDialogBuilder<T : MessageDialogBuilder<T>>(protected val tit
val options = arrayOf(yesText, noText, cancelText)
val choice = MessagesService.getInstance().showMessageDialog(
project = project, parentComponent = parentComponent, message = message, title = title, options = options,
icon = icon, doNotAskOption = doNotAskOption, alwaysUseIdeaUI = true, helpId = helpId, invocationPlace = invocationPlace)
icon = icon, doNotAskOption = doNotAskOption, alwaysUseIdeaUI = true, helpId = helpId, invocationPlace = invocationPlace,
exitActionTypes = arrayOf(ExitActionType.YES, ExitActionType.NO, ExitActionType.CANCEL))
return when (choice) {
0 -> YES
1 -> NO
@@ -212,6 +214,7 @@ class OkCancelDialogBuilder internal constructor(title: String, message: String)
val noText = noText ?: CommonBundle.getCancelButtonText()
return MessagesService.getInstance().showMessageDialog(
project = project, parentComponent = parentComponent, message = message, title = title, options = arrayOf(yesText, noText),
icon = icon, doNotAskOption = doNotAskOption, alwaysUseIdeaUI = true, helpId = helpId, invocationPlace = invocationPlace) == 0
icon = icon, doNotAskOption = doNotAskOption, alwaysUseIdeaUI = true, helpId = helpId, invocationPlace = invocationPlace,
exitActionTypes = arrayOf(ExitActionType.YES, ExitActionType.NO)) == 0
}
}

View File

@@ -4,6 +4,7 @@ package com.intellij.openapi.ui.messages
import com.intellij.openapi.application.ApplicationManager
import com.intellij.openapi.project.Project
import com.intellij.openapi.ui.DoNotAskOption
import com.intellij.openapi.ui.ExitActionType
import com.intellij.openapi.ui.InputValidator
import com.intellij.openapi.util.NlsContexts
import com.intellij.openapi.util.NlsContexts.DetailedDescription
@@ -61,7 +62,8 @@ interface MessagesService {
doNotAskOption: DoNotAskOption?,
alwaysUseIdeaUI: Boolean = false,
helpId: String? = null,
invocationPlace: String? = null
invocationPlace: String? = null,
exitActionTypes: Array<ExitActionType> = emptyArray()
): Int

View File

@@ -3664,7 +3664,9 @@ a:com.intellij.openapi.ui.DialogWrapper
- centerRelativeToParent():V
- clickDefaultButton():V
- f:close(I):V
- f:close(I,com.intellij.openapi.ui.ExitActionType):V
- f:close(I,Z):V
- f:close(I,Z,com.intellij.openapi.ui.ExitActionType):V
- p:continuousValidation():Z
- p:createActions():javax.swing.Action[]
- p:createButtonsPanel(java.util.List):javax.swing.JPanel
@@ -4600,6 +4602,7 @@ f:com.intellij.openapi.ui.cellvalidators.ValidationUtils
c:com.intellij.openapi.ui.messages.MessageDialog
- com.intellij.openapi.ui.DialogWrapper
- p:myDefaultOptionIndex:I
- p:myExitActionTypes:com.intellij.openapi.ui.ExitActionType[]
- p:myFocusedOptionIndex:I
- p:myIcon:javax.swing.Icon
- p:myMessage:java.lang.String
@@ -4608,12 +4611,12 @@ c:com.intellij.openapi.ui.messages.MessageDialog
- p:<init>(com.intellij.openapi.project.Project):V
- <init>(com.intellij.openapi.project.Project,java.awt.Component,java.lang.String,java.lang.String,java.lang.String[],I,I,javax.swing.Icon,com.intellij.openapi.ui.DoNotAskOption,Z):V
- <init>(com.intellij.openapi.project.Project,java.awt.Component,java.lang.String,java.lang.String,java.lang.String[],I,I,javax.swing.Icon,com.intellij.openapi.ui.DoNotAskOption,Z,java.lang.String):V
- <init>(com.intellij.openapi.project.Project,java.awt.Component,java.lang.String,java.lang.String,java.lang.String[],I,I,javax.swing.Icon,com.intellij.openapi.ui.DoNotAskOption,Z,java.lang.String,java.lang.String):V
- <init>(com.intellij.openapi.project.Project,java.awt.Component,java.lang.String,java.lang.String,java.lang.String[],I,I,javax.swing.Icon,com.intellij.openapi.ui.DoNotAskOption,Z,java.lang.String,java.lang.String,com.intellij.openapi.ui.ExitActionType[]):V
- <init>(com.intellij.openapi.project.Project,java.lang.String,java.lang.String,java.lang.String[],I,javax.swing.Icon,Z):V
- <init>(com.intellij.openapi.project.Project,Z):V
- <init>(java.lang.String,java.lang.String,java.lang.String[],I,javax.swing.Icon):V
- p:_init(java.lang.String,java.lang.String,java.lang.String[],I,I,javax.swing.Icon,com.intellij.openapi.ui.DoNotAskOption,java.lang.String):V
- p:_init(java.lang.String,java.lang.String,java.lang.String[],I,I,javax.swing.Icon,com.intellij.openapi.ui.DoNotAskOption,java.lang.String,java.lang.String):V
- p:_init(java.lang.String,java.lang.String,java.lang.String[],I,I,javax.swing.Icon,com.intellij.openapi.ui.DoNotAskOption,java.lang.String,java.lang.String,com.intellij.openapi.ui.ExitActionType[]):V
- p:createActions():javax.swing.Action[]
- p:createCenterPanel():javax.swing.JComponent
- p:createIconPanel():javax.swing.JPanel

View File

@@ -3,6 +3,7 @@ package com.intellij.internal.statistic.eventLog
import com.intellij.openapi.application.ApplicationManager
import com.intellij.openapi.options.Configurable
import com.intellij.openapi.ui.ExitActionType
import org.jetbrains.annotations.ApiStatus
@ApiStatus.Internal
@@ -24,7 +25,7 @@ interface FeatureUsageUiEvents {
fun logShowDialog(dialogClass: Class<*>, invocationPlace: String? = null)
fun logCloseDialog(dialogClass: Class<*>, exitCode: Int, invocationPlace: String? = null)
fun logCloseDialog(dialogClass: Class<*>, exitCode: Int, exitActionType: ExitActionType, invocationPlace: String? = null)
fun logClickOnHelpDialog(dialogClass: Class<*>, invocationPlace: String? = null)
}
@@ -43,7 +44,7 @@ object EmptyFeatureUsageUiEvents : FeatureUsageUiEvents {
override fun logShowDialog(dialogClass: Class<*>, invocationPlace: String?) {
}
override fun logCloseDialog(dialogClass: Class<*>, exitCode: Int, invocationPlace: String?) {
override fun logCloseDialog(dialogClass: Class<*>, exitCode: Int, exitActionType: ExitActionType, invocationPlace: String?) {
}
override fun logClickOnHelpDialog(dialogClass: Class<*>, invocationPlace: String?) {

View File

@@ -474,8 +474,8 @@ public abstract class DialogWrapper {
* @param isOk is OK
* @throws IllegalStateException if the dialog is invoked not on the event dispatch thread
*/
public final void close(int exitCode, boolean isOk) {
logCloseDialogEvent(exitCode);
public final void close(int exitCode, boolean isOk, ExitActionType exitActionType) {
logCloseDialogEvent(exitCode, exitActionType);
ensureEventDispatchThread();
if (myClosed) return;
myClosed = true;
@@ -499,8 +499,16 @@ public abstract class DialogWrapper {
}
}
public final void close(int exitCode, boolean isOk) {
close(exitCode, isOk, ExitActionType.UNDEFINED);
}
public final void close(int exitCode, ExitActionType exitActionType) {
close(exitCode, exitCode != CANCEL_EXIT_CODE, exitActionType);
}
public final void close(int exitCode) {
close(exitCode, exitCode != CANCEL_EXIT_CODE);
close(exitCode, exitCode != CANCEL_EXIT_CODE, ExitActionType.UNDEFINED);
}
/**
@@ -1017,7 +1025,7 @@ public abstract class DialogWrapper {
*/
public void doCancelAction() {
if (getCancelAction().isEnabled()) {
close(CANCEL_EXIT_CODE);
close(CANCEL_EXIT_CODE, ExitActionType.CANCEL);
}
}
@@ -1071,7 +1079,7 @@ public abstract class DialogWrapper {
protected void doOKAction() {
if (getOKAction().isEnabled()) {
applyFields();
close(OK_EXIT_CODE);
close(OK_EXIT_CODE, ExitActionType.OK);
}
}
@@ -1863,10 +1871,10 @@ public abstract class DialogWrapper {
.findFirst();
}
private void logCloseDialogEvent(int exitCode) {
private void logCloseDialogEvent(int exitCode, ExitActionType exitActionType) {
boolean canRecord = canRecordDialogId();
if (canRecord) {
FeatureUsageUiEventsKt.getUiEventLogger().logCloseDialog(getClass(), exitCode, invocationPlace);
FeatureUsageUiEventsKt.getUiEventLogger().logCloseDialog(getClass(), exitCode, exitActionType, invocationPlace);
}
}

View File

@@ -290,7 +290,8 @@ public class Messages {
@Nullable DialogWrapper.DoNotAskOption doNotAskOption,
@Nullable String invocationPlace) {
return MessagesService.getInstance()
.showMessageDialog(null, null, message, title, options, defaultOptionIndex, focusedOptionIndex, icon, doNotAskOption, false, null, invocationPlace);
.showMessageDialog(null, null, message, title, options, defaultOptionIndex, focusedOptionIndex, icon, doNotAskOption, false, null,
invocationPlace, new ExitActionType[0]);
}
/**
@@ -1086,6 +1087,7 @@ public class Messages {
for (int i = 0; i < myOptions.length; i++) {
String option = myOptions[i];
final int exitCode = i;
ExitActionType exitType = myExitActionTypes.length > i ? myExitActionTypes[i] : ExitActionType.UNDEFINED;
if (i == 0) { // "OK" is default button. It has index 0.
actions[0] = getOKAction();
actions[0].putValue(DialogWrapper.DEFAULT_ACTION, Boolean.TRUE);
@@ -1104,7 +1106,7 @@ public class Messages {
actions[i] = new AbstractAction(option) {
@Override
public void actionPerformed(ActionEvent e) {
close(exitCode);
close(exitCode, exitType);
}
};
}

View File

@@ -3,6 +3,7 @@ package com.intellij.openapi.ui.messages;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.DialogWrapper;
import com.intellij.openapi.ui.ExitActionType;
import com.intellij.openapi.ui.Messages;
import com.intellij.openapi.ui.MultiLineLabelUI;
import com.intellij.openapi.util.NlsContexts;
@@ -20,6 +21,7 @@ import java.util.List;
public class MessageDialog extends DialogWrapper {
protected @NlsContexts.DialogMessage @Nullable String myMessage;
protected String[] myOptions;
protected ExitActionType[] myExitActionTypes;
protected int myDefaultOptionIndex;
protected int myFocusedOptionIndex;
protected Icon myIcon;
@@ -60,9 +62,10 @@ public class MessageDialog extends DialogWrapper {
@Nullable com.intellij.openapi.ui.DoNotAskOption doNotAskOption,
boolean canBeParent,
@Nullable String helpId,
@Nullable String invocationPlace) {
@Nullable String invocationPlace,
ExitActionType @NotNull [] exitActionTypes) {
super(project, parentComponent, canBeParent, IdeModalityType.IDE);
_init(title, message, options, defaultOptionIndex, focusedOptionIndex, icon, doNotAskOption, helpId, invocationPlace);
_init(title, message, options, defaultOptionIndex, focusedOptionIndex, icon, doNotAskOption, helpId, invocationPlace, exitActionTypes);
}
public MessageDialog(@Nullable Project project,
@@ -76,7 +79,7 @@ public class MessageDialog extends DialogWrapper {
@Nullable com.intellij.openapi.ui.DoNotAskOption doNotAskOption,
boolean canBeParent,
@Nullable String helpId) {
this(project, parentComponent, message, title, options, defaultOptionIndex, focusedOptionIndex, icon, doNotAskOption, canBeParent, helpId, null);
this(project, parentComponent, message, title, options, defaultOptionIndex, focusedOptionIndex, icon, doNotAskOption, canBeParent, helpId, null, new ExitActionType[0]);
}
public MessageDialog(@NlsContexts.DialogMessage @Nullable String message,
@@ -107,7 +110,7 @@ public class MessageDialog extends DialogWrapper {
@Nullable Icon icon,
@Nullable com.intellij.openapi.ui.DoNotAskOption doNotAskOption,
@Nullable String helpId) {
_init(title, message, options, defaultOptionIndex, focusedOptionIndex, icon, doNotAskOption, helpId, null);
_init(title, message, options, defaultOptionIndex, focusedOptionIndex, icon, doNotAskOption, helpId, null, new ExitActionType[0]);
}
protected void _init(@NlsContexts.DialogTitle String title,
@@ -118,10 +121,12 @@ public class MessageDialog extends DialogWrapper {
@Nullable Icon icon,
@Nullable com.intellij.openapi.ui.DoNotAskOption doNotAskOption,
@Nullable String helpId,
@Nullable String invocationPlace) {
@Nullable String invocationPlace,
ExitActionType @NotNull [] exitActionTypes) {
setTitle(title);
myMessage = message;
myOptions = options;
myExitActionTypes = exitActionTypes;
myDefaultOptionIndex = defaultOptionIndex;
myFocusedOptionIndex = focusedOptionIndex;
myIcon = icon;
@@ -137,10 +142,11 @@ public class MessageDialog extends DialogWrapper {
for (int i = 0; i < myOptions.length; i++) {
String option = myOptions[i];
final int exitCode = i;
ExitActionType exitActionType = myExitActionTypes.length > i ? myExitActionTypes[i] : ExitActionType.UNDEFINED;
Action action = new AbstractAction(UIUtil.replaceMnemonicAmpersand(option)) {
@Override
public void actionPerformed(ActionEvent e) {
close(exitCode, true);
close(exitCode, true, exitActionType);
}
};

View File

@@ -16282,7 +16282,7 @@ c:com.intellij.ui.messages.MessagesServiceImpl
- showErrorDialog(com.intellij.openapi.project.Project,java.lang.String,java.lang.String):V
- showInputDialog(com.intellij.openapi.project.Project,java.awt.Component,java.lang.String,java.lang.String,javax.swing.Icon,java.lang.String,com.intellij.openapi.ui.InputValidator,com.intellij.openapi.util.TextRange,java.lang.String):java.lang.String
- showInputDialogWithCheckBox(java.lang.String,java.lang.String,java.lang.String,Z,Z,javax.swing.Icon,java.lang.String,com.intellij.openapi.ui.InputValidator):com.intellij.openapi.util.Pair
- showMessageDialog(com.intellij.openapi.project.Project,java.awt.Component,java.lang.String,java.lang.String,java.lang.String[],I,I,javax.swing.Icon,com.intellij.openapi.ui.DoNotAskOption,Z,java.lang.String,java.lang.String):I
- showMessageDialog(com.intellij.openapi.project.Project,java.awt.Component,java.lang.String,java.lang.String,java.lang.String[],I,I,javax.swing.Icon,com.intellij.openapi.ui.DoNotAskOption,Z,java.lang.String,java.lang.String,com.intellij.openapi.ui.ExitActionType[]):I
- showMoreInfoMessageDialog(com.intellij.openapi.project.Project,java.lang.String,java.lang.String,java.lang.String,java.lang.String[],I,I,javax.swing.Icon):I
- showMultilineInputDialog(com.intellij.openapi.project.Project,java.lang.String,java.lang.String,java.lang.String,javax.swing.Icon,com.intellij.openapi.ui.InputValidator):java.lang.String
- showPasswordDialog(com.intellij.openapi.project.Project,java.lang.String,java.lang.String,javax.swing.Icon,com.intellij.openapi.ui.InputValidator):java.lang.String

View File

@@ -11,6 +11,7 @@ import com.intellij.openapi.diagnostic.logger
import com.intellij.openapi.observable.properties.PropertyGraph
import com.intellij.openapi.project.Project
import com.intellij.openapi.ui.DialogWrapper
import com.intellij.openapi.ui.ExitActionType
import com.intellij.openapi.util.NlsContexts
import com.intellij.openapi.util.SystemInfoRt
import com.intellij.openapi.util.registry.Registry
@@ -226,14 +227,18 @@ internal class TrustedProjectStartupDialog(
val option = options[i]
val action: Action = object : AbstractAction(UIUtil.replaceMnemonicAmpersand(option)) {
override fun actionPerformed(e: ActionEvent) {
val exitActionType: ExitActionType
userChoice = when (option) {
trustButtonText -> {
exitActionType = ExitActionType.YES
OpenUntrustedProjectChoice.TRUST_AND_OPEN
}
distrustButtonText -> {
exitActionType = ExitActionType.NO
OpenUntrustedProjectChoice.OPEN_IN_SAFE_MODE
}
cancelButtonText -> {
exitActionType = ExitActionType.CANCEL
OpenUntrustedProjectChoice.CANCEL
}
else -> {
@@ -242,7 +247,7 @@ internal class TrustedProjectStartupDialog(
return
}
}
close(i, userChoice == OpenUntrustedProjectChoice.TRUST_AND_OPEN)
close(i, userChoice == OpenUntrustedProjectChoice.TRUST_AND_OPEN, exitActionType)
}
}
if (option == trustButtonText) trustAction = action

View File

@@ -14,9 +14,10 @@ import com.intellij.internal.statistic.service.fus.collectors.CounterUsagesColle
import com.intellij.openapi.options.Configurable
import com.intellij.openapi.options.ex.ConfigurableWrapper
import com.intellij.openapi.ui.DialogWrapper
import com.intellij.openapi.ui.ExitActionType
internal object DialogsCounterUsagesCollector : CounterUsagesCollector() {
private val GROUP = EventLogGroup("ui.dialogs", 62)
private val GROUP = EventLogGroup("ui.dialogs", 63)
val EXIT_CODE: PrimitiveEventField<Int> = object: PrimitiveEventField<Int>() {
override val name: String = "code"
@@ -39,9 +40,10 @@ internal object DialogsCounterUsagesCollector : CounterUsagesCollector() {
val DIALOG_CLASS: ClassEventField = EventFields.Class("dialog_class")
val INVOCATION_PLACE: StringEventField = StringValidatedByCustomRule("dialog_invocation_place", ListValidationRule::class.java)
val EXIT_ACTION_TYPE = EnumEventField("exit_action_type", ExitActionType::class.java) { it.name }
val SHOW: VarargEventId = GROUP.registerVarargEvent("show", DIALOG_CLASS, INVOCATION_PLACE, EventFields.PluginInfo)
val CLOSE: VarargEventId = GROUP.registerVarargEvent("close", DIALOG_CLASS, INVOCATION_PLACE, EXIT_CODE, EventFields.PluginInfo)
val CLOSE: VarargEventId = GROUP.registerVarargEvent("close", DIALOG_CLASS, INVOCATION_PLACE, EXIT_ACTION_TYPE, EXIT_CODE, EventFields.PluginInfo)
val HELP: VarargEventId = GROUP.registerVarargEvent("help.clicked", DIALOG_CLASS, INVOCATION_PLACE, EventFields.PluginInfo)
override fun getGroup(): EventLogGroup = GROUP
@@ -119,11 +121,12 @@ internal class FeatureUsageUiEventsImpl : FeatureUsageUiEvents {
}
}
override fun logCloseDialog(clazz: Class<*>, exitCode: Int, invocationPlace: String?) {
override fun logCloseDialog(clazz: Class<*>, exitCode: Int, exitActionType: ExitActionType, invocationPlace: String?) {
if (FeatureUsageLogger.getInstance().isEnabled()) {
DialogsCounterUsagesCollector.CLOSE.log(
DialogsCounterUsagesCollector.DIALOG_CLASS.with(clazz),
DialogsCounterUsagesCollector.INVOCATION_PLACE.with(invocationPlace),
DialogsCounterUsagesCollector.EXIT_ACTION_TYPE.with(exitActionType),
DialogsCounterUsagesCollector.EXIT_CODE.with(exitCode)
)
}

View File

@@ -10,6 +10,7 @@ import com.intellij.openapi.components.service
import com.intellij.openapi.project.Project
import com.intellij.openapi.ui.DialogWrapper
import com.intellij.openapi.ui.DoNotAskOption
import com.intellij.openapi.ui.ExitActionType
import com.intellij.openapi.ui.Messages
import com.intellij.openapi.ui.popup.IconButton
import com.intellij.openapi.util.NlsContexts
@@ -64,9 +65,10 @@ internal class AlertMessagesManager {
icon: Icon?,
doNotAskOption: DoNotAskOption?,
helpId: String?,
invocationPlace: String?): Int {
invocationPlace: String?,
exitActionTypes: Array<ExitActionType>): Int {
val dialog = AlertDialog(project, parentComponent, message, title, options, defaultOptionIndex, focusedOptionIndex, getIcon(icon),
doNotAskOption, helpId, invocationPlace)
doNotAskOption, helpId, invocationPlace, exitActionTypes)
AppIcon.getInstance().requestAttention(project, true)
dialog.show()
return dialog.exitCode
@@ -102,7 +104,8 @@ class AlertDialog(project: Project?,
icon: Icon,
doNotAskOption: com.intellij.openapi.ui.DoNotAskOption?,
val myHelpId: String?,
invocationPlace: String? = null) : DialogWrapper(project, parentComponent, false, IdeModalityType.IDE, false) {
invocationPlace: String? = null,
val exitActionTypes: Array<ExitActionType> = emptyArray()) : DialogWrapper(project, parentComponent, false, IdeModalityType.IDE, false) {
private val myIsTitleComponent = SystemInfoRt.isMac || !Registry.`is`("ide.message.dialogs.as.swing.alert.show.title.bar", false)
@@ -471,9 +474,10 @@ class AlertDialog(project: Project?,
val actions: MutableList<Action> = ArrayList()
for (i in myOptions.indices) {
val option = myOptions[i]
val exitActionType = if (exitActionTypes.size > i) exitActionTypes[i] else ExitActionType.UNDEFINED
val action: Action = object : AbstractAction(UIUtil.replaceMnemonicAmpersand(option)) {
override fun actionPerformed(e: ActionEvent) {
close(i, true)
close(i, true, exitActionType)
}
}
if (i == myDefaultOptionIndex) {
@@ -542,7 +546,7 @@ class AlertDialog(project: Project?,
return null
}
override fun doCancelAction() = close(-1, false)
override fun doCancelAction() = close(-1, false, ExitActionType.CANCEL)
override fun createHelpButton(insets: Insets): JButton {
val helpButton = super.createHelpButton(insets)

View File

@@ -45,7 +45,8 @@ public class MessagesServiceImpl implements MessagesService {
@Nullable DoNotAskOption doNotAskOption,
boolean alwaysUseIdeaUI,
@Nullable String helpId,
@Nullable String invocationPlace) {
@Nullable String invocationPlace,
ExitActionType @NotNull [] exitActionTypes) {
if (isApplicationInUnitTestOrHeadless()) {
return TestDialogManager.getTestImplementation().show(message);
}
@@ -53,11 +54,11 @@ public class MessagesServiceImpl implements MessagesService {
AlertMessagesManager alertMessagesManager = AlertMessagesManager.getInstanceIfPossible();
if (alertMessagesManager != null) {
return alertMessagesManager.showMessageDialog(project, parentComponent, message, title, options, defaultOptionIndex,
focusedOptionIndex, icon, doNotAskOption, helpId, invocationPlace);
focusedOptionIndex, icon, doNotAskOption, helpId, invocationPlace, exitActionTypes);
}
MessageDialog dialog = new MessageDialog(project, parentComponent, message, title, options, defaultOptionIndex, focusedOptionIndex,
icon, doNotAskOption, false, helpId, invocationPlace);
icon, doNotAskOption, false, helpId, invocationPlace, exitActionTypes);
dialog.show();
return dialog.getExitCode();
}
@@ -79,8 +80,8 @@ public class MessagesServiceImpl implements MessagesService {
if (moreInfo == null) {
AlertMessagesManager alertMessagesManager = AlertMessagesManager.getInstanceIfPossible();
if (alertMessagesManager != null) {
return alertMessagesManager.showMessageDialog(project, null, message, title, options, defaultOptionIndex,
focusedOptionIndex, icon, null, null, null);
return alertMessagesManager.showMessageDialog(project, null, message, title, options, defaultOptionIndex, focusedOptionIndex, icon,
null, null, null, null);
}
}

View File

@@ -1,6 +1,7 @@
package com.intellij.settingsSync.core.config
import com.intellij.openapi.ui.DialogWrapper
import com.intellij.openapi.ui.ExitActionType
import com.intellij.settingsSync.core.SettingsSyncBundle.message
import com.intellij.settingsSync.core.SettingsSyncLocalStateHolder
import com.intellij.settingsSync.core.SettingsSyncState
@@ -68,7 +69,7 @@ internal class EnableSettingsSyncDialog(
private fun applyAndClose(result: Result) {
applyFields()
dialogResult = result
close(0, true)
close(0, true, ExitActionType.OK)
}
fun getResult(): Result? = dialogResult

View File

@@ -7,6 +7,7 @@ import com.intellij.openapi.application.asContextElement
import com.intellij.openapi.project.Project
import com.intellij.openapi.ui.DialogWrapper
import com.intellij.openapi.ui.DialogWrapper.IS_VISUAL_PADDING_COMPENSATED_ON_COMPONENT_LEVEL_KEY
import com.intellij.openapi.ui.ExitActionType
import com.intellij.openapi.ui.ValidationInfo
import com.intellij.openapi.util.NlsContexts
import com.intellij.platform.util.coroutines.childScope
@@ -58,11 +59,11 @@ internal sealed class GHLoginDialog(
try {
val (login, token) = loginPanel.acquireLoginAndToken()
model.saveLogin(loginPanel.getServer(), login, token)
close(OK_EXIT_CODE, true)
close(OK_EXIT_CODE, true, ExitActionType.OK)
}
catch (e: Exception) {
if (e is CancellationException) {
close(CANCEL_EXIT_CODE, false)
close(CANCEL_EXIT_CODE, false, ExitActionType.CANCEL)
throw e
}
setError(e)

View File

@@ -6,6 +6,7 @@ import com.intellij.ide.util.PropertiesComponent
import com.intellij.openapi.fileChooser.FileChooserDescriptorFactory.createSingleFolderDescriptor
import com.intellij.openapi.project.Project
import com.intellij.openapi.ui.DialogWrapper
import com.intellij.openapi.ui.ExitActionType
import com.intellij.openapi.ui.TextFieldWithBrowseButton
import com.intellij.openapi.util.Disposer
import com.intellij.refactoring.copy.CopyFilesOrDirectoriesDialog
@@ -105,6 +106,6 @@ class MoveRefactoringActionDialog(
PropertiesComponent.getInstance().setValue(RECENT_SELECTED_PATH, selectedDirectoryName)
PropertiesComponent.getInstance().setValue(RECENT_SELECTED_RUN_COUNT, tfRefactoringRunCount.text)
close(OK_EXIT_CODE, /* isOk = */ true)
close(OK_EXIT_CODE, /* isOk = */ true, ExitActionType.OK)
}
}

View File

@@ -4,6 +4,7 @@ package org.jetbrains.kotlin.idea.refactoring.inline
import com.intellij.openapi.editor.Editor
import com.intellij.openapi.project.Project
import com.intellij.openapi.ui.DialogWrapper
import com.intellij.openapi.ui.ExitActionType
import com.intellij.psi.PsiReference
import com.intellij.refactoring.HelpID
import org.jetbrains.kotlin.psi.psiUtil.isExpectDeclaration
@@ -73,7 +74,7 @@ abstract class AbstractKotlinInlinePropertyHandler(protected val withPrompt: Boo
try {
dialog.doAction()
} finally {
dialog.close(DialogWrapper.OK_EXIT_CODE, true)
dialog.close(DialogWrapper.OK_EXIT_CODE, true, ExitActionType.OK)
}
}
}