package com.langtech.plm.performancemanagement.handlers;

import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;

import com.langtech.plm.performancemanagement.dialogs.TaskFolderMatchingDialog;
import com.teamcenter.rac.aif.AbstractAIFApplication;
import com.teamcenter.rac.aifrcp.AIFUtility;
import com.teamcenter.rac.kernel.TCComponent;
import com.teamcenter.rac.kernel.TCSession;
import com.teamcenter.rac.util.MessageBox;

/**
 * 功能描述：选中项目文件夹，导出绩效报表 数据库表维护任务要求表
 * 
 * 
 */
public class TaskFolderMatchingHandler extends AbstractHandler {
	@Override
	public Object execute(ExecutionEvent event) throws ExecutionException {

		AbstractAIFApplication app = AIFUtility.getCurrentApplication();
		TCSession session = (TCSession) app.getSession();
		TCComponent target = null;
		target = (TCComponent) app.getTargetComponent();
		// 选中项目类型，否则报错
		
		if(target==null) {
			MessageBox.post("请选择客户成品文件夹", "", MessageBox.INFORMATION);
		}else {
			
			String type = target.getType();
			if (type.equals("LD6_CusProdFolder") || type.equals("客户成品文件夹")) {
				TaskFolderMatchingDialog dialog = new TaskFolderMatchingDialog(app, target);
				new Thread(dialog).start();
			} else {
				MessageBox.post("请选择客户成品文件夹", "", MessageBox.INFORMATION);
			}
		}
		return null;
	}

}
