package cn.com.origin.autocode.newitem.system;

import java.awt.Frame;
import java.beans.PropertyChangeSupport;

import com.teamcenter.rac.aif.AbstractAIFApplication;
import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
import com.teamcenter.rac.aifrcp.AIFUtility;
import com.teamcenter.rac.commands.newitem.NewItemCommand;
import com.teamcenter.rac.kernel.TCSession;
import com.teamcenter.rac.util.MessageBox;
import com.teamcenter.rac.util.Registry;

public class ORNewItemCommand extends NewItemCommand {
	private String needShowItemType = "";
	public ORNewItemCommand() {
		// TODO Auto-generated constructor stub
	}

	public ORNewItemCommand(Frame arg0, AbstractAIFApplication arg1) {
		super(arg0, arg1);
	}

	public ORNewItemCommand(Frame arg0, AbstractAIFApplication arg1, String needShowItemType) {
		this(arg0, arg1, "Item", null, false, needShowItemType);
	}

	public ORNewItemCommand(Frame arg0, InterfaceAIFComponent[] arg1) {
		super(arg0, arg1);
	}

	public ORNewItemCommand(Frame arg0, AbstractAIFApplication arg1, boolean arg2) {
		super(arg0, arg1, arg2);
	}

	public String getNeedShowItemType() {
		return needShowItemType;
	}

	public void setNeedShowItemType(String needShowItemType) {
		this.needShowItemType = needShowItemType;
	}

	public ORNewItemCommand(Frame frame, AbstractAIFApplication abstractaifapplication, String s, String s1, boolean flag, String needShowItemType) {
		this();
		parentFrame = frame;
		application = abstractaifapplication;
		this.needShowItemType=needShowItemType;
		setPasteRelation(s1);
		setRevisionFlag(flag);
		try {
			session = (TCSession) AIFUtility.getCurrentApplication().getSession();
			InterfaceAIFComponent ainterfaceaifcomponent[] = getTargets();
			targetArray = checkComponents(ainterfaceaifcomponent);
			if (targetArray == null && ainterfaceaifcomponent != null)
				return;
		} catch (Exception exception) {
			MessageBox.post(frame, exception);
		}
		postDialog(frame);
	}

	public ORNewItemCommand(Frame frame, AbstractAIFApplication abstractaifapplication, String s, String s1, boolean flag) {
		super(frame, abstractaifapplication, s, s1, flag);
	}

	protected void postDialog(Frame frame) {
		Registry registry = Registry.getRegistry(this);
		// AbstractAIFDialog abstractaifdialog = null;
		ORNewItemDialog abstractaifdialog = null;
		abstractaifdialog = new ORNewItemDialog(this);

		if (abstractaifdialog != null) {
			abstractaifdialog.addPropertyChangeListener(this);
			propertySupport = new PropertyChangeSupport(this);
			// setRunnable(abstractaifdialog);
			abstractaifdialog.setVisible(true);
		} else {
			MessageBox.post(frame, registry.getString("failFindDialog"), registry.getString("error.TITLE"), 1);
		}
	}
}
