`
子衿青青
  • 浏览: 106154 次
  • 性别: Icon_minigender_1
  • 来自: 深圳
社区版块
存档分类
最新评论

我的第一个RCP程序

阅读更多

       RCP,就是Rich Client Platform的缩写,即胖客户端平台,是Eclipse进化的产物(自3.0版以后出现),是Eclipse组织向用户提供的强大的开放性开发平台,能够使用户方便地创建自己的基于Eclipse的应用程序,并且这些应用程序能够得到Eclipse的底层支持。更重要的是,我们可以利用Java创建象Eclipse这么漂亮的桌面程序。

桌面应用程序也可称为胖客户端程序或GUI程序。用SWT可以像SWING一样开发独立的桌面应用,但这样无法利用Eclipse的插件机制,所以有些人就折衷了一下:把桌面应用写成Eclipse插件。不过,插件基于Eclipse运行,Eclipse原有的菜单和工具栏无法消除。如果你连Eclipse的那些菜单和工具栏均不想被用户看到,那么就要用到RCP平台。

 

RCP的主要知识基于SWT/JFaceEclipse插件。

下面用向导建立一个RCP工程。

1、Plug-in Project,记得选择富客户端应用。

2、在ApplicationActionBarAdvisor.java类里

//文件菜单里的项目 public IWorkbenchAction newAction; public IWorkbenchAction openAction; public IWorkbenchAction refreshAction; public IWorkbenchAction exitAction; //编辑菜单里的项目 public IWorkbenchAction copyAction; public IWorkbenchAction pasteAction; //帮助菜单里的项目 public IWorkbenchAction helpAction; public ApplicationActionBarAdvisor(IActionBarConfigurer configurer) { super(configurer); } /** * 创建操作并注册操作 */ protected void makeActions(IWorkbenchWindow window) { newAction = ActionFactory.NEW.create(window); newAction.setText("创建窗口"); newAction.setToolTipText("创建一个新窗口"); register(newAction); //Problem openAction = ActionFactory.NEW_EDITOR.create(window); openAction.setText("打开文件"); register(openAction); refreshAction = ActionFactory.REFRESH.create(window); refreshAction.setText("刷新"); refreshAction.setToolTipText("刷新"); register(refreshAction); exitAction = ActionFactory.QUIT.create(window); exitAction.setText("退出"); register(exitAction); copyAction = ActionFactory.COPY.create(window); copyAction.setText("复制"); register(copyAction); pasteAction = ActionFactory.PASTE.create(window); pasteAction.setText("粘贴"); register(pasteAction); // helpAction = ActionFactory.ABOUT.create(window); helpAction = ActionFactory.HELP_CONTENTS.create(window); helpAction.setText("关于我们"); register(helpAction); } /** * 菜单栏 */ protected void fillMenuBar(IMenuManager menuBar) { MenuManager fileMenu = new MenuManager("文件(&F)",IWorkbenchActionConstants.M_FILE); MenuManager editMenu = new MenuManager("编辑(&E)",IWorkbenchActionConstants.M_EDIT); MenuManager helpMenu = new MenuManager("帮助(&H)",IWorkbenchActionConstants.M_HELP); fileMenu.add(newAction); fileMenu.add(openAction); fileMenu.add(refreshAction); fileMenu.add(exitAction); editMenu.add(copyAction); editMenu.add(pasteAction); helpMenu.add(helpAction); menuBar.add(fileMenu); menuBar.add(editMenu); menuBar.add(helpMenu); } /** * 工具栏 */ protected void fillCoolBar(ICoolBarManager coolBar) { // super.fillCoolBar(coolBar); IToolBarManager toolBar = new ToolBarManager(SWT.FLAT | SWT.RIGHT); IToolBarManager viewToolBar = new ToolBarManager(SWT.FLAT | SWT.RIGHT); toolBar.add(newAction); coolBar.add(new ToolBarContributionItem(toolBar,"新建")); viewToolBar.add(refreshAction); coolBar.add(new ToolBarContributionItem(viewToolBar,"刷新")); }


 3、帮助系统的开发

3.1、代码的实现

//帮助 private IWorkbenchAction helpAction; /** * 创建操作 */ protected void makeActions(IWorkbenchWindow window) { /* 帮助 */ helpAction = ActionFactory.HELP_CONTENTS.create(window); register(helpAction); } /** * 填充主菜单 */ protected void fillMenuBar(IMenuManager menuBar) { /* 主菜单栏 */ IMenuManager mainMenu = getActionBarConfigurer().getMenuManager(); MenuManager helpMenu = new MenuManager("帮助(&H)", IWorkbenchActionConstants.M_HELP); helpMenu.add(introAction); helpMenu.add(helpAction); mainMenu.add(helpMenu); }

 


 3.2、添加相关依赖项

打开plugin.xml,转到"依赖项"页,添加以下

  1. org.apache.lucene

2.org.eclipse.help.appserver

3.org.eclipse.help.base

4.org.eclipse.help.ui

5.org.eclipse.help.webapp

6.org.eclipse.tomcat

7.org.eclipse.ui.forms

3.3、添加org.eclipse.help.toc扩展点

"扩展向导"-->"帮助内容",确定后可以看到所有扩展的列表中多了一个org.eclipse.help.toc扩展,这里可能需要修改一下,生成的toc.xmltestToc.xml里面的label属性标签不能是乱码,不然帮助框架会读不出,到时候显示不出帮助的组织结构。

注意此处的扩展点哦:

<extension point="org.eclipse.help.toc"> <toc file="toc.xml"> </toc> <toc file="testToc.xml" primary="true"> </toc> </extension>

 


 

新建自己的帮助文档如toc.xmltestToc.xml

 

例如在toc.xml中

<toc label="Sample Table of Contents"> <topic label="Main Topic" href="html/maintopic.html"> <topic label="Sub Topic" href="html/subtopic.html"/> </topic> <topic label="Main Topic 2" href="html/maintopic.html"> <topic label="Sub Topic" href="html/subtopic.html"/> </topic> </toc>

 


 

    4、实现上下文帮助

   暂时没看懂,先不写了哈,呵呵……

 

   5、打包发行

   可用Ant脚本也可用product导出。

   

 

 

因为初次自学RCP,有不对的地方欢迎大家指正,不胜感激!

 

分享到:
评论

相关推荐

    开发您的第一个 Eclipse RCP 应用程序

    Eclipse Rich Client Platform (RCP) 的目标是在各种不是集成开发环境 (IDE) 的最终用户应用程序中使用 Eclipse。随着 Eclipse V3.1 的发布,创建 RCP 应用程序变得...本教程将指导您一步步创建自己的 RCP 应用程序。

    开发你的第一个EclipseRCP应用程序汇编.pdf

    开发你的第一个EclipseRCP应用程序汇编.pdf

    eclipse 3.6 rcp 开发

    将涉及以下内容:创建第一个RCP程序,创建菜单和工具栏,查看,编辑,对话,外部JAR的用法,向一个RCP应用程序产品中添加标志和帮助。每一章都基本独立于其他章节。欢迎访问我的网站——www.xeclipse.com。

    eclipse rcp 自学教程

    clipse RCP允许开发者使用eclipse结构风格设计...将涉及以下内容:创建第一个RCP程序,创建菜单和工具栏,查看,编辑,对话,外部JAR的用法,向一个RCP应用程序产品中添加标志和帮助。 每一章可能都基本独立于其他章节

    开发你的第一个Eclipse RCP应用程序(含源码)

    The objective of the Eclipse Rich Client Platform (RCP) is to enable Eclipse to be used in a wide range of end-user applications that are not integrated development environments (IDEs). With the ...

    Eclipse RCP详细教程

    2.创建你的第一个RCP程序 1 2.1.创建一个RCP程序 2 2.2.启动你的RCP程序 5 2.3.应用程序VS 产品 6 3.应用程序里的插件ID 7 4.Actions的用法(菜单和工具栏) 7 4.1.概述 7 4.2.通过编码添加 8 4.3.由...

    eclipse RCP开发的编辑器

    学习RCP后开发的第一个小程序,和大家分享下

    RCP程序设计思@@@@@@@@@@@@@@

    RCP程序设计思想,包括RCP的第一个实例,及以后的试图,菜单等的创建,适合初学者。 很不错的哦!!值得一阅哦!!

    Eclipse RCP Plugin 开发自学入门指南(CEC首发)

    2 创建第一个RCP程序 ........................................................................................................................ 11 2.1 创建一个RCP程序 .......................................

    Eclipse RCP Plug-in开发自学教程(Eclipse3.6)

    2 创建第一个RCP程序 ........................................................................................................................11 2.1 创建一个RCP程序 ........................................

    Eclipse+RCP深入浅出2

    Eclipse+RCP深入浅出第2版,是我之前上传的英文版的翻译版本,本文档为word文档,内容是从原书的第二部分开始,即从第三章到第十四章,全文完整介绍了如何开发一个完整的rcp程序。欢迎下载

    开发项目用SWING与RCP与SWT.JFACE的分析

    第一个SWT程序 下面让我们开始一个SWT程序。(注意:以下的例子和说明主要针对Windows平台,其它的操作系统应该大同小异)。首先要在Eclipse安装文件中找到SWT包,Eclipse组织并不提供单独的SWT包下载,必须下载...

    Eclipse RCP深入浅出(原书第2版)

    Eclipse RCP深入浅出,全文完整介绍了如何开发一个完整的rcp程序。从空白的开发环境配置,通过案例把开发中的技术点讲的淋漓尽致。并且是全书完整版

    使用EclipseRCP进行桌面程序开发(五):2D绘图

    看完这篇文章,可以实现如下界面:当我第一次看到RCP的时候,我就梦想着有一天能够用它开发界面华丽的2D和3D程序,经历过前面的探索,今天终于可以揭开2D绘图的神秘面纱。在包资源管理器的插件依赖项中,我们一眼就...

    gradle-and-eclipse-rcp:Gradle和Eclipse RCP

    该示例项目演示了使用以下技术构建Eclipse RCP应用程序: 从Maven和P2提取的依赖关系 Win / Mac / Linux的本机启动器 自动OSGi元数据 同一库的两个版本(同时有Guava 17和18) 生成IDE-as-build-artifact Gradle...

    Eclipse SWT JFace核心应用 PDF.part1 of 3

    全书共分5篇,第1篇介绍了SWT产生的背景以及SWT的一些基本概念和基础知识。第2篇介绍了SWT基本控件的使用,以及事件处理、布局等SWT基本知识的应用。第3篇介绍了关于SWT的高级应用。第4篇介绍了JFace 框架的知识及其...

    Eclipse SWT JFace核心应用 PDF.part3 of 3

    全书共分5篇,第1篇介绍了SWT产生的背景以及SWT的一些基本概念和基础知识。第2篇介绍了SWT基本控件的使用,以及事件处理、布局等SWT基本知识的应用。第3篇介绍了关于SWT的高级应用。第4篇介绍了JFace 框架的知识及其...

    Eclipse SWT JFace核心应用 PDF.part2 of 3

    全书共分5篇,第1篇介绍了SWT产生的背景以及SWT的一些基本概念和基础知识。第2篇介绍了SWT基本控件的使用,以及事件处理、布局等SWT基本知识的应用。第3篇介绍了关于SWT的高级应用。第4篇介绍了JFace 框架的知识及其...

Global site tag (gtag.js) - Google Analytics