其他 Windchill 功能 > 制造过程管理 > 自定义产品结构浏览器 (PSE) > 自定义 PSE 来处理模型化子类
  
自定义 PSE 来处理模型化子类
目标
您已创建自定义模型化业务对象;您想要自定义 PSE,使其完全支持您的模型化子类。
范围/适用性/假设
您已单独创建模型化子类。
预期结果
PSE 将采用与出厂设置模型化对象相同的方式检测和显示模型化子类的实例。
解决方法
在以下三个区域中进行更改:
LogicalAttributes.xml
PSE 表格和面板
自定义的命令委派
必备知识
要实现此目标,您需要了解以下内容:
XML 文件自定义的管理
RBINFO 文件自定义的管理
解决方案元素
元素
类型
说明
LogicalAttributes.xml
XML 文件
用于配置从“逻辑形式”到“外部形式”的模型化属性映射。
步骤 – 自定义 PSE 以处理模型化子类
本部分包含以下主题:
LogicalAttributes.xml
PSE 表格和面板
自定义的命令委派
LogicalAttributes.xml
位于 <Windchill>/codebase/LogicalAttributes.xml 的 LogicalAttributes.xml 文件用于配置从“逻辑形式”到其“外部形式”的模型化属性映射。表示对象间关联性的所有模型化属性均需要映射。例如,部分针对 WTPartMaste 至 WTPart 参考定义的条目如下:
<Class name="wt.part.WTPart">
<Property>
<LogicalForm>defaultUnit</LogicalForm>
<ExternalForm>MBA|masterReference^WCTYPE|
wt.part.WTPartMaster~MBA|defaultUnit</ExternalForm>
</Property>
<Property>
<LogicalForm>masterReference</LogicalForm>
<ExternalForm>MBA|masterReference^WCTYPE|
wt.part.WTPartMaster</ExternalForm>
</Property>
<Property>
<LogicalForm>name</LogicalForm>
<ExternalForm>MBA|masterReference^WCTYPE|
wt.part.WTPartMaster~MBA|name</ExternalForm>
</Property>
<Property>
<LogicalForm>number</LogicalForm>
<ExternalForm>MBA|masterReference^WCTYPE|
wt.part.WTPartMaster~MBA|number</ExternalForm>
</Property>
<Property>
<LogicalForm>organizationReference</LogicalForm>
<ExternalForm>MBA|masterReference^WCTYPE|
wt.part.WTPartMaster~MBA|organizationReference^WCTYPE|
wt.org.WTOrganization</ExternalForm>
</Property>
<Property>
<LogicalForm>organizationName</LogicalForm>
<ExternalForm>MBA|masterReference^WCTYPE|
wt.part.WTPartMaster~MBA|organizationReference^WCTYPE|
wt.org.WTOrganization~MBA|name</ExternalForm>
</Property>
<Property>
<LogicalForm>usedLineNumber</LogicalForm>
<ExternalForm>MBA|masterReference^WCTYPE|
wt.part.WTPartMaster~MBA|uses@WCTYPE|
wt.part.WTPartUsageLink~MBA|
lineNumber.value</ExternalForm>
</Property>
<Property>
<LogicalForm>usedLink</LogicalForm>
<ExternalForm>MBA|masterReference^WCTYPE|
wt.part.WTPartMaster~MBA|uses@WCTYPE|
wt.part.WTPartUsageLink</ExternalForm>
</Property>
</Class>
使用 "ext.cust.CustPart" 扩展 wt.part.WTPart 和 "ext.cust.SubPartMaster" 扩展 wt.part.WTPartMaster 的示例时,应将下列内容添加到名为 <Windchill>/codebase/LogicalAttributesSite.xml 的站点特定文件中:
<Class name="ext.cust.CustPart">
<Property>
<LogicalForm>defaultUnit</LogicalForm>
<ExternalForm>MBA|masterReference^WCTYPE|
ext.cust.SubPartMaster~MBA|defaultUnit</ExternalForm>
</Property>
<Property>
<LogicalForm>masterReference</LogicalForm>
<ExternalForm>MBA|masterReference^WCTYPE|
ext.cust.SubPartMaster</ExternalForm>
</Property>
<Property>
<LogicalForm>name</LogicalForm>
<ExternalForm>MBA|masterReference^WCTYPE|
ext.cust.SubPartMaster~MBA|name</ExternalForm>
</Property>
<Property>
<LogicalForm>number</LogicalForm>
<ExternalForm>MBA|masterReference^WCTYPE|
ext.cust.SubPartMaster~MBA|number</ExternalForm>
</Property>
<Property>
<LogicalForm>organizationReference</LogicalForm>
<ExternalForm>MBA|masterReference^WCTYPE|
ext.cust.SubPartMaster~MBA|organizationReference^WCTYPE|
wt.org.WTOrganization</ExternalForm>
</Property>
<Property>
<LogicalForm>organizationName</LogicalForm>
<ExternalForm>MBA|masterReference^WCTYPE|
ext.cust.SubPartMaster~MBA|organizationReference^WCTYPE|
wt.org.WTOrganization~MBA|name</ExternalForm>
</Property>
<LogicalForm>usedLineNumber</LogicalForm>
<ExternalForm>MBA|masterReference^WCTYPE|
ext.cust.SubPartMaster~MBA|uses@WCTYPE|
wt.part.WTPartUsageLink~MBA|
lineNumber.value</ExternalForm>
</Property>
<Property>
<LogicalForm>usedLink</LogicalForm>
<ExternalForm>MBA|masterReference^WCTYPE|
ext.cust.SubPartMaster~MBA|uses@WCTYPE|
wt.part.WTPartUsageLink</ExternalForm>
</Property>
</Class>
PSE 表格和面板
您无需将新的模型化属性添加到 LogicalAttributes.xml 文件中,但必须将它们添加到相应的 PSE 配置 XML 文件中。有关其他信息,请参阅针对子类型自定义 PSE
* 
指定仅针对子类对象定义的新模型化属性时,应将 "wt.part.WTPart" 上下文中定义的相应 "AttributeGroup" 或 "AttributeTable" 或 "Table" 复制到相应的子类上下文中。
只需列出新的模型化属性。现有属性将被继承。例如,将从 WTPart 继承名称和编号。
要从子类面板中移除继承的属性,请使用 "<Placement remove="true"/>",例如:
<AttributeDefinition id="contextName”>
<Placement remove="true"/>"
</AttributeDefinition>
为自定义对象添加元素组时,将所有自定义更改都放到一个单独的文件中而不编辑现有文件,这是一种不错的做法。对这些文件进行统一命名,例如 CustomExplorerForTablesAndPanels.xml。
使用之前的 "ext.cust.CustPart" 扩展 "wt.part.WTPart" 示例时,应将以下 AttributeGroup
<ExplorerElementGroup>
<LogicContext application="ptc.wnc.StructureExplorer"
dataType="wt.part.WTPart"/>
<AttributeGroup id="ptc.wnc.exp.ViewPropertiesPanel" displayMode="view">
<CellDefinition id="number">
<AttributeDefinition attributeId="number"/>
</CellDefinition>
<CellDefinition id="organizationIdentifier">
<AttributeDefinition attributeId="organizationIdentifier"/>
</CellDefinition>
<CellDefinition id="name">
<AttributeDefinition attributeId="name"/>
</CellDefinition>
<CellDefinition id="versionIterationView">
<AttributeDefinition attributeId="versionIterationView"/>
</CellDefinition>
...
</AttributeGroup>
</ElementGroup>
复制到 "ext.cust.CustPart" 的 LogicContext 下,如下所示:
<ExplorerElementGroup>
<LogicContext application="ptc.wnc.StructureExplorer"
dataType=" ext.cust.CustPart "/>
<AttributeGroup id="ptc.wnc.exp.ViewPropertiesPanel" displayMode="view">
<!-- name and number will inherit from WTPart -->
<!-- adding new modeled attributes here -->
<CellDefinition id="intMBA">
<AttributeDefinition attributeId="intMBA"/>
</CellDefinition>
...
</AttributeGroup>
</ElementGroup>
自定义的命令委派
PSE 使用 Command/CommandDelegate 映射来控制某些操作。最值得注意的示例为“复制操作”。要“复制”自定义类,您需要将相应的复制委派编入子类。在 "CustPart" 的情况下,您需要创建一个属于 wt.enterprise.CopyWTPartDelegate 子类的类,然后再复制自定义的模型化属性。
编写自定义类的复制委派
自定义出厂设置业务对象 (例如部件) 以创建模型化子类时,有必要创建和配置自定义复制委派类,以便在复制 (或另存为) 部件时正确处理其他模型化属性。
本文档以简单示例说明步骤:扩展 wt.part.WTPart 且具有单一字符串属性 "myAttr" 的自定义部件类 "MyPart"。
创建复制委派
如图所示,您只需扩展 wt.enterprise.CopyWTPartDelegate 并覆盖其 newCopy() 方法即可。目的是在此特定情况 (即 myAttr) 下,处理任何自定义属性。以下是如何执行此方法的说明:
public final RevisionControlled newCopy( RevisionControlled object
)throws WTException {
//##begin newCopy%461E645C0050f.body preserve=yes
if (object == null) return null;
MyPart new_copy = (MyPart) super.newCopy(object);
MyPart original = (MyPart) object;
String my_attr = original.getMyAttr();
if (my_attr != null) {
try {
new_copy.setMyAttr(original.getMyAttr());
}
catch (WTPropertyVetoException e) {
throw new WTException(e);
}
return new_copy;
//##end newCopy%461E645C0050f.body
}
创建复制委派
配置复制委派
要指示 Windchill 将自定义复制委派 CopyMyPartDelegate 用作 MyPart 的复制委派类,需要将下列行插入配置文件 <windchill-install-directory>/codebase/wt/enterprise/EnterpriseServerDelegate.properties。
wt.services/svc/default/wt.enterprise.CopyDelegate/null/<my-
package>.MyPart/0=<mypackage>.
CopyMyPartDelegate/singleton
自定义点
自定义可本地化的标签和枚举
每个模型化对象均具有在生成过程中创建的关联 RBINFO 文件,其中包含用作 PSE 中属性和列的标签的本地化字符串。如果标签需要更改,应编辑对应的 RBIFNO 文件。例如,在文件 CustPartModelRB.rbInfo 中,要更改属性 "booleanMBA" 的标签,请编辑下列行:
CustPart.booleanMBA.value=New Label for booleanMBA
当模型化枚举在 PSE 中显示为下拉菜单时,将会显示枚举的内部值。要更改显示在下拉菜单中的标签,应编辑枚举的对应 RBINFO 文件。例如,如果您生成一个值为 "apple"、"dog"、"cat" 的 "public final class MyEnum extends EnumeratedType" 类,且您想要更改下拉菜单中的显示值,请如下所示编辑文件 MyEnumRB.rbInfo:
# Entry Contents
apple.value=Apples
dog.value=Dogs
cat.value=Cats
其他资源
自定义 PSE 表格显示