/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.connor.ml.tcm.outfile.ML_01;

import java.util.List;

import org.jdesktop.swingx.treetable.DefaultMutableTreeTableNode;
import org.jdesktop.swingx.treetable.DefaultTreeTableModel;
import org.jdesktop.swingx.treetable.TreeTableNode;

import com.connor.ml.tcm.outfile.bean.NodeBean;

/**
 *
 * @author vearn
 */
public class JTreeTableModel extends DefaultTreeTableModel {

    private String[] _names = { "DBOM对象", "EBOM对象","选中", "EBOMID", "物料描述","数量","发布状态","对应父节点"};


	private List<Integer> isNotEditableRow;
	
	
    
    public JTreeTableModel(TreeTableNode node, String[] names) {
        super(node);
        
        _names = names;
    }


	public List<Integer> getIsNotEditableRow() {
		return isNotEditableRow;
	}

	public void setIsNotEditableRow(List<Integer> isNotEditableRow) {
		this.isNotEditableRow = isNotEditableRow;
	}
    
    /**
     * 列的数量
     */
    @Override
    public int getColumnCount() {
        return _names.length;
    }

    /**
     * 表头显示的内容
     */
    @Override
    public String getColumnName(int column) {
        return _names[column];
    }

    /**
     * 返回在单元格中显示的Object
     */
    @Override
    public Object getValueAt(Object node, int column) {
        Object value = null;
        if (node instanceof DefaultMutableTreeTableNode) {
            DefaultMutableTreeTableNode mutableNode = (DefaultMutableTreeTableNode) node;
            Object o = mutableNode.getUserObject();
            if (o != null && o instanceof NodeBean) {
                NodeBean bean = (NodeBean) o;
                value = bean.getValueAt(column);
                if(column == NodeBean.LABEL && value.equals("3")) {
                	value = "";
                }
//                if(column > 4)
//    				System.out.println("getValueAt" + column + "==" + value);
                /*switch (column) {
                    case 0:
                        value = bean.getDbom();
                        break;
                    case 1:
                        value = bean.getEbom();
                        break;
                    case 2:
                        value = bean.getLabel();
                        if(value.equals("3")) {
                        	value = "";
                        }
                        break;
                    case 3:
                        value = bean.getEbomId();
                        break;
                    case 4:
                        value = bean.getEbomDesc();
                        break;
                    case 5:
                        value = bean.getNum();
                        break;
                    case 6:
                        value = bean.getRefreshStatus();
                        break;
                    case 7:
                        value = bean.getParentString();
                        break;
                }*/
            }
        }
        return value;
    }
    
    /**
     * 设置所有单元格都不能编辑
     *
     * @param the node (i.e. row) for which editing is to be determined
     * @param the column for which editing is to be determined
     * @return false
     */
    @Override
    public boolean isCellEditable(Object node, int column) {
    	//if(column == 5)
    	//{
        	return true;
    	//}
    	//else
    	//{
        //	return false;
    	//}
    }
    
    
}
