What is the correct way to display complex dialogue in an Eclipse plugin?

I want a complex dialog to appear when the user clicks on some button added by my plugin, but I could not find any existing type of dialogue that supports adding arbitrary controls.

Instead, I was thinking of creating a one-page wizard — it would probably look good enough, but it doesn't seem right. Is there a better way to create dialogue with complex controls?

+3
source share
1 answer

You want a subclass of org.eclipse.jface.dialogs.TrayDialog. This will give you a dialog with a button bar and a pull-out tray that will appear when you click the help button. According to Javadoc TrayDialog:

It is recommended to subclass this class instead Dialogin all cases, unless the dialog should never show the tray

You put your complex code in a method createDialogArea(Composite parent). If you want everything to look right, make sure you use the composite returned from the super call instead of using the parent. This will ensure that the fields have a default value. For instance:

protected Control createDialogArea(Composite parent) {
  Composite parentWithMargins = (Composite) super.createDialogArea(parent);

  /*
   * Add your code here parenting off of parentWithMargins
   */

  return parentWithMargins;
}
+4
source

Source: https://habr.com/ru/post/1794266/


All Articles