package cn.net.connor.std.processedit.ldy;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Vector;
import java.util.Map.Entry;

import javax.swing.BorderFactory;
import javax.swing.DefaultCellEditor;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.SwingConstants;
import javax.swing.border.TitledBorder;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableColumnModel;

import org.eclipse.ui.internal.e4.compatibility.CompatibilityView;

import com.teamcenter.rac.aif.AbstractAIFDialog;
import com.teamcenter.rac.aif.kernel.AIFComponentContext;
import com.teamcenter.rac.aifrcp.AIFUtility;
import com.teamcenter.rac.kernel.ListOfValuesInfo;
import com.teamcenter.rac.kernel.TCComponent;
import com.teamcenter.rac.kernel.TCComponentBOMLine;
import com.teamcenter.rac.kernel.TCComponentBOPWindow;
import com.teamcenter.rac.kernel.TCComponentBOPWindowType;
import com.teamcenter.rac.kernel.TCComponentForm;
import com.teamcenter.rac.kernel.TCComponentItem;
import com.teamcenter.rac.kernel.TCComponentItemRevision;
import com.teamcenter.rac.kernel.TCComponentItemType;
import com.teamcenter.rac.kernel.TCComponentListOfValues;
import com.teamcenter.rac.kernel.TCComponentListOfValuesType;
import com.teamcenter.rac.kernel.TCComponentMEOP;
import com.teamcenter.rac.kernel.TCComponentMEProcess;
import com.teamcenter.rac.kernel.TCComponentMEProcessRevision;
import com.teamcenter.rac.kernel.TCComponentPseudoFolder;
import com.teamcenter.rac.kernel.TCProperty;
import com.teamcenter.rac.kernel.TCSession;
import com.teamcenter.rac.stylesheet.PropertyDateComponent;
import com.teamcenter.rac.util.MessageBox;
import com.teamcenter.rac.util.PlatformHelper;

//import cn.net.connor.std.processedit.processview.ProcessPropertyEditor;
//import cn.net.connor.std.processedit.processview.ProcessPropertyView;
//import cn.net.connor.std.processedit.processview.PropertyPanel;

@SuppressWarnings("restriction")
public class ProcessMultiplexDialog extends AbstractAIFDialog {
	private static final long serialVersionUID = 1L;
	private TCSession session;
	private TCComponentBOMLine targetLine;
	private JButton searchBtn;
	private JButton exportBtn;
	private JTable impTable;
	private DefaultTableModel impModel;
	private JTable processTable;
	private DefaultTableModel processModel;
	private Map<String, JComponent> compMap;
	private String queryName;
	private Vector<String[]> showOptions;
	private Vector<String[]> procedureOptions;
	private Vector<TCComponentItemRevision> processVec;
//	private Vector<Map<String, String>> proceduresVec;
	private Vector<String[]> options;
	private Map<String, Map<String, String>> lovMap;
	private Map<Integer, Vector<Vector<Object>>> tableMap;
	private Map<Vector<Object>, TCComponentBOMLine> proceduresMap;
	private Vector<String[]> updateProps;
	private Vector<String[]> clearProps;
	
	public ProcessMultiplexDialog(TCSession session, TCComponentBOMLine targetLine, Vector<String[]> options) throws Exception {
		super(AIFUtility.getActiveDesktop());
		this.session = session;
		this.targetLine = targetLine;
		this.options = options;
		compMap = new HashMap<>();
		lovMap = new HashMap<>();
		tableMap = new HashMap<>();
		proceduresMap = new HashMap<>();
		this.showOptions = new Vector<>();
		this.procedureOptions = new Vector<>();
		this.processVec = new Vector<>();
		this.updateProps = new Vector<>();
		this.clearProps = new Vector<>();
//		tableMap = new HashMap<>();
		setTitle("零组件工艺借用");

		String[] propOptions = options.get(3);
		for(String s : propOptions) {
			updateProps.add(s.split("\\."));
		}
		propOptions = options.get(4);
		for(String s : propOptions) {
			clearProps.add(s.split("\\."));
		}
//		JPanel msgPanel = new JPanel(new GridLayout(0,5,2,5));
		JPanel msgPanel = new JPanel(new FlowLayout());
//		String[] searchOptions = options.get(0);
		String[] searchOptions = new String[] { "零组件号ID=2", "名称=2" };
		queryName = options.get(0)[0];
		final AbstractAIFDialog dialog = this;
		TCComponentListOfValuesType lovType = (TCComponentListOfValuesType)session.getTypeComponent("ListOfValues");
		for(String s : searchOptions) {
			if(!s.contains("="))
				continue;
			String[] split = s.split("=");
			JLabel label = new JLabel(split[0], SwingConstants.RIGHT);
			label.setPreferredSize(new Dimension(80, 23));
//			label.setHorizontalTextPosition(JLabel.RIGHT);
//			JPanel propPanel = new JPanel(new BorderLayout());
			JPanel propPanel = new JPanel(new BorderLayout());
			propPanel.add(BorderLayout.WEST, label);
			if(split.length==3) {
				JComboBox<String> combo = new JComboBox<>();
				combo.setPreferredSize(new Dimension(118, 23));
				if(split[2].indexOf(";")>0) {
					String[] value = split[2].split(";");
					combo.addItem("");
					for(String v : value)
						combo.addItem(v);
				}else {
					TCComponentListOfValues[] lovs = lovType.find(split[2]);
					if (lovs != null && lovs.length > 0) {
						ListOfValuesInfo lovInfo = lovs[0].getListOfValues();
						String[] code = lovInfo.getStringListOfValues();
						String[] name = lovInfo.getLOVDisplayValues();
						Map<String, String> lovVal = new HashMap<>();
						if (code != null && name != null) {
							for (int i = 0; i < code.length; i++) {
								lovVal.put(name[i], code[i]);
								combo.addItem(name[i]);
							}
						}
						lovMap.put(split[0], lovVal);
//						bean.lovList = TCUtil.setAutoComplete(bean, name);
					}else
						throw new Exception("未找到"+split[2]+"，请检查首选项配置");
				}
				propPanel.add(BorderLayout.CENTER, combo);
				msgPanel.add(propPanel);
				compMap.put(split[0], combo);
			}else if(split[1].equals("2")) {
				JTextField field = new JTextField();
				field.setPreferredSize(new Dimension(118, 23));
				propPanel.add(BorderLayout.CENTER, field);
				msgPanel.add(propPanel);
				compMap.put(split[0], field);
			}else if(split[1].equals("3")) {
				PropertyDateComponent dateBtn = new PropertyDateComponent();
				dateBtn.setPreferredSize(new Dimension(118, 23));
				propPanel.add(BorderLayout.CENTER, dateBtn);
				msgPanel.add(propPanel);
				compMap.put(split[0], dateBtn);
			}else if(split[1].equals("4")) {
				final JTextField field = new JTextField();
				field.setEditable(false);
				field.setPreferredSize(new Dimension(60, 23));
				JButton userBtn = new JButton("选人");
				userBtn.addActionListener(new ActionListener() {
					@Override
					public void actionPerformed(ActionEvent arg0) {
						try {
							new SelectUserDialog(field, true).showDialog();
						} catch (Exception e) {
							e.printStackTrace();
							MessageBox.post(dialog, "错误：:"+e.getMessage(), "ERROR", MessageBox.ERROR);
						}
					}
				});
				userBtn.setPreferredSize(new Dimension(56, 23));
				propPanel.add(BorderLayout.CENTER, field);
				propPanel.add(BorderLayout.EAST, userBtn);
				msgPanel.add(propPanel);
				compMap.put(split[0], field);
			}
		}
		searchBtn = new JButton("查询");
		exportBtn = new JButton("导入");
		JPanel btnPanel = new JPanel(new FlowLayout());
		btnPanel.add(searchBtn);
		btnPanel.add(exportBtn);
		JPanel topPanel = new JPanel(new BorderLayout());
		topPanel.add(BorderLayout.WEST, msgPanel);
		topPanel.add(BorderLayout.EAST, btnPanel);

		String[] itemOptions = options.get(0);
		String[] tableHeader = new String[itemOptions.length];
		tableHeader[0] = "序号";
		for(int i=1; i<itemOptions.length; i++) {
			String[] split = itemOptions[i].split("=");
			tableHeader[i] = split[0];
			this.showOptions.add(split[1].split("\\."));
		}
		impModel = new DefaultTableModel(tableHeader, 0);
		impTable = new JTable() {
			private static final long serialVersionUID = 1L;
			@Override
			public boolean isCellEditable(int row, int col) {
				return false;
			}
		};
		impTable.getTableHeader().setReorderingAllowed(false);
		impTable.setFillsViewportHeight(true);
//		impTable.setEnabled(false);
		impTable.setEnabled(true);
//		impTable.setAutoResizeMode(JTable.AUTO_RESIZE_NEXT_COLUMN);
		impTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
		impTable.setModel(impModel);
		for(int i=1; i<impModel.getColumnCount(); i++) 
			impTable.getColumnModel().getColumn(i).setPreferredWidth(150);
		JScrollPane itemPanel = new JScrollPane(impTable);
		itemPanel.setBorder(new TitledBorder(BorderFactory.createEtchedBorder(), "零件信息："));
		//TODO processTable
		String[] processOption = options.get(1);
		tableHeader = new String[processOption.length+1];
		tableHeader[0] = "选择";
		for(int i=0; i<processOption.length; i++) {
			String[] split = processOption[i].split("=");
			tableHeader[i+1] = split[0];
			this.procedureOptions.add(split[1].split("\\."));
		}
		processModel = new DefaultTableModel(tableHeader, 0);
		processTable = new JTable() {
			private static final long serialVersionUID = 1L;
			@Override
			public boolean isCellEditable(int row, int col) {
				if (col==0) {
					return true;
				}
				return false;
			}
			public Class<?> getColumnClass(int column) {
				if (column==0) {
					return Boolean.class;
				}
				return super.getColumnClass(column);
			}
		};
//		processTable.getTableHeader().setReorderingAllowed(false);
		processTable.setFillsViewportHeight(true);
//		processTable.setEnabled(false);
		processTable.setEnabled(true);
//		processTable.setAutoResizeMode(JTable.AUTO_RESIZE_NEXT_COLUMN);
		processTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
		processTable.setModel(processModel);
		processTable.getTableHeader().setDefaultRenderer(new CheckHeaderCellRenderer(processTable, true));
		processTable.getTableHeader().setReorderingAllowed(false);
		TableColumnModel pColModel = processTable.getColumnModel();
		for(int i=1; i<processModel.getColumnCount(); i++) 
			pColModel.getColumn(i).setPreferredWidth(150);
		pColModel.getColumn(0).setCellEditor(new DefaultCellEditor(new JCheckBox()));
		JScrollPane processPanel = new JScrollPane(processTable);
		processPanel.setBorder(new TitledBorder(BorderFactory.createEtchedBorder(), "工艺信息："));
		JPanel tablePanel = new JPanel(new GridLayout(0,1,2,5));
		tablePanel.add(itemPanel);
		tablePanel.add(processPanel);
//		processModel.addRow(new Object[] { true, "", "", ""});
		
		addActionListener();
		
		setLayout(new BorderLayout());
		add(BorderLayout.NORTH, topPanel);
		add(BorderLayout.CENTER, tablePanel);
		pack();
		setSize(new Dimension(850, 600));
		setDefaultLookAndFeelDecorated(true);
		Dimension screen = getToolkit().getScreenSize();
		setLocation((screen.width - getSize().width) / 2, (screen.height - getSize().height) / 2);
//		setAlwaysOnTop(true);
		setVisible(true);
	}
	private void addActionListener() {
		final AbstractAIFDialog dialog = this;
		impTable.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseClicked(MouseEvent e) {
				if(processModel.getRowCount()>0) {
					for(int i=processModel.getRowCount(); i>0; i--)
						processModel.removeRow(i-1);
				}
				if(tableMap.size()==0)
					return;
				int i = impTable.getSelectedRow();
				for(Vector<Object> vo : tableMap.get(i)) {
					processModel.addRow(vo);
				}
			}
		});
		searchBtn.addActionListener(new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent arg0) {
				try {
					if(impModel.getRowCount()>0) {
						for(int i=impModel.getRowCount(); i>0; i--)
							impModel.removeRow(i-1);
					}
					if(processModel.getRowCount()>0) {
						for(int i=processModel.getRowCount(); i>0; i--)
							processModel.removeRow(i-1);
					}
					Vector<String> keyV = new Vector<>();
					Vector<String> valueV = new Vector<>();
					for(Entry<String, JComponent> e : compMap.entrySet()) {
						JComponent c = e.getValue();
						String text = "";
						if(c instanceof JTextField)
							text = ((JTextField)c).getText();
						else if(c instanceof PropertyDateComponent)
							text = ((PropertyDateComponent)c).getDateViewModel().getDateString();
						else {
							text = ((JComboBox<?>)c).getSelectedItem().toString();
							if(lovMap.containsKey(e.getKey())) {
								text = lovMap.get(e.getKey()).get(text);
							}
						}
						if(text!=null && !text.isEmpty()) {
//							if(e.getKey().equals("零组件号ID"))
//								text += "GY";
							keyV.add(e.getKey());
							valueV.add(text);
						}
					}
					
					//keyV.add("active_seq");
					//valueV.add("0");
					System.out.println("queryName==="+queryName);
					System.out.println(keyV.toString());
					System.out.println(valueV.toString());
					
					
					
					TCComponent[] result = session.search(queryName, keyV.toArray(new String[0]), valueV.toArray(new String[0]));
					
					System.out.println("result=="+result.length);
					
					
					 //result = TCUtil.query(session, queryName, keyV, valueV);
					//System.out.println("result:"+result.length);

					if(result.length==0) {
						MessageBox.post(dialog, "没有符合条件的工艺，请检查查询条件", "ERROR", MessageBox.ERROR);
						return;
					}
					result = TCUtil.TCsort(result, new int[] { 1, -1 }, "item_id", "item_revision_id");
					TCComponentBOPWindowType bomWinType = (TCComponentBOPWindowType) session.getTypeComponent("BOPWindow");
					TCComponentBOPWindow window = (TCComponentBOPWindow) bomWinType.createBOPWindow(null);
					for(int i=0; i<result.length; i++) {
						Vector<String> v = new Vector<>();
						int num = impModel.getRowCount();
						v.add(num+1+"");
						TCComponentMEProcessRevision meprocess = (TCComponentMEProcessRevision) result[i];
						TCComponentItem pitem = meprocess.getItem();
						TCComponentForm form = TCUtil.getItemRevisionMasterForm(meprocess);
						for(String[] prop : showOptions) {
							if(prop[0].equals("item"))
								v.add(pitem.getProperty(prop[1]));
							else if(prop[0].equals("rev"))
								v.add(meprocess.getProperty(prop[1]));
							else 
								v.add(form.getProperty(prop[1]));
						}
						processVec.add(meprocess);
						impModel.addRow(v);

						TCComponentBOMLine ebom = window.setWindowTopLine(pitem, meprocess, null, null);
						AIFComponentContext[] p = ebom.getChildren();
						Vector<Vector<Object>> vvo = new Vector<>();
						for(AIFComponentContext c : p) {
							Vector<Object> vo = new Vector<>();
							vo.add(true);
							TCComponentBOMLine procedure = (TCComponentBOMLine) c.getComponent();
							TCComponentItem pritem = procedure.getItem();
							if(!(pritem instanceof TCComponentMEProcess) && !(pritem instanceof TCComponentMEOP))
								continue;
							TCComponentItemRevision prrev = procedure.getItemRevision();
							if(pritem instanceof TCComponentMEOP)
								System.out.println(prrev+">>"+prrev.getReferenceProperty("root_activity").getReferenceListProperty("contents").length);
							TCComponentForm prform = TCUtil.getItemRevisionMasterForm(prrev);
							for(String[] prop : procedureOptions) {
								if(prop[0].equals("item"))
									vo.add(pritem.getProperty(prop[1]));
								else if(prop[0].equals("rev"))
									vo.add(prrev.getProperty(prop[1]));
								else if(prop[0].equals("bom"))
									vo.add(procedure.getProperty(prop[1]));
								else 
									vo.add(prform.getProperty(prop[1]));
							}
							vvo.add(vo);
							proceduresMap.put(vo, procedure);
						}
						tableMap.put(num, vvo);
					}
				} catch (Exception e1) {
					e1.printStackTrace();
					MessageBox.post(dialog, "错误：:"+e1.getMessage(), "ERROR", MessageBox.ERROR);
				}
			}
		});
		exportBtn.addActionListener(new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent arg0) {
				try {
					Map<String, String> borrowMap = new HashMap<>();
					for(String s : options.get(2)) {
//						String[] split = s.split("=");
						borrowMap.put(s, "true");
					}
					if(processTable.getRowCount()==0)
						throw new Exception("工序表格内容为空，无法导入");
					TCComponentItemRevision targetRev = targetLine.getItemRevision();
					TCComponentItemRevision proRev = processVec.get(impTable.getSelectedRow());
					if(!targetRev.getType().equals(proRev.getType()))
						throw new Exception("所选工艺类型不同，无法借用");
					TCComponentItemType itemType;
					TCComponentForm targetForm = TCUtil.getItemRevisionMasterForm(targetRev);
//					String revId = targetRev.getProperty("item_revision_id");
//					System.out.println("time1： " + (System.nanoTime() - time0) / 1000000);
					int n = 0;
					for(AIFComponentContext cs : targetLine.getChildren()) {
						int no = Integer.parseInt(((TCComponentBOMLine)cs.getComponent()).getProperty("bl_sequence_no"));
						if(no > n)
							n = no;
					}
					if(n%10 != 0)
						n = n/10*10 + 10;
					else
						n = n + 10;
					
					for(int i=0; i<processModel.getRowCount(); i++) {
						if(!(boolean)processModel.getValueAt(i, 0))
							continue;
//						System.out.println("for： " + (System.nanoTime() - time0) / 1000000);
						Vector<Object> v = tableMap.get(impTable.getSelectedRow()).get(i);
						TCComponentBOMLine p = proceduresMap.get(v);
						TCComponentItemRevision procedure = p.getItemRevision();
						TCComponentItem pitem = procedure.getItem();
						String type = pitem.getType();
						itemType = (TCComponentItemType) session.getTypeService().getTypeComponent(type);
//						TCComponentItem newItem = itemType.create(itemType.getNewID(), revId, type, pitem.getProperty("object_name"), "", null);
//						procedure.saveAsItem(arg0, arg1);
						TCComponentItem newItem = procedure.getItem().getLatestItemRevision().saveAsItem(itemType.getNewID(), "001");
						newItem.lock();
						TCComponentBOMLine newLine = targetLine.add(newItem, null);
						TCComponentItemRevision newRev = newItem.getLatestItemRevision();
						newLine.setProperty("bl_sequence_no", n+"");
						n += 10;
//						copyProperty(p, newLine, num);
						//TODO 
						TCComponentForm proForm = TCUtil.getItemRevisionMasterForm(proRev);
						for(String[] ss : updateProps) {
							if(ss[0].equals("rev")) {
								copyProperty(proRev, targetRev, ss[1]);
							}else if(ss[0].equals("master")) {
								copyProperty(proForm, targetForm, ss[1]);
							}
						}
						TCComponentForm newForm = TCUtil.getItemRevisionMasterForm(newRev);
						for(String[] ss : clearProps) {
							if(ss[0].equals("rev")) {
								newRev.setProperty(ss[1], "");
							}else if(ss[0].equals("master")) {
								newForm.setProperty(ss[1], "");
							}else if(ss[0].equals("item")) {
								newItem.setProperty(ss[1], "");
							}
						}
						
//						num++;
						AIFComponentContext[] children = newLine.getChildren();
						for(AIFComponentContext c : children) {
//							System.out.println("for2： " + (System.nanoTime() - time0) / 1000000);
//							System.out.println("for2： " + (System.nanoTime() - time0) / 1000000);
							TCComponentBOMLine child = (TCComponentBOMLine) c.getComponent();
							TCComponentItem subitem = child.getItem();
							String subtype = subitem.getType();
//							System.out.println("child：" + child +"	"+ (subitem instanceof TCComponentMEOP));
							if(subitem instanceof TCComponentMEOP) {
//								TCComponentItem newOpitem = itemType.create(itemType.getNewID(), "", subtype, subitem.getProperty("object_name"), "", null);
//								TCComponentBOMLine newOpline = newLine.add(newSubItem, null);
//								copyProperty(child, child, 0);
								itemType = (TCComponentItemType) session.getTypeService().getTypeComponent(subtype);
								TCComponentItem newSubItem = child.getItemRevision().saveAsItem(itemType.getNewID(), "");
								TCComponentItemRevision newSubRev = newSubItem.getLatestItemRevision();
								child.replace(newSubItem, newSubRev, null);
							}else if(borrowMap.containsKey(subtype)) {
								if(borrowMap.get(subtype).toLowerCase().equals("false")){
									TCComponentItem newsubItem = itemType.create(itemType.getNewID(), "", subtype, subitem.getProperty("object_name"), "", null);
//									newLine.add(newsubItem, null);
									child.replace(newsubItem, newsubItem.getLatestItemRevision(), null);
								}
							}else {
								child.cut();
							}
//							else 
//								newLine.add(subitem, null);
						}
						newItem.save();
						newItem.unlock();

					}
					List<Object> viewParts = PlatformHelper.getAllViewParts();
					for(Object view : viewParts) {
						if(view==null || !(view instanceof CompatibilityView))
							continue;
//						IViewPart v = ((CompatibilityView)view).getView();
////						System.out.println("ProcessPropertyView： "+((CompatibilityPart)view).ENABLE_DEPENDENCY_INJECTION_FOR_E3_PARTS);
//						if(!(v instanceof ProcessPropertyView))
//							continue;
//						ProcessPropertyView pv = (ProcessPropertyView)v;
//						Field field = pv.getClass().getDeclaredField("panel");
//						field.setAccessible(true);
//						Object editor = field.get(pv);
////						if(editor instanceof ProcessPropertyEditor)
////							((ProcessPropertyEditor) editor).updateSelection(targetLine);
//						Field pfield = ((ProcessPropertyEditor) editor).getClass().getDeclaredField("propPanel");
//						pfield.setAccessible(true);
//						Object panel = pfield.get(((ProcessPropertyEditor) editor));
//						((PropertyPanel)panel).loadData();
					}
					MessageBox.post(dialog, "工序导入成功", "提示", MessageBox.INFORMATION);
					dispose();
				} catch (Exception e1) {
					e1.printStackTrace();
					MessageBox.post(dialog, "错误："+e1.getMessage(), "ERROR", MessageBox.ERROR);
				}
			}
		});
	}
	private void copyProperty(TCComponent a, TCComponent b, String prop) throws Exception {
		TCProperty property = a.getTCProperty(prop);
		if(property==null) {
			System.out.println(a+"未找到属性：" + prop);
			return;
		}
		if(b.getTCProperty(prop)==null) {
			System.out.println(b+"未找到属性：" + prop);
			return;
		}
		int type = property.getPropertyType();
//		System.out.println(prop+">>" + type);
		if(type==TCProperty.PROP_untyped_relation || type==TCProperty.PROP_untyped_reference){
			TCComponentPseudoFolder folder = TCUtil.getPseudoFolder(a, prop);
//			System.out.println("folder:" + folder);
			TCComponent[] cps;
			if(folder == null) {
				cps = property.getReferenceValueArray();
			}else {
				AIFComponentContext[] cxs = folder.getChildren();
				cps = new TCComponent[cxs.length];
				for(int i=0; i<cxs.length; i++)
					cps[i] = (TCComponent) cxs[i].getComponent();
			}
			b.getTCProperty(prop).setReferenceValueArray(cps);
		}else {
			b.setProperty(prop, a.getProperty(prop));
		}
//		System.out.println(a +"=="+ property+">>" + b+"==" + b.getTCProperty(prop));
	}
	
	/*private void copyProperty(TCComponentBOMLine p, TCComponentBOMLine toLine, int num) throws Exception {
		System.out.println("copyProperty:"+p+"	copyProperty： " + (System.nanoTime() - time0) / 1000000);
		if(p.parent()!=null) {
			for(String s : propVecs.get(0)) {
				toLine.setProperty(s, "");
			}
		}
		TCComponentItemRevision rev = toLine.getItemRevision();
		for(String s : propVecs.get(1)) {
			rev.setProperty(s, "");
		}
		
		TCComponentItem item = rev.getItem();
		for(String s : propVecs.get(2)) {
			item.setProperty(s, "");
		}
		
		TCComponentForm form = TCUtil.getItemRevisionMasterForm(rev);
		for(String s : propVecs.get(3)) {
			form.setProperty(s, "");
		}
		if(num>0)
			form.setProperty("ac5_OperationNumber", num*5+"");
		System.out.println("copyProperty： " + (System.nanoTime() - time0) / 1000000);
	}
	private String getProperty(String comp, String prop, TCComponent... comps) throws Exception {
		if(comp.equals("rev"))
			return comps[0].getProperty(prop);
		else if(comp.equals("master"))
			return comps[1].getProperty(prop);
		else if(comp.equals("item"))
			return comps[2].getProperty(prop);
		else 
			return "";
	}*/
}