天生我才

          常用鏈接

          統(tǒng)計(jì)

          最新評論

          RCP4

          4定義WorkbenchAdvisor類 和Application

          1)創(chuàng)建WorkbenchAdvisor

          l         構(gòu)建 RCP 應(yīng)用程序的核心任務(wù)之一就是創(chuàng)建一個(gè)實(shí)現(xiàn)抽象類 org.eclipse.ui.application.WorkbenchAdvisor 的類

          l         WorkbenchAdvisor 類負(fù)責(zé)配置,在執(zhí)行 RCP 應(yīng)用程序時(shí)顯示的工作臺(tái)

          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()方法中,向新的工作臺(tái)窗口返回初始透視圖的標(biāo)識(shí)符

          l         增加preWindowOpen()方法,設(shè)置工作臺(tái)的窗口標(biāo)題和尺寸

          2)創(chuàng)建Application

          l         在執(zhí)行應(yīng)用程序之前,需要?jiǎng)?chuàng)建一個(gè) Application 類,這與 Java 類中的main方法類似, 是RCP應(yīng)用程序的入口點(diǎn)

          l         該類需要實(shí)現(xiàn)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()方法對大多數(shù)RCP 應(yīng)用程序而言,不需要定制,重新使用就可

          l         如前面所示,需要在plugin.xmlorg.eclipse.core.runtime.applications 擴(kuò)展點(diǎn)指定運(yùn)行的Application

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

          3)運(yùn)行應(yīng)用程序

          l         Run > Run...

          l         Configurations列表中選擇Run-time Workbench,并點(diǎn)擊 New 按鈕

          l         Name域中鍵入Google

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

          l         點(diǎn)擊Plug-ins頁,選擇Choose plug-ins and fragments to launch from the list

          l         點(diǎn)擊Deselect All按鈕

          l         選中Workspace Plug-ins選項(xiàng)包含Google項(xiàng)的選擇

          l         點(diǎn)擊Add Required Plug-ins按鈕,自動(dòng)包含執(zhí)行應(yīng)用程序必需的插件

          l         點(diǎn)擊Apply按鈕

          l         點(diǎn)擊Run按鈕來執(zhí)行該應(yīng)用程序

          l         如果正確進(jìn)行了所有配置的話,應(yīng)該顯示一個(gè)標(biāo)題為“Google”的窗口,這是一個(gè)普通工作臺(tái)框架



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

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


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


          網(wǎng)站導(dǎo)航:
           
          主站蜘蛛池模板: 洞头县| 日照市| 彭阳县| 扎赉特旗| 承德市| 永仁县| 崇礼县| 巴林左旗| 上思县| 武义县| 宝应县| 土默特右旗| 贵港市| 吉安县| 灵璧县| 成武县| 奉新县| 丰台区| 轮台县| 平果县| 仙桃市| 永年县| 甘孜| 雷波县| 浦东新区| 奈曼旗| 左贡县| 襄汾县| 南宁市| 横峰县| 石渠县| 和林格尔县| 高雄市| 德兴市| 常德市| 台北县| 墨玉县| 富蕴县| 桃园县| 湟源县| 尖扎县|