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
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
package com.vci.client.portal.platformPortal;
 
import java.awt.BorderLayout;
import java.awt.Dialog;
import java.awt.FlowLayout;
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.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
 
import javax.swing.ButtonGroup;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.JTextField;
import javax.swing.border.TitledBorder;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
 
import com.vci.client.LogonApplication;
import com.vci.client.omd.btm.ui.BtmClient;
import com.vci.client.omd.btm.wrapper.BtmItemWrapper;
import com.vci.client.omd.linktype.LinkTypeStart;
import com.vci.client.omd.linktype.LinkTypeWrapper;
import com.vci.client.portal.Formdesign.FormDesignDialog;
import com.vci.client.portal.utility.UITools;
import com.vci.client.ui.swing.VCIOptionPane;
import com.vci.client.ui.swing.VCISwingUtil;
import com.vci.client.ui.swing.components.VCIJButton;
import com.vci.client.ui.swing.components.VCIJComboBox;
import com.vci.client.ui.swing.components.VCIJPanel;
import com.vci.client.ui.swing.components.table.AbstractVCIJTableDataProvider;
import com.vci.client.ui.swing.components.table.VCIJTableNode;
import com.vci.client.ui.swing.components.table.VCIJTablePanel;
import com.vci.common.portal.enums.PortalVIType;
import com.vci.common.portal.enums.PortalVITypeFlag;
import com.vci.common.utility.ObjectUtility;
import com.vci.corba.common.VCIError;
import com.vci.corba.portal.PortalService.GetPagePortalVIArrayByPageInfoResult;
import com.vci.corba.portal.data.PortalVI;
 
public class PlatformPortalTablePanel extends JPanel {
    private static final long serialVersionUID = 1L;
    private VCIJButton addButton = VCISwingUtil.createVCIJButton("", "增加", "增加", "add.png", null);
    private VCIJButton editButton = VCISwingUtil.createVCIJButton("", "修改", "修改", "edit.png", null);
    private VCIJButton deleteButton = VCISwingUtil.createVCIJButton("", "删除", "删除", "delete.gif", null);
    private VCIJButton cloneBtn = VCISwingUtil.createVCIJButton("", "克隆", "克隆", "copy.gif");
//    private VCIJButton allExpBtn = new VCIJButton("全部导出");
    private VCIJButton expBtn = new VCIJButton("导出");
    private VCIJButton impBtn = new VCIJButton("导入");
    // private VCIJButton viewI18nButton =
    // VCISwingUtil.createVCIJButton("viewI18nButton", "查看国际化字典", "查看国际化字典",
    // "image.png");
    // add by guo
    private VCIJButton getSeletedNode = new VCIJButton("选择");
 
    private VCIJComboBox typeComb = new VCIJComboBox();
 
    private JTextField textField = null;
    private Object selectTreeNodeobject;
 
    private JRadioButton formRadio;
    private JRadioButton tableRadio;
    private ButtonGroup bg = new ButtonGroup();
//    private int type = -1;
//    private int type1 = -1;
    private PortalVITypeFlag typeFlag;
    private String searchValue;
    private JButton clonedestbutton;
    private Object clonedestObject;
    private String selectedObjectName;
    private Dialog parentDialog;
    // 是否通过输入界面的查询条件进行刷新
    private boolean isConditionRefresh = false;
    /**
     * 是否显示 Form & Table JRadioButton
     */
    private boolean showFormTableRadioButton = true;
    /**
     * 是否显示 克隆输入及按钮
     */
    private boolean showCloneOptButton = true;
    /**
     * 是否显示底部的操作按钮
     */
    private boolean showSouthNormalButtons = true;
    /**
     * 表单类型 -1:全部 0:table 1:form
     */
    private PortalVIType portalVIType = null;
 
//    public PlatformPortalTablePanel(Object object,
//            PortalVITypeFlag typeFlag) {
//        this(object, typeFlag, true, true, true, null, "门户管理", true);
//    }
 
    private boolean loadDataAfterBuildCompleted = true;
 
    public PlatformPortalTablePanel(Object object, PortalVITypeFlag typeFlag, boolean showFormTableRadioButton,
            boolean showCloneOptButton, boolean showSouthNormalButtons, PortalVIType portalVIType, String borderTitle,
            boolean loadDataAfterBuildCompleted) {
        this.selectTreeNodeobject = object;
        this.typeFlag = typeFlag;
        this.portalVIType = portalVIType;
        this.showFormTableRadioButton = showFormTableRadioButton;
        this.showCloneOptButton = showCloneOptButton;
        this.showSouthNormalButtons = showSouthNormalButtons;
        this.borderTitle = borderTitle;
        this.loadDataAfterBuildCompleted = loadDataAfterBuildCompleted;
        init();
        getSeletedNode.setVisible(false);
    }
 
    // add by guo==
    public PlatformPortalTablePanel(Object object, PortalVITypeFlag typeFlag, boolean isDialog, Dialog parentDialog,
            PortalVIType portalVIType, boolean isLinkType) {
        this.portalVIType = portalVIType;
        try {
            // 把选择的Btmtree上的节点类型由 String转换成需要的BtmItemWrapper类型,再赋值给selectTreeNodeobject
            if (isLinkType == true) {
                LinkTypeWrapper treeNode = new LinkTypeWrapper(LinkTypeStart.getService().getLinkType((String) object));
                this.selectTreeNodeobject = treeNode;
            } else {
                BtmItemWrapper treeNode = new BtmItemWrapper(BtmClient.getService().getBtmItemByName((String) object));
                this.selectTreeNodeobject = treeNode;
            }
        } catch (VCIError e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        this.typeFlag = typeFlag;
        this.parentDialog = parentDialog;
        init();
        getSeletedNode.setVisible(true);
    }
 
    private void init() {
        LogonApplication.getUserEntityObject().setModules(this.getClass().getName());
        initComponents();
        initAction();// 初始化按钮点击事件
    }
 
    private void initComponents() {
        setLayout(new BorderLayout());
        add(initTablePanel(), BorderLayout.CENTER);
 
        if (typeComb.getModel().getSize() > 0) {
            typeComb.setSelectedIndex(0);
            comboxActionPerformed();
        }
    }
 
    private List<VCIJButton> selfCustomButtons = new LinkedList<VCIJButton>();
 
    private List<VCIJButton> getSelfCustomButtons() {
        selfCustomButtons.clear();
        if (this.showSouthNormalButtons) {
            selfCustomButtons.add(addButton);
            selfCustomButtons.add(editButton);
            selfCustomButtons.add(deleteButton);
            selfCustomButtons.add(cloneBtn);
//            selfCustomButtons.add(allExpBtn);
            selfCustomButtons.add(expBtn);
            selfCustomButtons.add(impBtn);
            selfCustomButtons.add(getSeletedNode);
            // selfCustomButtons.add(viewI18nButton);
        }
        return selfCustomButtons;
    }
 
    class MyDataProvider extends AbstractVCIJTableDataProvider<PortalVI> {
 
        public PortalVI[] getDatas(int pageIndex, int pageSize) {
            int type = -1;
            if (portalVIType == null) {
                type = -1;
            }
            if (tableRadio.isSelected()) {
                type = 0;
            } else if (formRadio.isSelected()) {
                type = 1;
            } else {
                type = -1;
            }
            String btmName = "";
            if (selectTreeNodeobject instanceof BtmItemWrapper) {
                btmName = ((BtmItemWrapper) selectTreeNodeobject).btmItem.name;
            } else if (selectTreeNodeobject instanceof LinkTypeWrapper) {
                btmName = ((LinkTypeWrapper) selectTreeNodeobject).linkType.name;
            }
            PortalVI[] res = new PortalVI[0];
            int total = 0;
            try {
                short viTypeVal = -1;
                if (portalVIType != null) {
                    viTypeVal = portalVIType.getIntVal();
                }
                short typeFlagVal = -1;
                if (typeFlag != null) {
                    typeFlagVal = typeFlag.getIntVal();
                }
                GetPagePortalVIArrayByPageInfoResult result = UITools.getService().getPagePortalVIArrayByPageInfo(btmName, searchNameText.getText().trim(),
                        viTypeVal, typeFlagVal, pageIndex, pageSize);
                
                res = result.returnValue;
                total = (int)result.total;
                
            } catch (Exception ex) {
                ex.printStackTrace();
            }
            super.total = total;
            return res;
 
//            if (searchValue == null) {
//                searchValue = "";
//            }
//            if (isConditionRefresh) {
//                startPage = 1;
//            }
//            int start = (startPage - 1) * pageSize + 1;
//            int end = startPage * pageSize + 1;
//            PortalVI[] portalViInfos = null;
//            try {
//                String btmName = "";
//                if(selectTreeNodeobject instanceof BtmItemWrapper){
//                    btmName = ((BtmItemWrapper)selectTreeNodeobject).btmItem.name;
//                }else if(selectTreeNodeobject instanceof LinkTypeWrapper){
//                    btmName = ((LinkTypeWrapper)selectTreeNodeobject).o.name;
//                }
//                if(type!=-1){
//                    portalViInfos = Tool.getService().getPagePortalVIArrayByCondition(btmName, type, searchValue, start, end);
//                    List<PortalVI> list = new ArrayList<PortalVI>();
//                    for(PortalVI portalvi : portalViInfos){
//                        if(portalvi.viType==type){
//                            list.add(portalvi);
//                        }
//                    }
//                    if(searchValue!=null&&!"".equals(searchValue)){
//                        portalViInfos = list.toArray(new PortalVI[0]);
//                        list = new ArrayList<PortalVI>();
//                        for(PortalVI portalvi : portalViInfos){
//                            if(portalvi.viName.contains(searchValue)){
//                                list.add(portalvi);
//                            }
//                        }
//                    }
//                    portalViInfos = list.toArray(new PortalVI[0]);
//                }else{
//                    if(searchValue!=null&&!"".equals(searchValue)){
//                        portalViInfos = Tool.getService().getPagePortalVIArrayByCondition(btmName, type, searchValue, start, end);
//                    }else{
//                        portalViInfos = Tool.getService().getPagePortalVIArrayByCondition(btmName, type, searchValue, start, end);
//                    }
//                }
//                this.total = Tool.getService().getPortalVICountByCondition(btmName, type, searchValue);
//            } catch (VCIError e) {
//                e.printStackTrace();
//            } catch (Throwable e) {
//                e.printStackTrace();
//            }
//            return portalViInfos;
        }
 
        public VCIJTableNode<PortalVI> getNewRowNode(PortalVI dataObj) {
            VCIJTableNode<PortalVI> node = new VCIJTableNode<PortalVI>(dataObj);
            node.setPropertyValue(getSpecialColumns()[0], dataObj.typeName);
            node.setPropertyValue(getSpecialColumns()[1], dataObj.viName);
            String type = "";
            if (dataObj.viType == 1) {
                type = "表单";
            } else if (dataObj.viType == 0) {
                type = "表格";
            }
            node.setPropertyValue(getSpecialColumns()[2], type);
            return node;
        }
 
        public String[] getSpecialColumns() {
            return "业务名称, 名称,类型".split(",");
        }
 
        public int getTotal() {
            return this.total;
        }
 
    }
 
    MyDataProvider dataProvider = new MyDataProvider();
    VCIJTablePanel<PortalVI> tablePanel = new VCIJTablePanel<PortalVI>(dataProvider);
    private JTextField searchNameText = new JTextField();
    private JTextField textField_1 = new JTextField();
 
    public VCIJTablePanel<PortalVI> getTablePanel() {
        return tablePanel;
    }
 
    public void setTablePanel(VCIJTablePanel<PortalVI> tablePanel) {
        this.tablePanel = tablePanel;
    }
 
    private VCIJPanel tablePanel() {
        int startIndex = dataProvider.getDataColumnStartIndex();
        LinkedHashMap<Integer, Integer> widthMaps = new LinkedHashMap<Integer, Integer>();
        widthMaps.put(startIndex++, 150);
        widthMaps.put(startIndex++, 350);
        widthMaps.put(startIndex++, 100);
        tablePanel.setColumnWidthMaps(widthMaps);
        tablePanel.setPageSizeList(new int[] { 50, 100, 200, 500, 50 });
        tablePanel.setCustomButtonFlowAlign(FlowLayout.CENTER);
        tablePanel.setPageButtonFlowAlign(FlowLayout.CENTER);
        tablePanel.setCustomButtons(getSelfCustomButtons());
        tablePanel.setShowPaging(false);
        tablePanel.setShowExport(false);
        setTablePanelParams(tablePanel);
        tablePanel.buildTablePanel();
        if (loadDataAfterBuildCompleted) {
            tablePanel.refreshTableData();
        }
        return tablePanel;
    }
 
    protected void setTablePanelParams(VCIJTablePanel<PortalVI> tablePanel) {
 
    }
 
    private String borderTitle = "";
 
    private JPanel initTablePanel() {
 
        JPanel pal = new JPanel();
        pal.setLayout(new BorderLayout());
        pal.setBorder(new TitledBorder(borderTitle));
 
        pal.add(tablePanel(), BorderLayout.CENTER);
        JPanel searchPal = new JPanel();
        pal.add(searchPal, BorderLayout.NORTH);
        GridBagLayout gbl_searchPal = new GridBagLayout();
        gbl_searchPal.columnWidths = new int[] { 67, 48, 48, 42, 105, 0, 118, 0, 0 };
        gbl_searchPal.rowHeights = new int[] { 23, 0 };
        gbl_searchPal.columnWeights = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE };
        gbl_searchPal.rowWeights = new double[] { 0.0, Double.MIN_VALUE };
        searchPal.setLayout(gbl_searchPal);
 
        formRadio = new JRadioButton("表单");
        GridBagConstraints gbc_formRadio = new GridBagConstraints();
        gbc_formRadio.anchor = GridBagConstraints.NORTH;
        gbc_formRadio.insets = new Insets(0, 0, 0, 5);
        gbc_formRadio.gridx = 1;
        gbc_formRadio.gridy = 0;
        searchPal.add(formRadio, gbc_formRadio);
        bg.add(formRadio);
 
        tableRadio = new JRadioButton("表格(先导入表单,再导入表格!)");
        GridBagConstraints gbc_tableRadio = new GridBagConstraints();
        gbc_tableRadio.anchor = GridBagConstraints.NORTH;
        gbc_tableRadio.insets = new Insets(0, 0, 0, 5);
        gbc_tableRadio.gridx = 2;
        gbc_tableRadio.gridy = 0;
        searchPal.add(tableRadio, gbc_tableRadio);
        bg.add(tableRadio);
 
        // 选择选项确定是否显示
        formRadio.setVisible(this.showFormTableRadioButton);
        tableRadio.setVisible(this.showFormTableRadioButton);
 
        JLabel nameLab = new JLabel("名称");
        GridBagConstraints gbc_nameLab = new GridBagConstraints();
        gbc_nameLab.insets = new Insets(0, 0, 0, 5);
        gbc_nameLab.gridx = 3;
        gbc_nameLab.gridy = 0;
        searchPal.add(nameLab, gbc_nameLab);
 
        searchNameText = new JTextField();
        GridBagConstraints gbc_searchNameText = new GridBagConstraints();
        gbc_searchNameText.insets = new Insets(0, 0, 0, 5);
        gbc_searchNameText.fill = GridBagConstraints.HORIZONTAL;
        gbc_searchNameText.gridx = 4;
        gbc_searchNameText.gridy = 0;
        searchPal.add(searchNameText, gbc_searchNameText);
        searchNameText.setColumns(40);
 
        JLabel label = new JLabel("克隆目标");
        GridBagConstraints gbc_label = new GridBagConstraints();
        gbc_label.insets = new Insets(0, 0, 0, 5);
        gbc_label.gridx = 5;
        gbc_label.gridy = 0;
        searchPal.add(label, gbc_label);
 
        textField_1 = new JTextField();
        textField_1.setEditable(false);
        textField_1.setFocusable(false);
        GridBagConstraints gbc_textField_1 = new GridBagConstraints();
        gbc_textField_1.insets = new Insets(0, 0, 0, 5);
        gbc_textField_1.fill = GridBagConstraints.HORIZONTAL;
        gbc_textField_1.gridx = 6;
        gbc_textField_1.gridy = 0;
        searchPal.add(textField_1, gbc_textField_1);
        textField_1.setColumns(10);
 
        clonedestbutton = new JButton("克隆目标");
        clonedestbutton.setToolTipText("*如果选择克隆目标,则克隆到选择的类型下,如果没有选择克隆目标,则克隆到当前类型下");
        GridBagConstraints gbc_button = new GridBagConstraints();
        gbc_button.gridx = 7;
        gbc_button.gridy = 0;
        searchPal.add(clonedestbutton, gbc_button);
 
        label.setVisible(this.showCloneOptButton);
        textField_1.setVisible(this.showCloneOptButton);
        clonedestbutton.setVisible(this.showCloneOptButton);
 
        pal.setVisible(true);
        return pal;
    }
 
    /**
     * 事件
     */
    private void initAction() {
        searchNameText.getDocument().addDocumentListener(new DocumentListener() {
 
            @Override
            public void removeUpdate(DocumentEvent arg0) {
                searchValue = searchNameText.getText();
                isConditionRefresh = true;
                tablePanel.refreshTableData();
                isConditionRefresh = false;
            }
 
            @Override
            public void insertUpdate(DocumentEvent arg0) {
                searchValue = searchNameText.getText();
                isConditionRefresh = true;
                tablePanel.refreshTableData();
                isConditionRefresh = false;
            }
 
            @Override
            public void changedUpdate(DocumentEvent arg0) {
            }
        });
        formRadio.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent paramActionEvent) {
                tablePanel.setPageIndex(1);
                portalVIType = PortalVIType.Form;
                tablePanel.refreshTableData();
            }
        });
        tableRadio.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent paramActionEvent) {
                tablePanel.setPageIndex(1);
                portalVIType = PortalVIType.Table;
                tablePanel.refreshTableData();
            }
        });
        addButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(ActionEvent e) {
                addButton_conform();
            }
        });
 
        editButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(ActionEvent e) {
                editButton_conform();
            }
        });
 
        deleteButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(ActionEvent e) {
                deleteButton_conform();
            }
        });
 
        cloneBtn.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(ActionEvent e) {
                cloneButton_conform();
            }
        });
//         allExpBtn.addActionListener(new java.awt.event.ActionListener() {
//             public void actionPerformed(ActionEvent e) {
//                
//                 AllExportExcel allee = new AllExportExcel(typeFlag.getIntVal());
//                 if(allee.export())
//                 {
//                     VCIOptionPane.showMessage(LogonApplication.frame, "导出成功");
//                 }
//             }
//         });
//         viewI18nButton.addActionListener(new java.awt.event.ActionListener() {
//                public void actionPerformed(ActionEvent e) {
//                    i18nTable();
//                }
//         });
        expBtn.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(ActionEvent e) {
                List<PortalVI> objList = new ArrayList<PortalVI>();
                int len = tablePanel.getSelectedRowIndexs().length;
                if (len == 0) {
                    VCIOptionPane.showMessage(LogonApplication.frame, "请选择数据再进行修改操作!");
                    return;
                }
                int[] rows = tablePanel.getSelectedRowIndexs();
                for (int i = 0; i < len; i++) {
                    PortalVI obj = tablePanel.getSpecialObjectByRowIndex(rows[i]);
                    try {
                        obj = UITools.getService().getPortalVIById(obj.id);
                    } catch (Exception ex) {
                        // TODO: handle exception
                        ex.printStackTrace();
                        continue;
                    }
                    objList.add(obj);
                }
                ExportExcel ee = new ExportExcel(objList);
                if (ee.export()) {
                    VCIOptionPane.showMessage(LogonApplication.frame, "导出成功");
                }
            }
        });
        impBtn.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(ActionEvent e) {
                if (selectTreeNodeobject == null) {
                    VCIOptionPane.showMessage(LogonApplication.frame, "请选择一个类型!");
                    return;
                }
                ImportExcel imp = new ImportExcel(selectTreeNodeobject);
                if (imp.impExcel()) {
                    VCIOptionPane.showMessage(LogonApplication.frame, "导入成功");
                }
                tablePanel.refreshTableData();
            }
        });
        typeComb.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent arg0) {
                comboxActionPerformed();
            }
        });
        clonedestbutton.addActionListener(new ActionListener() {
 
            @Override
            public void actionPerformed(ActionEvent arg0) {
                UICloneDestDialog clonedestdia = new UICloneDestDialog();
                clonedestdia.setVisible(true);
                clonedestObject = clonedestdia.getTreeObject();
                if (clonedestObject instanceof BtmItemWrapper) {
                    textField_1.setText(((BtmItemWrapper) clonedestObject).btmItem.name);
                } else if (clonedestObject instanceof LinkTypeWrapper) {
                    textField_1.setText(((LinkTypeWrapper) clonedestObject).linkType.name);
                }
            }
        });
 
        // add by guo
        getSeletedNode.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent arg0) {
                int[] rows = tablePanel.getSelectedRowIndexs();
                int len = rows.length;
                if (len == 0) {
                    VCIOptionPane.showMessageDialog(null, "请选择一个对象!");
                    return;
                }
                if (len > 1) {
                    VCIOptionPane.showMessageDialog(null, "只能对一个对象!");
                    return;
                }
                PortalVI obj = tablePanel.getSpecialObjectByRowIndex(rows[0]);
                setSelectedObjectName(obj.viName);
                parentDialog.dispose();
            }
        });
 
//        searchButton.addActionListener(new ActionListener() {
//            public void actionPerformed(ActionEvent e) {
//                searchButton_actionPerformed();
//            }
//        });
    }
 
    /**
     * 
     * <p>
     * 国际化字典Dialog:
     * </p>
     * 
     * @author yangyang
     * @time 2017-10-31
     */
//    private void i18nTable(){
//        VciI18nTableDialog vi18n = new VciI18nTableDialog();
//        vi18n.setModal(true);
//        vi18n.init();
//        vi18n.setSize(900,600);
//        vi18n.setLocationRelativeTo(ClientContextVariable.getFrame());
//        vi18n.setVisible(true);
//    }
    public String getTextField() {
        return textField.getText().trim();
    }
 
    private void comboxActionPerformed() {
        tablePanel.refreshTableData();
    }
 
    /**
     * 添加事件
     */
    private void addButton_conform() {
        if (!tableRadio.isSelected() && !formRadio.isSelected()) {
            VCIOptionPane.showMessage(LogonApplication.frame, "请选择类型");
            return;
        }
        if (formRadio.isSelected()) {
            FormDesignDialog dt = new FormDesignDialog(selectTreeNodeobject, PortalVIType.Form, null, false, this, typeFlag);
            dt.setVisible(true);
        } else if (tableRadio.isSelected()) {
            TableDialog dialog = new TableDialog(null, selectTreeNodeobject, PortalVIType.Table, false, this, typeFlag);
            dialog.setVisible(true);
        }
        tablePanel.refreshTableData();
    }
 
    /**
     * 修改事件
     */
    private void editButton_conform() {
        int[] rows = tablePanel.getSelectedRowIndexs();
        int len = rows.length;
        if (len == 0) {
            VCIOptionPane.showMessage(this, "请选择数据再进行修改操作!");
            return;
        }
        if (len > 1) {
            VCIOptionPane.showMessage(this, "一次只能对一个对象进行修改,请重新选择!");
            return;
        }
        PortalVI obj = tablePanel.getSpecialObjectByRowIndex(rows[0]);
        try {
            obj = UITools.getService().getPortalVIById(obj.id);
        } catch (Exception ex) {
            ex.printStackTrace();
            return;
        }
 
        if (obj.viType == PortalVIType.Form.getIntVal()) {
            FormDesignDialog dt = new FormDesignDialog(selectTreeNodeobject, PortalVIType.getByIntVal(obj.viType), obj, true,
                    this, typeFlag);
            dt.setVisible(true);
        } else if (obj.viType == PortalVIType.Table.getIntVal()) {
            TableDialog dialog = new TableDialog(obj, selectTreeNodeobject, PortalVIType.getByIntVal(obj.viType), true,
                    this, typeFlag);
            dialog.setVisible(true);
        }
        tablePanel.refreshTableData();
    }
 
    /**
     * 克隆处理
     */
    private void cloneButton_conform() {
        int[] rows = tablePanel.getSelectedRowIndexs();
        int len = rows.length;
        if (len == 0) {
            VCIOptionPane.showMessage(this, "请选择数据再进行修改操作!");
            return;
        }
        for (int i = 0; i < len; i++) {
            PortalVI obj = tablePanel.getSpecialObjectByRowIndex(rows[i]);
            String viName = VCIOptionPane.showInputDialog(LogonApplication.frame, "源文件名称为:" + obj.viName + ",请输入新名称");
            if (viName != null) {
                if (checkViName(viName, obj))
                    return;
 
                try {
                    obj = UITools.getService().getPortalVIById(obj.id);
                    obj.id = ObjectUtility.getNewObjectID36();
                    obj.viName = viName;
                    if (clonedestObject != null) {
                        if (clonedestObject instanceof BtmItemWrapper) {
                            obj.typeName = ((BtmItemWrapper) clonedestObject).btmItem.name;
                        } else if (clonedestObject instanceof LinkTypeWrapper) {
                            obj.typeName = ((LinkTypeWrapper) clonedestObject).linkType.name;
                        }
                    }
                    UITools.getService().savePortalVI(obj);
                } catch (VCIError e) {
                    e.printStackTrace();
                }
            }
        }
        tablePanel.refreshTableData();
    }
 
    private boolean checkViName(String viName, PortalVI obj) {
        if ("".equals(viName)) {
            VCIOptionPane.showMessage(this, "请输入名称!");
            viName = VCIOptionPane.showInputDialog(LogonApplication.frame, "源文件名称为:" + obj.viName + ",请输入新名称");
            checkViName(viName, obj);
            return true;
        }
        if (viName == null) {
            return true;
        }
        return false;
    }
 
    /**
     * 删除事件
     */
    private void deleteButton_conform() {
        int[] rows = tablePanel.getSelectedRowIndexs();
        int len = rows.length;
        if (len == 0) {
            VCIOptionPane.showMessage(this, "请选择要删除的对象!");
            return;
        }
        Object[] options = { "Yes", "No" };
        int option = JOptionPane.showOptionDialog(LogonApplication.frame, "确定要删除所选择的数据吗?", "删除数据",
                JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[0]);
        if (option != JOptionPane.YES_OPTION) {
            return;
        }
 
        for (int row : rows) {
            PortalVI obj = tablePanel.getSpecialObjectByRowIndex(row);
            String name = obj.viName;
            String typeName = obj.typeName;
            String id = obj.id;
            int viType = obj.viType;
            boolean flag = false;
            boolean formFlag = false;
 
            try {
                if (viType == 1) {
                    // 判断该表单是否在表格中被引用
                    formFlag = UITools.getService().judgeDeleteButton(id, typeName);
                    if (formFlag) {
                        VCIOptionPane.showMessage(this, "第" + (row + 1) + "行表单已经在表格中被引用,请重新选择要删除的对象!");
                        return;
                    }
                }
                // 判断该表单或表格是否在UI定义时被引用
                flag = UITools.getService().judgeUpdateButton(obj.viType, name, typeName);
                if (flag) {
                    VCIOptionPane.showMessage(this, "第" + (row + 1) + "行数据已经被UI组件引用,请重新选择要删除的对象!");
                    return;
                }
                UITools.getService().deletePortalVIByID(obj.id);
            } catch (VCIError e) {
                e.printStackTrace();
            }
        }
        tablePanel.refreshTableData();
    }
 
    public String getSelectedObjectName() {
        return selectedObjectName;
    }
 
    public void setSelectedObjectName(String selectedObjectName) {
        this.selectedObjectName = selectedObjectName;
    }
 
    public Object getSelectTreeNodeobject() {
        return selectTreeNodeobject;
    }
 
    public void setSelectTreeNodeobject(Object selectTreeNodeobject) {
        this.selectTreeNodeobject = selectTreeNodeobject;
    }
 
    public PortalVITypeFlag getTypeFlag() {
        return typeFlag;
    }
 
    public void setTypeFlag(PortalVITypeFlag typeFlag) {
        this.typeFlag = typeFlag;
    }
 
    public JRadioButton getTableRadio() {
        return tableRadio;
    }
 
    public void setTableRadio(JRadioButton tableRadio) {
        this.tableRadio = tableRadio;
    }
 
    public JRadioButton getFormRadio() {
        return formRadio;
    }
 
    public void setFormRadio(JRadioButton formRadio) {
        this.formRadio = formRadio;
    }
 
}