rcp学习笔记(-)-----程序框架

下面是一些rcp(Rich Client Platform) 程序的说明笔记本,记下来免的以后又忘了.关于如何在Eclipse里面建立rcp程序向导, 这儿是一篇不错的翻译教程.


1.  Application 作用和一般java程序里面的主类一样,它是一个rcp程序的入口点.必须实现 IPlatformRunnable 接口.即实现run()方法.

在这而run()方法和main()方法作用一样.

2. rcp程序不必全是UI程序,可以是非图形程序.

3. rcp程序几个类:  application <= ApplicationWorkbenchAdvisor <== ApplicationWorkbenchWindowAdvisor ==  Perspective

 ==ApplicationActionBarAdvisor == xxxPlugin

4.代码示例如下:

org.eclipsercp.hyperbola/Application
public class Application implements IPlatformRunnable {
  public Object run(Object args) throws Exception {
    Display display = PlatformUI.createDisplay();
    try {
      int returnCode = PlatformUI.createAndRunWorkbench(
          display, new ApplicationWorkbenchAdvisor());
      if (returnCode == PlatformUI.RETURN_RESTART) {
        return IPlatformRunnable.EXIT_RESTART;
      return IPlatformRunnable.EXIT_OK;
    } finally {
      display.dispose();
    }
  }
}

* Display 在这个类里面生成,PlatformUI类里面全是static方法,主要是生成Workbench和访问Workbench.

*  new ApplicationWorkbenchAdvisor() 这个方法引出下面一个类 ApplicationWorkbenchAdvisor(),

5.

public class ApplicationWorkbenchAdvisor extends WorkbenchAdvisor {

    private static final String PERSPECTIVE_ID = "rcphello.perspective";

    public WorkbenchWindowAdvisor createWorkbenchWindowAdvisor(IWorkbenchWindowConfigurer configurer) {

        return new ApplicationWorkbenchWindowAdvisor(configurer);
    }

    public String getInitialWindowPerspectiveId() {

        return PERSPECTIVE_ID;
    }
}

说明: return new ApplicationWorkbenchWindowAdvisor(configurer) 生成ApplicationWorkbenchWindowAdvisor.

     *  初始化getInitialWindowPerspectiveId() .

6.
  public class ApplicationWorkbenchWindowAdvisor extends WorkbenchWindowAdvisor {

    public ApplicationWorkbenchWindowAdvisor(IWorkbenchWindowConfigurer configurer) {
        super(configurer);
    }

    public ActionBarAdvisor createActionBarAdvisor(IActionBarConfigurer configurer) {
        return new ApplicationActionBarAdvisor(configurer);
    }
   
    public void preWindowOpen() {
        IWorkbenchWindowConfigurer configurer = getWindowConfigurer();
        configurer.setInitialSize(new Point(400, 300));
        configurer.setShowCoolBar(false);
        configurer.setShowStatusLine(false);
        configurer.setTitle("Hello RCP");
    }
}

说明:  生成 new ApplicationActionBarAdvisor(configurer); 另外preWindowOpen() 里面做了好多设置界面的工作.比如是否显示

工具栏,状态栏...,

7.
 public class ApplicationActionBarAdvisor extends ActionBarAdvisor {

    public ApplicationActionBarAdvisor(IActionBarConfigurer configurer) {
        super(configurer);
    }

    protected void makeActions(IWorkbenchWindow window) {
    }

    protected void fillMenuBar(IMenuManager menuBar) {
    }
   
}

说明: 

    定义程序里面的动作.加到菜单和工具栏.快捷键...上.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值