カスタムテーブルビュー (ステップ 1)
1. 既成のテーブルビュークラスの 1 つを拡張します。
テーブル
ビュークラス
変更管理オブジェクト
変更適用オブジェクト
ChangeTaskAffectedItemsTableViews
VarianceAffectedDataTableViews
AffectedDataTableViews
変更タスク
一時許可
問題レポートと変更リクエスト
結果オブジェクト
ChangeTaskResultingItemsTableViews
変更タスク
2. getSpecialTableColumnsAttrDefinition() メソッドをオーバーライドして、新しい属性を含めます。
3. すべてのビューに列を追加するか、選択したビューのみに列を追加します。
すべてのビューに列を追加する場合は、メソッド getDefaultColumns() をオーバーライドして、列を適切な位置に挿入します。
選択したビューに列を追加する場合は、最初に super.getOOTBTableViews() を呼び出す getOOTBTableViews() をオーバーライドします。更新が必要なビューを検索し、TableColumnDefinitions を変更してこれらのビューを更新します。
4. カスタムサービスプロパティ xconf ファイル内の各テーブル ID に対してカスタムテーブルビューを登録するためのエントリを以下のように追加します。
<Service context="default"
name="com.ptc.core.htmlcomp.tableview.ConfigurableTable">
<Option
serviceClass="tableViews.custom.DistributingChangeTaskAffectedItemsTableViews"
selector="changeTask_affectedItems_table"
requestor="java.lang.Object"/>
</Service>
カスタムサービスプロバイダプロパティファイルを追加する方法については、「カスタムサービスプロバイダプロパティファイルの追加」を参照してください。
5. 以下に示すように、作成した xconf ファイルを適用します。
たとえば、codebase/ext/custom/ という場所にファイル CustomTableView.xconf および CustomTableView-service.properties.xconf を作成した場合、以下のコマンドを実行して xconf ファイルを適用します。
xconfmanager -i codebase/ext/custom/CustomTableView.xconf -p
xconfmanager -i codebase/ext/custom/CustomTableView-service.properties.xconf -p
両方のファイルのコンテンツについては、以下を参照してください。
CustomTableView.xconf ファイル:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE Configuration SYSTEM "xconf.dtd">
<Configuration targetFile="codebase/wt.properties">
<!-- Ensure that the file ext/custom/CustomTableView-service.properties.xconf
is appended to the list of custom property files. -->
<Property default="ext/custom/CustomTableView-service.properties.xconf"
name="wt.services.applicationcontext.WTServiceProviderFromProperties.
customPropertyFiles"/>
</Configuration>
CustomTableView-service.properties.xconf ファイル:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE Configuration SYSTEM "xconf.dtd">
<Configuration targetFile="codebase/service.properties">

<Service context="default"
name="com.ptc.core.htmlcomp.tableview.ConfigurableTable">
<Option
serviceClass="tableViews.custom.DistributingChangeTaskAffectedItemsTableViews"
selector="changeTask_affectedItems_table"
requestor="java.lang.Object"/>
</Service>
</Configuration>
サンプルコード

public class DistributingResultingItemsTableViews extends
ChangeTaskResultingItemsTableViews {

/**
* The distributionList will only be added to the Parts and All views
immediately after
* the name column.
*/
@SuppressWarnings("unchecked")
@Override
public List getOOTBTableViews(String tableId, Locale locale)
throws WTException
{
List<TableViewDescriptor> result =
super.getOOTBTableViews(tableId, locale);
for(TableViewDescriptor descriptor: result) {
if( descriptor.getName().equals(PARTS_VIEW) ||
descriptor.getName()
.equals(ALL_VIEW)) {
Vector<ableColumnDefinition> columns =
descriptor.getTableColumnDefinition();
for(int c = 0; c < columns.size(); c++) {
if( "name".equals(columns.get(c).getName())) {
String key = DistributingChangeRecordConstants.
DISTRIBUTION_ATTRIBUTE;
columns.add(c++,TableColumnDefinition.
newTableColumnDefinition
(key,isColumnLocked(key)));
break;
}
}
}
}
return result;
}

@Override
@SuppressWarnings("unchecked")
public List<?> getSpecialTableColumnsAttrDefinition(Locale locale) {
List<Attribute.TextAttribute> results = (List<TextAttribute>)
super.getSpecialTableColumnsAttrDefinition(locale);
results.add(new Attribute.TextAttribute
(DistributingChangeRecordConstants.
DISTRIBUTION_ATTRIBUTE,
"Distribution List" /*Should be localized label*/, locale));
return results;
}
}
これは役に立ちましたか?