在RCP定义状态栏
来源:互联网 发布:苏莱曼大帝 知乎 编辑:程序博客网 时间:2024/06/10 14:53
转自:http://blog.csdn.net/moneyice/archive/2006/05/12/726810.aspx
在Eclipse 中,每选中一个文件,底部的状态栏上都会显示出该文件的有关信息。客户端软件通常都会将一些全局的或当前的信息显示在底部的状态栏上。本文将在RCP中添加状态栏功能。
首先,必须在WorkbenchWindowAdvisor. preWindowOpen()启用状态栏功能,configurer.setShowStatusLine(true);
02 IWorkbenchWindowConfigurer configurer = getWindowConfigurer();
03 configurer.setInitialSize(new Point(600, 400));
04 configurer.setShowCoolBar(true);
05 configurer.setShowStatusLine(true);
06 configurer.setShowFastViewBars(true);
07 configurer.setShowPerspectiveBar(true);
08 configurer.setShowMenuBar(true);
09 configurer.setShowProgressIndicator(true);
10 configurer.setShowStatusLine(true);
11 PlatformUI.getPreferenceStore().setDefault(
12 IWorkbenchPreferenceConstants.ENABLE_ANIMATIONS, true);
13 PlatformUI.getPreferenceStore().setDefault(
14 IWorkbenchPreferenceConstants.SHOW_TRADITIONAL_STYLE_TABS,
15 false);
16 PlatformUI.getPreferenceStore().setDefault(
17 IWorkbenchPreferenceConstants.DOCK_PERSPECTIVE_BAR,
18 IWorkbenchPreferenceConstants.TOP_RIGHT);
19 }de>
和menu bar 和 toolbar一样,状态栏也是由ActionBarAdvisor控制,在ActionBarAdvisor.fillStatusLine (IStatusLineManager)中,状态栏信息的显示都由IStatusLineManager控制。
状态栏的结构
<!--co<wbr>de { font-family: courier new, courier; font-size: 10pt; margin: 0px; }--> -->-->Fast views 可以将View拖到Fast views中,提供View的快捷访问。
Icon/message 这里可以显示图标和信息
Progress 用来显示进度条,通常是不可见的。当有IWorkbenchWindow.run() 调用时,显示一个进度条和一个取消按钮。
Contributions 由来显示一些额外信息,例如Eclipse选中一个java editor时,底部的读写状态,行数等信息。
Jobs progress 用来显示执行的Job,默认是不现实。要启用此功能,要设置IWorkbenchWindowConfigurator.setShowProgressIndicator(boolean).
一般Icon/message已经可以满足显示信息的要求,如果想要添加,可以在ActionBarAdvisor.fillStatusLine (IStatusLineManager)执行IStatusLineManager.add(IContributionItem).
在View中使用StatusLine,当选中某个节点时,在状态栏显示节点信息。
为View中的TreeViewer添加监听选择事件:
2 public void selectionChanged(SelectionChangedEvent event) {
3 updateStatusline(event);
4 }
5 });de>
02 IStatusLineManager statusline = this.getViewSite().getActionBars()
03 .getStatusLineManager();
04 IStructuredSelection selection = (IStructuredSelection) event
05 .getSelection();
06 String msg = getSelectionMessage(selection);
07
08 statusline.setMessage(msg);
09 }
10
11 private String getSelectionMessage(IStructuredSelection selection) {
12 if (selection.isEmpty()) {
13 return "";
14 }
15 if (selection.size() == 1) {
16 return selection.getFirstElement().toString();
17 }
18 return selection.size() + " items selected";
19 }de>
在View中使用StatusLine,当输入不合法时,显示出错信息。
<!--co<wbr>de { font-family: courier new, courier; font-size: 10pt; margin: 0px; }--> -->-->2 if (groupName.getText().length() == 0) {
3 showErrorOnStatusline("Group name can not be blank");
4 return;
5 }
6 showErrorOnStatusline(null);
7 setDirty(true);
8 }de>
2 IStatusLineManager statusline = this.getEditorSite().getActionBars()
3 .getStatusLineManager();
4 if (error == null) {
5 statusline.setErrorMessage(null, error);
6 } else {
7 statusline.setErrorMessage(ImageShop.get("error"), error);
8 }
9 }de>
- 在RCP定义状态栏
- 在RCP定义状态栏
- 在RCP定义状态栏
- 在RCP定义状态栏
- 在RCP定义状态栏
- 在RCP定义状态栏
- Eclipse RCP 之 状态栏
- rcp 状态栏 显示时间
- RCP应用中创建系统托盘和状态栏
- 【Eclipse RCP】 定时清除状态栏信息
- 在rcp中获取文件
- 在RCP中使用Hibernate
- javaCV在rcp中拍照
- RCP
- rcp
- RCP
- RCP
- RCP
- 没事儿乐一乐
- VS2005不能调试,断点无效!
- PHP编写一个mp3音乐播放器,基于DOS的播放器你用过吗?
- 12031,终结你!
- 设置Eclipse RCP程序的外观和首选项
- 在RCP定义状态栏
- C++ 容易忽略的输入输出特性
- ARM ADS中的AXD 调试经验集锦
- 今天的项目会
- 取消每次开机输入密码对话框
- 细数在阿里巴巴工作的N种幸福
- WCF 入门笔记
- 谈谈编写程序时遇到的错误:管道的另一端没有可执行的程序
- jsp 跳转方式