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

查看:25
本文介绍了如何让工作台窗口在基于 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天全站免登陆