posts - 36, comments - 30, trackbacks - 0, articles - 3

          Eclipse插件開發中的問題一

          Posted on 2008-04-23 19:41 笑看人生 閱讀(2161) 評論(1)  編輯  收藏 所屬分類: Java插件開發
            問題描述:

          最近在Eclipse插件開發中遇到這樣的問題,我使用如入擴展點

          <extension
                 
          point="org.eclipse.debug.ui.launchConfigurationTabs">
              
          <tab
                    
          class="com.example.launch.SqlDebugTab"
                    group
          ="org.eclipse.jdt.debug.ui.launchConfigurationTabGroup.localJavaApplication"
                    id
          =" com.example.launchs.SqlDebugTab"
                    name
          ="SqlDebugTab">
                 
          <associatedDelegate
                       
          delegate=" com.example.launch.SqlDebugLaunchDelegate">
                 
          </associatedDelegate>
              
          </tab>
           
          </extension>

          <extension
                    
          point="org.eclipse.debug.core.launchDelegates">
                 
          <launchDelegate
                       
          delegate=" com.example.launch.SqlDebugLaunchDelegate"
                       id
          =" com.example.launch.SqlDebugLaunchDelegate"
                       modes
          ="debug"
                       type
          ="org.eclipse.jdt.launching.localJavaApplication">
                 
          </launchDelegate>
              
          </extension>

           

          也就是在調式Java Application的對話框中,增加一個Tab頁,Tab頁的名字為SqlDebugTab,在這個Tab頁上增加幾個復選框,復選框要顯示視圖的名稱,如果用戶選擇某個復選框,點“Debug”后,將顯示指定的視圖,可是在com.example.launch.SqlDebugLaunchDelegate類中的launch方法中調用PlatformUI.getWorkbench().getActiveWorkbenchWindow(),得到的對象卻為null,調試程序才發現,運行com.example.launch.SqlDebugLaunchDelegate類是,走的是新線程,也就是說點“Debug”按鈕時,Eclipse平臺啟動的是新的線程(非UI線程),而在新線程中是取不到ActiveWorkbenchWindow對象,為了解決這個問題,花費了很多時間,最后終于找到解決方法,launch方法通過如下程序來顯示視圖,就可以解決上面遇到的問題:

          PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {
                      
          public void run() {
                          IWorkbenchWindow window 
          = PlatformUI.getWorkbench()
                                  .getActiveWorkbenchWindow();
                          
          if (window != null){
                              window.getActivePage().showView(
          "……");
          }

          }

          }

          Feedback

          # re: Eclipse插件開發中的問題一[未登錄]  回復  更多評論   

          2009-03-23 13:55 by david
          你好!我將你的示例改成多頁的MultiPageEditorPart,怎么鍵盤事件無法響應了
          主站蜘蛛池模板: 涟源市| 西吉县| 舟山市| 包头市| 江西省| 普安县| 武清区| 二手房| 长岭县| 滨海县| 玉田县| 韩城市| 孝感市| 射洪县| 布拖县| 县级市| 聂拉木县| 青海省| 思茅市| 巴东县| 晋江市| 云阳县| 乐安县| 通渭县| 海兴县| 桐庐县| 荣昌县| 清水县| 汉川市| 内江市| 嵊泗县| 富平县| 丁青县| 奉贤区| 公安县| 湖北省| 屯昌县| 古浪县| 卢龙县| 云林县| 温泉县|