package cn.net.connor.std.processedit.meopviewfx.ui;

import java.awt.Window;

import com.teamcenter.rac.aif.kernel.AIFComponentContext;
import com.teamcenter.rac.kernel.TCComponentBOMLine;
import com.teamcenter.rac.pse.common.BOMLineNode;
import com.teamcenter.rac.util.MessageBox;

import cn.net.connor.std.fx.KFXPanel;

public class MEOPPanel extends KFXPanel{

	private MEOPPanelController controller;

	public MEOPPanel(Window dialog) {
		super(dialog, MEOPPanel.class, "style.css");
		this.controller = (MEOPPanelController)aifController;
		initData();
	}

	public void refreshUI(TCComponentBOMLine targetLine) throws Exception{
		this.controller.refreshUI(targetLine);
	}

	public synchronized void updateSelection(Object targetObj) {
		System.out.println("Update: "+targetObj);
		if (targetObj != null && targetObj instanceof AIFComponentContext) {
			targetObj = ((AIFComponentContext) targetObj).getComponent();
		}
		if (targetObj != null && targetObj instanceof BOMLineNode) {
			targetObj = ((BOMLineNode) targetObj).getComponent();
		}
		if (targetObj == null || !(targetObj instanceof TCComponentBOMLine)) {
		} else {
			TCComponentBOMLine targetLine = (TCComponentBOMLine) targetObj;
			try {
				refreshUI(targetLine);
			} catch (Exception e) {
				MessageBox.post(getParentDialog(), e);
				e.printStackTrace();
			}
		}
	}

}
