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

import java.awt.Frame;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import com.teamcenter.rac.commands.newitem.ItemInfoPanel;
import com.teamcenter.rac.commands.newitem.ItemMasterFormPanel;
import com.teamcenter.rac.commands.newitem.ItemRevMasterFormPanel;
import com.teamcenter.rac.commands.newitem.ItemTypePanel;
import com.teamcenter.rac.commands.newitem.NewItemAlternateIdInfoPanel;
import com.teamcenter.rac.commands.newitem.NewItemDialog;
import com.teamcenter.rac.commands.newitem.NewItemFinishPanel;
import com.teamcenter.rac.commands.newitem.NewItemPanel;
import com.teamcenter.rac.commands.newitem.SubmitToWorkflowPanel;
import com.teamcenter.rac.commands.newitem.AbstractNewItemPanel.IC_TypeSelectionListener;
import com.teamcenter.rac.kernel.TCSession;
import com.teamcenter.rac.util.HyperLink;
import com.teamcenter.rac.util.Instancer;
import com.teamcenter.rac.util.wizard.AbstractControlWizardStepPanel;
import com.teamcenter.rac.util.wizard.WizardControlLabel;

public class ORNewItemPanel extends NewItemPanel {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	String needShowItemType;

	public ORNewItemPanel(Frame frame, TCSession tcsession, NewItemDialog newitemdialog) {
		super(frame, tcsession, newitemdialog);
	}

	public ORNewItemPanel(Frame frame, TCSession tcsession, NewItemDialog newitemdialog, String needShowItemType) {
		super(frame, tcsession, newitemdialog);
		this.needShowItemType = needShowItemType;
	}

	public ORNewItemPanel(Frame frame, TCSession tcsession, NewItemDialog newitemdialog, Boolean boolean1) {
		super(frame, tcsession, newitemdialog, boolean1);
	}

	public void loadControlPanels() {
		loadPanels();
		int i = stepPanels.size();
		for (int j = 0; j < i; j++) {
			AbstractControlWizardStepPanel abstractcontrolwizardsteppanel = (AbstractControlWizardStepPanel) stepPanels.get(j);
			WizardControlLabel wizardcontrollabel = new WizardControlLabel(abstractcontrolwizardsteppanel.getControlName(), unblockIcon, false);
			wizardcontrollabel.setUnderLine(false);
			wizardcontrollabel.setToolTipText(abstractcontrolwizardsteppanel.getToolTip());
			wizardcontrollabel.setRequired(abstractcontrolwizardsteppanel.isRequired());
			controlLabels.add(wizardcontrollabel);
			controlPanel.add("top.nobind.left.top", wizardcontrollabel);
			final int index = j;
			wizardcontrollabel.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent actionevent) {
					controlLinkClicked(index);
				}
			});
		}
		originalFont = ((HyperLink) controlLabels.get(0)).getFont();

		// if (!stepPanels.isEmpty() && beforeSetPanel(0)) {
		// setPanel(0);
		// }
		
		// tyl 20130506 tc9 //
		if ((this.needShowItemType != null) && (this.needShowItemType.trim().length() > 0)) {
			this.itemTypePanel.setSelectedItemType(needShowItemType);
			this.setPanel(this.currentStep + 1);
			// tyl 20130506 tc9 //
		} else {
			if (!stepPanels.isEmpty() && beforeSetPanel(0)) {
				setPanel(0);
			}
		}
		
		afterLoadControlPanels();
		
		// tyl 20130506 tc9 //
		if ((this.needShowItemType != null) && (this.needShowItemType.trim().length() > 0)) {
			this.itemTypePanel.setSelectedItemType(needShowItemType);
		}
		// tyl 20130506 tc9 //
	}

	
	public ItemInfoPanel createInfoPanel(Frame frame, TCSession tcsession, boolean flag) {
		return new ORItemInfoPanel(frame, tcsession, this, flag, dialog.showUOM, dialog.showQuantity);
	}

}
