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

          ▓木浮于水,而皓月當空▓ 關注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 閱讀(1098) 評論(0)  編輯  收藏 所屬分類: Java編程
          主站蜘蛛池模板: 翁牛特旗| 沾化县| 丹棱县| 哈尔滨市| 无棣县| 河源市| 河南省| 永靖县| 娄烦县| 瓦房店市| 麻栗坡县| 保定市| 河西区| 安溪县| 逊克县| 方正县| 高要市| 凌云县| 广水市| 延安市| 仁布县| 嵩明县| 太原市| 民丰县| 阿坝县| 宁阳县| 桓仁| 广州市| 闸北区| 灵台县| 民县| 玉门市| 承德市| 定陶县| 剑阁县| 鞍山市| 宁远县| 陇川县| 吴旗县| 英吉沙县| 抚顺市|