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
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
package com.vci.client.portal.UI;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.FlowLayout;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
 
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JPopupMenu;
import javax.swing.JScrollPane;
import javax.swing.JSplitPane;
import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.JTree;
import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.TableColumn;
import javax.swing.table.TableModel;
import javax.swing.table.TableRowSorter;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.DefaultTreeModel;
import javax.swing.tree.TreeNode;
import javax.swing.tree.TreePath;
 
import com.vci.corba.omd.btm.BtmItem;
import com.vci.corba.portal.data.PLCommandParameter;
import com.vci.corba.portal.data.PLPageDefination;
import com.vci.corba.portal.data.PLUILayout;
import com.vci.corba.portal.data.PLTabButton;
import com.vci.corba.portal.data.PLTabPage;
import com.vci.client.LogonApplication;
import com.vci.client.common.VCIBasePanel;
import com.vci.client.framework.rightConfig.object.FunctionObject;
import com.vci.client.omd.provider.BtmProvider;
import com.vci.client.portal.UI.dialog.VCIGrandUIDialog;
import com.vci.client.portal.utility.UITools;
import com.vci.client.ui.process.QANProcessBar;
import com.vci.client.ui.process.QANProcessBarFrame;
import com.vci.client.ui.swing.VCIOptionPane;
import com.vci.client.ui.table.VCIBaseTableModel;
import com.vci.client.ui.table.VCIBaseTableNode;
import com.vci.client.ui.tree.VCIBaseTreeModel;
import com.vci.client.ui.tree.VCIBaseTreeNode;
import com.vci.client.ui.util.PostorderEnumeration;
import com.vci.corba.common.VCIError;
 
/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
/**
 * UI管理
 * @author liudi
 *
 * 2013-7-23
 */
public class UIFManager extends VCIBasePanel {
    /**
     * 
     */
    private static final long serialVersionUID = 7438323020031787177L;
    private JSplitPane jSplitPane;
    private JPanel btnPanel;
    private JScrollPane jScrollPane;
    private JPanel uifMangerTablePanel;
    private JTable uifMangerTabel;
    private TableRowSorter<TableModel> tableSorter;
    private boolean enableSort = true;
    private VCIBaseTableModel uiFMangerTableModel;
    private JPanel tablePanel;
    private JButton delBtn;
    private JButton editBtn;
    private JButton createBtn;
    private JPanel contentPanel;
    private JTree btTree;
    //=================
    private JPanel leftPanel;
    private JPanel topPanel;
    private JPanel rightPanel;
    private JPanel rightchaxunPanel;
    private JLabel Name;
    private JTextField chaxunByName;
    private JLabel shangxiawen;
    private JTextField chaxunByshangxiawen;
    private JButton chaxunbtn;
    private JTextField lefTtextField;
    private JButton leftBtnchaxun;
    private List<String> usedList = null;
 
    
    JPopupMenu popupMenu = new JPopupMenu();//弹出式菜单
    JMenuItem menuitem = new JMenuItem("刷新");
    
    Object[][] strings = null;
    private static UIFManager uiFManager = null;
    String[] columnHeaders = new String[] { "名称", "UI上下文"};
    Class types[] = new Class[] { String.class, String.class };
    private JButton btntab;
    private JButton btnForm;
    private JButton btnTree;
    private String btname = "";
    private JScrollPane jscrollPanel ;
    private JButton clonebtn;
    private JButton expBtn;
    private JButton impBtn;
    private JButton grandBtn;
    private JButton grandBtnBySelected;
    private JButton relatbutton;
//    public static UIFManager  getInstance(){
//        if(uiFManager == null){
//            uiFManager = new UIFManager();
//        }
//        return uiFManager;
//    }
    
    private JTree contextTree;
    private VCIBaseTreeModel contextTreeModel;
    private VCIBaseTreeNode contextTreerootNode;
    public UIFManager(FunctionObject funcObj){
        super(funcObj);
        initGUI();
    }
    private void initGUI() {
        try {
            {
                {
                    this.setLayout(new BorderLayout());
                    jSplitPane = new JSplitPane();
                    this.add(jSplitPane);
                    {
                        leftPanel = new JPanel();
                        BorderLayout leftPanelLayout = new BorderLayout();
                        leftPanel.setLayout(leftPanelLayout);
                        jSplitPane.add(leftPanel, JSplitPane.LEFT);
                        {
                            topPanel = new JPanel();
                            BorderLayout topPanelLayout = new BorderLayout();
                            
                            leftPanel.add(topPanel,BorderLayout.NORTH);
                            //搜索框的设置add by guo
                            GridBagConstraints gb = new GridBagConstraints();
                            gb.gridx = 0;
                            gb.gridy = 0;
                            //占长度的百分之七十
                            gb.weightx = 0.7;
                            gb.weighty = 0;
                            gb.fill = GridBagConstraints.HORIZONTAL;
                            topPanel.setLayout(new GridBagLayout());
                            {
                                lefTtextField = new JTextField();
                                topPanel.add(lefTtextField,gb);
                                leftBtnchaxun = new JButton("查询");
                                topPanel.add(leftBtnchaxun);
                                leftBtnchaxun.addActionListener(new ActionListener() {
                                    public void actionPerformed(ActionEvent e) {
                                    chaxun2();
                                    }
                                });
                                lefTtextField.addActionListener(new ActionListener() {
                                    public void actionPerformed(ActionEvent e) {
                                    chaxun2();
                                    }
                                });
                                        
                            }
                        }
                        
                        {
                            popupMenu.add(menuitem);
                            btTree = new JTree();
                            jscrollPanel = new JScrollPane();
                            jscrollPanel.setViewportView(btTree);
                            leftPanel.add(jscrollPanel,BorderLayout.CENTER);
                            btTree.setModel(createTreeModel());
                            btTree.addMouseListener(new MouseAdapter() {
                                @Override
                                public void mouseClicked(MouseEvent e) {
                                    super.mouseClicked(e);
                                    initData();
                                }
                                @Override
                                public void mouseReleased(MouseEvent e) {
                                    super.mouseReleased(e);
                                    if(e.isPopupTrigger()){
                                        popupMenu.show(btTree, e.getX(), e.getY());
                                    }
                                }
                            });
                            menuitem.addActionListener(new ActionListener() {
                                @Override
                                public void actionPerformed(ActionEvent arg0) {
                                    try {
                                        btTree.setModel(createTreeModel());
                                    } catch (VCIError e) {
                                        e.printStackTrace();
                                    }
                                }
                            });
                            
                        }
                    }
                    
                    {
                        contentPanel = new JPanel();
                        BorderLayout contentPanelLayout = new BorderLayout();
                        contentPanel.setLayout(contentPanelLayout);
                        jSplitPane.add(contentPanel, JSplitPane.RIGHT);
                        {
                            //add by guo 
                            GridBagConstraints gbc = new GridBagConstraints();
                            gbc.fill = GridBagConstraints.HORIZONTAL;
                            gbc.weightx = 0;
                            gbc.weighty = 0; 
                            gbc.gridx = 0;
                            gbc.gridy = 0;
                            rightPanel = new JPanel();
                            contentPanel.add(rightPanel,BorderLayout.NORTH);
                            rightPanel.setLayout(new GridBagLayout());{
                                
                                rightchaxunPanel = new JPanel();
                                rightPanel.add(rightchaxunPanel,gbc);{
 
                                    Name = new JLabel("名称");
                                    rightchaxunPanel.add(Name);
                                    chaxunByName = new JTextField(40);
                                    rightchaxunPanel.add(chaxunByName);
                                    
                                    shangxiawen = new JLabel("UI上下文");
                                    rightchaxunPanel.add(shangxiawen);
                                    chaxunByshangxiawen = new JTextField(40);
                                    rightchaxunPanel.add(chaxunByshangxiawen);
                                    
                                    chaxunbtn = new JButton("查询");
                                    rightchaxunPanel.add(chaxunbtn);
                                    chaxunbtn.addActionListener(new ActionListener() {
                                        public void actionPerformed(ActionEvent e) {
                                        chaxun1();
                                        }
                                    });
                                    chaxunByshangxiawen.addActionListener(new ActionListener() {
                                        public void actionPerformed(ActionEvent e) {
                                        chaxun1();
                                        }
                                    });
                                    chaxunByName.addActionListener(new ActionListener() {
                                        public void actionPerformed(ActionEvent e) {
                                        chaxun1();
                                        }
                                    });
                                }
                            }
                            {
                                gbc.gridx = 0;
                                gbc.gridy = 1;
 
                                btnPanel = new JPanel();
                                FlowLayout jPanel1Layout = new FlowLayout();
                                rightPanel.add(btnPanel, gbc);
                                btnPanel.setLayout(jPanel1Layout);
                                {
                                    createBtn = new JButton();
                                    btnPanel.add(createBtn);
                                    createBtn.setText("创建");
                                    createBtn.addActionListener(new ActionListener() {
                                        
                                        @Override
                                        public void actionPerformed(ActionEvent arg0) {
                                            
                                            TreePath path = btTree.getSelectionPath();
                                            String message = "请选择业务类型!";
                                            if(path ==null){
                                                VCIOptionPane.showMessage(LogonApplication.frame, message);
                                                return ;
                                            }
                                            VCIBaseTreeNode node = (VCIBaseTreeNode) path.getLastPathComponent();
                                            if(node.getObj()==null){
                                                VCIOptionPane.showMessage(LogonApplication.frame, message);
                                                return ;
                                            }
                                            if(node.getObj() instanceof String){
                                                VCIOptionPane.showMessage(LogonApplication.frame, message);
                                                return ;
                                            }
                                            int row = uifMangerTabel.getSelectedRow(); //选中数据的索引
                                            BtmItem obj = (BtmItem) node.getObj();
                                            UIContextDialog dialog = new UIContextDialog(obj,false,null);
                                            initData();
                                            //uifMangerTabel.setRowSelectionInterval(row, row);
                                        }
                                    });
                                }
                                {
                                    editBtn = new JButton();
                                    btnPanel.add(editBtn);
                                    editBtn.setText("修改");
                                    editBtn.addActionListener(new ActionListener() {
                                        
                                        @Override
                                        public void actionPerformed(ActionEvent e) {
                                            TreePath path = btTree.getSelectionPath();
                                            String message = "请选择业务类型!";
                                            if(path ==null){
                                                VCIOptionPane.showMessage(LogonApplication.frame, message);
                                                return ;
                                            }
                                            VCIBaseTreeNode node = (VCIBaseTreeNode) path.getLastPathComponent();
                                            if(node.getObj()==null){
                                                VCIOptionPane.showMessage(LogonApplication.frame, message);
                                                return ;
                                            }
                                            if(node.getObj() instanceof String){
                                                VCIOptionPane.showMessage(LogonApplication.frame, message);
                                                return ;
                                            }
                                            if(uiFMangerTableModel.list.size()==0){
                                                VCIOptionPane.showMessage(LogonApplication.frame, "请选择数据!");
                                                return ;
                                            }
                                            int row = uifMangerTabel.getSelectedRow(); //选中数据的索引
                                            int selectedRowCount = uifMangerTabel.getSelectedRowCount();//选中的数据条数
                                            if(selectedRowCount==0){
                                                VCIOptionPane.showMessage(LogonApplication.frame, "请选择数据!");
                                                return;
                                            }
                                            row=uifMangerTabel.convertRowIndexToModel(row);
                                            VCIBaseTableNode valueAt = uiFMangerTableModel.getValueAt(row);//获取选中行对象
                                            BtmItem obj = (BtmItem) node.getObj();
                                            PLUILayout plpagelayoutdefination = (PLUILayout) valueAt.getObj();//获取选中行的数据
                                            UIContextDialog dialog = new UIContextDialog(obj,true,plpagelayoutdefination);
                                            if(dialog.isSave() == true){
                                                initData(); //将本已选中的行去掉了
                                            }
                                            //加载完新窗体后,重新让原始数据被选中,选择从paramInt1到paramInt2之间的行
                                            //uifMangerTabel.setRowSelectionInterval(row, row);
                                        }
                                    });
                                }
                                {
                                    delBtn = new JButton();
                                    btnPanel.add(delBtn);
                                    btntab = new JButton("操作区");
                                    btntab.addActionListener(new ActionListener() {
                                        @Override
                                        public void actionPerformed(ActionEvent arg0) {
                                            if(uiFMangerTableModel.list.size()==0){
                                                VCIOptionPane.showMessage(LogonApplication.frame, "请选择数据!");
                                                return ;
                                            }
                                            int selectedRowCount = uifMangerTabel.getSelectedRowCount();
                                            int selectedRow = uifMangerTabel.getSelectedRow();
                                            if(selectedRow>=uiFMangerTableModel.list.size()){
                                                VCIOptionPane.showMessage(LogonApplication.frame, "请选择数据!");
                                                return ;
                                            }
                                            if(selectedRowCount==0){
                                                VCIOptionPane.showMessage(LogonApplication.frame, "请选择数据!");
                                                return ;
                                            }else if(selectedRowCount >1){
                                                VCIOptionPane.showMessage(LogonApplication.frame, "一次只能选择一条数据进行此操作!");
                                                return ;
                                            }
                                            int[] selectedRows = uifMangerTabel.getSelectedRows();
                                            for(int j=0;j<selectedRows.length;j++){
                                                selectedRows[j]=uifMangerTabel.convertRowIndexToModel(selectedRows[j]);
                                                PLUILayout plpagelayoutdefination = (PLUILayout) uiFMangerTableModel.getValueAt(selectedRows[j]).getObj();
                                                if(plpagelayoutdefination.plIsShowTab == 0){
                                                    VCIOptionPane.showMessage(LogonApplication.frame, "该上下没有配置显示‘操作区’!");
                                                    return;
                                                }
                                                TabMainDiaolg dialog = new TabMainDiaolg(plpagelayoutdefination,btname, (short)3);
                                                dialog.dispose();
                                            }
                                        }
                                    });
                                    {
                                        btnTree = new JButton("导航区");
                                        btnTree.addActionListener(new ActionListener() {
                                            @Override
                                            public void actionPerformed(ActionEvent paramActionEvent) {
                                                if(uiFMangerTableModel.list.size()==0){
                                                    VCIOptionPane.showMessage(LogonApplication.frame, "请选择数据!");
                                                    return ;
                                                }
                                                int selectedRow = uifMangerTabel.getSelectedRow();
                                                int selectedRowCount = uifMangerTabel.getSelectedRowCount();
                                                if(selectedRowCount==0){
                                                    VCIOptionPane.showMessage(LogonApplication.frame, "请选择数据!");
                                                    return ;
                                                } else if(selectedRowCount >1){
                                                    VCIOptionPane.showMessage(LogonApplication.frame, "一次只能选择一条数据进行此操作!");
                                                    return ;
                                                }
                                                int[] selectedRows = uifMangerTabel.getSelectedRows();
                                                for(int j=0;j<selectedRows.length;j++){
                                                    selectedRows[j]=uifMangerTabel.convertRowIndexToModel(selectedRows[j]);
                                                    PLUILayout plpagelayoutdefination = (PLUILayout) uiFMangerTableModel.getValueAt(selectedRows[j]).getObj();
                                                if(plpagelayoutdefination.plIsShowNavigator == 0){
                                                    VCIOptionPane.showMessage(LogonApplication.frame, "该上下没有配置显示‘导航区’!");
                                                    return;
                                                }
                                                    TabMainDiaolg dialog = new TabMainDiaolg(plpagelayoutdefination,btname, (short)1);
                                                    dialog.dispose();
                                                }
                                            }
                                        });
                                        {
                                            relatbutton = new JButton("级联删除");
                                            relatbutton.addActionListener(new ActionListener() {
                                                
                                                @Override
                                                public void actionPerformed(ActionEvent arg0) {
                                                    if(uiFMangerTableModel.list.size()==0){
                                                        VCIOptionPane.showMessage(LogonApplication.frame, "请选择删除的数据!");
                                                        return ;
                                                    }
                                                    int selectedRow = uifMangerTabel.getSelectedRow();
                                                    int selectedRowCount = uifMangerTabel.getSelectedRowCount();
                                                    if(selectedRowCount==0){
                                                        VCIOptionPane.showMessage(LogonApplication.frame, "请选择删除的数据!");
                                                        return ;
                                                    }
                                                    /*if (VCIOptionPane.showQuestion(LogonApplication.frame,
                                                            "确定要删除记录吗?") != 0) {
                                                        return;
                                                    }*/
                                                    selectedRow=uifMangerTabel.convertRowIndexToModel(selectedRow);
                                                    Object uicontextobj = uiFMangerTableModel.getValueAt(selectedRow).getObj();
                                                    PLUILayout plpagelayoutdefination = (PLUILayout) uicontextobj;
                                                    Object[] options = { "Yes", "No" };
                                                    int option = JOptionPane
                                                            .showOptionDialog(LogonApplication.frame, "确认是否删除ui定义\""
                                                                    + plpagelayoutdefination.plName + "\"", "ui定义级联删除",
                                                                    JOptionPane.YES_NO_OPTION,
                                                                    JOptionPane.QUESTION_MESSAGE, null, options,
                                                                    options[1]);
                                                    if(option != JOptionPane.YES_OPTION){
                                                        return;
                                                    }
                                                    try {
                                                        PLTabPage[] pltabPages = UITools.getService().getPLTabPagesByPageDefinationOId(plpagelayoutdefination.plOId);
                                                        for(PLTabPage plTabPage : pltabPages){
                                                            PLPageDefination[] obj = UITools.getService().getPLPageDefinationsByPageContextOId(plTabPage.plOId);
                                                            for(PLPageDefination plpagedefination : obj){
                                                                PLTabButton[] o = UITools.getService().getPLTabButtonsByTableOId(plpagedefination.plOId);
                                                                for(int i=0;i<o.length;i++){
                                                                    PLCommandParameter[] plcommandparameters = UITools.getService()
                                                                            .getPLCommandParametersByCommandOId(o[i].plOId);
                                                                    for(PLCommandParameter plCommandParameter : plcommandparameters){
                                                                        UITools.getService().deletePLCommandParameter(plCommandParameter);
                                                                    }
                                                                    UITools.getService().deletePLTabButton(o[i]);
                                                                }
                                                                UITools.getService().deletePLPageDefination(plpagedefination);
                                                            }
                                                            UITools.getService().deletePLTabPage(plTabPage);
                                                        }
                                                        boolean flag = UITools.getService().deletePLUILayout(plpagelayoutdefination);
                                                        VCIOptionPane.showMessage(LogonApplication.frame, "删除成功");
                                                        initData();
                                                    } catch (VCIError e) {
                                                        e.printStackTrace();
                                                        VCIOptionPane.showMessage(LogonApplication.frame, "删除失败");
                                                        return;
                                                    }
                                                }
                                            });
                                            btnPanel.add(relatbutton);
                                        }
                                        btnPanel.add(btnTree);
                                    }
                                    {
                                        btnForm = new JButton("控制区");
                                        btnForm.addActionListener(new ActionListener() {
                                            @Override
                                            public void actionPerformed(ActionEvent arg0) {
                                                if(uiFMangerTableModel.list.size()==0){
                                                    VCIOptionPane.showMessage(LogonApplication.frame, "请选择数据!");
                                                    return ;
                                                }
                                                int selectedRow = uifMangerTabel.getSelectedRow();
                                                int selectedRowCount = uifMangerTabel.getSelectedRowCount();
                                                if(selectedRowCount==0){
                                                    VCIOptionPane.showMessage(LogonApplication.frame, "请选择数据!");
                                                    return ;
                                                }else if(selectedRowCount >1){
                                                    VCIOptionPane.showMessage(LogonApplication.frame, "一次只能选择一条数据进行此操作!");
                                                    return ;
                                                }
                                                int[] selectedRows = uifMangerTabel.getSelectedRows();
                                                for(int j=0;j<selectedRows.length;j++){
                                                    selectedRows[j]=uifMangerTabel.convertRowIndexToModel(selectedRows[j]);
                                                    PLUILayout plpagelayoutdefination = (PLUILayout) uiFMangerTableModel.getValueAt(selectedRows[j]).getObj();
                                                    if(plpagelayoutdefination.plIsShowForm == 0){
                                                        VCIOptionPane.showMessage(LogonApplication.frame, "该上下没有配置显示‘控制区’!");
                                                        return;
                                                    }
                                                    TabMainDiaolg dialog = new TabMainDiaolg(plpagelayoutdefination,btname, (short)2);
                                                    dialog.dispose();
                                                }
                                            }
                                        });
                                        btnPanel.add(btnForm);
                                    }
                                    btnPanel.add(btntab);
                                    delBtn.setText("删除");
                                    {
                                        clonebtn = new JButton("克隆");
                                        clonebtn.addActionListener(new ActionListener() {
                                            @Override
                                            public void actionPerformed(ActionEvent arg0) {
                                                int row = uifMangerTabel.getSelectedRow(); //选中数据的索引
                                                int selectedRowCount = uifMangerTabel.getSelectedRowCount();//选中的数据条数
                                                if(selectedRowCount==0){
                                                    VCIOptionPane.showMessage(LogonApplication.frame, "请选择数据!");
                                                    return;
                                                }
                                                if(selectedRowCount > 1){
                                                    VCIOptionPane.showMessage(LogonApplication.frame, "一次只能选择一条数据进行此操作!");
                                                    return;
                                                }
//                                                int aa = uifMangerTabel.convertRowIndexToModel(row);
//                                                PLUILayout plpagelayoutdefination = (PLUILayout) uiFMangerTableModel.getValueAt(aa).getObj();
//                                                CloneDialog dialog = new CloneDialog(btTree,plpagelayoutdefination);
                                                if(enableSort && tableSorter != null){
                                                    row = tableSorter.convertRowIndexToModel(row);
                                                }
                                                VCIBaseTableNode rowNode = uiFMangerTableModel.getValueAt(row);
                                                PLUILayout pld = (PLUILayout) rowNode.getObj();
                                                CloneDialog dialog = new CloneDialog(btTree, pld);
                                                dialog.setVisible(true);
                                                initData();
//                                                initTreeNode();
                                                //uifMangerTabel.setRowSelectionInterval(row, row);
                                            }
                                        });
                                        btnPanel.add(clonebtn);
                                    }
                                    {
                                        expBtn = new JButton("导出");
                                        expBtn.addActionListener(new ActionListener() {
                                            @Override
                                            public void actionPerformed(ActionEvent arg0) {
                                                TreePath path = btTree.getSelectionPath();
                                                String message = "请选择业务类型!";
                                                if(path ==null){
                                                    VCIOptionPane.showMessage(LogonApplication.frame, message);
                                                    return ;
                                                }
                                                VCIBaseTreeNode node = (VCIBaseTreeNode) path.getLastPathComponent();
                                                if(node.getObj()==null){
                                                    VCIOptionPane.showMessage(LogonApplication.frame, message);
                                                    return ;
                                                }
                                                if(node.getObj() instanceof String){
                                                    VCIOptionPane.showMessage(LogonApplication.frame, message);
                                                    return ;
                                                }
                                                BtmItem obj = (BtmItem) node.getObj();
                                                
                                                PLUILayout[] contexts = null;
                                                int[] rows = uifMangerTabel.getSelectedRows();
                                                if(rows == null || rows.length <= 0){
                                                    VCIOptionPane.showMessage(LogonApplication.frame, "请选择上下文!");
                                                    return;
                                                }
                                                contexts = new PLUILayout[rows.length];
                                                for (int i = 0; i < rows.length; i++) {
                                                    int row = rows[i];
                                                    if(enableSort && tableSorter != null){
                                                        int modelRow = tableSorter.convertRowIndexToModel(row);
                                                        if(modelRow < uiFMangerTableModel.getRowCount()){
                                                            row = modelRow;
                                                        }
                                                    }
                                                    VCIBaseTableNode rowNode = uiFMangerTableModel.getValueAt(row);
                                                    contexts[i] = (PLUILayout) rowNode.getObj();
                                                }
                                                
                                                ExpDialog dialog = new ExpDialog(obj, contexts);
                                                dialog.setVisible(true);
                                            }
                                        });
                                        btnPanel.add(expBtn);
                                    }
                                    {
                                        impBtn = new JButton("导入");
                                        impBtn.addActionListener(new ActionListener() {
                                            @Override
                                            public void actionPerformed(ActionEvent arg0) {
                                                TreePath path = btTree.getSelectionPath();
                                                String message = "请选择业务类型!";
                                                if(path ==null){
                                                    VCIOptionPane.showMessage(LogonApplication.frame, message);
                                                    return ;
                                                }
                                                VCIBaseTreeNode node = (VCIBaseTreeNode) path.getLastPathComponent();
                                                if(node.getObj()==null){
                                                    VCIOptionPane.showMessage(LogonApplication.frame, message);
                                                    return ;
                                                }
                                                if(node.getObj() instanceof String){
                                                    VCIOptionPane.showMessage(LogonApplication.frame, message);
                                                    return ;
                                                }
                                                BtmItem obj = (BtmItem) node.getObj();
                                                ImportExcel  imp = new ImportExcel(obj);
                                                if(imp.impExcel()){
                                                    VCIOptionPane.showMessage(LogonApplication.frame, "导入成功");
                                                    initData();
                                                }
                                            }
                                        });
                                        btnPanel.add(impBtn);
                                    }
                                    //add start by lmh20151229,在UI定义增加对单独业务类型的UI功能模块授权
                                    {
                                        grandBtn = new JButton("授权");
                                        grandBtn.addActionListener(new ActionListener() {
                                            @Override
                                            public void actionPerformed(ActionEvent arg0) {
                                                showGrantDialog(false);
                                            }
                                            
                                        });
                                        btnPanel.add(grandBtn);
                                    }
                                    //add end
                                    
                                    {
                                        grandBtnBySelected =  new JButton("授权(基于选定的上下文)");
                                        grandBtnBySelected.addActionListener(new ActionListener() {
                                            @Override
                                            public void actionPerformed(ActionEvent arg0) {
                                                showGrantDialog(true);
                                            }
                                            
                                        });
                                        btnPanel.add(grandBtnBySelected);
                                    }
                                    delBtn.addActionListener(new ActionListener() {
                                        
                                        @Override
                                        public void actionPerformed(ActionEvent arg0) {
                                            if(uiFMangerTableModel.list.size()==0){
                                                VCIOptionPane.showMessage(LogonApplication.frame, "请选择删除的数据!");
                                                return ;
                                            }
                                            int selectedRow = uifMangerTabel.getSelectedRow();
                                            int selectedRowCount = uifMangerTabel.getSelectedRowCount();
                                            if(selectedRowCount==0){
                                                VCIOptionPane.showMessage(LogonApplication.frame, "请选择删除的数据!");
                                                return ;
                                            }
                                            /*if (VCIOptionPane.showQuestion(LogonApplication.frame,
                                                    "确定要删除记录吗?") != 0) {
                                                return;
                                            }*/
                                            selectedRow=uifMangerTabel.convertRowIndexToModel(selectedRow);
                                            PLUILayout plpagelayoutdefination = (PLUILayout) uiFMangerTableModel.getValueAt(selectedRow).getObj();
                                            Object[] options = { "Yes", "No" };
                                            int option = JOptionPane
                                                    .showOptionDialog(LogonApplication.frame, "确认是否删除ui定义\""
                                                            + plpagelayoutdefination.plName + "\"", "ui定义删除",
                                                            JOptionPane.YES_NO_OPTION,
                                                            JOptionPane.QUESTION_MESSAGE, null, options,
                                                            options[1]);
                                            if(option != JOptionPane.YES_OPTION){
                                                return;
                                            }
                                            //
                                            if(check(plpagelayoutdefination)){
                                                VCIOptionPane.showMessage(LogonApplication.frame, "包含子数据,不能删除!");
                                                return;
                                            }
                                            try {
                                                boolean flag = UITools.getService().deletePLUILayout(plpagelayoutdefination);
                                                VCIOptionPane.showMessage(LogonApplication.frame, "删除成功");
                                            } catch (VCIError e) {
                                                e.printStackTrace();
                                                VCIOptionPane.showMessage(LogonApplication.frame, "删除失败");
                                            }
                                            initData();
                                        }
                                    });
                                }
                            
                                
                            }
                            
                        }
                        {
                            tablePanel = new JPanel();
                            BorderLayout tablePanelLayout = new BorderLayout();
                            contentPanel.add(tablePanel, BorderLayout.CENTER);
                            tablePanel.setLayout(tablePanelLayout);
                            {
                                initTable();
                            }
                        }
                    }
                }
            }
        } catch(Exception e) {
            e.printStackTrace();
        }
    }
 
    private void showGrantDialog(boolean fromSelected){
        TreePath path = btTree.getSelectionPath();
        String message = "请选择业务类型!";
        if(path ==null){
            VCIOptionPane.showMessage(LogonApplication.frame, message);
            return ;
        }
        VCIBaseTreeNode node = (VCIBaseTreeNode) path.getLastPathComponent();
        if(node.getObj()==null){
            VCIOptionPane.showMessage(LogonApplication.frame, message);
            return ;
        }
        if(node.getObj() instanceof String){
            VCIOptionPane.showMessage(LogonApplication.frame, message);
            return ;
        }
        final BtmItem obj = (BtmItem) node.getObj();
        
        final PLUILayout[] allContexts = new PLUILayout[this.uifMangerTabel.getRowCount()];
        for (int i = 0; i < allContexts.length; i++) {
            int row = i;
            if(this.enableSort && this.tableSorter != null){
                int modelRow = this.tableSorter.convertRowIndexToModel(row);
                if(modelRow < this.uiFMangerTableModel.getRowCount()){
                    row = modelRow;
                }
            }
            VCIBaseTableNode rowNode = this.uiFMangerTableModel.getValueAt(row);
            allContexts[i] = (PLUILayout) rowNode.getObj();
        }
        
        PLUILayout[] contexts = null;
        if(fromSelected){
            int[] rows = this.uifMangerTabel.getSelectedRows();
            if(rows == null || rows.length <= 0){
                VCIOptionPane.showMessage(LogonApplication.frame, "请选择上下文!");
                return;
            }
            contexts = new PLUILayout[rows.length];
            for (int i = 0; i < rows.length; i++) {
                int row = rows[i];
                if(this.enableSort && this.tableSorter != null){
                    int modelRow = this.tableSorter.convertRowIndexToModel(row);
                    if(modelRow < this.uiFMangerTableModel.getRowCount()){
                        row = modelRow;
                    }
                }
                VCIBaseTableNode rowNode = this.uiFMangerTableModel.getValueAt(row);
                contexts[i] = (PLUILayout) rowNode.getObj();
            }
        } else {
            contexts = allContexts;
        }
        
        final PLUILayout[] contextsx = contexts;
        final QANProcessBarFrame frame = new QANProcessBarFrame();
        final QANProcessBar bar = new QANProcessBar(new Thread(new Runnable() {
            @Override
            public void run() {
                try{
                    frame.setContent("正在构建UI授权界面,请稍等...");
                    VCIGrandUIDialog dialog = new VCIGrandUIDialog(obj, funcObj, contextsx, allContexts);
                    frame.setContent("");
                    frame.setProcessBarCancel(true);
                    dialog.setLocationAndSize();
                } finally{
                    frame.setProcessBarCancel(true);
                }
            }
        }){}, (JFrame) LogonApplication.frame, frame, "", false);
        String title = "UI授权";
        frame.setTitle(title);
        bar.setTitle(title);
        bar.setVisible(true);
    }
    
    private void initTable() {
        if(uifMangerTablePanel!=null){
            tablePanel.remove(uifMangerTablePanel);
        }
        uifMangerTablePanel = new JPanel();
        tablePanel.add(uifMangerTablePanel, BorderLayout.CENTER);
        {
            jScrollPane = new JScrollPane();
            uifMangerTablePanel.setLayout(new BorderLayout());
            uifMangerTablePanel.add(jScrollPane);
            {
                uiFMangerTableModel = new VCIBaseTableModel(columnHeaders,types);
                uifMangerTabel = new JTable();
                jScrollPane.setViewportView(uifMangerTabel);
                uifMangerTabel.setModel(uiFMangerTableModel);
                
                if(this.enableSort){
                    tableSorter = new TableRowSorter<TableModel>(uiFMangerTableModel);
                    uifMangerTabel.setRowSorter(tableSorter);
                }
            }
        }
    }
    
    
    
    //设置JTable斑马线效果  
    public void setBanMaXian(JTable table)  
    {  
        //斑马线设置  
        DefaultTableCellRenderer d = new DefaultTableCellRenderer()  
        {//需要重写类中的getTableCellRendererComponent的方法  
            @Override  
            public Component getTableCellRendererComponent(JTable table,  
                    Object value, boolean isSelected, boolean hasFocus,  
                    int row, int column)  
            {  
                if(row % 2 == 0)//JTable中的奇数行  
                {  
                    setBackground(Color.WHITE);  
                }  
                else//JTable中的偶数行  
                {  
                    setBackground(Color.LIGHT_GRAY);  
                }  
                return super.getTableCellRendererComponent(table, value, isSelected, hasFocus,  
                        row, column);  
            }  
        };  
            for(int i = 0; i< table.getColumnCount();i++)  
            {  
                TableColumn col = table.getColumn(table.getColumnName(i));  
                col.setCellRenderer(d);//将斑马线对象放置到表格中  
            }  
    }  
    private PLUILayout[] getSortedContexts(PLUILayout[] contexts){
        Arrays.sort(contexts, new Comparator<PLUILayout>(){
            @Override
            public int compare(PLUILayout o1,
                    PLUILayout o2) {
                return o1.plName.compareTo(o2.plName);
            }
        });
        return contexts;
    }
    private void initData(){
        uiFMangerTableModel.list.clear();
        TreePath path = btTree.getSelectionPath();
        if(path == null) return;
        VCIBaseTreeNode node = (VCIBaseTreeNode) path.getLastPathComponent();
        if(node.getObj() instanceof BtmItem){
            BtmItem obj = (BtmItem) node.getObj();
            btname = obj.name;
            lefTtextField.setText(btname);
            uiFMangerTableModel=  (VCIBaseTableModel) uifMangerTabel.getModel();
            VCIBaseTableNode vciBaseTableNode = null;
            try {
                PLUILayout[] plpagelayoutdefinations = UITools.getService().getPLUILayoutsByRelatedType(btname);
                plpagelayoutdefinations = getSortedContexts(plpagelayoutdefinations);
                int length = plpagelayoutdefinations.length;
                for(int i =0;i<length;i++){
                    vciBaseTableNode = new VCIBaseTableNode(plpagelayoutdefinations[i]);
                    vciBaseTableNode.setPropertyValueByName(uifMangerTabel.getColumnName(0), plpagelayoutdefinations[i].plName);
                    vciBaseTableNode.setPropertyValueByName(uifMangerTabel.getColumnName(1), plpagelayoutdefinations[i].plCode);
                    uiFMangerTableModel.addRow(i, vciBaseTableNode);
                }
                uiFMangerTableModel.fireTableDataChanged();
                uifMangerTabel.setModel(uiFMangerTableModel);
                setBanMaXian(uifMangerTabel); 
                uifMangerTabel.updateUI();
            } catch (VCIError e) {
                e.printStackTrace();
            }
        }else{
            uifMangerTabel.setModel(uiFMangerTableModel);
            uifMangerTabel.updateUI();
        }
    }
    private DefaultTreeModel createTreeModel() throws VCIError {
        BtmItem[] allBtItems = BtmProvider.getInstance().getAllBtmItems();
        VCIBaseTreeNode rootNode = new VCIBaseTreeNode("业务类型树","root");
        VCIBaseTreeModel treeModel = new VCIBaseTreeModel(rootNode);
        for(int i=0;i<allBtItems.length;i++){
            VCIBaseTreeNode node = new VCIBaseTreeNode(allBtItems[i].name,allBtItems[i]);
            treeModel.insertNodeInto(node, rootNode, rootNode.getChildCount());
        }
        return new DefaultTreeModel(rootNode);
    }
 
    private boolean check(PLUILayout plpagelayoutdefination){
        boolean flag = false;
        try {
            PLPageDefination[] obj = UITools.getService().getPLPageDefinationsByPageContextOId(plpagelayoutdefination.plOId);
            PLTabPage[] pltabPage = UITools.getService().getPLTabPagesByPageDefinationOId(plpagelayoutdefination.plOId);
            if(obj.length>0||pltabPage.length>0){
                flag = true;
            }
        } catch (VCIError e) {
            e.printStackTrace();
        }
        return flag;
    }
    //右边的业务类型的详细显示add by guo
    private void chaxun1() {
        uiFMangerTableModel.list.clear();
        TreePath path = btTree.getSelectionPath();
        if(path == null) return;
        VCIBaseTreeNode node = (VCIBaseTreeNode) path.getLastPathComponent();
        if(node.getObj() instanceof BtmItem){
            BtmItem obj = (BtmItem) node.getObj();
            btname = obj.name;
            uiFMangerTableModel=  (VCIBaseTableModel) uifMangerTabel.getModel();
            VCIBaseTableNode vciBaseTableNode = null;
            try {
                PLUILayout[] plpagelayoutdefinations = UITools.getService().getPLUILayoutsByRelatedType(btname);
                int length = plpagelayoutdefinations.length;
                    if(!chaxunByName.getText().equals("") && chaxunByshangxiawen.getText().equals("")){
                        for(int i =0;i<length;i++){
                            if(plpagelayoutdefinations[i].plName.contains(chaxunByName.getText())){
                                vciBaseTableNode = new VCIBaseTableNode(plpagelayoutdefinations[i]);
                                vciBaseTableNode.setPropertyValueByName(uifMangerTabel.getColumnName(0), plpagelayoutdefinations[i].plName);
                                vciBaseTableNode.setPropertyValueByName(uifMangerTabel.getColumnName(1), plpagelayoutdefinations[i].plCode);
                                 uiFMangerTableModel.addRow(i, vciBaseTableNode);
                          }
                       }
                    }else if(chaxunByName.getText().equals("") && !chaxunByshangxiawen.getText().equals("")){
                        for(int i =0;i<length;i++){
                            if(plpagelayoutdefinations[i].plCode.contains(chaxunByshangxiawen.getText())){
                                vciBaseTableNode = new VCIBaseTableNode(plpagelayoutdefinations[i]);
                                vciBaseTableNode.setPropertyValueByName(uifMangerTabel.getColumnName(0), plpagelayoutdefinations[i].plName);
                                vciBaseTableNode.setPropertyValueByName(uifMangerTabel.getColumnName(1), plpagelayoutdefinations[i].plCode);
                                 uiFMangerTableModel.addRow(i, vciBaseTableNode);
                          }
                       }
                    }else if(!chaxunByName.getText().equals("") && !chaxunByshangxiawen.getText().equals("")){
                        for(int i =0;i<length;i++){
                            if(plpagelayoutdefinations[i].plName.contains(chaxunByName.getText()) && plpagelayoutdefinations[i].plCode.contains(chaxunByshangxiawen.getText()) ){
                                vciBaseTableNode = new VCIBaseTableNode(plpagelayoutdefinations[i]);
                                vciBaseTableNode.setPropertyValueByName(uifMangerTabel.getColumnName(0), plpagelayoutdefinations[i].plName);
                                vciBaseTableNode.setPropertyValueByName(uifMangerTabel.getColumnName(1), plpagelayoutdefinations[i].plCode);
                                 uiFMangerTableModel.addRow(i, vciBaseTableNode);
                          }
                       }
                  }else {
                    for(int i =0;i<length;i++){
                    vciBaseTableNode = new VCIBaseTableNode(plpagelayoutdefinations[i]);
                    vciBaseTableNode.setPropertyValueByName(uifMangerTabel.getColumnName(0), plpagelayoutdefinations[i].plName);
                    vciBaseTableNode.setPropertyValueByName(uifMangerTabel.getColumnName(1), plpagelayoutdefinations[i].plCode);
                    uiFMangerTableModel.addRow(i, vciBaseTableNode);
                }
            }
                uiFMangerTableModel.fireTableDataChanged();
                uifMangerTabel.setModel(uiFMangerTableModel);
                setBanMaXian(uifMangerTabel); 
                uifMangerTabel.updateUI();
                
            } catch (VCIError e) {
                e.printStackTrace();
            }
        }else{
            uifMangerTabel.setModel(uiFMangerTableModel);
            uifMangerTabel.updateUI();
        }
 
    }
 
   //左边的节点的查询显示add by guo
    private void chaxun2() {
        // TODO Auto-generated method stub
        String test = lefTtextField.getText().trim();
        DefaultTreeModel model = (DefaultTreeModel) btTree.getModel();
        model.reload();
        TreeNode root = (TreeNode) model.getRoot();
        PostorderEnumeration enumeration = new PostorderEnumeration(
                root);
        while (enumeration.hasMoreElements()) {
            DefaultMutableTreeNode element = (DefaultMutableTreeNode) enumeration
                    .nextElement();
            if (element.getUserObject() instanceof String) {
                String wrapper = (String) element
                        .getUserObject();
                if (wrapper != null 
                        && wrapper.equals(test)) {
                    TreeNode[] path = element.getPath();
                    TreePath treePath = new TreePath(path);
                    btTree.setSelectionPath(treePath);
                    initData();
                    return;
                };
            }
        } if (test.equals("")) {
            JOptionPane.showMessageDialog(this, "业务类型名不能为空,请填写正确的业务类型名!" , "提示", JOptionPane.INFORMATION_MESSAGE);
        } else {
            JOptionPane.showMessageDialog(this, "业务类型不存在,请检查!" , "提示", JOptionPane.INFORMATION_MESSAGE);
        }
    }
}