自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

Eclipse中perspective的兩種使用方法詳解

開發(fā) 后端
本文介紹如何給RCP程序或Eclipse插件定義透視圖,并向透視圖中添加視圖及對各視圖間的擺放位置給出定義。

這里要介紹的是如何給你的RCP程序或Eclipse插件定義透視圖,并向透視圖中添加視圖及對各視圖間的擺放位置給出定義。 好,進入正題,給我們的插件定義一個透視圖先:定義透視圖的方法相信很多人都比較清楚,要擴展org.eclipse.ui.perspectives擴展點,好,直接在我們的plugin.xml文件中加入下面一句代碼就ok了:

﹤extension point="org.eclipse.ui.perspectives">      

        ﹤perspective

                 class="com.test.blog.core.ui.perspective.Perspective"

                 icon="icons/amc_perspect.gif"

                 id="com.test.blog.core.ui.perspective.Perspective"

                 name="%perspective.amc">

        ﹤/perspective>

   ﹤/extension>

 

       上面的代碼中,表明我們的透視圖id為org.talend.amc.plugin.Perspective,好,記住這個id。下面我們就要向這個透視圖中來添加我們的view(視圖)了。有兩種方法都可以實現(xiàn)視圖的添加,一種是通過代碼直接添加,另外一種方法則是直接就在plugin.xml里進行配置:

通過代碼向已知透視圖中添加視圖并布局
上面的代碼中已指出該perspective所對應(yīng)的類為org.talend.amc.plugin.Perspective,該類需要實現(xiàn)IPerspectiveFactory接口,并實現(xiàn)它的createInitialLayout(IPageLayout layout) 方法,createInitialLayout(IPageLayout layout) 方法就能夠?qū)崿F(xiàn)對perspective中view的布局,詳細代碼如下:

package com.test.blog.core.ui.perspective;

  import org.eclipse.ui.IFolderLayout;

  import org.eclipse.ui.IPageLayout;

  import org.eclipse.ui.IPerspectiveFactory; 

  import com.test.blog.core.ui.views.detaillog.DetailLogsView;  import com.test.blog.core.ui.views.jobinfo.JobInformationView; import com.test.blog.core.ui.views.statinfo.DetailStatsView; import com.test.blog.core.ui.views.statinfo.SimpleStatsView;

 /** *//**  * The class define for the test blog perspective. ﹤br/>  *   * $Id: Perspective.java,v 1.9 2007/03/23 07:48:54 pub Exp $  *   */ public class Perspective implements IPerspectiveFactory ...{           public static final String ID = "com.test.blog.core.ui.perspective.Perspective"; //$NON-NLS-1$          public void createInitialLayout(IPageLayout layout) ...{           //這里不需要顯示editor,故而設(shè)置為不可見         layout.setEditorAreaVisible(false);         String editorArea = layout.getEditorArea();          //下面給出的是各view的位置布局定義,這些代碼都可以直接在plugin.xml進行配置,可以達到相同效果         layout.addView(JobInformationView.ID, IPageLayout.LEFT, 0.45f, editorArea);         layout.addView(DetailLogsView.ID, IPageLayout.BOTTOM, 0.4f, editorArea);                  String logInfoFolderID = "position.statlog";         IFolderLayout bottomFolder = layout.createFolder(logInfoFolderID, IPageLayout.BOTTOM, 0.5f,                 JobInformationView.ID);         bottomFolder.addView(SimpleStatsView.ID);         bottomFolder.addView(DetailStatsView.ID);         layout.getViewLayout(JobInformationView.ID).setCloseable(false);         layout.getViewLayout(SimpleStatsView.ID).setCloseable(false);         layout.getViewLayout(DetailStatsView.ID).setCloseable(false);     }  }

這里只是在代碼中直接使用view id, 如果真要讓這些id所對應(yīng)的view顯示出來,當然還需要你在自己的插件中給出這些view id的定義。

在plugin.xml中直接添加視圖并配置布局

  Eclipse 為各個view在透視圖的布局也提供了專用的擴展點,它就是org.eclipse.ui.perspectiveExtensions,利用這個擴展點,我們甚至不需要對org.talend.amc.plugin.Perspective類進行任何修改,就可以按我們的要求向perspective中添加新的視圖(view), 比如要達到上面同效果的視圖布局,可向plugin.xml中添加以下配置代碼:

 

﹤extension point="org.eclipse.ui.perspectiveExtensions">

          ﹤perspectiveExtension    

              targetID="com.test.blog.core.ui.perspective.Perspective">            

             ﹤view

                id="com.test.blog.core.ui.views.jobinfo.JobInformationView"

                relative="org.eclipse.ui.editorss"            

                relationship="left"            

                ratio="0.45"            

               closeable="false"/>

            ﹤view

                id="com.test.blog.core.ui.views.detaillog.DetailLogsView"

                relative="org.eclipse.ui.editorss"

                relationship="bottom"

                ratio="0.4"/>

          ﹤view

                id="com.test.blog.core.ui.views.statinfo.SimpleStatsView"

                relative="com.test.blog.core.ui.views.jobinfo.JobInformationView"

                relationship="bottom"

                ratio="0.5"

                closeable="false"/>

          ﹤view

                 id="com.test.blog.core.ui.views.statinfo.DetailStatsView"

                 relative="com.test.blog.core.ui.views.statinfo.SimpleStatsView"

                 relationship="stack"

                 closeable="false"/>

    ﹤/perspectiveExtension>

﹤/extension>


運行后,各view間的布局關(guān)系如下圖所示:

Eclipse中perspective(透視圖)的兩種使用方法詳解

Eclipse的幫助文件中已對該擴展點進行了詳細的說明,在Eclipse的幫助中直接搜索‘org.eclipse.ui.perspectiveExtensions’,即可得知該擴展點的相關(guān)信息。

【編輯推薦】

  1. 奇怪的Eclipse debug異常
  2. 在Eclipse中使用JUnit4進行單元測試(3)
  3. 在Eclipse中使用JUnit4進行單元測試(2)
  4. 在Eclipse中使用JUnit4進行單元測試(1)
  5. eclipse字符編碼
責(zé)任編輯:book05 來源: 163博客
相關(guān)推薦

2010-03-15 15:30:35

Python模塊

2011-03-03 17:00:37

pure-ftpdchroot

2010-10-09 10:30:03

JS event

2024-06-06 08:32:52

.NET框架代碼

2022-03-15 08:25:32

SparkShuffle框架

2021-08-11 06:57:16

ShuffleSpark核心

2009-12-07 13:42:24

WCF框架

2010-03-16 15:23:32

java動態(tài)載入

2022-01-17 09:01:41

Pythonnc文件Python基礎(chǔ)

2010-07-13 10:10:28

WPF

2010-10-09 10:04:45

FunctionJS

2009-06-29 17:57:30

ApplicationJSP

2019-11-07 23:48:12

shell腳本getopts

2009-12-02 16:04:44

PHP fsockop

2011-06-23 09:07:16

2012-10-16 09:40:38

洗牌算法

2010-10-14 14:33:15

MySQL多表聯(lián)查

2010-03-18 08:55:50

C#

2010-06-02 15:29:06

SVN版本控制

2012-05-10 10:53:10

Linuxhistory
點贊
收藏

51CTO技術(shù)棧公眾號