自定义 HTML 客户端对象选择页面
HTML 客户端对象选择页面在 Creo Parametric HTML 客户端中用来让用户从 Windchill 数据库中选取完成某操作所需的对象。
要确定用于对象选择页的下拉列表、搜索条件和结果列,可使用已配置的
com.ptc.windchill.cadx.common.picker.PickerSearchAttributeListDelegate。默认配置的
PickerSearchAttributeListDelegate 为
com.ptc.windchill.cadx.common.picker.PickerSearchAttributeList。将配置用于在对象选择页面上创建各种类型列表的已配置
wt.query.SearchAttributeListDelegate 的
PickerSearchAttributeList 委派,来支持和确定搜索条件,以及确定在对象选择页面中显示的结果列。(有关
SearchAttributeListDelegate 的详细信息,请参阅
自定义 HTML 搜索。)
如果此 PickerSearchAttributeListDelegate 实现不能满足需要,则可创建和配置用户自己的 PickerSearchAttributeList 以由对象选择页使用。
|
此功能适用于所有与第三方 CAD 工具集成的 Windchill Workgroup Manager
|
修改搜索属性列表委派
要实现自己的自定义 PickerSearchAttributeListDelegate,请创建一个实现 wt.query.SearchAttributeListDelegate 和 com.ptc.windchill.cadx.common.picker.PickerSearchAttributeListDelegate 的类,或者创建一个对 com.ptc.windchill.cadx.common.picker.PickerSearchAttributeList 进行子类化的类。
有关更多详细信息,请参阅 PickerSearchAttributeListDelegate 和 PickerSearchAttributeList 及其方法的 Javadoc。
|
PickerSearchAttributeList 扩展了 SearchAttributeList;因此,自定义类可以用作 SearchAttributeListDelegate 和 PickerSearchAttributeListDelegate。
|
|
如果扩展 PickerSearchAttributeList,可能需要设置筛选器以滤掉 NullPointerExceptions。此问题将在以后的版本中解决。
|
要配置新的 PickerSearchAttributeListDelegate:
1. 使用 xconfmanager 将条目添加到 com/ptc/windchill/cadx/common/picker/picker.properties 中,类似于:
wt.services/svc/default/com.ptc.windchill.cadx.common.picker.PickerSearchAttributeListDelegate/
<unique delegate id which is also specified for com.ptc.windchill.cadx.common.picker.pickerSearchAttributeList>/java.lang.Object/0=mine.MyPickerSearchAttributeList/duplicate.
2. 使用 xconfmanager,将 wt.properties 中的 pickerSearchAttributeList 条目更改为 com.ptc.windchill.cadx.common.picker.pickerSearchAttributeList=<唯一的委派 id>。如果在 wt.properties 中没有条目,则将 STANDARD 用作委派 ID
修改类型列表
Creo Parametric HTML 客户端对象选择页面使用由类型列表 ID 标识的已配置类型列表,类型列表 ID 被指定为对象选择页面的 typeListID 特性值。
类型列表在 com\ptc\windchill\cadx\propfiles\picker.properties 文件中定义。
要向某个新类型列表 ID 添加一个类型列表条目,可使用 xconfmanager 添加条目,类似于:wt.services/rsc/default/<type list id>/java.lang.Object/0=<有效查询值的逗号分隔列表>
如果列表中仅有一个值,则不需要逗号。如果要将一个“全部”条目添加到类型列表,必须在类型 ID 的列表中指定“全部”(ALL) 类型列表条目值。
|
对于对象选择页的默认实现,这些有效类型列表值是在 wt.query.queryResource 中指定的查询值。
|
可从类型 ID 的列表中删除为类型列表 ID 指定的类型 ID,但是不能删除条目或保留类型列表为空。
自定义 HTML 搜索
要自定义 HTML 搜索以更改默认搜索对象的显示或者添加新类,请参阅以下分发为源 Windchill\src\wt\query\SearchAttributeList.java 的文件。如此类的 javadoc 中所述,创建 SearchAttributeList 的子类并在 service.properties 和 wt.properties 中生成相应条目。以下方法应在自定义 SearchAttributeList 中实现,例如:
public final class MySearchAttributeList extends SearchAttributeList implements Externalizable {
public void setLocale( Locale locale ) {
// Load in the values for the drop down list for selecting what to search against.
clientLocale = locale;
// **Customize --------------------------------------------------------------
--------------
// Add new classes to search to list below.
// Make sure that they are assigned numbers in sequence from 0 to N.
// Set dropDownListCount to N+1.
final int ALL = 0;
final int WTPART = 1;
…
final int MYCLASS = 22
int dropDownListCount = 23;
// -------------------------------------------------------------------------
------------…
pickList = new String[classCount];
pickList[ALL] =
WTMessage.getLocalizedMessage(RESOURCE,queryResource.ALL,null,clientLocale);
pickList[WTPART] =
WTMessage.getLocalizedMessage(RESOURCE,queryResource.WTPART,null,clientLocale);
…
pickList[MYCLASS] = WTMessage.getLocalizedMessage(RESOURCE,queryResource.
MYCLASS,null,clientLocale);
pickValues = new String[classCount];
pickValues[ALL] = queryResource.ALL;
pickValues[WTPART] = queryResource.WTPART;
…
pickValues[MYCLASS] = queryResource.MYCLASS;
// **Customize You will need a string in here to correspond to each item in
pickList
// The string is a space separated list of what classes to query
// against. If you want to query against multiple classes that have a common
parent that
// has all of the attributes that you are interested in use that one class. If
you want
// to query against multiple classes that don't have a good common parent then
you can
// add them to a list and the search will loop through each class and combine
the results
// at the end. All classes in one list must only search against COMMON
attributes or
// attributes with the same name and of the same class! If you add both a
parent and
// a child class to the list you will get duplicate entries, when the results
are
// combined duplicate entries are not deleted.
queryClass = new String[classCount];
queryClass[ALL] =
"wt.part.WTPart wt.doc.WTDocument wt.change2.WTChangeIssue
wt.change2.WTChangeRequest2 " +
"wt.change2.WTChangeInvestigation wt.change2.WTAnalysisActivity
wt.change2.WTChangeProposal " +
"wt.change2.WTChangeOrder2 wt.change2.WTChangeActivity2
wt.csm.businessentity.BusinessEntity " +
"wt.effectivity.ConfigurationItem wt.epm.EPMDocument " +
"wt.replication.unit.WTUnit " +
"wt.part.WTProductConfiguration " +
"wt.part.WTProductInstance2 "; // Please remember to keep a space at the
end so that conditionally added items work.
…
queryClass[WTPART] = "wt.part.WTPart";
…
queryClass[MYCLASS] = "?.?.MyClass";
// **Customize These are the
// attributes that can be queried against.
inputAttributes = new String[classCount];
inputAttributes[ALL] =
"number name lifeCycleState projectId cabinet creator modifier
modifyTimestamp";
inputAttributes[WTPART] =
"number name view versionIdentifier partType source lifeCycleState projectId
cabinet creator modifier modifyTimestamp";
…
inputAttributes[MYCLASS] =
"name modifyTimestamp";
// **Customize Each individual
// string must match with the string listed above for the inputAttributes. "0"
stands for no
// input processing. If an attribute is an enumerated type use "0" and the
code will generate
// the drop down list. In the first string: projectId is in the fourth
position in inputAttributes
// so the method to generate the drop down list for it is also in the fourth
position in the
// string. The "0"s and methods must match in number with the number of
attributes listed
// under inputAttributes. You may add a fully qualified method from your
customization package
// as long as it is static and returns a vector of strings.
inputProcessing = new String[classCount];
inputProcessing[ALL] =
"0 0 0 wt.query.LocalSearchProcessor.getProjectList
wt.query.LocalSearchProcessor.getCabinetList 0 0 0";
inputProcessing[WTPART] =
"0 0 wt.query.LocalSearchProcessor.getViewList 0 0 0 0
wt.query.LocalSearchProcessor.getProjectList
wt.query.LocalSearchProcessor.getCabinetList 0 0 0";
…
inputProcessing[MYCLASS] =
"0 0";
// **Customize This is similar in concept to inputAttributes only these are
the attributes
// that will be displayed in the search results.
outputAttributes = new String[classCount];
outputAttributes[ALL] =
"number name versionDisplayIdentifier displayType lifeCycleState projectId
modifyTimestamp";
outputAttributes[WTPART] =
"number name versionDisplayIdentifier projectId lifeCycleState
modifyTimestamp";
…
outputProcessing[MYCLASS] =
"ObjProps 0";
// **New for 6.0
// **Customize This is similar in concept to outputAttributes only this list
is used
// to indicate which attributes can be sorted, can't be sorted, or an alternate
attribute
// that can be sorted to have the same affect as the display attribute. The
string that is used
// here should be the column descriptor so that it can be used to create the
ClassAttribute for
// the query. The query that is used for search is a simple query that will
not sort on all
// of the display attributes. Changing the 0 to 1 for an unsupported attribute
will
// either cause exceptions or sorts that don't work. Attributes of the
following types are
// just some examples of the attributes that will either throw exceptions or
sort incorrectly:
// EnumeratedType, CabinetReference, DataFormatReference,
LifeCycleTemplateReference, ProjectReference,
// and ViewReference.
sortAttributes = new String[classCount];
sortAttributes[ALL] =
"1 1 versionInfo.identifier.versionId 0 0 01";
sortAttributes[WTPART] =
"1 1 versionInfo.identifier.versionId 0 0 1";
…
sortAttributes[MYCLASS] =
"1 1";
// **New for 6.0
// **Customize This is similar in concept to outputAttributes only this list
is used
// for assigning a unique key to the sort preferences for this search. This
string will
// be persisted and used to retrieve the sort preferences for users. If the
value of one
// of these strings is changed or deleted after the system is in operation it
will create orphaned
// preferences in the system and users will lose the value that they had
persisted for that
// search. New entries can be added when a new search is added so that sort
preferences
// can be saved for that new search. These strings are arbitrary and never
displayed to the user.
sortPref = new String[classCount];
sortPref[ALL] =
"all";
sortPref[WTPART] =
"wtpart";
…
sortPref[MYCLASS] =
"myclass";
}
/**
*
* <BR><BR><B> Supported API: </B>false
*
* @param locale
* @return MySearchAttributeList
**/
public MySearchAttributeList( Locale locale ) {
setLocale(locale);
}
/**
*
* <BR><BR><B> Supported API: </B>false
*
* @return MySearchAttributeList
**/
public MySearchAttributeList() {
return;
}
}
wt.query.SearchAttributeList 始终都是最新的,应将其用作参考。
本部分的后续部分说明了 wt.query.SearchAttributeList、sortAttributes 和 sortPref 中的两个新数组。
由于对某些类使用的数据结构所限,在搜索结果中显示的属性并不都可进行排序。wt.query.SearchAttributeList 中的 sortAttributes 数组用于指定哪些属性可排序,以及是否应使用替代属性进行排序。
例如,版本属性是用于排序的替代属性:用于显示的属性是 versionDisplayIdentifier,但用于排序的属性是 versionInfo.identifier.versionId。
基本 java 类型 (例如 String 和 int) 可进行排序。请使用 wt.query.SearchAttributeList 中的示例确定是否所有自定义类型都可排序。否则,简单测试会显示属性正常、无效会是抛出异常。
sortPref 数组 (上述代码示例中所示) 用于定义排序首选项基本名称,从而使用户能够为该“搜索”对象定义自己的排序首选项。应在系统级别定义排序首选项的默认设置,以便用户首次使用系统时,或者用户未定义首选项时,合乎逻辑地排序各列。可使用 wt.load.LoadFromFile 或“首选项管理”实用程序“系统管理”门户页面来定义默认值。
如果是新数据库,则在运行 wt.load.Demo (其运行 wt.load.LoadFromFile) 的必要部分期间加载默认设置。使用“首选项管理”实用程序可以轻松添加或修改站点默认设置。如果数据库是在 6.0 版本之前的系统上创建的,则 wt.load.LoadFromFile 可用于为 HTML 搜索类别的已传送配置加载基本默认设置。有关示例,请参阅 Windchill\loadFiles\preferences.txt 中的 "PrefEntry…/wt/query/htmlsearch" 条目。
每个用户首选项都有一个内部名称,在客户端看不到该名称,但在“首选项管理”实用程序中可看到该名称。因为当前搜索使用 wt.query.SearchAttributeList 来让用户添加新搜索,并且因为每个新搜索都必须有一组排序首选项,所以“搜索”列表中的每个名称都需要唯一的排序名称。
“搜索”列表中的每个对象不一定是一个对象,可以是一个对象列表。wt.query.SearchAttributeList 中的 sortPref 数组定义构成首选项名称一部分的唯一字符串。排序的首选项存储在 /wt/query/htmlsearch 首选项节点下,并且命名格式如下:
<sort preference base name>sortAttrib<#>
<sort preference base name>sortDirect<#>
<sort preference base name> 是 wt.query.SearchAttributeList 中的 sortPref 数组的唯一字符串;它只需在排序名称中是唯一的。sortAttrib 表示属性名,sortDirect 用于指示升序或降序。升序为 false,降序为 true。<#> 是排序键的编号,0 = 第一个键,以此类推。以下是针对“全部”排序而使用 wt.load.LoadFromFile 和 Windchill\loadFiles\preferences.txt 加载的首选项:
#All
PrefEntry~allsortAttrib0~number~/wt/query/htmlsearch
PrefEntry~allsortDirect0~false~/wt/query/htmlsearch
PrefEntry~allsortAttrib1~versionInfo.identifier.versionId~/wt/query/htmlsearch
PrefEntry~allsortDirect1~true~/wt/query/htmlsearch
在“全部默认”示例中,依次按编号列和版本列对结果排序,其中编号按升序排序,版本按降序排序。当前,虽然理论上排序键的数目只受 Oracle 性能的限制,但是所支持的排序键的数目为 3。尚未在系统上执行超过 3 个键的测试。