2006-12-13
动态改变RCP应用程序的标题
关键字: rcp
我们知道,Title是在ApplicationWorkbenchWindowAdvisor里面通过
来实现的,那么如何在运行时动态的更改它呢?
最开始一直在想如何获得IWorkbenchWindowConfigurer,但是一点头绪都没有,后来到RCP新闻组里面问了一下,两个人给了回复,不过都不怎么满意,但其中一个给了我启示,他信中写道:
- public void preWindowOpen() {
- IWorkbenchWindowConfigurer configurer = getWindowConfigurer();
- configurer.setInitialSize(new Point(600, 500));
- configurer.setShowCoolBar(false);
- configurer.setShowStatusLine(true);
- configurer.setShowProgressIndicator(true);
- configurer.setTitle(xxx);
- }
来实现的,那么如何在运行时动态的更改它呢?
最开始一直在想如何获得IWorkbenchWindowConfigurer,但是一点头绪都没有,后来到RCP新闻组里面问了一下,两个人给了回复,不过都不怎么满意,但其中一个给了我启示,他信中写道:
I've used the following technique:
- public static void changeAppTitle(String newTitle) {
- Display display = Display.getDefault();
- if (display != null) {
- // Look at all the shells and pick the first one
- // that is a workbench window.
- Shell shells[] = display.getShells();
- for (int i = 0; i < shells.length; i++) {
- Object data = shells[i].getData();
- // Check whether this shell points to the
- // Application main window's shell
- if (data instanceof IWorkbenchWindow) {
- shells[i].setText(newTitle);
- break;
- }
- }
- }
- }
既然可以通过IWorkbenchWindow的Shell来设置标题,那么一切就好解决了。
在ActionBarAdvisor中初始化Action时,把WorkbenchWindow作为参数传入构造器中,然后在Action中就可以使用window.getShell().setText()了:)
- 18:47
- 浏览 (1560)
- 论坛浏览 (1892)
- 评论 (0)
- 分类: RCP系列
- 相关推荐
发表评论
该博客是同时发布到论坛的,无法评论在论坛已被锁定的帖子
我的相册
sina
共 3 张
共 3 张
最近加入圈子
链接
最新评论
-
羡慕,那你也加入啊
和我的拒信一模一样。哎
-- by niwtsew -
web环境下开发quartz简易 ...
你写的很好。我的是在rcp下面是用quartz还得自己摸索..........
-- by futionbai -
Starting Struts2中文版已 ...
呵呵,希望大家可以喜欢
-- by dearwolf -
Starting Struts2中文版已 ...
正在看这本书!! 哈哈
-- by kanokano -
CSDN英雄大会上,跟苏某翻 ...
我只想到。。。这么年轻就有仔了,好可怜阿。。。。
-- by akane







评论排行榜