wangting
2025-01-16 18c43123b51a1688ab4ae01fe3d171c7d92e619b
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
package com.vci.client.portal.NewNewUI.actionmng;
 
import java.awt.BorderLayout;
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.awt.event.ComponentAdapter;
import java.awt.event.ComponentEvent;
import java.io.File;
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
 
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JFileChooser;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JSplitPane;
import javax.swing.JTable;
import javax.swing.JTree;
import javax.swing.ListSelectionModel;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import javax.swing.event.TreeSelectionEvent;
import javax.swing.event.TreeSelectionListener;
import javax.swing.filechooser.FileFilter;
import javax.swing.table.DefaultTableModel;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.DefaultTreeModel;
import javax.swing.tree.TreePath;
import javax.swing.tree.TreeSelectionModel;
 
import com.vci.corba.portal.data.Constraint;
import com.vci.corba.portal.data.PLAction;
import com.vci.corba.portal.data.PLActionCls;
import com.vci.corba.portal.data.PLActionParam;
import com.vci.mw.ClientContextVariable;
import com.vci.client.LogonApplication;
import com.vci.client.common.PinyinCommon;
import com.vci.client.common.VCIBasePanel;
import com.vci.client.framework.rightConfig.object.FunctionObject;
import com.vci.client.portal.NewNewUI.actionExport.ExpActionStep1Panel;
import com.vci.client.portal.NewNewUI.actionExport.ImpActionStep1Panel;
import com.vci.client.portal.UI.dialog.VCICommonGuideDialog;
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.VCIJLabel;
import com.vci.client.ui.swing.components.VCIJPanel;
import com.vci.client.ui.swing.components.VCIJTextField;
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.corba.common.VCIError;
 
/**
 * Action管理
 */
public class ActionConfPanel3 extends VCIBasePanel {
 
    /**
     * 
     */
    private static final long serialVersionUID = 1L;
    private VCIJButton addBtn = VCISwingUtil.createVCIJButton("add", "增加", "增加", "add.png");
    private VCIJButton editBtn = VCISwingUtil.createVCIJButton("edit", "修改", "修改", "edit.png");
    private VCIJButton delBtn = VCISwingUtil.createVCIJButton("delete", "删除", "查询", "delete.png");
    private VCIJTablePanel<PLAction> actionTablePanel = null;
    private JTable paramTable;
    private VCIJButton paramCreateBtn;
    private VCIJButton paramEditBtn;
    private VCIJButton paramDeleteBtn;
    private JTree clsTree;
    String[] headerName = new String[] { "编号", "名称", "类路径", "链接地址", "类型", "描述" };
    private VCIJLabel lblCode = new VCIJLabel("编号:");
    private VCIJTextField txtCode = new VCIJTextField("");
    private VCIJLabel lblName = new VCIJLabel("名称:");
    private VCIJTextField txtName = new VCIJTextField("");
 
    private VCIJLabel lblBSClass = new VCIJLabel("B/S类路径:");
    private VCIJTextField txtBSClass = new VCIJTextField("");
    private VCIJLabel lblCSClass = new VCIJLabel("C/S类路径:");
    private VCIJTextField txtCSClass = new VCIJTextField("");
 
    private VCIJLabel lblType = new VCIJLabel("业务类型:");
    private VCIJComboBox cbxType = new VCIJComboBox(new String[] { "", "业务类型", "链接类型" });
    private VCIJLabel lblDesc = new VCIJLabel("描述:");
    private VCIJTextField txtDesc = new VCIJTextField("");
 
    private VCIJButton btnSearch = VCISwingUtil.createVCIJButton("search", "查询", "查询", "search.png");
    private VCIJButton btnClear = VCISwingUtil.createVCIJButton("clear", "清空", "清空", "clear.gif");
 
    private JSplitPane mainSplitPanel;
    private JSplitPane rightSplitPanel;
 
    /**
     * 当前选择的分类节点 当选择根节点时为null
     */
    private PLActionCls currentCls = null;
 
    public ActionConfPanel3(FunctionObject funcObj) {
        super(funcObj);
        init();
    }
 
    private void init() {
        initUI();
        initActionListener();
 
        // 设置第一个分类选中状态
        clsTree.expandRow(0);
        clsTree.setSelectionRow(0);
    }
 
    private void initUI() {
        //
        this.setLayout(new BorderLayout());
 
        // 得到分类树面板
        JPanel treePanel = getTreePanel();
 
        // 刷新分类树
        refreshClsTree(clsTree.getPathForRow(0));
 
        // 得到Action列表
        JPanel actionPanel = getActionPanel();
        actionPanel.setBorder(BorderFactory.createTitledBorder("Action列表"));
 
        // 得到Action参数列表
        JPanel parameterPanel = getParamPanel();
        parameterPanel.setBorder(BorderFactory.createTitledBorder("参数列表"));
 
        rightSplitPanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
        rightSplitPanel.setDividerSize(2);
        rightSplitPanel.setDividerLocation(0.5);
        rightSplitPanel.add(actionPanel, JSplitPane.TOP);
        rightSplitPanel.add(parameterPanel, JSplitPane.BOTTOM);
 
        mainSplitPanel = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
        mainSplitPanel.setDividerSize(2);
        mainSplitPanel.setDividerLocation(0.2);
        mainSplitPanel.add(treePanel, JSplitPane.LEFT);
        mainSplitPanel.add(rightSplitPanel, JSplitPane.RIGHT);
 
        this.add(mainSplitPanel);
 
        this.addComponentListener(new ComponentAdapter() {
            @Override
            public void componentResized(ComponentEvent e) {
                mainSplitPanel.setDividerLocation(0.2);
                rightSplitPanel.setDividerLocation(0.7);
            }
        });
    }
 
    // add by zylon 存储所有父分类id 用于删除树节点时,检查是否存在子分类
    private HashSet<String> clsPids = new HashSet<String>();
 
    private void refreshClsTree(TreePath tp) {
        try {
            // 分类较少,直接查询所有分类
            PLActionCls[] clses = UITools.getService().getPLActionClsArray();
            // 将所有分类父分类保存
            clsPids.clear();
            for (PLActionCls plActionCls : clses) {
                clsPids.add(plActionCls.pid);
            }
 
            DefaultTreeModel dtml = (DefaultTreeModel) clsTree.getModel();
            DefaultMutableTreeNode node = (DefaultMutableTreeNode) tp.getLastPathComponent();
            addClsTreeNode(dtml, node, clses);
        } catch (VCIError e1) {
            e1.printStackTrace();
            JOptionPane.showMessageDialog(ClientContextVariable.getFrame(), "刷新分类树异常:" + e1.getMessage(), "系统异常",
                    JOptionPane.ERROR_MESSAGE);
        }
    }
 
    /**
     * 得到Action分类树面板
     * 
     * @return
     */
    private JPanel getTreePanel() {
        JPanel panel = new JPanel(new BorderLayout());
        // 初始化按钮面板
        JPanel btnPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
        // 创建分类按钮
        JButton createBtn = new JButton("创建");
        createBtn.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                createCls();
            }
        });
        // 修改分类按钮
        JButton editBtn = new JButton("修改");
        editBtn.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                editCls();
            }
        });
        // 删除分类按钮
        JButton deleteBtn = new JButton("删除");
        deleteBtn.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                deleteCls();
            }
        });
        JButton expBtn = new JButton("导出");
        expBtn.addActionListener(new ActionListener() {
            private VCICommonGuideDialog dialog = null;
 
            public void actionPerformed(ActionEvent e) {
                /*
                 * ExpActionDialog dialog = new ExpActionDialog(); dialog.setVisible(true);
                 */
                // MOdify by ZhongGY,直接利用公共向导执行Action导出(测试向导窗口)
                if (dialog == null) {
                    dialog = new VCICommonGuideDialog("Action模型导出", -1, -1);
                    /*
                     * HashMap VCIGuideMap = new HashMap();
                     * dialog.setDialogCommonShareData(VCIGuideMap);
                     */
                    /*
                     * dialog.getDialogCommonShareData().put("exportTree",new
                     * VCIActionExportTree());
                     */
                    ExpActionStep1Panel step1Panel = new ExpActionStep1Panel();
                    dialog.addStepUI(step1Panel);
                }
                dialog.setVisible(true);
            }
        });
        JButton impBtn = new JButton("导入");
        impBtn.addActionListener(new ActionListener() {
            private VCICommonGuideDialog dialog = null;
            private ImpActionStep1Panel step1Panel = null;;
 
            public void actionPerformed(ActionEvent e) {
                // MOdify by ZhongGY,直接利用公共向导执行Action导出(测试向导窗口)
 
                if (dialog == null) {
                    dialog = new VCICommonGuideDialog("Action模型导入", -1, -1);
 
                    step1Panel = new ImpActionStep1Panel();
                    dialog.addStepUI(step1Panel);
                }
 
                JFileChooser jf = new JFileChooser();
                jf.setFileSelectionMode(JFileChooser.FILES_ONLY);
                jf.removeChoosableFileFilter(jf.getFileFilter());
                jf.setFileFilter(new FileFilter() {
                    public String getDescription() {
                        return "文件夹";
                    }
 
                    public boolean accept(File f) {
                        return (f.isDirectory() || f.getName().endsWith(".vciamf"));
                    }
                });
                jf.setDialogTitle("选择Action导出文件");
                int showOpenDialog = jf.showOpenDialog(LogonApplication.frame);
 
                if (showOpenDialog == JFileChooser.CANCEL_OPTION) {
                    return;
                }
                if (showOpenDialog == JFileChooser.APPROVE_OPTION) {
                    File selectedFile = jf.getSelectedFile();
                    String filePath = selectedFile.getAbsolutePath();
                    step1Panel.setFilePath(filePath);
 
                }
 
                dialog.setVisible(true);
                if (!dialog.isVisible()) {
                    ActionConfPanel3.this.refreshClsTree(new TreePath(clsTree.getModel().getRoot()));
                    TreePath selectionPath = ActionConfPanel3.this.clsTree.getSelectionPath();
                    if (selectionPath != null)
                        clsTree.expandPath(selectionPath);
                }
            }
        });
        btnPanel.add(createBtn);
        btnPanel.add(editBtn);
        btnPanel.add(deleteBtn);
        btnPanel.add(expBtn);
        btnPanel.add(impBtn);
 
        // 初始化树
        DefaultMutableTreeNode root = new DefaultMutableTreeNode("Action分类");
        DefaultTreeModel dtml = new DefaultTreeModel(root);
        clsTree = new JTree(dtml);
        clsTree.setCellRenderer(new ActionManagerTreeCellRenderer());
        clsTree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
        clsTree.addTreeSelectionListener(new TreeSelectionListener() {
            public void valueChanged(TreeSelectionEvent e) {
                clsTreeSelectionListener(e);
            }
        });
 
        // 添加树
        JScrollPane scrollPane = new JScrollPane(clsTree);
        panel.add(btnPanel, BorderLayout.NORTH);
        panel.add(scrollPane, BorderLayout.CENTER);
        return panel;
    }
 
    /**
     * 添加分类树节点
     * 
     * @param dtml  树模型
     * @param node  节点
     * @param clses 分类
     */
    private void addClsTreeNode(DefaultTreeModel dtml, DefaultMutableTreeNode node, PLActionCls[] clses) {
        node.removeAllChildren();
        String pid = "";
        Object userObject = node.getUserObject();
        if (userObject instanceof ClientPLActionCls) {
            PLActionCls pac = ((ClientPLActionCls) userObject).getPac();
            pid = pac.id;
        }
        // 添加子节点
        for (PLActionCls plac : clses) {
            if (plac.pid.equals(pid)) {
                DefaultMutableTreeNode child = new DefaultMutableTreeNode(new ClientPLActionCls(plac));
                dtml.insertNodeInto(child, node, node.getChildCount());
                addClsTreeNode(dtml, child, clses);
            }
        }
        if (pid.equals("")) {
            PLActionCls plac = new PLActionCls("", "未分类", "", "", "", 0, (short)0);
            DefaultMutableTreeNode child = new DefaultMutableTreeNode(new ClientPLActionCls(plac));
            dtml.insertNodeInto(child, node, node.getChildCount());
        }
        dtml.reload(node);
    }
 
    /**
     * 树节点选择事件
     * 
     * @param e
     */
    private void clsTreeSelectionListener(TreeSelectionEvent e) {
        this.addBtn.setVisible(true);
        this.editBtn.setVisible(true);
        this.delBtn.setVisible(true);
        TreePath tp = e.getPath();
        DefaultMutableTreeNode node = (DefaultMutableTreeNode) tp.getLastPathComponent();
        Object userObject = node.getUserObject();
        if (userObject instanceof String) {
            this.currentCls = null;
 
            // 当选择为根节点时设置Action操作按钮不显示
            this.addBtn.setVisible(false);
            this.editBtn.setVisible(false);
//             this.delBtn.setVisible(false);
        } else {
            ClientPLActionCls pac = (ClientPLActionCls) userObject;
            this.currentCls = pac.getPac();
        }
        actionTablePanel.refreshTableData();
    }
 
    /**
     * Action管理
     * 
     * @return
     */
    private JPanel getActionPanel() {
        JPanel topPanel = new JPanel();
        topPanel.setLayout(new BorderLayout());
        // 查询区域
        VCIJPanel queryPanel = new VCIJPanel(new GridBagLayout());
        int gridx = 0;
        int gridy = 0;
        int padxy = 2;
        int anchor = GridBagConstraints.NORTHWEST;
        int fill = GridBagConstraints.BOTH;
        queryPanel.add(lblCode, getGBC(gridx++, gridy, 1, 1, 0, 0, anchor, fill, padxy));
        queryPanel.add(txtCode, getGBC(gridx++, gridy, 1, 1, 1.0, 0.0, anchor, fill, padxy));
        queryPanel.add(lblName, getGBC(gridx++, gridy, 1, 1, 0, 0, anchor, fill, padxy));
        queryPanel.add(txtName, getGBC(gridx++, gridy, 1, 1, 1.0, 0.0, anchor, fill, padxy));
 
        gridx = 0;
        gridy += 1;
        queryPanel.add(lblBSClass, getGBC(gridx++, gridy, 1, 1, 0, 0, anchor, fill, padxy));
        queryPanel.add(txtBSClass, getGBC(gridx++, gridy, 1, 1, 1.0, 0.0, anchor, fill, padxy));
        queryPanel.add(lblCSClass, getGBC(gridx++, gridy, 1, 1, 0, 0, anchor, fill, padxy));
        queryPanel.add(txtCSClass, getGBC(gridx++, gridy, 1, 1, 1.0, 0.0, anchor, fill, padxy));
 
        gridx = 0;
        gridy += 1;
        queryPanel.add(lblType, getGBC(gridx++, gridy, 1, 1, 0, 0, anchor, fill, padxy));
        queryPanel.add(cbxType, getGBC(gridx++, gridy, 1, 1, 1.0, 0.0, anchor, fill, padxy));
        queryPanel.add(lblDesc, getGBC(gridx++, gridy, 1, 1, 0, 0, anchor, fill, padxy));
        queryPanel.add(txtDesc, getGBC(gridx++, gridy, 1, 1, 1.0, 0.0, anchor, fill, padxy));
 
        VCIJPanel pb = new VCIJPanel();
        pb.add(btnSearch);
        pb.add(btnClear);
 
//        JPanel btnPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
//        btnPanel.add(addBtn);
//        btnPanel.add(editBtn);
//        btnPanel.add(delBtn);
 
        VCIJPanel pp = new VCIJPanel(new BorderLayout());
        pp.add(queryPanel, BorderLayout.NORTH);
        pp.add(pb, BorderLayout.CENTER);
        //pp.add(btnPanel, BorderLayout.SOUTH);
 
        // 按钮列表
        actionTablePanel = new VCIJTablePanel<PLAction>(new ActionDataProvider());
        actionTablePanel.setPageSizeList(new int[] { 100, 150, 200, 250, 300, 350, 400 });
        HashMap<Integer, Integer> columnWidthMap = new HashMap<Integer, Integer>();
        columnWidthMap.put(1, 150);
        columnWidthMap.put(2, 250);
        columnWidthMap.put(3, 400);
        columnWidthMap.put(4, 500);
        columnWidthMap.put(5, 300);
        columnWidthMap.put(6, 200);
        columnWidthMap.put(7, 500);
        actionTablePanel.setColumnWidthMaps(columnWidthMap);
        actionTablePanel.setLastClickRowToChecked(true);
        actionTablePanel.setShowCheckbox(false);
        actionTablePanel.setShowPaging(false);
        actionTablePanel.setCustomButtons(getSelfCustomButtons());
        actionTablePanel.buildTablePanel();
        actionTablePanel.refreshTableData();
        actionTablePanel.getTable().getSelectionModel().addListSelectionListener(new ListSelectionListener() {
            public void valueChanged(ListSelectionEvent e) {
                refreshParamTable();
            }
        });
 
        topPanel.add(pp, BorderLayout.NORTH);
        topPanel.add(actionTablePanel, BorderLayout.CENTER);
 
        return topPanel;
    }
    
    private List<VCIJButton> selfCustomButtons = new LinkedList<VCIJButton>();
 
    private List<VCIJButton> getSelfCustomButtons() {
        selfCustomButtons.clear();
        
        selfCustomButtons.add(addBtn);
        selfCustomButtons.add(editBtn);
        selfCustomButtons.add(delBtn);
        
        return selfCustomButtons;
    }
 
 
    class ActionDataProvider extends AbstractVCIJTableDataProvider<PLAction> {
        @Override
        public PLAction[] getDatas(int pageIndex, int pageSize) {
            PLAction[] res = getTablePanelData();
            super.total = res.length;
            return res;
        }
 
        @Override
        public VCIJTableNode<PLAction> getNewRowNode(PLAction obj) {
            return getTablePanelNode(obj);
        }
 
        @Override
        public String[] getSpecialColumns() {
            return headerName;
        }
 
        @Override
        public int getTotal() {
            return total;
        }
    }
 
    /**
     * 查询Action表格数据
     * 
     * @return
     */
    private PLAction[] getTablePanelData() {
        PLAction[] res = null;
        try {
            res = UITools.getService().getPLActionsByConsArray(getFilterConstraints());
        } catch (VCIError e) {
            e.printStackTrace();
        }
 
        Arrays.sort(res, new Comparator<PLAction>() {
            @Override
            public int compare(PLAction o1, PLAction o2) {
                String py1 = PinyinCommon.getPingYin(o1.plCode);
                String py2 = PinyinCommon.getPingYin(o2.plCode);
                return py1.compareTo(py2);
            }
        });
        return res;
    }
 
    /**
     * 设置table查询条件
     * 
     * @return
     */
    private Constraint[] getFilterConstraints() {
        Constraint[] consArray = new Constraint[7];
        if (this.currentCls == null) {
            consArray = new Constraint[6];
        }
        consArray[0] = new Constraint("plcode", txtCode.getText().trim());
        consArray[1] = new Constraint("plname", txtName.getText().trim());
        consArray[2] = new Constraint("plbsurl", txtBSClass.getText().trim());
        consArray[3] = new Constraint("plcsclass", txtCSClass.getText().trim());
        String type = cbxType.getSelectedItem().toString();
        if (type.equals("业务类型")) {
            type = "business";
        } else if (type.equals("链接类型")) {
            type = "link";
        }
        consArray[4] = new Constraint("pltypetype", type);
        consArray[5] = new Constraint("pldesc", txtDesc.getText().trim());
        if (this.currentCls != null) {
            if (this.currentCls.name.equals("未分类")) {
                consArray[6] = new Constraint("plactioncls", "");
            } else {
                consArray[6] = new Constraint("plactioncls", this.currentCls.id);
            }
        }
        return consArray;
    }
 
    private VCIJTableNode<PLAction> getTablePanelNode(PLAction obj) {
        VCIJTableNode<PLAction> res = new VCIJTableNode<PLAction>(obj);
        res.setPropertyValue(headerName[0], obj.plCode);
        res.setPropertyValue(headerName[1], obj.plName);
        res.setPropertyValue(headerName[2], obj.plCSClass);
        res.setPropertyValue(headerName[3], obj.plBSUrl);
        String plTypeType = obj.plTypeType;
        String disType = "";
        if (plTypeType.equals("business")) {
            disType = "业务类型";
        } else if (plTypeType.equals("link")) {
            disType = "链接类型";
        }
        res.setPropertyValue(headerName[4], disType);
        res.setPropertyValue(headerName[5], obj.plDesc);
        return res;
    }
 
    /**
     * 得到按钮参数列表
     * 
     * @return
     */
    private JPanel getParamPanel() {
        JPanel btnPanel = new JPanel();
        btnPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
        paramCreateBtn = VCISwingUtil.createVCIJButton("add", "增加", "增加", "add.png");
        paramCreateBtn.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                paramCreateBtnActionListener();
            }
        });
        paramEditBtn = VCISwingUtil.createVCIJButton("edit", "修改", "修改", "edit.png");
        paramEditBtn.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                paramEditBtnActionListener();
            }
        });
        paramDeleteBtn = VCISwingUtil.createVCIJButton("delete", "删除", "查询", "delete.png");
        paramDeleteBtn.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                paramDeleteBtnActionListener();
            }
        });
        btnPanel.add(paramCreateBtn);
        btnPanel.add(paramEditBtn);
        btnPanel.add(paramDeleteBtn);
 
        DefaultTableModel dtml = new DefaultTableModel(new String[0][0], getParamTableColumns()) {
            /**
             * serialVersionUID
             */
            private static final long serialVersionUID = 1L;
 
            @Override
            public boolean isCellEditable(int row, int column) {
                return false;
            }
        };
        paramTable = new JTable(dtml);
        paramTable.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
 
        // DefaultTableColumnModel tcml = (DefaultTableColumnModel)
        // paramTable.getColumnModel();
        JScrollPane tableScrollPane = new JScrollPane(paramTable);
 
        JPanel paramPanel = new JPanel(new BorderLayout());
        paramPanel.add(btnPanel, BorderLayout.NORTH);
        paramPanel.add(tableScrollPane, BorderLayout.CENTER);
        return paramPanel;
    }
 
    /**
     * 得到参数列表列头
     * 
     * @return
     */
    private String[] getParamTableColumns() {
        return new String[] { "参数名称", "默认值", "提示信息" };
    }
 
    /**
     * 参数创建事件
     */
    private void paramCreateBtnActionListener() {
        int[] row = actionTablePanel.getSelectedRowIndexs();
        if (row != null && row.length > 0) {
            PLAction action = actionTablePanel.getSpecialObjectByRowIndex(row[0]);
            PLActionParamEditDialog dialog = new PLActionParamEditDialog(ClientContextVariable.getFrame(), "添加参数", 0,
                    action, null);
            if (dialog.isOk()) {
                refreshParamTable(action);
            }
        } else {
            JOptionPane.showMessageDialog(this, "请选择Action再进行按钮参数创建!", "系统提示", JOptionPane.INFORMATION_MESSAGE);
        }
    }
 
    /**
     * 按钮参数修改事件
     */
    private void paramEditBtnActionListener() {
        int row = actionTablePanel.getTable().getSelectedRow();
        if (row != -1) {
            // 得到按钮
            PLAction action = actionTablePanel.getSpecialObjectByRowIndex(row);
            // 得到参数
            DefaultTableModel dtml = (DefaultTableModel) paramTable.getModel();
            if (paramTable.getSelectedRow() == -1) {
                JOptionPane.showMessageDialog(this, "请选择按钮参数进行修改操作!", "系统提示", JOptionPane.INFORMATION_MESSAGE);
                return;
            }
            ClientPLActionParam valueAt = (ClientPLActionParam) dtml.getValueAt(paramTable.getSelectedRow(), 0);
            PLActionParamEditDialog dialog = new PLActionParamEditDialog(ClientContextVariable.getFrame(), "添加参数", 1,
                    action, valueAt.getPap());
            if (dialog.isOk()) {
                refreshParamTable(action);
            }
        } else {
            JOptionPane.showMessageDialog(this, "请选择Action再进行按钮参数创建!", "系统提示", JOptionPane.INFORMATION_MESSAGE);
        }
    }
 
    /**
     * 按钮参数删除事件
     */
    private void paramDeleteBtnActionListener() {
        DefaultTableModel dtml = (DefaultTableModel) paramTable.getModel();
        if (paramTable.getSelectedRow() == -1) {
            JOptionPane.showMessageDialog(this, "请选择按钮参数进行删除操作!", "系统提示", JOptionPane.INFORMATION_MESSAGE);
            return;
        }
        ClientPLActionParam valueAt = (ClientPLActionParam) dtml.getValueAt(paramTable.getSelectedRow(), 0);
        Object[] options = { "Yes", "No" };
        int option = JOptionPane.showOptionDialog(this, "确认是否删除Action参数\"" + valueAt.getPap().name + "\"", "Action参数删除",
                JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[1]);
        if (option != JOptionPane.YES_OPTION) {
            return;
        }
        String message = UITools.getService().deletePLActionParam(valueAt.getPap().oid);
        if (message.startsWith("0")) {
            JOptionPane.showMessageDialog(this, "删除按钮参数时发生异常:" + message.substring(1), "系统提示",
                    JOptionPane.INFORMATION_MESSAGE);
            return;
        }
        JOptionPane.showMessageDialog(this, "按钮参数删除成功!", "系统提示", JOptionPane.INFORMATION_MESSAGE);
        refreshParamTable();
    }
 
    /**
     * 刷新按钮参数列表数据
     */
    private void refreshParamTable() {
        int row = actionTablePanel.getTable().getSelectedRow();
        if (row != -1) {
            PLAction action = actionTablePanel.getSpecialObjectByRowIndex(row);
            refreshParamTable(action);
        } else {
            refreshParamTable(null);
        }
    }
 
    /**
     * 刷新按钮参数列表
     * 
     * @param action
     */
    private void refreshParamTable(PLAction action) {
        try {
            // 重新加载按钮参数对象
            PLActionParam[] params = null;
            Object[][] cParams = null;
            if (action != null) {
                String id = action.plOId;
                params = UITools.getService().getPLActionParamArrayByActionId(id);
                cParams = new Object[params.length][3];
                for (int i = 0; i < params.length; i++) {
                    Object[] objs = new Object[3];
                    objs[0] = new ClientPLActionParam(params[i]);
                    objs[1] = params[i].defaultValue;
                    objs[2] = params[i].description;
                    cParams[i] = objs;
                }
            }
            if (cParams == null) {
                cParams = new Object[0][0];
            }
            // 重新设置表格数据
            DefaultTableModel dtml = (DefaultTableModel) paramTable.getModel();
            // DefaultTableColumnModel tcml = (DefaultTableColumnModel)
            // paramTable.getColumnModel();
            dtml.setDataVector(cParams, getParamTableColumns());
            paramTable.updateUI();
        } catch (VCIError e) {
            e.printStackTrace();
            JOptionPane.showMessageDialog(ClientContextVariable.getFrame(), "加载参数信息异常:" + e.getMessage(), "",
                    JOptionPane.ERROR_MESSAGE);
        }
    }
 
    private PLAction getSelectedAction() {
        int[] rows = actionTablePanel.getSelectedRowIndexs();
        int selectedRowCount = rows.length;
        if (selectedRowCount == 0) {
            VCIOptionPane.showMessage(LogonApplication.frame, "请选择一条数据!");
            return null;
        } else if (selectedRowCount > 1) {
            VCIOptionPane.showMessage(LogonApplication.frame, "一次只能选择一条数据进行此操作!");
            return null;
        }
        return actionTablePanel.getSpecialObjectByRowIndex(rows[0]);
    }
 
    private void clear() {
        txtCode.setText("");
        txtName.setText("");
        txtBSClass.setText("");
        txtCSClass.setText("");
        cbxType.setSelectedIndex(0);
        cbxType.setSelectedItem("");
        txtDesc.setText("");
    }
 
    private void initActionListener() {
        btnClear.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent arg0) {
                clear();
            }
        });
        btnSearch.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent arg0) {
                actionTablePanel.refreshTableData();
            }
        });
        addBtn.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent arg0) {
                addBtnAction();
            }
        });
        editBtn.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent arg0) {
                PLAction obj = getSelectedAction();
                if (obj == null)
                    return;
                @SuppressWarnings("unused")
                ActionEditDialog dialog = new ActionEditDialog(currentCls, obj);
                actionTablePanel.refreshTableData();
            }
        });
        delBtn.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent arg0) {
                PLAction obj = getSelectedAction();
                if (obj == null)
                    return;
                Object[] options = { "Yes", "No" };
                int option = JOptionPane.showOptionDialog(LogonApplication.frame, "确认是否删除Action\"" + obj.plName + "\"",
                        "Action删除", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[1]);
                if (option != JOptionPane.YES_OPTION) {
                    return;
                }
                try {
                    UITools.getService().deletePLAction(obj);
                    VCIOptionPane.showMessage(LogonApplication.frame, "删除成功!");
                } catch (VCIError e) {
                    VCIOptionPane.showMessage(LogonApplication.frame, "删除失败!");
                    e.printStackTrace();
                }
                actionTablePanel.refreshTableData();
            }
        });
    }
 
    /**
     * 
     */
    private void addBtnAction() {
        if (currentCls == null) {
            JOptionPane.showMessageDialog(ClientContextVariable.getFrame(), "请选择分类节点创建Action!", "系统提示",
                    JOptionPane.INFORMATION_MESSAGE);
            return;
        }
        @SuppressWarnings("unused")
        ActionEditDialog dialog = new ActionEditDialog(currentCls, null);
        actionTablePanel.refreshTableData();
    }
 
    /**
     * 创建分类按钮
     */
    private void createCls() {
        TreePath selectionPath = this.clsTree.getSelectionPath();
        if (selectionPath == null) {
            JOptionPane.showMessageDialog(ClientContextVariable.getFrame(), "请选择分类进行子分类的创建!", "系统提示",
                    JOptionPane.INFORMATION_MESSAGE);
            return;
        }
        // 得到父节点的ID
        PLActionCls pac = null;
        DefaultMutableTreeNode dmtn = (DefaultMutableTreeNode) selectionPath.getLastPathComponent();
        Object userObject = dmtn.getUserObject();
        if (!(userObject instanceof String)) {
            ClientPLActionCls cplac = (ClientPLActionCls) userObject;
            pac = cplac.getPac();
            if (pac.name.equals("未分类")) {
                JOptionPane.showMessageDialog(ClientContextVariable.getFrame(), "未分类下不能创建子分类!", "系统提示",
                        JOptionPane.INFORMATION_MESSAGE);
                return;
            }
        }
        // 打开创建窗口
        PLActionClsEditDialog dialog = new PLActionClsEditDialog(ClientContextVariable.getFrame(), "创建分类", 0, pac,
                null);
        if (dialog.isOk()) {
            this.refreshClsTree(selectionPath);
            clsTree.expandPath(selectionPath);
        }
    }
 
    /**
     * 修改分类按钮
     */
    private void editCls() {
        TreePath selectionPath = this.clsTree.getSelectionPath();
        if (selectionPath == null) {
            JOptionPane.showMessageDialog(ClientContextVariable.getFrame(), "请选择分类进行修改!", "系统提示",
                    JOptionPane.INFORMATION_MESSAGE);
            return;
        }
        // 得到父节点的ID
        PLActionCls pac = null;
        DefaultMutableTreeNode dmtn = (DefaultMutableTreeNode) selectionPath.getLastPathComponent();
        Object userObject = dmtn.getUserObject();
        if (!(userObject instanceof String)) {
            ClientPLActionCls cplac = (ClientPLActionCls) userObject;
            pac = cplac.getPac();
            if (pac.name.equals("未分类")) {
                JOptionPane.showMessageDialog(ClientContextVariable.getFrame(), "未分类不能修改!", "系统提示",
                        JOptionPane.INFORMATION_MESSAGE);
                return;
            }
        } else {
            JOptionPane.showMessageDialog(ClientContextVariable.getFrame(), "根节点不能修改!", "系统提示",
                    JOptionPane.INFORMATION_MESSAGE);
            return;
        }
        // 得到父节点信息
        TreePath parentPath = selectionPath.getParentPath();
        DefaultMutableTreeNode parentNode = (DefaultMutableTreeNode) parentPath.getLastPathComponent();
        Object parentObject = parentNode.getUserObject();
        PLActionCls parent = null;
        if (!(parentObject instanceof String)) {
            ClientPLActionCls cplac = (ClientPLActionCls) userObject;
            parent = cplac.getPac();
        }
        // 打开创建窗口
        PLActionClsEditDialog dialog = new PLActionClsEditDialog(ClientContextVariable.getFrame(), "修改分类", 1, parent,
                pac);
        // 打开创建窗口
        if (dialog.isOk()) {
            this.refreshClsTree(parentPath);
            clsTree.setSelectionPath(selectionPath);
        }
    }
 
    /**
     * 删除分类
     */
    private void deleteCls() {
        TreePath selectionPath = this.clsTree.getSelectionPath();
        if (selectionPath == null) {
            JOptionPane.showMessageDialog(ClientContextVariable.getFrame(), "请选择分类进行删除!", "系统提示",
                    JOptionPane.INFORMATION_MESSAGE);
            return;
        }
        // 得到父节点的ID
        PLActionCls pac = null;
        DefaultMutableTreeNode dmtn = (DefaultMutableTreeNode) selectionPath.getLastPathComponent();
        Object userObject = dmtn.getUserObject();
        if (!(userObject instanceof String)) {
            ClientPLActionCls cplac = (ClientPLActionCls) userObject;
            pac = cplac.getPac();
            if (pac.name.equals("未分类")) {
                JOptionPane.showMessageDialog(ClientContextVariable.getFrame(), "未分类不能删除!", "系统提示",
                        JOptionPane.INFORMATION_MESSAGE);
                return;
            }
        } else {
            JOptionPane.showMessageDialog(ClientContextVariable.getFrame(), "根节点不能删除!", "系统提示",
                    JOptionPane.INFORMATION_MESSAGE);
            return;
        }
 
        if (existChildCls(pac)) {
            JOptionPane.showMessageDialog(ClientContextVariable.getFrame(), "该分类下存在子分类不能删除!\n请删除此分类下的子分类!", "系统提示",
                    JOptionPane.INFORMATION_MESSAGE);
            return;
        }
        // 确认窗口
        /*
         * int confirm = JOptionPane.showConfirmDialog(
         * ClientContextVariable.getFrame(),
         * "是否确定执行删除操作,如果执行删除操作,\n该分类下所有Action将变为未分类!", "系统提示",
         * JOptionPane.OK_CANCEL_OPTION);
         */
        Object[] options = { "Yes", "No" };
        int confirm = JOptionPane.showOptionDialog(ClientContextVariable.getFrame(),
                "确认是否删除Action分类\"" + pac.name + "\"", "Action分类删除", JOptionPane.YES_NO_OPTION,
                JOptionPane.QUESTION_MESSAGE, null, options, options[1]);
        if (confirm != JOptionPane.YES_OPTION) {
            return;
        }
        if (confirm == JOptionPane.OK_OPTION) {
            // 执行删除操作
            String message = UITools.getService().deletePLActionClsById(pac.id);
            if (message.startsWith("0")) {
                JOptionPane.showMessageDialog(ClientContextVariable.getFrame(), "删除分类失败!" + message.substring(1),
                        "系统提示", JOptionPane.INFORMATION_MESSAGE);
                return;
            }
            JOptionPane.showMessageDialog(ClientContextVariable.getFrame(), "分类删除成功!" + message.substring(1), "系统提示",
                    JOptionPane.INFORMATION_MESSAGE);
            this.refreshClsTree(selectionPath.getParentPath());
        }
    }
 
    // add by zylon 删除树节点时,检查是否存在子分类
    private boolean existChildCls(PLActionCls pac) {
        if (clsPids.contains(pac.id)) {
            return true;
        }
        return false;
    }
 
    private GridBagConstraints getGBC(int gridx, int gridy, int gridwidth, int gridheight, double weightx,
            double weighty, int anchor, int fill, int padxy) {
        return new GridBagConstraints(gridx, gridy, gridwidth, gridheight, weightx, weighty, anchor, fill,
                new Insets(padxy, padxy, padxy, padxy), padxy, padxy);
    }
}