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
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
package com.vci.client.portal.UI.v3.comptdesign.compt;
 
import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.util.Arrays;
 
import javax.swing.ButtonGroup;
 
import com.vci.client.portal.UI.v3.comptdesign.UIComptDesignDialog;
import com.vci.client.portal.UI.v3.comptdesign.compt.al.BtmTypeChooseActionListener;
import com.vci.client.portal.UI.v3.comptdesign.compt.al.BtmTypeEditActionListener;
import com.vci.client.portal.UI.v3.comptdesign.compt.al.LinkTypeChooseActionListener;
import com.vci.client.portal.UI.v3.comptdesign.compt.al.LinkTypeEditActionListener;
import com.vci.client.portal.UI.v3.comptdesign.compt.al.QTChooseActionListener;
import com.vci.client.portal.UI.v3.comptdesign.compt.al.QTEditActionListener;
import com.vci.client.portal.utility.PLDefination;
import com.vci.client.ui.swing.VCISwingUtil;
import com.vci.client.ui.swing.components.VCIJButton;
import com.vci.client.ui.swing.components.VCIJLabel;
import com.vci.client.ui.swing.components.VCIJPanel;
import com.vci.client.ui.swing.components.VCIJRadioButton;
import com.vci.client.ui.swing.components.VCIJScrollPane;
import com.vci.client.ui.swing.components.VCIJTextField;
 
/**
 * 树 组件定义面板
 * 
 * <p>Title: </p>
 * <p>Description: </p>
 * <p>Copyright: Copyright (c) 2016</p>
 * <p>Company: VCI</p>
 * @author xiongchao
 * @time 2017-2-22
 * @version 1.0
 */
public class TreeComptPanel extends BaseComptPanel {
 
    /**
     * 
     */
    private static final long serialVersionUID = -4664149137809084420L;
    
    /************************  关联对象 BtmType ********************************/
    private VCIJPanel palBtmType = new VCIJPanel();
    private VCIJLabel lblBtmType = new VCIJLabel("业务类型");
    private VCIJTextField txtBtmType = new VCIJTextField(true);
    private VCIJButton btnBtmType = VCISwingUtil.createVCIJButton("btmType", "", "", "search.png");
    private VCIJButton btnBtmTypeEdit = VCISwingUtil.createVCIJButton("btmTypeEdit", "", "", "edit.png");
    
    private VCIJLabel lblLinkType = new VCIJLabel("链接类型");
    private VCIJTextField txtLinkType = new VCIJTextField(false);
    private VCIJButton btnLinkType = VCISwingUtil.createVCIJButton("linkType", "", "", "search.png");
    private VCIJButton btnLinkTypeEdit = VCISwingUtil.createVCIJButton("linkTypeEdit", "", "", "edit.png");
    
    private VCIJLabel lblQueryTemplateName = new VCIJLabel("查询模板");
    private VCIJTextField txtQueryTemplateName = new VCIJTextField(true);
    private VCIJButton btnChooseQT = VCISwingUtil.createVCIJButton("choosePortalVI", "", "", "search.png");
    private VCIJButton btnChooseQTEdit = VCISwingUtil.createVCIJButton("choosePortalVIEdit", "", "", "edit.png");
 
    private VCIJLabel lblShowExpressionRoot = new VCIJLabel("根节点显示表达式");
    private VCIJTextField txtShowExpressionRoot = new VCIJTextField(true);
    
    private VCIJLabel lblShowExpression = new VCIJLabel("树节点显示表达式");
    private VCIJTextField txtShowExpression = new VCIJTextField(true);
    
    private VCIJLabel lblRefTreeSet = new VCIJLabel("参照树设置");
    private VCIJTextField txtRefTreeSet = new VCIJTextField(true);
    
    private VCIJLabel lblSplitChar = new VCIJLabel("分隔符");
    private VCIJTextField txtSplitChar = new VCIJTextField(false);
    
    private VCIJLabel lblExpandMode = new VCIJLabel("展开方式");
    private ButtonGroup expandModeGroup = new ButtonGroup();
    private VCIJRadioButton rbtnExpandModeOne = new VCIJRadioButton("逐级展开", true);
    private VCIJRadioButton rbtnExpandModeAll = new VCIJRadioButton("全部展开");
    
//    private VCIJLabel lblExpandDirect = new VCIJLabel("展开方向");
//    private ButtonGroup expandDirectGroup = new ButtonGroup();
//    private VCIJRadioButton rbtnExpandDirectPositive = new VCIJRadioButton("正向", true);
//    private VCIJRadioButton rbtnExpandDirectOpposite = new VCIJRadioButton("反向");
//    private VCIJCheckBox cbxShowIcon = new VCIJCheckBox("显示图标");
    
    public TreeComptPanel(UIComptDesignDialog ownedUIComptDesignDialog){
        super(ownedUIComptDesignDialog);
    }
    
    @Override
    public boolean checkInputIsOk(){
        boolean res = false;
        res = checkBtmTypeInputIsOk();
        return res;
    }
    
    private boolean checkBtmTypeInputIsOk(){
        boolean res = false;
        if(!(super.checkBtmTypeTxtIsOk(lblBtmType, txtBtmType))){
            res = false;
            return res;
        }
        // 链接类型不为空时,需要同时检查链接类型及链接类型下的查询模板是否有效
        if(!"".equals(txtLinkType.getText().trim())){
            if(!(super.checkLinkTypeTxtIsOk(lblLinkType, txtLinkType))){
                res = false;
                return res;
            } else if(!(super.checkQTNameTxtIsOk(lblQueryTemplateName, txtQueryTemplateName, txtLinkType))){
                res = false;
                return res;
            }
        } else {
        // 链接类型为空时,只需要检查业务类型下的查询模板是否有效
            if(!(super.checkQTNameTxtIsOk(lblQueryTemplateName, txtQueryTemplateName, txtBtmType))){
                res = false;
                return res;
            } 
        }
        
        if(!super.checkRequiredIsOk(lblShowExpressionRoot, txtShowExpressionRoot)){
            res = false;
        }
        else if(!super.checkRequiredIsOk(lblShowExpression, txtShowExpression)){
            res = false;
        }
        else if(!super.checkRequiredIsOk(lblRefTreeSet, txtRefTreeSet)){
            res = false;
        }
        else {
            res = true;
        }
        return res;
    }
    
    @Override
    public void buildPanel(){
        initUI();
    }
    
    private void initUI(){
        init();
    }
    
    private void init(){
        setLayout(new BorderLayout());
        add(getCenterDynamicContentPanel(), BorderLayout.CENTER);
    }
    
    private VCIJPanel getCenterDynamicContentPanel(){
        palBtmType = initBtmTypePanel();
        return palBtmType;
    }
    
    private VCIJPanel initBtmTypePanel(){
        VCIJPanel pal = new VCIJPanel();
        pal.setLayout(new GridBagLayout());
        
        pal.add(lblBtmType,  new GridBagConstraints(1, 0, 1, 1, 0, 0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 0, 5), 0, 0));
        pal.add(txtBtmType, new GridBagConstraints(2, 0, 1, 1, 1.0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 0, 1), 0, 0));
        pal.add(btnBtmType, new GridBagConstraints(3, 0, 1, 1, 0.0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(1, 0, 0, 0), 0, 0));
        pal.add(btnBtmTypeEdit, new GridBagConstraints(4, 0, 1, 1, 0.0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(1, 0, 0, 5), 0, 0));
        
        pal.add(lblLinkType,  new GridBagConstraints(1, 1, 1, 1, 0, 0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 0, 5), 0, 0));
        pal.add(txtLinkType, new GridBagConstraints(2, 1, 1, 1, 1.0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(1, 5, 0, 1), 0, 0));
        pal.add(btnLinkType, new GridBagConstraints(3, 1, 2, 1, 0.0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(1, 0, 0, 0), 0, 0));
        pal.add(btnLinkTypeEdit, new GridBagConstraints(4, 1, 1, 1, 0.0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(1, 0, 0, 0), 0, 0));
        
        pal.add(lblQueryTemplateName,  new GridBagConstraints(1, 2, 1, 1, 0, 0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 0, 5), 0, 0));
        pal.add(txtQueryTemplateName, new GridBagConstraints(2, 2, 1, 1, 1.0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(1, 5, 0, 1), 0, 0));
        pal.add(btnChooseQT, new GridBagConstraints(3, 2, 2, 1, 0.0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(1, 0, 0, 0), 0, 0));
        pal.add(btnChooseQTEdit, new GridBagConstraints(4, 2, 1, 1, 0.0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(1, 0, 0, 5), 0, 0));
 
        pal.add(lblShowExpressionRoot,  new GridBagConstraints(1, 3, 1, 1, 0, 0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 0, 5), 0, 0));
        pal.add(txtShowExpressionRoot, new GridBagConstraints(2, 3, 3, 1, 1.0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(1, 5, 0, 5), 0, 0));
 
        pal.add(lblShowExpression,  new GridBagConstraints(1, 4, 1, 1, 0, 0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 0, 5), 0, 0));
        pal.add(txtShowExpression, new GridBagConstraints(2, 4, 3, 1, 1.0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(1, 5, 0, 5), 0, 0));
        
        pal.add(lblRefTreeSet,  new GridBagConstraints(1, 5, 1, 1, 0, 0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 0, 5), 0, 0));
        pal.add(txtRefTreeSet, new GridBagConstraints(2, 5, 3, 1, 1.0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(1, 5, 0, 5), 0, 0));
        
        txtSplitChar.setText(","); txtSplitChar.setEditable(false);txtSplitChar.setEnabled(false);
        pal.add(lblSplitChar,  new GridBagConstraints(1, 6, 1, 1, 0, 0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 0, 5), 0, 0));
        pal.add(txtSplitChar, new GridBagConstraints(2, 6, 3, 1, 1.0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(1, 5, 0, 5), 0, 0));
        
        expandModeGroup.add(rbtnExpandModeOne);
        expandModeGroup.add(rbtnExpandModeAll);
        VCIJPanel palRbtnExpandMode = new VCIJPanel(new FlowLayout(FlowLayout.LEADING));
        palRbtnExpandMode.add(rbtnExpandModeOne);
        palRbtnExpandMode.add(rbtnExpandModeAll);
        pal.add(lblExpandMode, new GridBagConstraints(1, 7, 1, 1, 0.0, 0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 0, 5), 0, 0));
        pal.add(palRbtnExpandMode, new GridBagConstraints(2, 7, 3, 1, 0.0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(1, 5, 0, 5), 0, 0));
        
//        expandDirectGroup.add(rbtnExpandDirectPositive);
//        expandDirectGroup.add(rbtnExpandDirectOpposite);
//        VCIJPanel palRbtnExpandDirect = new VCIJPanel(new FlowLayout(FlowLayout.LEADING));
//        palRbtnExpandDirect.add(rbtnExpandDirectPositive);
//        palRbtnExpandDirect.add(rbtnExpandDirectOpposite);
//        palRbtnExpandDirect.add(cbxShowIcon);
//        pal.add(lblExpandDirect, new GridBagConstraints(1, 8, 1, 1, 0.0, 0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 0, 5), 0, 0));
//        pal.add(palRbtnExpandDirect, new GridBagConstraints(2, 8, 3, 1, 0.0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 0, 0, 5), 0, 0));
 
        pal.add(new VCIJLabel(""), new GridBagConstraints(1, 15, 4, 1, 1.0, 1.0, GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(5, 5, 0, 5), 0, 0));
        
        VCIJPanel palRes = new VCIJPanel(new BorderLayout());
        palRes.add(new VCIJScrollPane(pal));
        return palRes;
    }
    @Override
    protected void initBtmTypeActionListener(){
        BtmTypeChooseActionListener btmTypeChooseActionListener = new BtmTypeChooseActionListener(
                this, super.getOwnedUIComptDesignDialog(), txtBtmType, Arrays.asList(
                        txtLinkType, txtQueryTemplateName));
        btnBtmType.addActionListener(btmTypeChooseActionListener);
        super.getActions().add(btmTypeChooseActionListener);
        
        LinkTypeChooseActionListener linkTypeChooseActionListener = new LinkTypeChooseActionListener(
                this, super.getOwnedUIComptDesignDialog(), txtLinkType,
                Arrays.asList(txtQueryTemplateName), txtBtmType);
        btnLinkType.addActionListener(linkTypeChooseActionListener);
        super.getActions().add(linkTypeChooseActionListener);
        
        QTChooseActionListener qTChooseActionListener = new QTChooseActionListener(
                this, super.getOwnedUIComptDesignDialog(), txtQueryTemplateName, 
                null, txtLinkType){
            @Override
            public void actionPerformed(ActionEvent e) {
                if(!"".equals(txtLinkType.getText().trim())){
                    setBtmLinkTypeTextField(txtLinkType);
                } else {
                    setBtmLinkTypeTextField(txtBtmType);
                }
                super.actionPerformed(e);
            }
        };
        btnChooseQT.addActionListener(qTChooseActionListener);
        super.getActions().add(qTChooseActionListener);
        
        
 
        BtmTypeEditActionListener btmTypeEditActionListener = new BtmTypeEditActionListener(
                this, super.getOwnedUIComptDesignDialog(), txtBtmType, null);
        btnBtmTypeEdit.addActionListener(btmTypeEditActionListener);
        super.getActions().add(btmTypeEditActionListener);
        
        LinkTypeEditActionListener linkTypeEditActionListener = new LinkTypeEditActionListener(
                this, super.getOwnedUIComptDesignDialog(), txtLinkType, null);
        btnLinkTypeEdit.addActionListener(linkTypeEditActionListener);
        super.getActions().add(linkTypeEditActionListener);
        
        QTEditActionListener qtEditAction = new QTEditActionListener(
                this, super.getOwnedUIComptDesignDialog(), txtQueryTemplateName, null);
        btnChooseQTEdit.addActionListener(qtEditAction);
        super.getActions().add(qtEditAction);
    }
    
    @Override
    protected void initLinkTypeActionListener(){
        
    }
    
    @Override
    public void setDataToUISpec(PLDefination d) {
        txtBtmType.setText(d.getShowType());
        if(!"".equals(d.getLinkType())){
            txtLinkType.setText(d.getLinkType());
        }
        txtQueryTemplateName.setText(d.getTemplateId());
        txtShowExpressionRoot.setText(d.getRootContent());
        txtShowExpression.setText(d.getShowAbs());
        txtRefTreeSet.setText(d.getShowLinkAbs());
        if(d.getSeparator() == null || "".equals(d.getSeparator())){
            txtSplitChar.setText(",");
        } else {
            txtSplitChar.setText(d.getSeparator());
        }
        if("1".equals(d.getExpandMode())){
            rbtnExpandModeOne.setSelected(true);
        } else if("0".equals(d.getExpandMode())){
            rbtnExpandModeAll.setSelected(true);
        } 
//        if(d.getOrientation().equals(QTConstants.DIRECTION_POSITIVE)){
//            rbtnExpandDirectPositive.setSelected(true);
//        }
//        else if(d.getOrientation().equals(QTConstants.DIRECTION_OPPOSITE)){
//            rbtnExpandDirectOpposite.setSelected(true);
//        }
//        if("1".equals(d.getIsShowImage())){
//            cbxShowIcon.setSelected(true);
//        }
    }
 
    @Override
    public PLDefination getNewPLDefination(PLDefination d) {
        if(d == null){
            d = new PLDefination();
        }
        d.setShowType(txtBtmType.getText().toString());
        d.setLinkType(txtLinkType.getText().toString());
        d.setTemplateId(txtQueryTemplateName.getText().toString());
        d.setRootContent(txtShowExpressionRoot.getText().trim());
        d.setShowAbs(txtShowExpression.getText().trim());
        d.setShowLinkAbs(txtRefTreeSet.getText().trim());
        d.setSeparator(txtSplitChar.getText().trim());
        if(rbtnExpandModeOne.isSelected()){
            d.setExpandMode("1");
        } else if(rbtnExpandModeAll.isSelected()){
            d.setExpandMode("0");
        }
//        if(rbtnExpandDirectPositive.isSelected()){
//            d.setOrientation(QTConstants.DIRECTION_POSITIVE);
//        } else if(rbtnExpandDirectOpposite.isSelected()){
//            d.setOrientation(QTConstants.DIRECTION_OPPOSITE);
//        }
//        d.setIsShowImage(cbxShowIcon.isSelected() ? "1":"0");
        return d;
    }
 
}