田源
2024-03-07 4b4083fd73dc27ece42f4835483565eef0e4f608
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
package com.vci.client.portal.UI;
 
import java.awt.BorderLayout;
import java.awt.FlowLayout;
 
import javax.swing.ButtonGroup;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
 
import com.vci.client.LogonApplication;
import com.vci.client.omd.provider.BtmProvider;
import com.vci.client.portal.utility.PLDefination;
import com.vci.client.portal.utility.UITools;
import com.vci.client.ui.swing.VCIOptionPane;
import com.vci.client.ui.table.VCIBaseTableNode;
import com.vci.common.portal.constants.TemplateTypeConstants;
import com.vci.common.utility.ObjectUtility;
import com.vci.corba.common.VCIError;
 
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.awt.GridBagLayout;
import javax.swing.JLabel;
import java.awt.GridBagConstraints;
import javax.swing.JRadioButton;
import java.awt.Insets;
import javax.swing.JComboBox;
 
import com.vci.corba.omd.btm.BtmItem;
import com.vci.corba.portal.data.PLPageDefination;
import com.vci.corba.portal.data.PLUILayout;
import com.vci.corba.portal.data.PLTabPage;
import com.vci.corba.portal.data.PortalVI;
 
public class FormDialog extends JDialog {
 
    private final JPanel contentPanel = new JPanel();
 
    private JButton okButton;
    private JButton cancelButton;
    private JLabel label;
    private ButtonGroup bg = new ButtonGroup();
    private ButtonGroup bg1 = new ButtonGroup();
    private JRadioButton genralRdb;
    private JLabel label_1;
    private JRadioButton rootRdb;
    private JLabel label_2;
    private JComboBox rootObjCom;
    private JLabel label_3;
    private JComboBox rootObjSelectCom;
    
    private PLUILayout plpagelayoutdefination;
    private String plPageDefinationID;
    private PLDefination pldefination;
    private JButton delBtn;
    private JButton button;
    private String btmName;
    private static String buttonArea = "form";
    public FormDialog(PLUILayout plpagelayoutdefination,String btmName) {
        super(LogonApplication.frame,true);
        setTitle("form设计窗口");
        this.plpagelayoutdefination = plpagelayoutdefination;
        this.btmName = btmName;
        setBounds(100, 100, 450, 300);
        init();
        actionListener();
        initRootObjCom();
        initData();
        this.setLocationRelativeTo(null);
        this.setVisible(true);
    }
 
    private void init() {
        getContentPane().setLayout(new BorderLayout());
        contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
        getContentPane().add(contentPanel, BorderLayout.CENTER);
        GridBagLayout gbl_contentPanel = new GridBagLayout();
        gbl_contentPanel.columnWidths = new int[]{0, 0, 0, 0, 0};
        gbl_contentPanel.rowHeights = new int[]{0, 0, 0, 0, 0};
        gbl_contentPanel.columnWeights = new double[]{0.0, 0.0, 0.0, 1.0, Double.MIN_VALUE};
        gbl_contentPanel.rowWeights = new double[]{0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE};
        contentPanel.setLayout(gbl_contentPanel);
        {
            label = new JLabel("模板类型");
            GridBagConstraints gbc_label = new GridBagConstraints();
            gbc_label.insets = new Insets(0, 0, 5, 5);
            gbc_label.gridx = 1;
            gbc_label.gridy = 0;
            contentPanel.add(label, gbc_label);
        }
        {
            genralRdb = new JRadioButton("普通模板");
            GridBagConstraints gbc_radioButton = new GridBagConstraints();
            gbc_radioButton.insets = new Insets(0, 0, 5, 0);
            gbc_radioButton.gridx = 3;
            gbc_radioButton.gridy = 0;
            contentPanel.add(genralRdb, gbc_radioButton);
        }
        {
            label_1 = new JLabel("搜索类型");
            GridBagConstraints gbc_label_1 = new GridBagConstraints();
            gbc_label_1.insets = new Insets(0, 0, 5, 5);
            gbc_label_1.gridx = 1;
            gbc_label_1.gridy = 1;
            contentPanel.add(label_1, gbc_label_1);
        }
        {
            rootRdb = new JRadioButton("本对象属性");
            GridBagConstraints gbc_radioButton_1 = new GridBagConstraints();
            gbc_radioButton_1.insets = new Insets(0, 0, 5, 0);
            gbc_radioButton_1.gridx = 3;
            gbc_radioButton_1.gridy = 1;
            contentPanel.add(rootRdb, gbc_radioButton_1);
        }
        genralRdb.setSelected(true);
        rootRdb.setSelected(true);
        bg.add(genralRdb);
        bg1.add(rootRdb);
        {
            label_2 = new JLabel("源对象");
            GridBagConstraints gbc_label_2 = new GridBagConstraints();
            gbc_label_2.insets = new Insets(0, 0, 5, 5);
            gbc_label_2.gridx = 1;
            gbc_label_2.gridy = 2;
            contentPanel.add(label_2, gbc_label_2);
        }
        {
            rootObjCom = new JComboBox();
            GridBagConstraints gbc_comboBox = new GridBagConstraints();
            gbc_comboBox.insets = new Insets(0, 0, 5, 0);
            gbc_comboBox.fill = GridBagConstraints.HORIZONTAL;
            gbc_comboBox.gridx = 3;
            gbc_comboBox.gridy = 2;
            contentPanel.add(rootObjCom, gbc_comboBox);
        }
        {
            label_3 = new JLabel("选择模板");
            GridBagConstraints gbc_label_3 = new GridBagConstraints();
            gbc_label_3.insets = new Insets(0, 0, 0, 5);
            gbc_label_3.gridx = 1;
            gbc_label_3.gridy = 3;
            contentPanel.add(label_3, gbc_label_3);
        }
        {
            rootObjSelectCom = new JComboBox();
            GridBagConstraints gbc_comboBox_1 = new GridBagConstraints();
            gbc_comboBox_1.fill = GridBagConstraints.HORIZONTAL;
            gbc_comboBox_1.gridx = 3;
            gbc_comboBox_1.gridy = 3;
            contentPanel.add(rootObjSelectCom, gbc_comboBox_1);
        }
        {
            JPanel buttonPane = new JPanel();
            buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT));
            getContentPane().add(buttonPane, BorderLayout.SOUTH);
            {
                button = new JButton("按钮设计");
                buttonPane.add(button);
            }
            {
                delBtn = new JButton("删除");
                buttonPane.add(delBtn);
            }
            {
                okButton = new JButton("保存");
                buttonPane.add(okButton);
            }
            {
                cancelButton = new JButton("关闭");
                buttonPane.add(cancelButton);
            }
        }
    }
 
    private void actionListener(){
        button.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent paramActionEvent) {
                ButtonDialog dialog = new ButtonDialog(null,plpagelayoutdefination,buttonArea);
            }
        });
        rootObjCom.addActionListener(new ActionListener() {
            
            @Override
            public void actionPerformed(ActionEvent arg0) {
                rootObjSelectCom.removeAllItems();
                String selectedItem = (String) rootObjCom.getSelectedItem();
                PortalVI[] portalViInfos;
                try {
                    portalViInfos = UITools.getService().getPortalVIArrayByTypeName(selectedItem);
                    for(int i=0;i<portalViInfos.length;i++){
                        if(portalViInfos[i].viType==1){
                            rootObjSelectCom.addItem(portalViInfos[i].viName);
                        }
                    }
                } catch (VCIError e) {
                    e.printStackTrace();
                }
                rootObjSelectCom.updateUI();
            }
        });
        delBtn.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent paramActionEvent) {
                PLPageDefination plPageDefination = new PLPageDefination();
                plPageDefination.plOId = plPageDefinationID;
                try {
                    boolean flag = UITools.getService().deletePLPageDefination(plPageDefination);
                } catch (VCIError e) {
                    e.printStackTrace();
                }
                dispose();
            }
        });
        okButton.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent arg0) {
                if(pldefination!=null){
                    edit();
                }else{
                    save();
                }
                dispose();
            }
 
            private void edit() {
                PLPageDefination plPageDefination = new PLPageDefination();
                plPageDefination.plOId = plPageDefinationID;
                plPageDefination.plTabPageOId = plpagelayoutdefination.plOId;
                plPageDefination.plType=2;
                PLDefination obj = new PLDefination();
                if(genralRdb.isSelected()){
                    obj.setTemplateType("1");
                    if(rootRdb.isSelected()){
                        obj.setSearchTarger("1");
                        obj.setShowType(String.valueOf(rootObjCom.getSelectedItem()));
                        obj.setTemplateId(String.valueOf(rootObjSelectCom.getSelectedItem()));
                    }
                }
                try {
                    plPageDefination.plDefination = UITools.getPLDefinationText(obj);
                    boolean flag = UITools.getService().updatePLPageDefination(plPageDefination);
                } catch (Throwable e) {
                    e.printStackTrace();
                }
            }
 
            private void save() {
                PLPageDefination plPageDefination = new PLPageDefination();
                plPageDefination.plOId = ObjectUtility.getNewObjectID36();
                plPageDefination.plTabPageOId = plpagelayoutdefination.plOId;
                plPageDefination.plType=2;
                PLDefination obj = new PLDefination();
                if(genralRdb.isSelected()){
                    obj.setTemplateType("1");
                    if(rootRdb.isSelected()){
                        obj.setSearchTarger("1");
                        obj.setShowType(String.valueOf(rootObjCom.getSelectedItem()));
                        obj.setTemplateId(String.valueOf(rootObjSelectCom.getSelectedItem()));
                    }
                }
                try {
                    plPageDefination.plDefination = UITools.getPLDefinationText(obj);
                    boolean flag = UITools.getService().savePLPageDefination(plPageDefination);
                } catch (Throwable e) {
                    e.printStackTrace();
                }
            }
        });
        cancelButton.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent arg0) {
                dispose();
            }
        });
    }
    
    private void initRootObjCom(){
        rootObjCom.addItem("");
        BtmItem[] allBtItems = BtmProvider.getInstance().getAllBtmItems();
        for(int i=0;i<allBtItems.length;i++){
            rootObjCom.addItem(allBtItems[i].name);
        }
        rootObjCom.setSelectedItem(btmName);
    }
    private void  initData(){
        PLPageDefination[] obj;
        PLDefination p ;
        try {
            obj = UITools.getService().getPLPageDefinationsByPageContextOId(plpagelayoutdefination.plOId);
            for(int i=0;i<obj.length;i++){
                if(obj[i].plType==TemplateTypeConstants.FORM){
                    plPageDefinationID = obj[i].plOId;
                    p = UITools.getPLDefination(obj[i].plDefination);
                    if("1".equals(p.getTemplateType())){
                        genralRdb.setSelected(true);
                        if("1".equals(p.getSearchTarger())){
                            rootRdb.setSelected(true);
                            rootObjCom.setSelectedItem(p.getShowType());
                            rootObjSelectCom.setSelectedItem(p.getTemplateId());
                        }
                    }
                    this.pldefination = p;
                }
            }
        } catch (VCIError e) {
            e.printStackTrace();
        } catch (Throwable e) {
            e.printStackTrace();
        }
    }
}