/**
 * @author tyl
 * @Action  ini
 * 2011-4-4
 */
package cn.com.origin.autocode.handlers;

import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import cn.com.origin.autocode.newitem.generatcode.NewCodeItemDialog;
import cn.com.origin.autocode.newitem.system.ORNewItemCommand;
import cn.com.origin.autocodemanager.common.TCPreferenceUitl;
import com.teamcenter.rac.aif.AIFDesktop;
import com.teamcenter.rac.aifrcp.AIFUtility;
import com.teamcenter.rac.kernel.TCSession;

public class AutoCodeNewItemFilterTypeHandler extends AbstractHandler {
	private String origin_newItemDialogType = "origin_newItemDialogType";

	public Object execute(ExecutionEvent arg0) throws ExecutionException {
	
		String value = TCPreferenceUitl.getTCPreferenceValue((TCSession) AIFUtility.getCurrentApplication().getSession(), origin_newItemDialogType);
		if (value.equals("2")) {
			new Thread() {
				public void run() {
					ORNewItemCommand command = new ORNewItemCommand(AIFDesktop.getActiveDesktop().getFrame(), AIFUtility.getCurrentApplication());
					// ExcelTemplate Item
					// ORNewItemCommand command = new ORNewItemCommand(AIFDesktop.getActiveDesktop().getFrame(), AIFUtility.getCurrentApplication(),"DMTemplate");
					try {
						command.executeModal();
					} catch (Exception e) {
						e.printStackTrace();
					}
				}
			}.start();
		} else {
			new NewCodeItemDialog(AIFDesktop.getActiveDesktop().getShell(),"HX3_WL",true).open();
		}
		return null;
	}
}
