Announcement: You can find the guides for Commerce 7.5 and later on the new Elastic Path Documentation site. This site contains the guides for Commerce 6.13.0 through 7.4.1.Visit new site

This version of Elastic Path Commerce is no longer supported or maintained. To upgrade to the latest version, contact your Elastic Path representative.

Abstract Dialog

Abstract Dialog

Overview

AbstractEPDialog is meant to be used for all dialogs that have title bar area consisting of a title, description and image. It provides utility methods for creating the more commonly used buttons like OK, Save, Set, Confirm and Cancel. By default a combination of Save and Cancel buttons is configured.

How to use AbstractEPDialog

AbstractEPDialog should be extended and the following abstract methods implemented when necessary:

  1. /**
  2. * Populates the controls for the contents.
  3. */
  4. protected abstract void populateControls();
  5.  
  6. /**
  7. * Binds the controls for the contents.
  8. */
  9. protected abstract void bindControls();
  10.  
  11. /**
  12. * Creates the controls that have to be displayed in the client area of the dialog.
  13. *
  14. * @param dialogComposite the EP layout composite to be used
  15. */

Copy

...
Read more

For values that should not be displayed a simple return of null value will leave the title, image or description fields empty.

Creating a custom dialog implies the usage of the EP UI Framework as the main tool to create and manage the UI controls.

For creating custom buttons or to change the default buttons a specific method has to be overridden. The following is an example of creating a custom labeled OK button along with a Cancel one.

  1. protected void createButtonsForButtonBar(final Composite parent) {
  2. createEpOkButton(parent, "My Button", null);
  3. createEpCancelButton(parent);
  4. }

Copy

Hadling OK button click event is done in okPressed() method. Cancel button event closes the dialog by default but this behaviour can be changed by overriding cancelPressed() method.

For creating one of the predefined button sets you can do the following:

  1. protected void createButtonsForButtonBar(final Composite parent) {
  2. createEpButtonsForButtonsBar(ButtonsBarType.CONFIRM, parent);
  3. }

Copy

What not to use AbstractEpDialog for?

Do not use AbstractEpDialog for displaying dialogs that are a part of the standard SWT API:

  • Errors, warnings, and informational messages
  • Question/confirmation dialogs

All of these can be displayed using the MessageDialog API:

  1. MessageDialog.openError(...)
  2. MessageDialog.openWarning(...)
  3. MessageDialog.openInformation(...)
  4. MessageDialog.openQuestion(...)
  5. MessageDialog.openConfirm(...)

Copy

Example

For reference you can take a look at the numerous dialogs implemented on top of the AbstractEpDialog (e.g. CustomerAddEditAddressDialog, VirtualCatalogDialog, etc.)