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
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
package com.vci.client.portal.UI.v3.comptdesign;
 
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Dialog;
import java.awt.FlowLayout;
import java.awt.Frame;
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.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
 
import javax.swing.ButtonGroup;
import javax.swing.DefaultListModel;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
 
import com.vci.client.portal.UI.ClickEventInfoPanel;
import com.vci.client.portal.UI.v3.comptdesign.compt.BaseComptPanel;
import com.vci.client.portal.UI.v3.comptdesign.compt.CustomComptPanel;
import com.vci.client.portal.UI.v3.comptdesign.compt.FormComptPanel;
import com.vci.client.portal.UI.v3.comptdesign.compt.SubUIComptPanel;
import com.vci.client.portal.UI.v3.comptdesign.compt.TableComptPanel;
import com.vci.client.portal.UI.v3.comptdesign.compt.TreeComptPanel;
import com.vci.client.portal.UI.v3.comptdesign.compt.TreeTableComptPanel;
import com.vci.client.portal.utility.PLDefination;
import com.vci.client.portal.utility.UITools;
import com.vci.client.ui.swing.VCISwingUtil;
import com.vci.client.ui.swing.components.VCIJButton;
import com.vci.client.ui.swing.components.VCIJDialog;
import com.vci.client.ui.swing.components.VCIJIntegerTextField;
import com.vci.client.ui.swing.components.VCIJLabel;
import com.vci.client.ui.swing.components.VCIJOptionPane;
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.VCIJTextArea;
import com.vci.client.ui.swing.components.VCIJTextField;
import com.vci.common.portal.enums.ComponentType;
import com.vci.common.utility.ObjectUtility;
import com.vci.corba.common.VCIError;
import com.vci.corba.portal.data.PLPageDefination;
import com.vci.corba.portal.data.PLTabPage;
 
public class UIComptDesignDialog extends VCIJDialog {
    
    /**
     * 
     */
    private static final long serialVersionUID = -1149485725224247322L;
    private String title = "页面设计窗口";
    private int width = 750;
    private int height = 700;
    private Component relativeToCompt = null;
 
    private PLTabPage tabPage = null;
    private PLPageDefination pageDefination = null;
    
    private VCIJLabel lblName = new VCIJLabel("名称");
    private VCIJTextField txtName = new VCIJTextField(true);
    private VCIJLabel lblSeq = new VCIJLabel("编号");
    private VCIJIntegerTextField txtSeq = new VCIJIntegerTextField("");
    private VCIJLabel lblDesc = new VCIJLabel("描述");
    private VCIJTextArea txtDesc = new VCIJTextArea(false);
    private VCIJLabel lblUIParser = new VCIJLabel("UI解析类型");
    private VCIJTextArea txtUIParser = new VCIJTextArea(false);
    private final String lblUIParserNoteContent = "" +
            "<html>" +
            "<p color='red'>示例:java_cs:xxx;java_bs:xxx;net_cs:xxx;net_bs:xxx;mobile_cs:xx;mobile_bs:xxx;</p>" +
            "<p color='blue'>1、用英文半角分号;分隔各组值;(这里结尾的是中文字符的分号)</p>" +
            "<p color='blue'>2、每组用英文半角冒号:分隔单一扩展属性名称及属性值;</p>" +
            "<p color='blue'>3、其中的xxx是各种解析类的完整类型名称(完全限定名);</p>" +
            "<p color='blue'>4、输入时,不要敲回车换行;</p>" +
            "<p><br/></p>" +
            "</html>";
    
    private VCIJLabel lblExtAttrs = new VCIJLabel("扩展属性");
    private VCIJTextArea txtExtAttrs = new VCIJTextArea(false);
    private final String lblExtAttrNoteContent = "" +
            "<html>" +
            "<p color='red'>示例:ext1:xx;ext2;ext3:xx;ext4:xxx;extn:xxx;</p>" +
            "<p color='blue'>1、用英文半角分号;分隔各组值;</p>" +
            "<p color='blue'>2、每组用英文半角冒号:分隔单一扩展属性名称及属性值;</p>" +
            "<p color='blue'>3、可以定义任意组,但总字符长度不得超过4000;</p>" +
            "<p color='blue'>4、输入时,不要敲回车换行;</p>" +
            "<p><br/></p>" +
            "</html>";
    
    private VCIJLabel lblComptType = new VCIJLabel("模板类型");
    private ButtonGroup rbtnComptTypeGroup = new ButtonGroup();
    private VCIJRadioButton rbtnComptTypeTable = new VCIJRadioButton("Table(表格)");
    private VCIJRadioButton rbtnComptTypeCustom= new VCIJRadioButton("Custom(自定义模板)");
    private VCIJRadioButton rbtnComptTypeTreeTable = new VCIJRadioButton("TreeTable(树表)");
    private VCIJRadioButton rbtnComptTypeForm = new VCIJRadioButton("Form(表单)");
    private VCIJRadioButton rbtnComptTypeTree = new VCIJRadioButton("Tree(树)");
    private VCIJRadioButton rbtnComptTypeUI = new VCIJRadioButton("UILayout(UI定义)");
    
    private VCIJLabel lblShowType = new VCIJLabel("显示类型");
    private ButtonGroup rbtnShowTypeGroup = new ButtonGroup();
    private VCIJRadioButton rbtnShowTypeNotShow = new VCIJRadioButton("不显示");
    private VCIJRadioButton rbtnShowTypeShowRole= new VCIJRadioButton("显示角色");
    private VCIJRadioButton rbtnShowTypeShowFolder = new VCIJRadioButton("显示Folder");
    
    private VCIJPanel dynamicContentPanel = new VCIJPanel(new BorderLayout());
    
    // 表格 组件
    private TableComptPanel tableComptPanel = null;
    // 自定义 组件
    private CustomComptPanel customComptPanel = null;
    // TreeTable 组件
    private TreeTableComptPanel treeTableComptPanel = null;
    // 表单 组件
    private FormComptPanel formComptPanel = null;
    // Tree 组件
    private TreeComptPanel treeComptPanel = null;
    // 子UI 组件
    private SubUIComptPanel subUIComptPanel = null;
    
    // 组件类型对应的组件实例Map
    private Map<ComponentType, BaseComptPanel> uiComptPanelMap = new HashMap<ComponentType, BaseComptPanel>();
    // 组件类型对应的rbtnMap
    private Map<ComponentType, VCIJRadioButton> comptTypeToRbtnMap = new HashMap<ComponentType, VCIJRadioButton>();
    
    private ClickEventInfoPanel eventInfoPanel = null;
    private VCIJButton btnOk = VCISwingUtil.createVCIJButton("ok", "确定", "确定", "accept.png", new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            btnOk_actionPerformed(e);
        }
    });
    private VCIJButton btnCancel = VCISwingUtil.createVCIJButton("cancel", "取消", "取消", "cancel.png", new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            btnCancel_actionPerformed(e);
        }
    });
    
    public UIComptDesignDialog(Dialog ownerDialg, boolean modal){
        super(ownerDialg, modal);
    }
    public UIComptDesignDialog(Frame ownerFrame, boolean modal){
        super(ownerFrame, modal);
    }
    public void buildDialog(){
        init();
        initDataToUI();
    }
    
    private void init(){
        setLayout(new BorderLayout());
        getContentPane().setLayout(new BorderLayout());
        
        initComptTypeToRbtnMap();
        
        add(getNorthNormalInfoPanel(), BorderLayout.NORTH);
        add(getCenterDynamicContentPanel(), BorderLayout.CENTER);
        add(getSouthButtonPanel(), BorderLayout.SOUTH);
        
        rbtnComptTypeTable.setSelected(true);
        rbtnComptTypeTable.doClick();
        setLocationAndSize();
    }
 
    private void initComptTypeToRbtnMap(){
        comptTypeToRbtnMap.put(ComponentType.Table, rbtnComptTypeTable);
        comptTypeToRbtnMap.put(ComponentType.Custom, rbtnComptTypeCustom);
        comptTypeToRbtnMap.put(ComponentType.TreeTable, rbtnComptTypeTreeTable);
        comptTypeToRbtnMap.put(ComponentType.Form, rbtnComptTypeForm);
        comptTypeToRbtnMap.put(ComponentType.Tree, rbtnComptTypeTree);
        comptTypeToRbtnMap.put(ComponentType.UILayout, rbtnComptTypeUI);
    }
    
    private void initDataToUI(){
        if(getPageDefination() == null) return;
        
        PLPageDefination pd = getPageDefination();
        PLDefination d = null;
        try {
            d = UITools.getPLDefination(pd.plDefination);
        } catch (Throwable e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        txtName.setText(pd.name);
        txtSeq.setText(String.valueOf(pd.seq));
        txtDesc.setText(pd.desc);
        if(d != null){
            txtUIParser.setText(d.getUiParser());
            txtExtAttrs.setText(d.getExtAttr());
 
            if ("1".equals(d.getNavigatorType())) {
                rbtnShowTypeNotShow.setSelected(true);
                rbtnShowTypeNotShow.doClick();
            } else if("2".equals(d.getNavigatorType())){
                rbtnShowTypeShowRole.setSelected(true);
                rbtnShowTypeShowRole.doClick();
            } else if("3".equals(d.getNavigatorType())){
                rbtnShowTypeShowFolder.setSelected(true);
                rbtnShowTypeShowFolder.doClick();
            }
        }
        
        ComponentType comptType = ComponentType.getByVal(Integer.valueOf(d.getTemplateType()));
        if(comptTypeToRbtnMap.containsKey(comptType)){
            VCIJRadioButton rbtn = comptTypeToRbtnMap.get(comptType);
            rbtn.setSelected(true);
            rbtn.doClick();
        }
        initEventData(d);
    }
    
    private void initEventData(PLDefination d){
        String eventKey = d.getEventKey();
        String[] eventKeySplit = eventKey.split(",");
        String eventValue = d.getEventValue();
        String[] eventValueSplit = eventValue.split(",");
        String listValue = "";
        for(int i=0;i<eventKeySplit.length;i++){
            String[] eventValueSplits = eventValueSplit[i].split(";");
            for(int j=0;j<eventValueSplits.length;j++){
                if(!"".equals(eventKeySplit[i])){
                    listValue = eventKeySplit[i] + ":" + eventValueSplits[j];
                    eventInfoPanel.getListModel().addElement(listValue);
                }
            }
        }
    }
 
    private VCIJPanel getNorthNormalInfoPanel(){
        VCIJPanel pal = new VCIJPanel();
        pal.setBorder(new EmptyBorder(5, 5, 5, 5));
        GridBagLayout gbl_contentPanel = new GridBagLayout();
        pal.setLayout(gbl_contentPanel);
 
        GridBagConstraints gbc_label_9 = new GridBagConstraints();
        gbc_label_9.insets = new Insets(0, 0, 0, 0);
        gbc_label_9.gridx = 1;
        gbc_label_9.gridy = 0;
        pal.add(lblName, gbc_label_9);
 
        txtName = new VCIJTextField(true);
        GridBagConstraints gbc_nameTxt = new GridBagConstraints();
        gbc_nameTxt.insets = new Insets(0, 0, 0, 0);
        gbc_nameTxt.fill = GridBagConstraints.BOTH;
        gbc_nameTxt.gridx = 2;
        gbc_nameTxt.gridy = 0;
        pal.add(txtName, gbc_nameTxt);
 
        GridBagConstraints gbc_label_11 = new GridBagConstraints();
        gbc_label_11.insets = new Insets(1, 0, 0, 0);
        gbc_label_11.gridx = 1;
        gbc_label_11.gridy = 1;
        pal.add(lblSeq, gbc_label_11);
 
        txtSeq = new VCIJIntegerTextField("");
        txtSeq.setRequired(true);
        GridBagConstraints gbc_seqTxt = new GridBagConstraints();
        gbc_seqTxt.insets = new Insets(1, 0, 0, 0);
        gbc_seqTxt.fill = GridBagConstraints.BOTH;
        gbc_seqTxt.gridx = 2;
        gbc_seqTxt.gridy = 1;
        gbc_seqTxt.weightx = 1.0;
        pal.add(txtSeq, gbc_seqTxt);
 
        GridBagConstraints gbc_label_10 = new GridBagConstraints();
        gbc_label_10.insets = new Insets(0, 0, 0, 0);
        gbc_label_10.gridx = 3;
        gbc_label_10.gridy = 0;
        pal.add(lblDesc, gbc_label_10);
 
        VCIJScrollPane  scrollPane = new VCIJScrollPane();
        GridBagConstraints gbc_scrollPane = new GridBagConstraints();
        gbc_scrollPane.gridheight = 2;
        gbc_scrollPane.insets = new Insets(0, 0, 0, 0);
        gbc_scrollPane.fill = GridBagConstraints.BOTH;
        gbc_scrollPane.gridx = 4;
        gbc_scrollPane.gridy = 0;
        gbc_scrollPane.weightx = 1.0;
        pal.add(scrollPane, gbc_scrollPane);
 
        txtDesc = new VCIJTextArea();
        txtDesc.setRows(2);
        txtDesc.setWrapStyleWord(true);
        txtDesc.setLineWrap(true);
        scrollPane.setViewportView(txtDesc);
 
        
        /************************  UI解析类、扩展属性定义 ****************************/
        {
            gbc_scrollPane = new GridBagConstraints();
            gbc_scrollPane.insets = new Insets(1, 0, 0, 0);
            gbc_scrollPane.gridx = 1;
            gbc_scrollPane.gridy = 3;
            pal.add(lblUIParser, gbc_scrollPane);
        }
        {
            scrollPane = new VCIJScrollPane();
            gbc_scrollPane = new GridBagConstraints();
            gbc_scrollPane.insets = new Insets(1, 0, 0, 0);
            gbc_scrollPane.fill = GridBagConstraints.BOTH;
            gbc_scrollPane.gridx = 2;
            gbc_scrollPane.gridy = 3;
            pal.add(scrollPane, gbc_scrollPane);
            {
                txtUIParser = new VCIJTextArea();
                txtUIParser.setRows(2);
                txtUIParser.setWrapStyleWord(true);
                txtUIParser.setLineWrap(true);
                txtUIParser.setToolTipText(lblUIParserNoteContent);
                scrollPane.setViewportView(txtUIParser);
            }
        }
 
        {
            GridBagConstraints gbc_label_3 = new GridBagConstraints();
            gbc_label_3.insets = new Insets(0, 0, 0, 0);
            gbc_label_3.gridx = 3;
            gbc_label_3.gridy = 3;
            pal.add(lblExtAttrs, gbc_label_3);
        }
        {
            scrollPane = new VCIJScrollPane();
            gbc_scrollPane = new GridBagConstraints();
            gbc_scrollPane.fill = GridBagConstraints.BOTH;
            gbc_scrollPane.gridx = 4;
            gbc_scrollPane.gridy = 3;
            gbc_scrollPane.weightx = 4.0;
            pal.add(scrollPane, gbc_scrollPane);
            {
                txtExtAttrs = new VCIJTextArea();
                txtExtAttrs.setRows(2);
                txtExtAttrs.setWrapStyleWord(true);
                txtExtAttrs.setLineWrap(true);
                txtExtAttrs.setToolTipText(lblExtAttrNoteContent);
                scrollPane.setViewportView(txtExtAttrs);
            }
        }
        /************************  UI解析类、扩展属性定义 ****************************/
        {
            GridBagConstraints gbc_label = new GridBagConstraints();
            gbc_label.insets = new Insets(0, 0, 0, 0);
            gbc_label.gridx = 1;
            gbc_label.gridy = 5;
            pal.add(lblComptType, gbc_label);
        }
        {
            VCIJPanel panel = new VCIJPanel(new FlowLayout(FlowLayout.LEFT));
            GridBagConstraints gbc_panel = new GridBagConstraints();
            gbc_panel.insets = new Insets(0, 0, 0, 0);
            gbc_panel.gridwidth = 2;
            gbc_panel.fill = GridBagConstraints.BOTH;
            gbc_panel.gridx = 2;
            gbc_panel.gridy = 5;
            pal.add(panel, gbc_panel);
            {
                panel.add(rbtnComptTypeTable);
            }
            {
                panel.add(rbtnComptTypeCustom);
            }
            {
                panel.add(rbtnComptTypeTreeTable);
            }
            
            VCIJPanel panel2 = new VCIJPanel(new FlowLayout(FlowLayout.LEFT));
            GridBagConstraints gbc_panel2 = new GridBagConstraints();
            gbc_panel2.insets = new Insets(0, 0, 0, 0);
            gbc_panel2.gridwidth = 2;
            gbc_panel2.fill = GridBagConstraints.BOTH;
            gbc_panel2.gridx = 2;
            gbc_panel2.gridy = 6;
            pal.add(panel2, gbc_panel2);
            {
                panel2.add(rbtnComptTypeForm);
            }
            {
                panel2.add(rbtnComptTypeTree);
            }
            {
                panel2.add(rbtnComptTypeUI);
            }
            
            rbtnComptTypeGroup.add(rbtnComptTypeTable);
            rbtnComptTypeGroup.add(rbtnComptTypeCustom);
            rbtnComptTypeGroup.add(rbtnComptTypeTreeTable);
            rbtnComptTypeGroup.add(rbtnComptTypeForm);
            rbtnComptTypeGroup.add(rbtnComptTypeTree);
            rbtnComptTypeGroup.add(rbtnComptTypeUI);
            initComptTypeRbtnActionListener();
        }
 
        GridBagConstraints gbc_label_2 = new GridBagConstraints();
        gbc_label_2.insets = new Insets(0, 0, 0, 0);
        gbc_label_2.gridx = 1;
        gbc_label_2.gridy = 7;
        pal.add(lblShowType, gbc_label_2);
 
        VCIJPanel panel_1 = new VCIJPanel();
        FlowLayout flowLayout = (FlowLayout) panel_1.getLayout();
        flowLayout.setAlignment(FlowLayout.LEFT);
        GridBagConstraints gbc_panel_1 = new GridBagConstraints();
        gbc_panel_1.gridwidth = 2;
        gbc_panel_1.fill = GridBagConstraints.BOTH;
        gbc_panel_1.gridx = 2;
        gbc_panel_1.gridy = 7;
        pal.add(panel_1, gbc_panel_1);
 
        
        rbtnShowTypeNotShow.setSelected(true);
        panel_1.add(rbtnShowTypeNotShow);
        rbtnShowTypeGroup.add(rbtnShowTypeNotShow);
 
        panel_1.add(rbtnShowTypeShowRole);
        rbtnShowTypeGroup.add(rbtnShowTypeShowRole);
        
        panel_1.add(rbtnShowTypeShowFolder);
        rbtnShowTypeGroup.add(rbtnShowTypeShowFolder);
 
        return pal;
    }
    
    private void initComptTypeRbtnActionListener(){
        ActionListener al = new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                rbtnComptType_actionPerformed(e);
            }
        };
        rbtnComptTypeTable.setObj(ComponentType.Table);
        rbtnComptTypeCustom.setObj(ComponentType.Custom);
        rbtnComptTypeTreeTable.setObj(ComponentType.TreeTable);
        rbtnComptTypeForm.setObj(ComponentType.Form);
        rbtnComptTypeTree.setObj(ComponentType.Tree);
        rbtnComptTypeUI.setObj(ComponentType.UILayout);
        
        rbtnComptTypeTable.addActionListener(al);
        rbtnComptTypeCustom.addActionListener(al);
        rbtnComptTypeTreeTable.addActionListener(al);
        rbtnComptTypeForm.addActionListener(al);
        rbtnComptTypeTree.addActionListener(al);
        rbtnComptTypeUI.addActionListener(al);
    }
    
    private ComponentType lastComponentType = null;
    private BaseComptPanel lastComptPanel = null;
    
    private void rbtnComptType_actionPerformed(ActionEvent e){
        VCIJRadioButton rbtn = (VCIJRadioButton)e.getSource();
        ComponentType comptType = (ComponentType) rbtn.getObj();
        if(lastComponentType != null && comptType.getIntVal() == lastComponentType.getIntVal()){
            return;
        }
        lastComponentType = comptType;
        changeDyanmicContentPanel(comptType);
    }
    
    private void changeDyanmicContentPanel(ComponentType comptType){
        BaseComptPanel comptPanel = tableComptPanel;
        if(uiComptPanelMap.containsKey(comptType)){
            comptPanel = uiComptPanelMap.get(comptType);
        } else {
            comptPanel = initComptPanelToMap(comptType);
        }
        if(lastComptPanel != null){
            lastComptPanel.hidePopupDialog();
        }
        lastComptPanel = comptPanel;
        
        dynamicContentPanel.removeAll();
        dynamicContentPanel.add(comptPanel, BorderLayout.CENTER);
        try {
            comptPanel.setDataToUI(getPageDefination());
        } catch (Throwable e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        dynamicContentPanel.updateUI();
        if(getContentPane() instanceof JPanel){
            ((JPanel)getContentPane()).updateUI();
        }
    }
    
    private BaseComptPanel initComptPanelToMap(ComponentType comptType){
        BaseComptPanel res = null;
        if(ComponentType.Table.getIntVal() == comptType.getIntVal()){
            tableComptPanel = new TableComptPanel(this);
            res = tableComptPanel;
 
            uiComptPanelMap.put(ComponentType.Table, tableComptPanel);
        }else if(ComponentType.Custom.getIntVal() == comptType.getIntVal()){
            customComptPanel = new CustomComptPanel(this);
            res = customComptPanel;
 
            uiComptPanelMap.put(ComponentType.Custom, customComptPanel);
        }else if(ComponentType.TreeTable.getIntVal() == comptType.getIntVal()){
            treeTableComptPanel = new TreeTableComptPanel(this);
            res = treeTableComptPanel;
            
            uiComptPanelMap.put(ComponentType.TreeTable, treeTableComptPanel);
        }else if(ComponentType.Form.getIntVal() == comptType.getIntVal()){
            formComptPanel = new FormComptPanel(this);
            res = formComptPanel;
 
            uiComptPanelMap.put(ComponentType.Form, formComptPanel);
        }else if(ComponentType.Tree.getIntVal() == comptType.getIntVal()){
            treeComptPanel = new TreeComptPanel(this);
            res = treeComptPanel;
 
            uiComptPanelMap.put(ComponentType.Tree, treeComptPanel);
        }else if(ComponentType.UILayout.getIntVal() == comptType.getIntVal()){
            subUIComptPanel = new SubUIComptPanel(this);
            res = subUIComptPanel;
 
            uiComptPanelMap.put(ComponentType.UILayout, subUIComptPanel);
        }
        res.buildPanel();
        res.initActionListener();
        return res;
    }
    private VCIJPanel getCenterDynamicContentPanel(){
        dynamicContentPanel = new VCIJPanel(new BorderLayout());
        return dynamicContentPanel;
    }
    
    private VCIJPanel getSouthButtonPanel(){
        VCIJPanel palRes = new VCIJPanel(new BorderLayout());
        VCIJPanel pal = new VCIJPanel();
        pal.add(btnOk);
        pal.add(btnCancel);
        
        eventInfoPanel = new ClickEventInfoPanel();
        palRes.add(eventInfoPanel, BorderLayout.CENTER);
        palRes.add(pal, BorderLayout.SOUTH);
        return palRes;
    }
 
    private void setLocationAndSize(){
        setTitle(getTitle());
        setSize(getWidth(), getHeight());
        setLocationRelativeTo(getRelativeToCompt());
    }
    
    private void btnOk_actionPerformed(ActionEvent e){
        try{
            PLPageDefination pd = getPageDefination();
            PLDefination d = null;
            boolean isEdit = (pd != null);
            if(isEdit){
                d = UITools.getPLDefination(pd.plDefination);
            } else {
                pd = new PLPageDefination();
                d = new PLDefination();
                pd.plTabPageOId = getTabPage().plOId;
                pd.plOId = ObjectUtility.getNewObjectID36();
            }
            if(!baseInfoIsOk(pd, isEdit)){
                return;
            }
            setUIValueToObject(pd, d);
            if(!newPLDefinationIsOk(pd, isEdit)){
                return;
            }
            BaseComptPanel comptPanel = getLastComptPanel();
            
            // 检查各个组件内部的数据是否有效
            if(!comptPanel.checkInputIsOk()){
                return;
            }
            
            d = comptPanel.getNewPLDefination(d);
            d = setEventDataToPLDefination(d);
            pd.plDefination = UITools.getPLDefinationText(d);
            
            boolean res = false;
            if(isEdit){
                res = UITools.getService().updatePLPageDefination(pd);
            } else {
                res = UITools.getService().savePLPageDefination(pd);
            }
            if(res){
                close(DialogResult.OK);
            } 
        }catch(Throwable ex){
            //TODO
            ex.printStackTrace();
        }
    }
    
    private boolean baseInfoIsOk(PLPageDefination pd, boolean isEdit) throws VCIError{
        boolean res = false;
        if(!checkRequiredIsOk(lblName, txtName)){
            return false;
        }
        else if(!checkRequiredIsOk(lblSeq, txtSeq)){
            return false;
        }
        res = true;
        return res;
    }
    
    private boolean checkRequiredIsOk(VCIJLabel lbl, VCIJTextField txt){
        boolean res = false;
        String text = txt.getText();
        if("".equals(text) && txt.isRequired()){
            txt.requestFocus();
            VCIJOptionPane.showMessage(this, lbl.getText() + " 不能为空!");
            res = false;
        } else {
            res = true;
        }
        return res;
    }
    
    private boolean newPLDefinationIsOk(PLPageDefination pd, boolean isEdit) throws VCIError{
        boolean res = false;
        boolean nameExist = false;
        boolean seqExist = false;
        PLPageDefination[] pds = UITools.getService().getPLPageDefinationsByPageContextOId(getTabPage().plOId);
        for (PLPageDefination pdGet : pds) {
            if(!isEdit){
                if(pd.name.equals(pdGet.name)){
                    nameExist = true;
                } else if(pd.seq == pdGet.seq){
                    seqExist = true;
                }
            } else {
                if(!pd.plOId.equals(pdGet.plOId)){
                    if(pd.name.equals(pdGet.name)){
                        nameExist = true;
                    } else if(pd.seq == pdGet.seq){
                        seqExist = true;
                    }
                }
            }
            if(nameExist || seqExist){
                break;
            }
        }
        if(nameExist){
            txtName.requestFocus();
            VCIJOptionPane.showMessage(this, lblName.getText() + " 已经存在!");
            return false;
        }
 
        if(seqExist){
            txtSeq.requestFocus();
            VCIJOptionPane.showMessage(this, lblSeq.getText() + " 已经存在!");
            return false;
        }
        res = true;
        return res;
    }
    private PLDefination setEventDataToPLDefination(PLDefination d){
        DefaultListModel listModel = eventInfoPanel.getListModel();
        int size = listModel.getSize();
        List<String> keyList = new ArrayList<String>();
        Map<String,String> keyMap = new HashMap<String,String>();
        for(int i=0;i<size;i++){
            String elementAt = (String) listModel.getElementAt(i);
            String[] split = elementAt.split(":");
            if(!keyList.contains(split[0])){
                keyList.add(split[0]);
            }
        }
        fetchEventValue(listModel, size, keyList,keyMap);
        String eventKey = "";
        String eventValue = "";
        for(Entry<String, String> es : keyMap.entrySet()){
            String key = es.getKey();
            String value = es.getValue();
            eventKey += key+",";
            eventValue += value+",";
        }
        if(eventKey!=null&&!"".equals(eventKey)){
            d.setEventKey(eventKey.substring(0,eventKey.length()-1));
            d.setEventValue(eventValue.substring(0,eventValue.length()-1));
        }else{
            d.setEventKey("");
            d.setEventValue("");
        }
        return d;
    }
 
    private void fetchEventValue(DefaultListModel listModel, int size,
            List<String> keyList,Map<String,String> keyMap) {
        for(int j=0;j<keyList.size();j++){
            String eventValue="";
            String eventKey = keyList.get(j);
            for(int i=0;i<size;i++){
                String elementAt = (String) listModel.getElementAt(i);
                String[] split = elementAt.split(":");
                if(eventKey.equals(split[0])){
                    eventValue += split[1]+";";
                }
            }
            keyMap.put(eventKey, eventValue.substring(0,eventValue.length()-1));
        }
    }
    private BaseComptPanel getLastComptPanel(){
        return lastComptPanel;
    }
    private void setUIValueToObject(PLPageDefination pd, PLDefination d){
        pd.name = txtName.getText().trim();
        pd.seq = Short.valueOf(txtSeq.getText().trim());
        pd.desc = txtDesc.getText().trim();
        
        d.setName(txtName.getText().trim());
        d.setUiParser(txtUIParser.getText().trim());
        d.setExtAttr(txtExtAttrs.getText().trim());
        d.setTemplateType(String.valueOf(lastComponentType.getIntVal()));
    }
    
    private void btnCancel_actionPerformed(ActionEvent e){
        close(DialogResult.CANCEL);
    }
    
    private void close(DialogResult dialogRes){
        setDialogResult(dialogRes);
        setVisible(false);
        dispose();
    }
    
    public String getTitle() {
        return title;
    }
    public void setTitle(String title) {
        this.title = title;
    }
    public int getWidth() {
        return width;
    }
    public void setWidth(int width) {
        this.width = width;
    }
    public int getHeight() {
        return height;
    }
    public void setHeight(int height) {
        this.height = height;
    }
    public Component getRelativeToCompt() {
        return relativeToCompt;
    }
    public void setRelativeToCompt(Component relativeToCompt) {
        this.relativeToCompt = relativeToCompt;
    }
    public PLTabPage getTabPage() {
        return tabPage;
    }
    public void setTabPage(PLTabPage tabPage) {
        this.tabPage = tabPage;
    }
    public PLPageDefination getPageDefination() {
        return pageDefination;
    }
    public void setPageDefination(PLPageDefination pageDefination) {
        this.pageDefination = pageDefination;
    }
}