How do I get the workbench window to open a modal dialog in an Eclipse based project?

后端 未结 3 1078
夕颜
夕颜 2021-02-12 15:07

In order to open a modal dialog, you need to pass a parent window, and pass the necessary flags for the dialog to be modal of course.

Depending on where you are in the e

3条回答
  •  孤独总比滥情好
    2021-02-12 15:45

    The piece of code from the previous answer will work. However, keep in mind you can only open your dialog from the UI thread. If you are opening the dialog from a different thread, e.g. a background process, you need to do something like this:

    PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {
        public void run() {
            Shell activeShell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
        }
    });
    

    Otherwise you will get an exception when creating the dialog.

提交回复
热议问题