How do I get the workbench window to open a modal dialog in an Eclipse based project?(如何让工作台窗口在基于 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 的项目中打开模式对话框?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何让工作台窗口在基于 Eclipse 的项目中打开模式对话框?


基础教程推荐
- 如何在 JFrame 中覆盖 windowsClosing 事件 2022-01-01
- 如何在 Spring @Value 注解中正确指定默认值? 2022-01-01
- 不推荐使用 Api 注释的描述 2022-01-01
- 在 Java 中创建日期的正确方法是什么? 2022-01-01
- Java Swing计时器未清除 2022-01-01
- 多个组件的复杂布局 2022-01-01
- Java 实例变量在两个语句中声明和初始化 2022-01-01
- 大摇大摆的枚举 2022-01-01
- 验证是否调用了所有 getter 方法 2022-01-01
- 从 python 访问 JVM 2022-01-01