学习RCP编程

很早很早就听说RCP了。也很想来玩玩,但是一直没有找到好的点子来练手。不过近段时间有个老朋友要求帮他做个小东西。他现在的需求很简单。我怕他以后有要加什么内容。所以就想用RCP来做。刚好用他来好好学习一下,要不都不好意思在bbs.rcp.cn混了。

找了本书(《Eclipse Rich Client Platform Designing Coding and Packaging Java Applications》)按照书中的例子看了起来。

了解基本的:

AbstractUIPlugin

WorkbenchWindowAdvisor

WorkbenchAdvisor

ActionBarAdvisor

IperspectiveFactoryViewPart几个类。

收获最大的就是看到yipsilonbbs.rcp.cn中关于布局的帖子。

http://www.eclipseworld.org/bbs/read.php?tid=1312&page=e#a

public   class  MGRPerspective  implements  IPerspectiveFactory {

public   void  createInitialLayout(IPageLayout layout) {

  Plugin plugin 
=  Plugin.getDefault();

  LSEmployee employee 
=  plugin.getEmployee();

  
// 只有在用户登陆后才能画界面
   if  (employee  !=   null ) {
    
    String editorArea 
=  layout.getEditorArea();
    
    layout.setEditorAreaVisible(
false );
    
    
//  主要界面
    IFolderLayout main  =  layout.createFolder( " main " , IPageLayout.TOP,  0.95f , editorArea);
    
//  属性界面
    IFolderLayout property  =  layout.createFolder( " property " , IPageLayout.RIGHT,  0.75f " main " );
    
//  字典界面
    IFolderLayout dictionary  =  layout.createFolder( " dictionary " , IPageLayout.BOTTOM,  0.95f " property " );

    LSPosition position 
=  employee.getPosition();

    
boolean  isManager  =  position.getManager().booleanValue();

    
if  (isManager) {
    main.addView(EmployeeTableView.
class .getName());
    property.addView(PositionPropertyView.
class .getName());
    property.addView(EmployeePropertyView.
class .getName());
    }

    
if  (position.getBuyer().booleanValue()  ||  isManager) {
    main.addView(ProviderTableView.
class .getName());
    main.addView(JHInvoiceTableView.
class .getName());
    property.addView(ProviderPropertyView.
class .getName());
    property.addView(JHInvoicePropertyView.
class .getName());
    }

    
if  (position.getKeeper().booleanValue()  ||  isManager) {
    dictionary.addView(DDRepositoryView.
class .getName());
    main.addView(DBInvoiceTableView.
class .getName());
    property.addView(DBInvoicePropertyView.
class .getName());
    }

    
if  (position.getSeller().booleanValue()  ||  isManager) {
    main.addView(MemberTableView.
class .getName());
    main.addView(YDInvoiceTableView.
class .getName());
    main.addView(XSInvoiceTableView.
class .getName());
    property.addView(MemberPropertyView.
class .getName());
    property.addView(YDInvoicePropertyView.
class .getName());
    property.addView(XSInvoicePropertyView.
class .getName());
    }

    
if  (position.getMaintainer().booleanValue()  ||  isManager) {
    dictionary.addView(DDAreaView.
class .getName());
    dictionary.addView(DDBrandView.
class .getName());
    dictionary.addView(DDColorView.
class .getName());
    dictionary.addView(DDCompView.
class .getName());
    dictionary.addView(DDLevelView.
class .getName());
    dictionary.addView(DDSizeView.
class .getName());
    dictionary.addView(DDSortView.
class .getName());
    dictionary.addView(DDDescriptionView.
class .getName());
    }
  }
}
}

根据这段代码做出如下界面:

rcp ui.bmp
很简单。大家见笑了。呵呵。
我的代码就不贴了。看
yipsilon的代码就可以搞定布局了。再次感谢yipsilon。
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值