You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

103 lines
3.1 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

package com.langtech.plm.mpart;
import java.util.ArrayList;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import com.teamcenter.rac.aif.AbstractAIFApplication;
import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
import com.teamcenter.rac.aifrcp.AIFUtility;
import com.teamcenter.rac.kernel.TCComponent;
import com.teamcenter.rac.kernel.TCComponentItemRevision;
import com.teamcenter.rac.kernel.TCComponentSchedule;
import com.teamcenter.rac.kernel.TCComponentScheduleTask;
import com.teamcenter.rac.kernel.TCComponentTask;
import com.teamcenter.rac.kernel.TCException;
import com.teamcenter.rac.kernel.TCSession;
import com.teamcenter.rac.util.MessageBox;
public class MpartHandler extends AbstractHandler{
@Override
public Object execute(ExecutionEvent arg0) throws ExecutionException {
AbstractAIFApplication app = AIFUtility.getCurrentApplication();
TCSession session = (TCSession) app.getSession();
try {
new Thread() {
@Override
public void run() {
InterfaceAIFComponent[] targetComponent = app.getTargetComponents();
ArrayList<TCComponentItemRevision> arrayList = new ArrayList<TCComponentItemRevision>();
String[] types = session.getPreferenceService().getStringValues("LY6_EPartType");
if(types != null && types.length > 0) {
for (int i = 0; i < targetComponent.length; i++) {
InterfaceAIFComponent component = targetComponent[i];
if(component instanceof TCComponentItemRevision) {
String type = component.getType();
System.out.println("type================"+type);
if(types[0].contains(type)) {
arrayList.add((TCComponentItemRevision)component);
}
}else if(component instanceof TCComponentTask) {
TCComponentTask task = (TCComponentTask)component;
try {
TCComponent[] targets = task.getRelatedComponents("root_target_attachments");
for(TCComponent attachment:targets) {
if(attachment instanceof TCComponentItemRevision) {
String type = attachment.getType();
System.out.println("type================"+type);
if(types[0].contains(type)) {
arrayList.add((TCComponentItemRevision)attachment);
}
}
}
} catch (TCException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
System.out.println("arrayList.size()==========="+arrayList.size());
if(arrayList.size() > 0) {
try {
new MpartDialog(session,arrayList);
} catch (TCException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}else {
MessageBox.post(<><CEB4>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", "<22><>ʾ ", MessageBox.INFORMATION);
return;
}
}else {
MessageBox.post("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1>LY6_EPartType<70><65>", "<22><>ʾ ", MessageBox.INFORMATION);
return;
}
}
}.start();
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}
return null;
}
}