WindChill(2)自定义右键搜索页面

1.添加搜索用户.java类

PartRelationDocBuilderTest.java编写

package com.catl.part.relation;

import com.ptc.mvc.components.*;
import com.ptc.mvc.util.ClientMessageSource;
import wt.fc.PersistenceServerHelper;
import wt.fc.QueryResult;
import wt.org.WTUser;
import wt.query.ClassAttribute;
import wt.query.ConstantExpression;
import wt.query.QuerySpec;
import wt.query.SearchCondition;
import wt.util.WTException;

import java.util.ArrayList;

@ComponentBuilder("com.catl.part.relation.PartRelationDocBuilderTest")
public class PartRelationDocBuilderTest extends AbstractComponentBuilder {

    private ClientMessageSource msgSource;

    @Override
    public Object buildComponentData(ComponentConfig arg0, ComponentParams params) throws Exception {
        String wtUserFullName = (String) params.getParameter("null___wtUserValue___textbox");
        QueryResult queryResult = null;
        if (wtUserFullName != null && wtUserFullName != "") {
            queryResult = SelectUsersTest001(wtUserFullName);
        } else {
            queryResult = SelectUsersTest001("");
        }
        return queryResult;
    }

    @Override
    public ComponentConfig buildComponentConfig(ComponentParams arg0) throws WTException {
        ComponentConfigFactory factory = getComponentConfigFactory();
        TableConfig config = factory.newTableConfig();

        config.setConfigurable(false);
        config.setType("wt.fc.WTObject");
        config.setLabel("RelatedDocument");
        config.setSelectable(true);
        config.setSingleSelect(true);


        ColumnConfig oidColumn = factory.newColumnConfig("oid", true);
        config.addComponent(oidColumn);
        oidColumn.setHidden(true);
        oidColumn.setSortable(true);

        ColumnConfig nameColumn = factory.newColumnConfig("name", true);
        nameColumn.setLabel("NAME");
        config.addComponent(nameColumn);

        Object fullNameColumn = factory.newColumnConfig("fullName", true);
        config.addComponent((ComponentConfig) fullNameColumn);

        Object eMailColumn = factory.newColumnConfig("eMail", true);
        config.addComponent((ComponentConfig) eMailColumn);

//        ColumnConfig infoPageColumn = factory.newColumnConfig("attributes", false);
//        infoPageColumn.setDataUtilityId("infoPageAction");
//        config.addComponent(infoPageColumn);


        return config;
    }

    private static QueryResult SelectUsersTest001(String wtUserFullName) throws WTException {
        int[] ints = new int[]{0};
        QuerySpec qs = new QuerySpec(WTUser.class);
        ClassAttribute ca = new ClassAttribute(WTUser.class, WTUser.FULL_NAME);
        ConstantExpression ce = new ConstantExpression("%" + wtUserFullName + "%");
        ce.setUseEscape(true);
        SearchCondition sc = new SearchCondition(ca, SearchCondition.LIKE, ce);
        qs.appendWhere(sc, ints);
        System.out.println("===qs=" + qs);
        QueryResult qr = PersistenceServerHelper.manager.query(qs);


        return qr;
    }

}

看不懂的可以看我第一篇文件PartRelationDocBuilderTest.java类部分代码解释

2、添加搜索用户按钮

custom-actions.xml

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


	<include href="config/custom/actions/customPart-actions.xml"/>
	
</listofactions>

custom-actionModels.xml

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

	<include href="config/custom/actions/customPart-actionModels.xml"/>
	
</actionmodels>

customPart-acionModels.xml

<?xml version="1.0"?>
<!DOCTYPE actionmodels SYSTEM 'actionmodels.dtd'>

<actionmodels resourceBundle="com.ptc.windchill.enterprise.part.partResource">

   <!-- *************************************************** -->
   <!-- ***   Information Page Actions Lists            *** -->
   <!-- *************************************************** -->



   <!-- Part information page Actions list -->
   <model name="more parts actions" menufor="wt.part.WTPart">
   
	   <action name="testSelect" type="custom"/>     
   
	   <action name="view" type="object"/>                             <!-- View Information -->
       <action name="separator" type="separator"/>                     <!-- ===================================== -->
       <submodel name="thingworxActionsMenu"/>
       <action name="separator" type="separator"/>                     <!-- ===================&
  • 2
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值