ludc
2025-01-16 986aa62ed00bee39363bab41b4eeb8259d446efd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
package com.vci.client.oq.ui.linkqtexport;
 
import java.io.File;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
 
import javax.swing.JOptionPane;
import javax.swing.JTable;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.DefaultTreeModel;
import javax.swing.tree.TreeNode;
import javax.swing.tree.TreePath;
import javax.swing.tree.TreeSelectionModel;
 
import com.vci.corba.omd.ltm.LinkType;
import com.vci.corba.omd.qtm.QTInfo;
import com.vci.mw.ClientContextVariable;
import com.vci.client.common.providers.ServiceProvider;
import com.vci.client.omd.linktype.LinkTypeStart;
import com.vci.client.oq.QTClient;
import com.vci.client.oq.QTDClient;
import com.vci.client.portal.NewNewUI.Export.ExportTreeCellRenderer;
import com.vci.client.portal.NewNewUI.Export.VCIExportTree;
import com.vci.client.ui.tree.CheckBoxTreeManager;
import com.vci.corba.common.VCIError;
 
//查询模板导出结构树
public class LinkQTExportTree extends VCIExportTree {
 
    private static final long serialVersionUID = 1L;    
    private CheckBoxTreeManager  treeManager = null;
    public CheckBoxTreeManager getTreeManager() {
        return treeManager;
    }
 
    public void setTreeManager(CheckBoxTreeManager treeManager) {
        this.treeManager = treeManager;
    }
    
 
    public LinkQTExportTree(DefaultTreeModel treeModel) {
        super(treeModel);
        this.setCellRenderer(new ExportTreeCellRenderer());    //ExportTreeCellRenderer??
    }
    
    public LinkQTExportTree() {
        super(new DefaultTreeModel(new DefaultMutableTreeNode("业务类型")));        
        this.setCellRenderer(new ExportTreeCellRenderer());    //ExportTreeCellRenderer?
    }
    
    @Override
    public String getExportDataFileName(String paramString, Long paramLong) {
        // TODO Auto-generated method stub
        return paramString + File.separator + "VCIQTMODELFILE"
        + paramLong + ".vciqtf";
    }
 
    @Override
    public String getExportLogFileName(String paramString, Long paramLong) {
        // TODO Auto-generated method stub
        return paramString + File.separator + "VCIQTMODELFILE"
        + paramLong + ".log";
    }
 
    @Override
    public void init() {
        this.getSelectionModel().setSelectionMode(
                TreeSelectionModel.SINGLE_TREE_SELECTION);
        // 刷新分类树
        //this.getPathForRow(0).
        initExportTree(this.getPathForRow(0));
        if (treeManager == null) {
            treeManager = new CheckBoxTreeManager(this);
        }
    }
 
    private QTInfo[] qts = null;
    private LinkType[] linkTypes= null;
    private void initExportTree(TreePath pathForRow) {
        try {
            System.out.println(this.getParent());    
            if (linkTypes == null) {
//                    btmArray = BtmClient.getService().getAllBtmItem("");                
                List<LinkType> es = new ArrayList<LinkType>();
                    linkTypes = LinkTypeStart.getService().getLinkTypes();
                    for (LinkType lt : linkTypes) {
                        QTInfo[] qtWrappers = ServiceProvider.getOMDService().getQTDService().getObjTypeQTs(lt.name);
                        if (qtWrappers.length!=0) {
                            es.add(lt);
                        }
                    }
                    linkTypes = es.toArray(new LinkType[es.size()]);
                //TODO:需修正没有关联查询模板业务类型去掉
                qts = ServiceProvider.getOMDService().getQTDService().getAllQTs();//获取所有查询模板
            }
            DefaultTreeModel dtml = (DefaultTreeModel) this.getModel();
            DefaultMutableTreeNode node = (DefaultMutableTreeNode) pathForRow
                    .getLastPathComponent();
            addExportTreeNode(dtml, node, linkTypes, qts);
            // 展开所有树节点
            TreeNode rootNode = (TreeNode) this.getModel().getRoot();
            TreePath rootPath = new TreePath(rootNode);
            //this.expandAllTreeNode(rootPath, true);
            this.expandPath(rootPath);
            
        } catch (VCIError e1) {
            e1.printStackTrace();
            JOptionPane.showMessageDialog(ClientContextVariable.getFrame(),
                    "刷新分类树异常:" + e1.getMessage(), "系统异常",
                    JOptionPane.ERROR_MESSAGE);
        }
    }
    
    /**
     * 
     * @Title        :addExportTreeNode
     * @Description    :
     * @param dtml
     * @param node
     * @param allBtm
     * @param plActions
     */
    private void addExportTreeNode(DefaultTreeModel dtml,
            DefaultMutableTreeNode node, LinkType[] allBtm/*业务类型树*/,QTInfo[] qts/*查询模板对象*/) {
        // TODO Auto-generated method stub
        // node.removeAllChildren();
        String curBtmName = "";
        Object userObject = node.getUserObject();
        if (!(userObject instanceof String)) {
            //业务类型对象节点
            if (userObject instanceof LinkQTExportBTMNode) {
                LinkType pac = ((LinkQTExportBTMNode) userObject).getBean();
                curBtmName = pac.name;    //业务类型名称
                /*for (LinkType plac : allBtm) {
                    if (plac.fName.equals(curBtmName)) {
                        DefaultMutableTreeNode child = new DefaultMutableTreeNode(new QTExportBTMNode(plac));
                        dtml.insertNodeInto(child, node, node.getChildCount());
                        addExportTreeNode(dtml, child, allBtm, qts);
                    }
                }*/
                // 添加查询模板对象子节点
                for (QTInfo qtItem : qts) {
                    if ((!curBtmName.equals("")) && qtItem.btmName.equals(curBtmName)) {
                        DefaultMutableTreeNode newChild = new DefaultMutableTreeNode(new LinkQTExportQTNode(qtItem));
                        /*TreePath newChildTreePath = new TreePath(newChild);    */
                        dtml.insertNodeInto(newChild, node,node.getChildCount());
                    }
                }
            }
        }else {
            //添加业务类型根节点
            for (LinkType plAction : allBtm) {                
                    DefaultMutableTreeNode newChild = new DefaultMutableTreeNode(new LinkQTExportBTMNode(plAction));//, false
                    dtml.insertNodeInto(newChild, node, node.getChildCount());
                    addExportTreeNode(dtml, newChild, allBtm, qts);                
            }
        }
        dtml.reload(node);    
    }
 
 
    @Override
    public boolean hasSelectExportContent() {
        // TODO Auto-generated method stub
        return false;
    }
 
    @SuppressWarnings("rawtypes")
    @Override
    public HashMap getExportBeans(HashMap arg0, PrintWriter arg1, JTable arg2) {
        // TODO Auto-generated method stub
        return null;
    }
 
    /*@Override
    public HashMap<String, Object> getExportBeans(
            HashMap<String, Object> exportBeansMap, PrintWriter logFileWriter,
            JTable tblExportLog) {
        // TODO Auto-generated method stub
        return null;
    }*/
 
}