基本的なカスタマイズ > ユーザーインタフェースのカスタマイズ > UI の情報の表示 > アイコン委任 > ソリューション > 手順 - カスタム IconDelegate の作成 > カスタム IconDelegate の作成
  
カスタム IconDelegate の作成
1. wt.fc.IconDelegate または既存の wt.fc.IconDelegate のサブクラスを拡張できます。
2. アイコン決定ロジックの設定のため、オーバーライドが必要となる API はあまりありません。
a. これら 2 つの API は、特定の Windchill オブジェクトのアイコン情報を持つ IconSelector オブジェクトを返します。
API 署名
説明
public IconSelector getStandardIconSelector() throws WTException, IllegalAccessException, InvocationTargetException;
アイコンの標準セレクタを取得します。
public IconSelector getOpenIconSelector() throws WTException, IllegalAccessException, InvocationTargetException;
いつオブジェクトを開くかのセレクタを取得します (フォルダを開いたときなど)。
b. この API は、アイコンに表示するローカライズされたツールチップ値を返します。
API 署名
説明
public String getToolTip()
アイコンとともに表示するツールチップ。
c. この API は、TypeInstances を処理するのに必要です。メソッドで、使用可能な TypeInstance に、アイコンとツールチップの判断に最低限必要な属性値がすべて含まれるかどうかを確認する必要があります。足りない場合は、TypeInstance をインフレートする必要があります。
API 署名
説明
protected Boolean inflateRequired()
アイコン/ツールチップの計算に必要な属性が TypeInstance にない場合は、インフレートが必要です。
@Override
protected boolean inflateRequired() {
boolean need = super.inflateRequired();
TypeInstance ti = getTypeInstanceObject();
if(ti != null && !need){
//check you necessary attributes in TypeInstance
// to determine to inflate it or not.
}
}
return need;
}
d. この API は、TypeInstances を処理するのに必要です。メソッドで、アイコン/ツールチップを決めるのに必要なすべての属性を追加する必要があります。これにより、getStandardIconSelector() または getOpenIconSelector() を呼び出したときに、必要な属性が正しく入力されるようになります。
API 署名
説明
protected void initAttributes(Set<AttributeTypeIdentifier> attributes)
アイコン/ツールチップの決定に必要な属性で <AttributeTypeIdentifier> を更新します。
@Override
protected void initAttributes(Set<AttributeTypeIdentifier>
attributes) {
super.initAttributes(attributes);
//add your attributes here
}
3. IconDelegate は、以下の例のように、サブクラスで使用可能な AttributeTypeIdentifierTypeIdentifier オブジェクトを作成する静的ヘルパーメソッドを定義します。
AttributeTypeIdentifier NAME_ATI = getIdentifier("name",
"wt.part.WTPart");
TypeIdentifier WTPART_TI = getIdentifier("wt.part.WTPart",
null);
4. getObject() API は、Persistable がない場合は、現在の TypeInstance を Persistable に変換します。このため、この使用は避けて、getObject(false) を優先します。