代碼實現對Workbench的簡單配置

來源:互聯網
上載者:User

對workbench的簡單配置包括控制perspective的現實,view如何show,還有如何在在菜單perspective 和 view 中添加shortcut。

 

    範例程式碼如下:

  1. public
     class
     ApplicationWorkbenchAdvisor extends
     WorkbenchAdvisor {  
  2.     /* (non-Javadoc)
     
  3.      * @see org.eclipse.ui.application.WorkbenchAdvisor#initialize(org.eclipse.ui.application.IWorkbenchConfigurer)
     
  4.      */
      
  5.     public
     void
     initialize(IWorkbenchConfigurer configurer) {  
  6.       // 讓perspective表徵圖在workbench的右側顯示
  7.         PlatformUI.getPreferenceStore().setDefault(  
  8.             IWorkbenchPreferenceConstants.
    DOCK_PERSPECTIVE_BAR

    , IWorkbenchPreferenceConstants.TOP_RIGHT
    );  
  9.     }  

    效果如下:你的perspecive將會和java/debug一樣出現在你想要的位置

 

常量在 IWorkbenchPreferenceConstants中都有說明,特殊變數羅列如下(引)

  

  1. SHOW_PROGRESS_ON_STARTUP

              在splash的畫面中, 是否顯示進度條
  2. DISABLE_NEW_FAST_VIEW

                      是否禁止左下角的Show View As a Fast View按鈕
  3. SHOW_MEMORY_MONITOR

                       是否顯示記憶體情況, 並可進行GC操作, 這個比較有意思
  4. SHOW_OPEN_ON_PERSPECTIVE_BAR

       在PerspectiveBar上,是否顯示New Perspective按鈕
  5. SHOW_TEXT_ON_PERSPECTIVE_BAR

        在PerspectiveBar上,是否顯示Perspective的名稱
  6. SHOW_TRADITIONAL_STYLE_TABS

            Editor或ViewPart是否使用傳統的Tab的樣式. 這個肯定用true, false的太老土了.
  7. DOCK_PERSPECTIVE_BAR

                         PerspectiveBar的顯示位置, 左上 還是 右上.

===============================================================================

 

    如何增加像debug一樣的shortcut?範例程式碼如下:

   

 

此代碼來自於對IPerspectiveFactory介面的實現,擴充點為:org.eclipse.ui.perspectives

 

其中IPageLayout中就可以設定您要展現的shortcut的menu,layout.addPerspectiveShortcut(perspectiveId);

 

 

 

 

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.