|
|
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;
|
|
|
}
|
|
|
|
|
|
|
|
|
}
|