其他 Windchill 功能 > 製造流程管理 > 自訂產品結構總管 (PSE) > 自訂 PSE 以處理模型子類別
  
自訂 PSE 以處理模型子類別
目標
您已建立自訂模型企業物件;您想要自訂 PSE,使其完全支援您的模型子類別。
範圍/適用性/假設
您已分別建立模型子類別。
預期結果
PSE 會採用與現成模型物件相同的方式偵測及呈現模型子類別的實例。
解決方案
在下列三個區域中進行變更:
LogicalAttributes.xml
PSE 表格與面板
自訂指令委派
必備知識
欲達成此目標,您需瞭解下列事項:
XML 檔案自訂的管理
RBINFO 檔案自訂的管理
解決方案元素
元素
類型
描述 (Description)
LogicalAttributes.xml
XML 檔案
用於配置模型屬性對應:從「邏輯形式」到其「外部形式」。
程序 – 自訂 PSE 以處理模型子類別
本節包含下列主題:
LogicalAttributes.xml
PSE 表格與面板
自訂指令委派
LogicalAttributes.xml
位於 <Windchill>/codebase/LogicalAttributes.xml 的 LogicalAttributes.xml 檔案用於配置模型屬性對應 (從「邏輯形式」到其「外部形式」)。因此,呈現出物件間關聯性的所有模型屬性都需要對應。例如,部份針對 WTPart 至 WTPartMaster 參照而定義的項目如下:
<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 表格顯示