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
package com.vci.client.portal.UI.v3.comptdesign.compt;
 
import java.awt.BorderLayout;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
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.PortalVIChooseActionListener;
import com.vci.client.portal.UI.v3.comptdesign.compt.al.PortalVIEditActionListener;
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.UI.v3.comptdesign.compt.al.UILayoutChooseActionListener;
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;
import com.vci.common.portal.enums.PortalVIType;
import com.vci.common.portal.enums.PortalVITypeFlag;
 
/**
 * 子UI组件面板
 * 
 * <p>
 * Title:
 * </p>
 * <p>
 * Description:
 * </p>
 * <p>
 * Copyright: Copyright (c) 2016
 * </p>
 * <p>
 * Company: VCI
 * </p>
 * 
 * @author Jason
 * @time 2022-12-27
 * @version 1.0
 */
public class SubUIComptPanel extends BaseComptPanel {
 
    /**
     * 
     */
    private static final long serialVersionUID = -4327897738306488347L;
 
//    protected PortalVIType getPortalVIType() {
//        return PortalVIType.UI;
//    }
 
    /************************ 关联对象 BtmType ********************************/
    private VCIJPanel palBtmType = new VCIJPanel();
    private VCIJLabel lblUIBtmType = new VCIJLabel("对象类型");
    private VCIJTextField txtUIBtmType = new VCIJTextField(true);
    private VCIJButton btnUIBtmType = VCISwingUtil.createVCIJButton("btmType", "", "", "search.png");
    private VCIJButton btnUIBtmTypeEdit = VCISwingUtil.createVCIJButton("btmTypeEdit", "", "", "edit.png");
 
    private VCIJLabel lblChooseUILayout = new VCIJLabel("UI定义");
    private VCIJTextField txtChooseUILayout = new VCIJTextField(true);
    private VCIJButton btnChooseUILayout = VCISwingUtil.createVCIJButton("chooseUILayout", "", "", "search.png");
    private VCIJButton btnChooseUILayoutEdit = VCISwingUtil.createVCIJButton("chooseUILayoutEdit", "", "", "edit.png");
 
    private VCIJLabel lblSearchType = new VCIJLabel("查询类型");
    private ButtonGroup searchTypeGroup = new ButtonGroup();
    private VCIJPanel palRadioBtn = new VCIJPanel();
    private VCIJRadioButton rbtnBtmType = new VCIJRadioButton("业务类型");
    private VCIJRadioButton rbtnLinkType = new VCIJRadioButton("链接类型");
 
    private VCIJLabel lblQryType = new VCIJLabel("查询对象类型");
    private VCIJTextField txtQryType = new VCIJTextField(false);
    private VCIJButton btnQryType = VCISwingUtil.createVCIJButton("qryType", "", "", "search.png");
    private VCIJButton btnQryTypeEdit = VCISwingUtil.createVCIJButton("qryTypeEdit", "", "", "edit.png");
 
    private VCIJLabel lblQueryTemplateName = new VCIJLabel("查询模板");
    private VCIJTextField txtQueryTemplateName = new VCIJTextField(false);
    private VCIJButton btnChooseQT = VCISwingUtil.createVCIJButton("chooseUILayout", "", "", "search.png");
    private VCIJButton btnChooseQTEdit = VCISwingUtil.createVCIJButton("chooseUILayoutEdit", "", "", "edit.png");
    
    BtmTypeChooseActionListener qryBTypeChooseActionListener = new BtmTypeChooseActionListener(this,
            super.getOwnedUIComptDesignDialog(), txtQryType, Arrays.asList(txtQueryTemplateName));
    LinkTypeChooseActionListener qryLTypeChooseActionListener = new LinkTypeChooseActionListener(this,
            super.getOwnedUIComptDesignDialog(), txtQryType, Arrays.asList(txtQueryTemplateName), null);
 
    public SubUIComptPanel(UIComptDesignDialog ownedUIComptDesignDialog) {
        super(ownedUIComptDesignDialog);
    }
 
    @Override
    public boolean checkInputIsOk() {
        boolean res = checkUILayoutInputIsOk();
//        if(rbtnBtmType.isSelected()){
//            res = checkBtmTypeInputIsOk();
//        } else if(rbtnLinkType.isSelected()){
//            res = checkLinkTypeInputIsOk();
//        }
        return res;
    }
 
    private boolean checkUILayoutInputIsOk() {
        boolean res = false;
        if (!(super.checkBtmTypeTxtIsOk(lblUIBtmType, txtUIBtmType))) {
            res = false;
        } else if (!(super.checkUILayoutTxtIsOk(lblChooseUILayout, txtChooseUILayout, txtUIBtmType))) {
            res = false;
        } else if (!(super.checkQTNameTxtIsOk(lblQueryTemplateName, txtQueryTemplateName, txtQryType))) {
            res = false;
        } else {
            res = true;
        }
        return res;
    }
 
    @Override
    public void buildPanel() {
        initUI();
    }
 
    private void initUI() {
        init();
    }
 
    private void init() {
        setLayout(new BorderLayout());
        add(initUILayoutPanel(), BorderLayout.CENTER);
    }
    
 
    private VCIJPanel initUILayoutPanel() {
        VCIJPanel pal = new VCIJPanel();
        pal.setLayout(new GridBagLayout());
 
        pal.add(lblUIBtmType, new GridBagConstraints(1, 0, 1, 1, 0, 0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 0, 5), 0, 0));
        pal.add(txtUIBtmType, new GridBagConstraints(2, 0, 1, 1, 1.0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 0, 1), 0, 0));
        pal.add(btnUIBtmType, new GridBagConstraints(3, 0, 1, 1, 0.0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 0, 0, 0), 0, 0));
        pal.add(btnUIBtmTypeEdit, new GridBagConstraints(4, 0, 1, 1, 0.0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 0, 0, 5), 0, 0));
 
        pal.add(lblChooseUILayout, new GridBagConstraints(1, 1, 1, 1, 0, 0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(1, 5, 0, 5), 0, 0));
        pal.add(txtChooseUILayout, new GridBagConstraints(2, 1, 1, 1, 1.0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(1, 5, 0, 1), 0, 0));
        pal.add(btnChooseUILayout, new GridBagConstraints(3, 1, 1, 1, 0.0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(1, 0, 0, 0), 0, 0));
        pal.add(btnChooseUILayoutEdit, new GridBagConstraints(4, 1, 1, 1, 0.0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(1, 0, 0, 0), 0, 0));
 
        searchTypeGroup.add(rbtnBtmType);
        searchTypeGroup.add(rbtnLinkType);
        
        palRadioBtn.setLayout(new GridBagLayout());
        palRadioBtn.add(rbtnBtmType, new GridBagConstraints(1, 0, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 0, 5), 0, 0));
        palRadioBtn.add(rbtnLinkType, new GridBagConstraints(2, 0, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 0, 5), 0, 0));
        
        ActionListener al = new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                rbtn_actionPerformed(e);
            }
        };
        rbtnBtmType.setObj("btm");
        rbtnLinkType.setObj("linktype");
        
        rbtnBtmType.addActionListener(al);
        rbtnLinkType.addActionListener(al);    
 
        pal.add(lblSearchType, new GridBagConstraints(1, 2, 1, 1, 0, 0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(1, 5, 0, 5), 0, 0));
        pal.add(palRadioBtn, new GridBagConstraints(2, 2, 1, 1, 1.0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(1, 5, 0, 1), 0, 0));
 
        pal.add(lblQryType, new GridBagConstraints(1, 3, 1, 1, 0, 0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(1, 5, 0, 5), 0, 0));
        pal.add(txtQryType, new GridBagConstraints(2, 3, 1, 1, 1.0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(1, 5, 0, 1), 0, 0));
        pal.add(btnQryType, new GridBagConstraints(3, 3, 1, 1, 0.0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(1, 0, 0, 0), 0, 0));
        pal.add(btnQryTypeEdit, new GridBagConstraints(4, 3, 1, 1, 0.0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(1, 0, 0, 5), 0, 0));
 
        pal.add(lblQueryTemplateName, new GridBagConstraints(1, 4, 1, 1, 0, 0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(1, 5, 0, 5), 0, 0));
        pal.add(txtQueryTemplateName, new GridBagConstraints(2, 4, 1, 1, 1.0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(1, 5, 0, 1), 0, 0));
        pal.add(btnChooseQT, new GridBagConstraints(3, 4, 2, 1, 0.0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(1, 0, 0, 0), 0, 0));
        pal.add(btnChooseQTEdit, new GridBagConstraints(4, 4, 1, 1, 0.0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(1, 0, 0, 0), 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, 0), 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(), txtUIBtmType,
                Arrays.asList(txtChooseUILayout));
        btnUIBtmType.addActionListener(btmTypeChooseActionListener);
        super.getActions().add(btmTypeChooseActionListener);
 
        UILayoutChooseActionListener uiLayoutChooseActionListener = new UILayoutChooseActionListener(this,
                super.getOwnedUIComptDesignDialog(), txtChooseUILayout, null, txtUIBtmType);
        
        btnChooseUILayout.addActionListener(uiLayoutChooseActionListener);
        super.getActions().add(uiLayoutChooseActionListener);
 
        super.getActions().add(qryBTypeChooseActionListener);
        super.getActions().add(qryLTypeChooseActionListener);
        
        QTChooseActionListener qTChooseActionListener = new QTChooseActionListener(this,
                super.getOwnedUIComptDesignDialog(), txtQueryTemplateName, null, txtUIBtmType);
        
        btnChooseQT.addActionListener(qTChooseActionListener);
        super.getActions().add(qTChooseActionListener);
 
        // ------------------------------------------------------------------------------
        BtmTypeEditActionListener btmTypeEditActionListener = new BtmTypeEditActionListener(this,
                super.getOwnedUIComptDesignDialog(), txtUIBtmType, null);
        btnUIBtmTypeEdit.addActionListener(btmTypeEditActionListener);
        super.getActions().add(btmTypeEditActionListener);
 
//        PortalVIEditActionListener portalVIEditActionListener = new PortalVIEditActionListener(this,
//                super.getOwnedUIComptDesignDialog(), txtChooseUILayout, null, txtBtmType, getPortalVIType(),
//                PortalVITypeFlag.BtmType);
//        btnChooseUILayoutEdit.addActionListener(portalVIEditActionListener);
//        super.getActions().add(portalVIEditActionListener);
 
        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) {
        txtUIBtmType.setText(d.getSubUiObjType());
        txtChooseUILayout.setText(d.getSubUILayout());
        
        if (d.getSearchTarger().equals("2")) {
            rbtnBtmType.setSelected(false);
            rbtnLinkType.setSelected(true);
            txtQryType.setText(d.getLinkType());
        } else {
            rbtnBtmType.setSelected(true);
            rbtnLinkType.setSelected(false);
            txtQryType.setText(d.getShowType());
        }
        txtQueryTemplateName.setText(d.getQueryTemplateName());
    }
 
    @Override
    public PLDefination getNewPLDefination(PLDefination d) {
        if (d == null) {
            d = new PLDefination();
        }
 
        d.setSearchTarger("1");
        d.setSubUiObjType(txtUIBtmType.getText().toString().trim());
        d.setSubUILayout(txtChooseUILayout.getText().toString().trim());
        
        if (rbtnBtmType.isSelected()) {
            d.setSearchTarger("1");
            d.setShowType(txtQryType.getText().toString().trim());
        } else {
            d.setSearchTarger("2");
            d.setLinkType(txtQryType.getText().toString().trim());
        }
        d.setQueryTemplateName(txtQueryTemplateName.getText().toString().trim());
 
        return d;
    }
    
    
    private void rbtn_actionPerformed(ActionEvent e){
        VCIJRadioButton rbtn = (VCIJRadioButton)e.getSource();
        String rbtnObj = (String)rbtn.getObj();
 
        super.hidePopupDialog();
        //changeDyanmicContentPanel(rbtnObj);
        if (rbtnObj.equals("Btm")) {
            btnQryType.removeActionListener(qryLTypeChooseActionListener);
            btnQryType.addActionListener(qryBTypeChooseActionListener);
        } else {
            btnQryType.removeActionListener(qryBTypeChooseActionListener);
            btnQryType.addActionListener(qryLTypeChooseActionListener);
        }
    }
 
}