package cn.com.customization.schedule;

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.aifrcp.AIFUtility;
import com.teamcenter.rac.kernel.TCComponentSchedule;
import com.teamcenter.rac.kernel.TCComponentScheduleTask;
import com.teamcenter.rac.kernel.TCException;
import com.teamcenter.rac.util.MessageBox;

public class BOMTransPlanCommand extends AbstractAIFCommand {

	private AbstractAIFUIApplication application = null;

	public BOMTransPlanCommand() {

		super();

		application = AIFUtility.getCurrentApplication();

		InterfaceAIFComponent selectTarget = application.getTargetComponent();
		if (selectTarget instanceof TCComponentScheduleTask) {
			try {
				final TCComponentSchedule scheduleTag = (TCComponentSchedule) ((TCComponentScheduleTask) selectTarget).getReferenceProperty("schedule_tag");
				SwingUtilities.invokeLater(new Runnable() {
					public void run() {
						application.getDesktop();
						new BOMTransPlanDialog(application, AIFDesktop.getActiveDesktop(), scheduleTag);
					}
				});
			} catch (TCException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}

		} else {
			MessageBox.post(application.getDesktop().getShell(), "请选择一个时间表对象执行此功能！", "提示", MessageBox.INFORMATION);
		}
	}
}
