/*
#=======================================================================================================
#
#                   Copyright (c) 2007 Origin Enterprise Solution LTD.
#
#=======================================================================================================
# File description:  BatchDownLoadFileCommand.java
#=======================================================================================================
#	 Date	       time   	   Name	 Action	   Description of Change
#	2011-4-20      16:05    	liqz  	Ini	            文件批量下载Command
#=======================================================================================================
*/
package cn.com.customization.download;

import com.teamcenter.rac.aif.AbstractAIFCommand;
import com.teamcenter.rac.aif.AbstractAIFUIApplication;
import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
import com.teamcenter.rac.kernel.TCComponentFolder;
import com.teamcenter.rac.kernel.TCComponentItem;
import com.teamcenter.rac.kernel.TCComponentItemRevision;
import com.teamcenter.rac.kernel.TCComponentPseudoFolder;
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 BatchDownLoadFileCommand2 extends AbstractAIFCommand {

	private AbstractAIFUIApplication	application;
	private TCSession session;
	public BatchDownLoadFileCommand2(AbstractAIFUIApplication abstractaifapplication) throws TCException {
		application = abstractaifapplication;
		session = (TCSession)application.getSession();
		execute();
	}

	private void execute() throws TCException {
		try {
			final InterfaceAIFComponent targetCom = application.getTargetComponent();
			if (targetCom != null) {
				String strType = targetCom.getType();
				System.out.println("targetCom.type============" + strType);
//				String name = targetCom.toString().trim();
				System.out.println("targetCom.toString============" + targetCom.toString());
				if (targetCom instanceof TCComponentTask || targetCom instanceof TCComponentFolder || targetCom instanceof TCComponentPseudoFolder ||
					targetCom instanceof TCComponentItem ||
					targetCom instanceof TCComponentItemRevision) {
					DatasetFileDown2 filedown = new DatasetFileDown2(application, session, targetCom);
					//-*-*- 10.1改动
					//new Thread((Runnable) filedown).start();
					new Thread(filedown).start();
				} else {
					MessageBox.post("选择的对象类型不正确！", "WARNING", 1);
					return;
				}
			} else {
				MessageBox.post("请选择对象！", "WARNING", 1);
				return;
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

}
