2008年7月2日水曜日

パースペクティブを作ってみる

またもやAIR GEAR関連ですが、パースペクティブを作成してみました。
それまで、Eclipseのパースペクティブって特に気にせず使っていたので、機能をよく知っていなかった事が判明。

WindowメニューのReset Perspectiveで、選択中のPerspectiveのデフォルトに戻してくれる。
Customize Perspectiveでショートカットメニューの表示有無や、ToolBarのアイコンの表示有無が切り替えできる。
逆の使い方としては、ToolBarにメニューが出てきたけど、これってどのPluginが表示しているの?を調べることもできますねー。

あと、感動的だったのが専用のPerspectiveを作るのは思った以上に簡単だってこと。
(自分でViewとかNavigatorとか作るなら別ですけども)

自分なりのとか、案件専用とかのPerspectiveを作ってみるのもいいかも。
作り方は、拡張ポイントorg.eclipse.ui.perspectives を使います。


<extension
point="org.eclipse.ui.perspectives">
<perspective
name="AIR GEAR"
icon="icons/air.gif"
class="net.sf.amateras.air.ui.AirPerspective"
id="net.sf.amateras.air.perspective">
</perspective>
</extension>


net.sf.amateras.air.ui.AirPerspectiveってクラスは自作するクラス。
IPerspectiveFactoryを実装したクラスにします。

package net.sf.amateras.air.ui;

import org.eclipse.ui.IPageLayout;
import org.eclipse.ui.IPerspectiveFactory;

public class AirPerspective implements IPerspectiveFactory {

public void createInitialLayout(IPageLayout layout) {

}
}

createInitialLayoutの中に記述を書いていってもいいんですけど、このまま空にしておいて、plugin.xmlに書いていく事ができます。
こんな感じ。

<extension
point="org.eclipse.ui.perspectiveExtensions">
<perspectiveExtension
targetID="org.eclipse.ui.resourcePerspective">
<perspectiveshortcut id="net.sf.amateras.air.perspective">
</perspectiveextension>
<perspectiveextension targetid="net.sf.amateras.air.perspective">
<newwizardshortcut id="org.eclipse.ui.wizards.new.folder">
<newwizardshortcut id="org.eclipse.ui.wizards.new.file">
<viewshortcut id="org.eclipse.ui.views.ResourceNavigator">
<viewshortcut id="org.eclipse.ui.views.ProblemView">

<view
ratio="0.20"
relative="org.eclipse.ui.editorss"
relationship="left"
id="org.eclipse.jdt.ui.PackageExplorer">
</view>
<view
relative="org.eclipse.jdt.ui.PackageExplorer"
relationship="stack"
id="org.eclipse.ui.views.ResourceNavigator">
</view>

<view
ratio="0.75"
relative="org.eclipse.ui.editorss"
relationship="right"
id="org.eclipse.ui.views.PropertySheet">
</view>
<view
ratio="0.60"
relative="org.eclipse.ui.views.PropertySheet"
relationship="bottom"
id="org.eclipse.ui.views.ContentOutline">
</view>

<view
ratio="0.75"
relative="org.eclipse.ui.editorss"
relationship="bottom"
id="org.eclipse.ui.views.ProblemView">
</view>
<view
relative="org.eclipse.ui.views.ProblemView"
relationship="stack"
id="org.eclipse.ui.console.ConsoleView">
</view>

<actionSet
id="org.eclipse.debug.ui.launchActionSet">
</actionset>
</perspectiveextension>
</extension>

たったこれだけで、幸せな気分になれますよー。
• • •