如何使工作台窗口在基于Eclipse的项目中打开模态对话框? [英] How do I get the workbench window to open a modal dialog in an Eclipse based project?

查看:426
本文介绍了如何使工作台窗口在基于Eclipse的项目中打开模态对话框?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为了打开模态对话框,您需要传递一个父窗口,并将对话框的必要标志传递给当前的模态。

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.

根据在eclipse基础架构中,找到这个父窗口并不总是容易的。

Depending on where you are in the eclipse infrastructure, finding this parent window is not always easy.

如何访问父窗口?

推荐答案

从视图或编辑器(这部分很简单):

From a view or an editor (this part is easy):

this.getSite().getWorkbenchWindow().getShell()

从别处访问视图或编辑器和上述相同。

From elsewhere, access a view or editor and same as above.

如果您发现自己处于无法访问视图或编辑器的类中,则可能不想调用任何UI代码,但如果你真的想在脚下拍摄自己:

If you find yourself in a class where you don't have access to a view or editor, you probably don't want to be calling any UI code, but if you really want to shoot yourself in the foot:

PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell()

这篇关于如何使工作台窗口在基于Eclipse的项目中打开模态对话框?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆