我可以使 eclipse SWT UI 看起来像 Eclipse 插件 UI 吗?

Can I make eclipse SWT UI to look like Eclipse plugin UI?

我正在向 Eclipse 添加一些功能,就像在 Eclipse 插件中一样

我有一项是复选框选择(见图)

    final ListSelectionDialog dialog = new ListSelectionDialog(window.getShell(), list,
            ArrayContentProvider.getInstance(), new LabelProvider(), "");
    dialog.setTitle("Create Events");
    dialog.setHelpAvailable(false);
    dialog.setMessage("Potential events in code:");
    dialog.create();
    dialog.getOkButton().setText("Create");
    dialog.open();

和另一个包含单选按钮的项目(我找不到类似 ListSelectionDialog 的单选按钮

public void display(List<String> list){
    Display.getDefault().asyncExec(new Runnable(){
        public void run() {
            Display display = Display.getDefault();
            Shell shell = new Shell(display);
            shell.setLayout(new GridLayout());
            shell.setText("Create Object");
            Label label = new Label(shell, SWT.NULL);
            label.setText("Entry point: ");
            for (String item: list){
                Button btn  = new Button(shell, SWT.RADIO);
                btn.setText(item);                    
            }
            Composite composite = new Composite(shell, SWT.NULL);
            composite.setLayout(new RowLayout());

            Button createButton = new Button(composite, SWT.PUSH);
            createButton.setText("Create");
            Button cancelButton = new Button(composite, SWT.PUSH);
            cancelButton.setText("Cancel");
            shell.setSize(400, 200);
            shell.open ();
            while (!shell.isDisposed ()) {
                if (!display.readAndDispatch ()) display.sleep ();
            }
            shell.dispose ();
                }
        });
}

如您所见,基于 SWT 的项目看起来格格不入,与 Eclipse 的 UI 不一致。 有没有可能让它看起来像另一个?

使用提供标准外观的 JFace Dialog。类似于:

public class CreateDialog extends Dialog
{
  public CreateDialog(final Shell parentShell)
  {
    super(parentShell);
  }

  @Override
  protected void configureShell(final Shell newShell)
  {
    super.configureShell(newShell);

    newShell.setText("Create Object");
  }

  @Override
  protected void createButtonsForButtonBar(Composite parent)
  {
    createButton(parent, IDialogConstants.OK_ID, "Create", true);
    createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false);
 }

  @Override
  protected Control createDialogArea(Composite parent)
  {
    Composite body  = (Composite)super.createDialogArea(parent);

    String [] list = {"e", "e1"};

    Label label = new Label(body, SWT.NULL);
    label.setText("Entry point: ");

    for (String item: list) {
        Button btn = new Button(body, SWT.RADIO);
        btn.setText(item);
    }

    return body;
  }
}