邋遢居

我的Java天堂

  BlogJava :: 首页 :: 联系 :: 聚合  :: 管理
  61 Posts :: 2 Stories :: 90 Comments :: 0 Trackbacks

开始学习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。
今天就写到这儿了。争取周末能把ui全部画好。
posted on 2006-02-23 23:06 Jet Geng 阅读(2385) 评论(0)  编辑  收藏 所属分类: Eclipse

只有注册用户登录后才能发表评论。


网站导航: