dialog_wrapper.md: structure

This commit is contained in:
Yann Cébron 2021-05-20 12:01:39 +02:00
parent a6378d5d70
commit b0990a8ff9

View File

@ -18,11 +18,13 @@ It provides the following features:
* <shortcut>Y</shortcut>/<shortcut>N</shortcut> for <control>Yes</control>/<control>No</control> actions if they exist in the dialog
* Optional <control>Do not ask again</control> checkbox
### Usage
When using the [`DialogWrapper`](upsource:///platform/platform-api/src/com/intellij/openapi/ui/DialogWrapper.java) class for a dialog, follow these steps:
* Call the base class constructor and provide either a project in the frame of which the dialog will be displayed, or a parent component for the dialog.
* Call the base class constructor and provide either a `Project` in the frame of which the dialog will be displayed, or a parent component for the dialog.
* Call the `init()` method from the constructor of the dialog class
* Call the `setTitle()` method to set the title for the dialog box
* Call the `setTitle()` method to set the title for the dialog
* Implement the `createCenterPanel()` method to return the component comprising the main contents of the dialog.
* *Optional*: Override the `getPreferredFocusedComponent()` method and return the component that should be focused when the dialog is first displayed.
@ -45,6 +47,8 @@ Both of these methods return an array of Swing Action objects.
If a button closes the dialog, use [`DialogWrapperExitAction`](upsource:///platform/platform-api/src/com/intellij/openapi/ui/DialogWrapper.java) as the base class for the action.
Use `action.putValue(DialogWrapper.DEFAULT_ACTION, true)` to set the default button.
### Input Validation
To validate the data entered into the dialog, override the `doValidate()` method.
The method will be called automatically by timer.
If the currently entered data is valid, return `null`.