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

          ▓木浮于水,而皓月當空▓ 關注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編程
          主站蜘蛛池模板: 开鲁县| 左权县| 巫山县| 罗甸县| 渝北区| 泸溪县| 鄂托克旗| 雷波县| 于田县| 高邑县| 乌拉特前旗| 安化县| 桐柏县| 洪雅县| 自治县| 札达县| 玛纳斯县| 满洲里市| 惠州市| 古丈县| 嘉善县| 奎屯市| 宁远县| 讷河市| 荥经县| 峡江县| 三原县| 鄂托克前旗| 中卫市| 商水县| 旬阳县| 承德市| 施秉县| 镇原县| 甘南县| 庄河市| 卢湾区| 大安市| 河间市| 台南市| 博湖县|