与其他应用程序集成 > 在 Windchill 中管理 CAD 和部件关系 > 自定义自动关联 > AutoAssociatePartFinderCreator 修改示例
  
AutoAssociatePartFinderCreator 修改示例
使用下列源创建并编译 <WT_HOME>src\com\ptcts\autoassociate\CustomizedAutoAssociatePartFinderCreator.java
// package com.ptc.windchill.uwgm.cadx.autoassociate;
package com.ptcts;
import java.lang.String;
import wt.epm.EPMDocument;
import wt.epm.workspaces.EPMWorkspace;
import wt.part.WTPart;
import wt.pom.UniquenessException;
import wt.util.WTException;
import wt.util.WTPropertyVetoException;
import wt.vc.VersionControlException;
// import com.ptc.windchill.uwgm.task.autoassociate.
DefaultAutoAssociatePartFinderCreator;
import com.ptc.windchill.uwgm.common.autoassociate.
DefaultAutoAssociatePartFinderCreator;
// import com.ptc.windchill.cadx.autoassociate.AutoAssociatePartFinderCreator;
import com.ptc.windchill.uwgm.common.autoassociate.
AutoAssociatePartFinderCreator;
import wt.type.TypedUtilityServiceHelper;
import com.ptc.windchill.uwgm.common.associate.AssociatePartDescriptor;
import wt.inf.container.WTContainer;
import java.rmi.RemoteException;
public class CustomizedAutoAssociatePartFinderCreator extends
DefaultAutoAssociatePartFinderCreator
implements AutoAssociatePartFinderCreator
{
public boolean isIsNewPart()
{
System.out.println("Invoked CustomizedAutoAssociatePartFinderCreator ::
isIsNewPart()");
return super.isIsNewPart();
}
public void setIsNewPart( boolean a_IsNewPart ) throws WTPropertyVetoException
{
System.out.println("Invoked CustomizedAutoAssociatePartFinderCreator ::
setIsNewPart()");
super.setIsNewPart(a_IsNewPart);
}
public WTPart findOrCreateWTPart(EPMDocument epmDoc, EPMWorkspace workspace)
throws WTException,
WTPropertyVetoException, VersionControlException, UniquenessException
{
System.out.println("Invoked CustomizedAutoAssociatePartFinderCreator ::
findOrCreateWTPart()");
return super.findOrCreateWTPart(epmDoc, workspace);
}
public WTPart findWTPart(EPMDocument epmDoc) throws WTException
{
System.out.println("Invoked CustomizedAutoAssociatePartFinderCreator ::
findWTPart()");
return super.findWTPart(epmDoc);
}

public WTPart createNewWTPart(AssociatePartDescriptor newPartDescriptor)
throws WTException,
WTPropertyVetoException {

System.out.println("Invoked CustomizedAutoAssociatePartFinderCreator ::
createNewWTPart()");

// get epmdoc
EPMDocument epmDoc = newPartDescriptor.getSourceDoc();
// get workspace
EPMWorkspace ws = newPartDescriptor.getEPMWorkspace();

// get workspace container
WTContainer container = ws.getContainer();

// create wtpart with super class
WTPart newpart = super.createNewWTPart(newPartDescriptor);

// manipulate new part, e.g. set attributes

// return modified new part
return newpart;
}

}