windchill 如何再WTPart对象下增加功能按钮

场景:给WTPart对象配置一个功能按钮(此文章为示例,不可直接复制使用,仅记录大概的操作步骤)

一. 配置路由文件

1. 在 custom-actions.xml中添加如下配置

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE listofactions SYSTEM "actions.dtd">
<listofactions>
	<include href="config/actions/extWorkflow-actions.xml" />
    <include href="config/actions/extChange-actions.xml" />
	<include href="config/actions/extPromotion-actions.xml" /> 
	<include href="config/actions/extDoc-actions.xml" />
	<include href="config/actions/extPart-actions.xml" /> <!-- 我们需要演示的 -->
	<include href="config/actions/extFolderManagement-action.xml"/>
	<include href="config/actions/extNavigation-actions.xml"/> 
</listofactions>

2. 在 custom-actionModels.xml中添加如下配置

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE actionmodels SYSTEM "actionmodels.dtd">
<actionmodels>   
	<include href="config/actions/extWorkflow-actionModels.xml" />
	<include href="config/actions/extFolderManagement-actionModels.xml" />
	<include href="config/actions/extNavigation-actionModels.xml" /> 
	<include href="config/actions/extDoc-actionModels.xml" />
    <include href="config/actions/extChange-actionModels.xml" />
    <include href="config/actions/extPart-actionModels.xml" /> <!-- 我们需要演示的 -->
    <include href="config/actions/extEPM-actionModels.xml" />
</actionmodels>

配置 extPart-actions.xmlextPart-actionModels.xml

文件名 路径 说明
extPart-actions.xml /codebase/config/actions/extPart-actions.xml 用于配置引用
extPart-actionModels.xml /codebase/config/actions/extPart-actionModels.xml 配置按钮行为

1.配置 extPart-actionModels.xml

<actionmodels resourceBundle="com.ptc.windchill.enterprise.part.partResource">
   <model name="more parts actions" menufor="wt.part.WTPart">
       
       <!-- 自定义的按钮 -->
       <action name="createPcbFootprint" type="extPart"/>              <!-- 创建封装库  -->
       <action name="exprotMaterialsAttr" type="extPart"/>             <!-- 导出物料属性  -->
       <action name="importMaterialsAttr" type="extPart"/>             <!-- 导入物料属性  -->
       
    </model>
   
</actionmodels>

2. 配置 extPart-actions.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE listofactions SYSTEM "actions.dtd">
<listofactions>

<!-- 系统按钮 -->
<objecttype name="part" class="wt.part.WTPart" resourceBundle="com.ptc.windchill.enterprise.part.partResource">
	...
</objecttype>

<!-- 自定义按钮 -->
<!-- resourceBundle : 配置按钮样式的类路径 -->
<objecttype name="extPart" resourceBundle="ext.bica3.resource.PartResource">
	<action name="createPcbFootprint">
	    <!-- url: 点击按钮弹出的页面路径 -->
	    <!-- windowType: 窗口打开方式 -->
		<command url="/netmarkets/jsp/ext/bica3/pcb/createPcbFootprint.jsp" windowType="popup" />
		<!-- 配置监听,默认是全部可见 -->
		<includeFilter name="createPcbFootprintValidator" />
	</action>
	<action name="exprotMaterialsAttr" >
        <command url="/netmarkets/jsp/ext/bica3/exprotPart/exprotMaterialsAttr.jsp" windowType="popup" />
    </action>
	<action name="importMaterialsAttr" >
        <command url="/netmarkets/jsp/ext/bica3/extPart/importMaterialsAttr/index.jsp" windowType="popup" />
    </action>
</objecttype>

</listofactions>

二. 配置按钮样式

配置英文按钮 :

@RBUUID("ext.bica3.resource.PartResource")
public final class PartResource extends WTListResourceBundle {
    
    @RBEntry("Create PCB Footprint")
    public static final String EXTPART_CREATEPCBFOOTPRINT_TITLE = "extPart.createPcbFootprint.title";
    @RBEntry("Create PCB Footprint")
    public static final String EXTPART_CREATEPCBFOOTPRINT_DESCRIPTION = "extPart.createPcbFootprint.description";
    @RBEntry("Create PCB Footprint")
    public static final String EXTPART_CREATEPCBFOOTPRINT_TOOLTIP = "extPart.createPcbFootprint.tooltip";
    @RBEntry("width=800,height=630")
    @RBPseudo(false)
    public static final String EXTPART_CREATEPCBFOOTPRINT__MOREURLINFO = "extPart.createPcbFootprint.moreurlinfo";

}

配置中文文按钮 :

@RBUUID("ext.bica3.resource.PartResource")
public final class PartResource_zh_CN extends WTListResourceBundle {
    
    @RBEntry("创建封装库")
    public static final String EXTPART_CREATEPCBFOOTPRINT_TITLE = "extPart.createPcbFootprint.title";
    @RBEntry("创建封装库")
    public static final String EXTPART_CREATEPCBFOOTPRINT_DESCRIPTION = "extPart.createPcbFootprint.description";
    @RBEntry("创建封装库")
    public static final String EXTPART_CREATEPCBFOOTPRINT_TOOLTIP = "extPart.createPcbFootprint.tooltip";
    @RBEntry("width=800,height=630")
    @RBPseudo(false)
    public static final String EXTPART_CREATEPCBFOOTPRINT__MOREURLINFO = "extPart.createPcbFootprint.moreurlinfo";
    
}

三. 权限配置(根据需求,可加可不加)

1. 编写过滤器

public class CreatePcbFootprintValidator extends DefaultSimpleValidationFilter {
    // 校验规则方法
    @Override
    public UIValidationStatus preValidateAction(UIValidationKey key, UIValidationCriteria criteria) {
        UIValidationStatus status = super.preValidateAction(key, criteria);
        Object obj = criteria.getContextObject().getObject();
        // 显示:UIValidationStatus.HIDDEN
        // 隐藏:UIValidationStatus.ENABLED
        // 禁用:UIValidationStatus.DISABLED
        status = UIValidationStatus.ENABLED;
        
        // 编写校验规则

        return status;
    }
}

2. 注册过滤器

/windchill/declarations.xconf 目录下找到配置文件,并添加 <ConfigurationRef xlink:href="codebase/ext/bica3/conf/bica_functions.xconf"/> 如下图位置

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE Configuration
  SYSTEM "xconf.dtd">
<Configuration xmlns:xlink="http://www.w3.org/1999/xlink">
   <!-- 其它还有很多配置,这里我将其删除了,只保留我们要添加的 -->
   <ConfigurationRef xlink:href="codebase/ext/bica3/conf/bica_functions.xconf"/>
</Configuration>

配置bica_functions.xconf

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE Configuration SYSTEM "xconf.dtd">
<Configuration targetFile="codebase/service.properties">
      <!-- 过滤器 -->
    <Service name="com.ptc.core.ui.validation.SimpleValidationFilter">
      <Option cardinality="duplicate" requestor="null"  selector="ExtExportFolderValidator"
        serviceClass="ext.bica3.folder.validator.ExtExportFolderValidator"/>
    </Service>
	<!-- listener -->
	<Property name="wt.services.service.95001" overridable="true" targetFile="codebase/wt.properties" 
		default="ext.bica3.epm.listener.EpmListenerService/ext.bica3.epm.listener.EpmListenerService"/>
	<Property name="wt.services.service.95002" overridable="true" targetFile="codebase/wt.properties"
		default="ext.bica3.part.listener.PartListenerService/ext.bica3.part.listener.PartListenerService"/>
</Configuration>

3. 执行命令,注册过滤器

xconfmanager  -i C:\ptc\Windchill_11.0\Windchill\codebase\ext\bica3\conf\bica_functions.xconf -p
posted @ 2020-11-09 17:00  Wzzzz~  阅读(1020)  评论(0)    收藏  举报