★★★★★ 龍門亂彈 ★★★★★

          ▓木浮于水,而皓月當空▓ 關注Java程序設計▓Linux系統▓人工智能(AI)進展▓數學▓

            BlogJava :: 首頁 :: 新隨筆 ::  :: 聚合  :: 管理 ::
            39 隨筆 :: 2 文章 :: 170 評論 :: 0 Trackbacks
          下面是一些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) {
              }
             
          }

          說明: 

              定義程序里面的動作.加到菜單和工具欄.快捷鍵...上.


          posted on 2006-02-27 11:05 LoveBNU 小六 WangBNU 閱讀(1102) 評論(0)  編輯  收藏 所屬分類: Java編程
          主站蜘蛛池模板: 衡山县| 孝感市| 木里| 丽水市| 新沂市| 邵阳县| 古田县| 峨边| 田林县| 龙陵县| 桃园县| 徐州市| 上高县| 宁武县| 察雅县| 瓦房店市| 开江县| 西宁市| 上饶市| 青神县| 雷波县| 光泽县| 东辽县| 革吉县| 亳州市| 巴里| 平塘县| 扬州市| 黎城县| 桐梓县| 博乐市| 鹤岗市| 黔东| 哈尔滨市| 宕昌县| 体育| 会昌县| 青州市| 郯城县| 昔阳县| 和林格尔县|