diff --git a/topics/user_interface_components/dialog_wrapper.md b/topics/user_interface_components/dialog_wrapper.md index fba0a45a5..78f1a11a3 100644 --- a/topics/user_interface_components/dialog_wrapper.md +++ b/topics/user_interface_components/dialog_wrapper.md @@ -43,16 +43,16 @@ Optionally: * Override the `getDimensionServiceKey()` method to return the identifier which will be used for persisting the dialog dimensions. * Override the `getHelpId()` method to return the context help topic associated with the dialog (see [Context Help](ide_infrastructure.md#context-help)). -The `DialogWrapper` class is often used together with [GUI Designer forms](https://www.jetbrains.com/help/idea/gui-designer-basics.html). +Use [Kotlin UI DSL](kotlin_ui_dsl_version_2.md) to provide the dialog's contents (see [samples](#kotlin)). +Alternatively or when using Java, the `DialogWrapper` class can be used together with [GUI Designer forms](https://www.jetbrains.com/help/idea/gui-designer-basics.html). In this case, bind a GUI Designer form to the class extending `DialogWrapper`, bind the top-level panel of the form to a field and return that field from the `createCenterPanel()` method. -When using Kotlin, use [Kotlin UI DSL](kotlin_ui_dsl_version_2.md) to provide the dialog's contents. > See [](layout.md) topic in UI Guidelines for recommendations on arranging UI controls in dialogs. > > Existing dialogs can be inspected at runtime using [UI Inspector](internal_ui_inspector.md), e.g., to locate the underlying implementation of UI components. > -To display the dialog, call the `show()` method and then use the `getExitCode()` method to check how the dialog was closed (see `DialogWrapper#OK_EXIT_CODE|CANCEL_EXIT_CODE|CLOSE_EXIT_CODE`). +To display the dialog, call the `show()` method and then use the `getExitCode()` method to check how the dialog was closed (see `DialogWrapper#OK_EXIT_CODE, CANCEL_EXIT_CODE, CLOSE_EXIT_CODE`). The `showAndGet()` method can be used to combine these two calls. To customize the buttons displayed in the dialog (replacing the standard OK/Cancel/Help set of buttons), override either the `createActions()` or `createLeftActions()` methods. @@ -70,9 +70,9 @@ If the currently entered data is valid, return `null`. Otherwise, return a [`ValidationInfo`](%gh-ic%/platform/ide-core/src/com/intellij/openapi/ui/ValidationInfo.java) object which encapsulates an error message, and an optional component associated with the invalid data. When specifying a component, an error icon will be displayed next to it, and it will be focused when the user tries to invoke the OK action. -## Example +## Examples -Simple definition of a [`DialogWrapper`](%gh-ic%/platform/platform-api/src/com/intellij/openapi/ui/DialogWrapper.java): +Minimum sample of a [`DialogWrapper`](%gh-ic%/platform/platform-api/src/com/intellij/openapi/ui/DialogWrapper.java): ```java public class SampleDialogWrapper extends DialogWrapper { @@ -107,3 +107,10 @@ testButton.addActionListener(actionEvent -> { } }); ``` + +### Kotlin + +Dialogs using [Kotlin UI DSL](kotlin_ui_dsl_version_2.md): + +- [`AddActionDialog`](%gh-ic%/platform/platform-impl/src/com/intellij/ide/ui/customization/AddActionDialog.kt) +- [`InvalidateCachesDialog`](%gh-ic%/platform/platform-impl/src/com/intellij/ide/actions/InvalidateCachesDialog.kt)