Top / Eclipse / プラグイン開発のTIPS集 / org.eclipse.ui.IPerspectiveFactory(パースペクティブ)

自分用のパースペクティブを作成したいときはorg.eclipse.ui.IPerspectiveFactory? を使用します。このクラスのpublic void createInitialLayout?(IPageLayout? layout)メソッド内で、IPageLayout?のインスタンスに対して

  • ビューの配置
  • ツールバーやメニューバーへの設置

などを行います。

拡張ポイント

org.eclipse.ui.perspectives

plugin.xmlのサンプル

 <extension point="org.eclipse.ui.perspectives">
  <perspective name="パースペクティブ名"
    icon="icons/sample.gif" <-アイコン
    class="nu.mine.kino.example.MyPerspectiveFactory" <-実装クラス
    id="nu.mine.kino.example.MyPerspectiveFactory"> <-ID
  </perspective>
</extension>

ポイント

ビューの配置

基本的に、エディタエリアの取得を行い、その場所から相対的な位置を指定してビューを配置していくようです。例えば、

//エディタの場所を取得。
String editorArea = layout.getEditorArea();

IFolderLayout topLeft =
  layout.createFolder("topLeft", IPageLayout.LEFT, 0.26F, editorArea);
//"topLeft"という文字列の参照部分を作った <-第一引数。変数名でなく
//この参照は、editorAreaのLEFTを指している。

topLeft.addView("org.eclipse.ui.views.ResourceNavigator");

IFolderLayout bottomLeft =
  layout.createFolder("bottomLeft", IPageLayout.BOTTOM, 0.5F, "topLeft");
//"bottomLeft"という文字列の参照部分を作った
//この参照は、"topLeft"のBOTTOMを指している。

//    よってこれはエディタから見て、左の下、つまり左下になる。
bottomLeft.addView("org.eclipse.ui.views.ContentOutline");

の様に行います。ちなみに、IPageLayout?の定数ですが、

public static final int LEFT = 1;
public static final int RIGHT = 2;
public static final int TOP = 3;
public static final int BOTTOM = 4;

となっていました。

createInitialLayout?(IPageLayout? layout) のlayoutのメソッドたち

layout.addView("viewのID");
パースペクティブに配置
layout.addNewWizardShortcut?("wizardのID");
ファイル>新規の箇所にウィザードを追加
layout.addShowViewShortcut?("viewのID");
ウィンドウ>ビューの表示にビューを追加
layout.addPerspectiveShortcut?("perspectiveのID");
ウィンドウ>パースペクティブを開くにパースペクティブを追加

この記事は

選択肢 投票
おもしろかった 7  
そうでもない 1  

Top / Eclipse / プラグイン開発のTIPS集 / org.eclipse.ui.IPerspectiveFactory(パースペクティブ)

現在のアクセス:11659


トップ   編集 凍結 差分 バックアップ 添付 複製 名前変更 リロード   新規 一覧 単語検索 最終更新   ヘルプ   最終更新のRSS
Last-modified: 2016-10-21 (金) 11:10:24 (2742d)