天生我才

          導航

          <2025年8月>
          272829303112
          3456789
          10111213141516
          17181920212223
          24252627282930
          31123456

          留言簿(1)

          文章分類(16)

          隨筆檔案(8)

          文章檔案(17)

          閱讀排行榜

          評論排行榜

          常用鏈接

          統計

          最新評論

          RCP4

          4定義WorkbenchAdvisor類 和Application

          1)創建WorkbenchAdvisor

          l         構建 RCP 應用程序的核心任務之一就是創建一個實現抽象類 org.eclipse.ui.application.WorkbenchAdvisor 的類

          l         WorkbenchAdvisor 類負責配置,在執行 RCP 應用程序時顯示的工作臺

          package com.xqtu.google;
           
          import org.eclipse.ui.application.IWorkbenchWindowConfigurer;
          import org.eclipse.ui.application.WorkbenchAdvisor;
          import org.eclipse.swt.graphics.Point;
           
          public class GoogleWorkbenchAdvisor extends WorkbenchAdvisor {
           
              public String getInitialWindowPerspectiveId() {
           
                  return "com.xqtu.google.GooglePerspective";
              }
           
              public void preWindowOpen(IWorkbenchWindowConfigurer configurer) {
           
                  super.preWindowOpen(configurer);
                  configurer.setTitle("Google");
                  configurer.setInitialSize(new Point(300, 300));
                  configurer.setShowMenuBar(false);
                  configurer.setShowStatusLine(false);
                  configurer.setShowCoolBar(false);
              }
          }

          l         getInitialWindowPerspectiveId()方法中,向新的工作臺窗口返回初始透視圖的標識符

          l         增加preWindowOpen()方法,設置工作臺的窗口標題和尺寸

          2)創建Application

          l         在執行應用程序之前,需要創建一個 Application 類,這與 Java 類中的main方法類似, 是RCP應用程序的入口點

          l         該類需要實現org.eclipse.core.runtime.IPlatformRunnable接口

          package com.xqtu.google;
           
          import org.eclipse.core.runtime.IPlatformRunnable;
          import org.eclipse.swt.widgets.Display;
          import org.eclipse.ui.PlatformUI;
          import org.eclipse.ui.application.WorkbenchAdvisor;
           
          public class GoogleApplication implements IPlatformRunnable {
           
              public Object run(Object args) throws Exception {
           
                  WorkbenchAdvisor workbenchAdvisor = new GoogleWorkbenchAdvisor();
                  Display display = PlatformUI.createDisplay();
                  int returnCode = PlatformUI.createAndRunWorkbench(display,
                                workbenchAdvisor);
                  if (returnCode == PlatformUI.RETURN_RESTART) {
                          return IPlatformRunnable.EXIT_RESTART;
                  } else {
                          return IPlatformRunnable.EXIT_OK;
                  }
              }
           
          }

          l         其中的run()方法對大多數RCP 應用程序而言,不需要定制,重新使用就可

          l         如前面所示,需要在plugin.xmlorg.eclipse.core.runtime.applications 擴展點指定運行的Application

             <extension
                   id="GoogleApplication"
                   point="org.eclipse.core.runtime.applications">
                <application>
                   <run class="com.xqtu.google.GoogleApplication"/>
                </application>
             </extension>

          3)運行應用程序

          l         Run > Run...

          l         Configurations列表中選擇Run-time Workbench,并點擊 New 按鈕

          l         Name域中鍵入Google

          l         Arguments頁中,Run an application下拉框中選擇Google.GoogleApplication

          l         點擊Plug-ins頁,選擇Choose plug-ins and fragments to launch from the list

          l         點擊Deselect All按鈕

          l         選中Workspace Plug-ins選項包含Google項的選擇

          l         點擊Add Required Plug-ins按鈕,自動包含執行應用程序必需的插件

          l         點擊Apply按鈕

          l         點擊Run按鈕來執行該應用程序

          l         如果正確進行了所有配置的話,應該顯示一個標題為“Google”的窗口,這是一個普通工作臺框架



          Trackback: http://tb.blog.csdn.net/TrackBack.aspx?PostId=79401

          posted on 2006-02-06 16:56 天生我才 閱讀(340) 評論(0)  編輯  收藏 所屬分類: RCP/RIA


          只有注冊用戶登錄后才能發表評論。


          網站導航:
           
          主站蜘蛛池模板: 武平县| 新源县| 乌审旗| 双流县| 玉环县| 广河县| 陈巴尔虎旗| 临武县| 外汇| 上虞市| 八宿县| 芒康县| 遵义市| 合阳县| 凭祥市| 英山县| 富裕县| 巨鹿县| 大荔县| 志丹县| 石门县| 德惠市| 玛纳斯县| 昌平区| 汕尾市| 额尔古纳市| 大港区| 廉江市| 通辽市| 常宁市| 哈巴河县| 龙山县| 嵩明县| 大埔区| 衢州市| 鹤山市| 阳东县| 洞口县| 三门峡市| 雷州市| 谷城县|