打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
在rcp中获得父Shell的几种方法 .

在实现了IWorkbenchWindowActionDelegate接口的类中:

private IWorkbenchWindow window;

public void init(IWorkbenchWindow window) {
   
this.window = window;
}

public void run(IAction action) {
   Shell parentShell 
= window.getShell();
   MyDialog dialog 
= new MyDialog(parentShell, 
);
   
 etc 

}


在实现了IObjectActionDelegate 接口的类中:
private IWorkbenchPart targetPart;

public void setActivePart(IAction action, IWorkbenchPart targetPart)
{
   
this.targetPart = targetPart;
}


public void run(IAction action) {
   IWorkbenchPartSite site 
= targetPart.getSite();
   MyDialog dialog 
= new MyDialog(site, 
);
   
 etc 

}


IViewPart 或者IEditorPart
IShellProvider shellProvider = viewOrEditor.getSite();
PlatformUI:
Shell parentShell =
   PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();

Display
Shell parentShell = Display.getDefault().getActiveShell();


以上各种方法对于获取其它的一些rcp中的重要对象也都有借鉴意义。
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
Eclipse RCP 插件开发中经常调用的几个方法
使用Eclipse中的更新配置界面
使用Eclipse RCP进行桌面程序开发(二):菜单、工具栏和对话框 - 海边沫沫 - ...
rcp程序最小化窗口到系统托盘(代码)
在RCP中实现系统托盘功能
WPF关于WindowInteropHelper的一个BUG
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服