RCP工程系统托盘功能
2010-02-24 17:12
330 查看
在开发RCP工程过程中,有时候在最小化窗口的时候希望将窗口托管在系统栏。添加代码如下:
在ApplicationWorkbenchWindowAdvisor类中添加下面的代码:
private Image statusImage; private TrayItem trayItem; private Image trayImage; private ApplicationActionBarAdvisor actionBarAdvisor; public void postWindowOpen() { initStatusLine(); final IWorkbenchWindow window = getWindowConfigurer().getWindow(); trayItem = initTaskItem(window); if (trayItem != null) { hookPopupMenu(window); hookMinimize(window); } } private void hookMinimize(final IWorkbenchWindow window) { window.getShell().addShellListener(new ShellAdapter() { public void shellIconified(ShellEvent e) { window.getShell().setVisible(false); } }); trayItem.addListener(SWT.DefaultSelection, new Listener() { public void handleEvent(Event event) { Shell shell = window.getShell(); if (!shell.isVisible()) { shell.setVisible(true); window.getShell().setMinimized(false); } } }); } private void hookPopupMenu(final IWorkbenchWindow window) { trayItem.addListener(SWT.MenuDetect, new Listener() { public void handleEvent(Event event) { MenuManager trayMenu = new MenuManager(); Menu menu = trayMenu.createContextMenu(window.getShell()); actionBarAdvisor.fillTrayItem(trayMenu); menu.setVisible(true); } }); } private TrayItem initTaskItem(IWorkbenchWindow window) { final Tray tray = window.getShell().getDisplay().getSystemTray(); if (tray == null) return null; TrayItem trayItem = new TrayItem(tray, SWT.NONE); trayImage = AbstractUIPlugin.imageDescriptorFromPlugin( "org.eclipsercp.hyperbola", IImageKeys.ONLINE).createImage(); trayItem.setImage(trayImage); trayItem.setToolTipText("Hyperbola"); return trayItem; } public void dispose() { if (trayImage != null) { trayImage.dispose(); trayItem.dispose(); } }
在ApplicationActionBarAdvisor中添加下面函数 protected void fillTrayItem(IMenuManager trayItem) { trayItem.add(aboutAction); trayItem.add(exitAction); }
相关文章推荐
- 在RCP中实现系统托盘功能
- 在RCP中实现系统托盘功能
- 在RCP中实现系统托盘功能
- 在RCP中实现系统托盘功能
- 在RCP中实现系统托盘功能
- 在office 2007中无法使用粘贴功能, 系统提示:该工程中的宏被禁止,请参阅联机帮助或主应用程序的文档来决定如何激活宏
- 系统托盘功能
- RCP应用中创建系统托盘和状态栏
- C#实现右下角图标(系统托盘)功能
- java jdk1.5、 windows 32位字节 ----->实现系统托盘功能
- VC实现程序最小化到系统托盘功能
- 系统托盘功能
- Java中实现系统托盘功能(代码全贴,附加运行截图)
- 水利水电工程施工导截流方案辅助设计系统DivClose软件功能
- 把rcp最小化到系统托盘
- 将Flash CS5的XFL工程压缩成FLA功能集成到系统右键
- Delphi中实现系统托盘的功能
- windows下注册系统热键及系统托盘功能
- 实现系统托盘的功能
- Swing实现系统托盘功能