EAS BOS 左树右表实现

1、创建左树右表形式的UI,为treeMain添加值改变事件保存并发布

EAS BOS 左树右表实现_第1张图片

为treeMain添加值改变事件:EAS BOS 左树右表实现_第2张图片

2、对发布后生成的代码进行修改

package com.kingdee.eas.dj.test.client;

import javax.swing.event.TreeSelectionEvent;

import org.apache.log4j.Logger;

import com.kingdee.bos.ctrl.swing.tree.DefaultKingdeeTreeNode;
import com.kingdee.bos.metadata.entity.FilterInfo;
import com.kingdee.bos.metadata.entity.FilterItemInfo;
import com.kingdee.bos.metadata.query.util.CompareType;
import com.kingdee.bos.ui.face.CoreUIObject;
import com.kingdee.eas.basedata.org.OrgViewType;
import com.kingdee.eas.ec.basedata.ResourceFactory;
import com.kingdee.eas.ec.basedata.ResourceInfo;
import com.kingdee.eas.ec.common.client.TypeTreeBuilder;
import com.kingdee.eas.framework.ITreeBase;
import com.kingdee.eas.util.client.MsgBox;


public class TestBaseDataListUI extends AbstractTestBaseDataListUI {
    private static final Logger logger = CoreUIObject.getLogger(TestBaseDataListUI.class);

    public TestBaseDataListUI() throws Exception {
        super();
    }

    @Override
    public void onLoad() throws Exception {
        initTree();
        super.onLoad();

        //设置默认选中节点
        if (this.defaultTreeNode != null)
            this.treeMain.setSelectionNode((DefaultKingdeeTreeNode)this.defaultTreeNode);
        else {
            this.treeMain.setSelectionRow(0);
        }

        this.treeMain.expandRow(0);//展开根节点
    }
	
    /**
     * 初始化树形
     */
    protected void initTree() throws Exception {
        buildTypeTree();
    }

    /**
     * 构建树形
     */
    protected void buildTypeTree() throws Exception {
        TypeTreeBuilder builder = new TypeTreeBuilder(getTreeBase(), getTreeFilter(), getRootName());
        builder.buildTypeTree(this, this.treeMain, this.actionOnLoad);
        this.treeMain.setShowsRootHandles(true);
    }
	
    /**
     * 获取树形过滤条件
     * 由此过滤需要显示的节点
     */
    protected FilterInfo getTreeFilter() throws Exception {
        FilterInfo f = new FilterInfo();

        f.getFilterItems().add(
                new FilterItemInfo("industryType.id",
                "00000000-0000-0000-0000-000000000000F7E3790D"));

        return f;
    }
	
    /**
     * 获取树形节点类型
     */
    protected ITreeBase getTreeBase() throws Exception {
        return ResourceFactory.getRemoteInstance();
    }
	
    /**
     * 获取树形根节点名称
     */
    protected String getRootName() {
        return "物资分类";
    }
	
    /**
     * 获取树形当前选中节点的值
     */
    protected Object getSelcetedNodeObject() {
        DefaultKingdeeTreeNode treeNode = (DefaultKingdeeTreeNode)this.treeMain.getLastSelectedPathComponent();

        return treeNode == null ? null : treeNode.getUserObject();
    }
	
    /**
     * 为树形添加节点改变事件
     * 节点改变时根据节点过滤刷新数据
     */
    @Override
    protected void treeMain_valueChanged(TreeSelectionEvent e) throws Exception {
        execQuery();
    }
	
    /**
     * 根据当前选中节点来对数据进行过滤
     */
    @Override
    protected FilterInfo getDefaultFilterForQuery() {
        FilterInfo filter = super.getDefaultFilterForQuery();
		
        if(getSelcetedNodeObject() != null && getSelcetedNodeObject() instanceof ResourceInfo){
            ResourceInfo resource = (ResourceInfo) getSelcetedNodeObject();
            filter.getFilterItems().add(new FilterItemInfo("resouce.id", resource.getId().toString(), CompareType.EQUALS));
        }
		
        return filter;
    }
}

 

你可能感兴趣的:(EAS,BOS)