package cn.com.customization.project;

import javax.swing.SwingUtilities;

import com.teamcenter.rac.aif.AIFDesktop;
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.TCSession;
import com.teamcenter.rac.util.MessageBox;

public class CreateProjectFolderCommand extends AbstractAIFCommand {
	AbstractAIFUIApplication app;
	TCSession session;
	public int i = 0;

	public CreateProjectFolderCommand(AbstractAIFUIApplication abstractaifuiapplication, final String folderType) {
		super();
		this.app = abstractaifuiapplication;
		session = (TCSession) app.getSession();
		System.out.println("第2个参数" + "\n传递进来的String=" + folderType);
		final InterfaceAIFComponent[] pasteTargets = app.getTargetComponents();
		if (pasteTargets.length == 1 && pasteTargets[0] instanceof TCComponentFolder) {
			SwingUtilities.invokeLater(new Runnable() {
				public void run() {
					app.getDesktop();
					new CopyFolderAndAssginToProjectDialog(app, session, AIFDesktop.getActiveDesktop(), true, folderType, pasteTargets[0]);
				}
			});
		} else {
			MessageBox.post(app.getDesktop().getShell(), "请选择一个文件夹！", "警告", MessageBox.ERROR);
		}
	}
}
