Tabbed Properties ViewにCustomTabを追加する for GMF 1.0.3
id:kojihashi:20070807で,GMF 2.0向けにカスタムタブをTabbed Properties Viewに追加する方法を紹介しました。GMF 2.0になって,簡単にカスタムタブを追加できるようになりました。
しかし,GMF 1.0.3においても,2.0ほど簡単ではありませんが,カスタムタブを追加できます。既にEclipse Community Forums: GMF (Graphical Modeling Framework)でその方法を紹介していますが,ここでは日本語で紹介します。
1. まず,拡張ポイント"propertyTabs"を使って,GMFで提供している"Advanced"タブにカスタムタブの内容を実装するPropertySectionのid(この例ではproperty.tab.YourAdvancedPropertySection)を追加します。
<extension point="org.eclipse.ui.views.properties.tabbed.propertyTabs"> <propertyTabs contributorId="org.eclipse.gmf.runtime.diagram.ui.properties"> <propertyTab category="Advanced" id="property.tab.YourAdvancedPropertySection" label="YourCustomLabel"/> </propertyTabs> </extension>
2. 拡張ポイント"propertySections"を使って,property.tab.YourAdvancedPropertySectionに対応した,カスタムタブを実装するクラスとフィルタクラスを追加します。
<extension point="org.eclipse.ui.views.properties.tabbed.propertySections"> <propertySections contributorId="org.eclipse.gmf.runtime.diagram.ui.properties"> <propertySection class="org.example.YourPropertySection" filter="org.example.YourEditPartPropertySectionFilter" id="property.section.YourAdvancedPropertySection" tab="property.tab.YourAdvancedPropertySection"/> </propertySections> </extension>
3. 2.で追加したYourPropertySectionクラスをAbstractPropertySectionを拡張して作成します。YourPropertySectionクラスの実装例はid:kojihashi:20070807に紹介しています。
4. 2.で追加したフィルタクラスYourEditPartPropertySectionFilterを作成します。本クラスはIFilterを実装する必要があります。以下のサンプルコードでは,"YourEditPart"に対応するノードがキャンバス上に選択された場合にカスタムタブを表示するように"true"を返すように実装しています。
public class YourEditPartPropertySectionFilter implements IFilter { public boolean select(Object toTest) { if (toTest instanceof YourEditPart) { return true; } return false; } }
以上で,GMF 1.0.3でもカスタムタブを追加できます。