RCP开发实例

RCP开发小结

 

1  RCP是一种插件式开发系统,其运行流程是这样的:

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

2  增加菜单和命令

<!--[if !supportLists]-->(1)<!--[endif]-->plugin.xml文件里增加一个扩menu扩展点,然后再新建一个menu

<!--[if !supportLists]-->(2)<!--[endif]-->然后在menu里新建一个command

<!--[if !supportLists]-->(3)<!--[endif]-->plugin.xml文件里增加一个command扩展点;

 

 

创建和打开对话框

 

Shell shell = HandlerUtil.getActiveWorkbenchWindow(event).getShell();

//创建一个文件对话框

FileDialog fileDialog=new FileDialog(shell);

fileDialog.setText("select file");

fileDialog.setFilterExtensions(new String[]{"*.txt"});

fileDialog.setFilterNames(new String[]{"textFiles(*.txt)"});

String selected= fileDialog.open();

System.out.println(selected);

//创建一个格式对话框

FontDialog fontDialog=new FontDialog(shell);

fontDialog.setText("select the your favorite font");

FontData fontData=fontDialog.open();

System.out.println(fontData);

//创建一个颜色对话框

ColorDialog colorDialog=new ColorDialog(shell);

colorDialog.setText("select your favorite color");

RGB rgb=colorDialog.open();

System.out.println(rgb);

 

MessageDialog.openConfirm(shell, "confirm""please confirm");

MessageDialog.openError(shell, "error""Error accured");

MessageDialog.openInformation(shell, "info""info for you");

MessageDialog.openQuestion(shell, "question""Really,really?");

MessageDialog.openWarning(shell, "warning""I warn you");

 

创建列表选择对话框

Shell shell=HandlerUtil.getActiveWorkbenchWindow(event).getShell();

ElementListSelectionDialog dialog=new ElementListSelectionDialog(shell, new LabelProvider());

dialog.setElements(new String[]{"linux","mac","windows"});

dialog.setTitle("which os dou you select");

int retcode=dialog.open();

Object[] result=dialog.getResult();

for(Object s:result){

System.out.println(s.toString());

 

}

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值