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
package com.vci.client.auth2.utils;
 
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
 
import javax.swing.DefaultListModel;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.ListModel;
import javax.swing.table.JTableHeader;
import javax.swing.table.TableColumn;
import javax.swing.table.TableColumnModel;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.TreePath;
import javax.swing.tree.TreeSelectionModel;
 
import org.dom4j.Document;
 
import com.vci.client.LogonApplication;
import com.vci.client.auth2.model.BooleanTableModel;
import com.vci.client.auth2.view.AbstractUIFunclet;
import com.vci.client.auth2.view.OrdinaryOpPanel;
import com.vci.client.auth2.view.RelationAndLifeCycleOpPanel;
import com.vci.client.auth2.vo.OpItem;
import com.vci.client.auth2.vo.SelectedSubjectItem;
import com.vci.client.omd.btm.wrapper.BtmItemWrapper;
import com.vci.client.omd.provider.BtmProvider;
import com.vci.client.omd.provider.LifeCycleProvider;
import com.vci.client.omd.provider.LinkTypeProvider;
import com.vci.client.oq.ui.ConditionPanel;
import com.vci.client.common.ClientLog4j;
import com.vci.client.common.oq.OQTool;
import com.vci.client.common.providers.ServiceProvider;
import com.vci.common.qt.object.QueryTemplate;
import com.vci.common.qt.object.Symbol;
//import com.vci.corba.auth2.Auth2ServicePrx;
import com.vci.corba.framework.data.GrandValue;
import com.vci.corba.framework.FrameworkServicePrx;
import com.vci.corba.common.VCIError;
import com.vci.corba.omd.btm.BtmItem;
import com.vci.corba.omd.lcm.LifeCycle;
import com.vci.corba.omd.lcm.TransitionVO;
import com.vci.corba.omd.ltm.LinkType;
import com.vci.corba.omd.qtm.QTD;
import com.vci.corba.omd.qtm.QTInfo;
import com.vci.corba.portal.data.PLAction;
 
public class RightManagerHelper {
//    private static FrameworkServicePrx frameService = null;
//
//    public static FrameworkServicePrx getFrameworkService() throws VCIError {
//        if (frameService != null) {
//            return frameService;
//        }
//        try {
//
//            return frameService = ServiceProvider.getFrameService();
//        } catch (Exception e) {
//            ClientLog4j.logger.error(e.getMessage(), e);
//            throw new VCIError("1", new String[] { e.getMessage() });
//        }
//    }
 
 
    public static BtmItem getResourceType(AbstractUIFunclet funclet) {
        TreeSelectionModel model = (TreeSelectionModel) funclet.getResourceTree().getSelectionModel();
        TreePath path = model.getSelectionPath();
        if (null == path) {
            return null;
        }
        DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getLastPathComponent();
        if (!(node.getUserObject() instanceof BtmItemWrapper)) {
            return null;
        }
        // 类型信息
        BtmItemWrapper btmWrap = (BtmItemWrapper) node.getUserObject();
        if (null == btmWrap || btmWrap.btmItem == null) {
            return null;
        }
        return btmWrap.btmItem;
    }
 
    public static GrandValue[] getRightDatas(String typeName) {
        GrandValue[] dataSets = null;
        try {
            dataSets = ServiceProvider.getFrameService().queryGrand(typeName);
        } catch (Throwable e) {
            JOptionPane.showMessageDialog(LogonApplication.frame,
                    ((VCIError) e).messages[0], "错误提示", JOptionPane.ERROR_MESSAGE);
            return dataSets;
        }
        return dataSets;
    }
 
    public static void setRuleListDatas(AbstractUIFunclet funclet, GrandValue[] values, String typeName) {
        BooleanTableModel ruleModel = (BooleanTableModel) funclet.getRightMainPanel().getRuleTable().getModel();
        // 刷新页面缓存
        funclet.getRightMainPanel().getRuleTable().removeAll();
        // ruleModel.RemoveAllConditionValue();
        setRuleTableHeader(funclet, values, typeName); // add by caill 2015.12.18 增加参数typeName
        setColunmData(funclet, values, typeName); // add by caill 2015.12.18 增加参数typeName
        funclet.getRightMainPanel().getRuleTable().setModel(ruleModel);
    }
 
    private static void setColunmData(AbstractUIFunclet funclet, GrandValue[] values, String typeName) {
        BooleanTableModel ruleModel = (BooleanTableModel) funclet.getRightMainPanel().getRuleTable().getModel();
        // 依据规则名称,规则分类
        Map<String, List<GrandValue>> splitRuleMap = splitRuleByName(values);
        // 依据规则名称
        int row = 0;
        // 设置规则记录行数
        ruleModel.setRowCount(splitRuleMap.size());
        // add by caill start 2016.1.11 得到btm、link、lifeCyles
        LinkType[] links = null;
        LifeCycle lifeCycle = null;
        BtmItem btm = null;
        try {
            btm = BtmProvider.getInstance().getBtmItemByName(typeName);
            links = LinkTypeProvider.getInstance().getLinkTypeByBtmName(btm.name, Symbol.FROM);
            LifeCycle[] lifeCyles = LifeCycleProvider.getInstance().getLifeCyles();
            for (int m = 0; m < lifeCyles.length; m++) {
                if (lifeCyles[m].name.equals(btm.lifeCycle)) {
                    lifeCycle = lifeCyles[m];
                    break;
                }
            }
        } catch (Throwable e) {
            e.printStackTrace();
        }
 
        // add by caill end
        ActionConstants act = new ActionConstants();
        PLAction[] allActions = act.getAllPLActionEntityByType(typeName);
        for (Iterator<Map.Entry<String, List<GrandValue>>> iter = splitRuleMap.entrySet().iterator(); iter.hasNext();) {
            Entry<String, List<GrandValue>> entry = iter.next();
            List<GrandValue> rules = entry.getValue();
 
            // 增加页面缓存
            ruleModel.setConditionValue(row, rules);
            // add by caill start 2015 12.18 将查出的action放到map中,注意不要落下“查询”
            Map<String, String> actionMap = new HashMap<String, String>();
            actionMap.put("query", "查询"); // 将操作中的query放入actionMap中
            for (int i = 0; i < allActions.length; i++) {
                if (allActions[i].plTypeType.equals("business")) {
                    actionMap.put(allActions[i].plCode, allActions[i].plName); // 将操作放入actionMap中
                }
            }
            for (int j = 0; j < links.length; j++) {
                for (int i = 0; i < allActions.length; i++) {
                    if (allActions[i].plTypeType.equals("link")) {
                        actionMap.put(links[j].name + "." + allActions[i].plCode,
                                links[j].name + "." + allActions[i].plName);// 将关系放入actionMap中
                    }
                }
                actionMap.put(links[j].name + "." + "query", links[j].name + "." + "查询"); // 将关系中的query放入actionMap中
            }
 
            TransitionVO[] transitions = lifeCycle != null ? lifeCycle.routes : new TransitionVO[0];
            for (int j = 0; j < transitions.length; j++) {
                String name = lifeCycle.name + "." + transitions[j].connect;
                actionMap.put(name, name); // 将跃迁放入actionMap中
            }
            // add by caill end
            for (int j = 0; j < rules.size(); j++) {
                // 规则名和类型
                ruleModel.setValueAt(rules.get(j).ruleName, row, 0);
                if (rules.get(j).ruleType.equals(IRightConstant.RULETYPE__HAS)) {
                    ruleModel.setValueAt("允许规则", row, 1);
                } else if (rules.get(j).ruleType.equals(IRightConstant.RULETYPE__NOTHAS)) {
                    ruleModel.setValueAt("拒绝规则", row, 1);
                } else if (rules.get(j).ruleType.equals(IRightConstant.RULETYPE_ALL_HAS)) {
                    ruleModel.setValueAt("全部有权", row, 1);
                } else {
                    ruleModel.setValueAt("全部无权", row, 1);
                }
                // 指定的操作赋值
                TableColumnModel columnModel = funclet.getRightMainPanel().getRuleTable().getColumnModel();
                int start = rules.get(j).identifier.lastIndexOf("_") + 1;
                String op = rules.get(j).identifier.substring(start, rules.get(j).identifier.length());
                // add by caill start 2015.12.18 遍历map,根据英文名称找到相应的中文名称,并根据中文名称找到对应的列
                String headerName = null;
                Set<String> keys = null;
                if (actionMap.size() > 0) {
                    keys = actionMap.keySet();
                }
                if (keys.size() != 0) {
                    for (Iterator<String> iterator = keys.iterator(); iterator.hasNext();) {
                        String key = iterator.next();
                        if (op.equals(key)) {
                            headerName = actionMap.get(key);
                            break;
                        }
                    }
                }
 
                int columnIndex = -1;
                if (headerName != null) {
                    columnIndex = columnModel.getColumnIndex(headerName);
                }
                // add by caill end
                // int columnIndex = columnModel.getColumnIndex(op);
                if (columnIndex >= 0) {
                    ruleModel.setValueAt(rules.get(j).isGrand == '1' ? true : false, row, columnIndex);
                }
 
            }
            ++row;
        }
    }
 
    private static Map<String, List<GrandValue>> splitRuleByName(GrandValue[] values) {
        Map<String, List<GrandValue>> splitRuleMap = new HashMap<String, List<GrandValue>>();
        for (int i = 0; i < values.length; i++) {
            if (splitRuleMap.get(values[i].ruleName) == null) {
                List<GrandValue> ruleOfOneName = new ArrayList<GrandValue>();
                ruleOfOneName.add(values[i]);
                splitRuleMap.put(values[i].ruleName, ruleOfOneName);
            } else {
                splitRuleMap.get(values[i].ruleName).add(values[i]);
            }
 
        }
        return splitRuleMap;
 
    }
 
    private static void setRuleTableHeader(AbstractUIFunclet funclet, GrandValue[] values, String typeName) {
        BooleanTableModel ruleModel = (BooleanTableModel) funclet.getRightMainPanel().getRuleTable().getModel();
        // 操作信息
        List<String> ops = new ArrayList<String>();
        for (int i = 0; i < values.length; i++) {
            int start = values[i].identifier.lastIndexOf("_") + 1;
            String op = values[i].identifier.substring(start, values[i].identifier.length());
            if (!ops.contains(op)) {
                ops.add(op);
            }
        }
        // 操作信息
        String[] operations = ops.toArray(new String[ops.size()]);
        // 设置Table列头信息
        List<String> tableHeader = new ArrayList<String>();
        List<String> tablerule = new ArrayList<String>();
        tableHeader.add("规则名称");
        tableHeader.add("规则类型");
 
        // add by caill start 2015.12.18 将中文名称装入表头
        ActionConstants act = new ActionConstants();
        PLAction[] allActions = act.getAllPLActionEntityByType(typeName);
        for (int m = 0; m < operations.length; m++) {
            if (allActions != null && allActions.length != 0) {
                for (int i = 0; i < allActions.length; i++) {
                    if (allActions[i].plCode.equals(operations[m])) {
                        tableHeader.add(allActions[i].plName);
                        break;
                    } else if (operations[m].endsWith("." + allActions[i].plCode)) {
                        int index = operations[m].indexOf("." + allActions[i].plCode);
                        StringBuilder sb = new StringBuilder(operations[m]);
                        StringBuilder actionChina = sb.replace(index + 1, operations[m].length(), allActions[i].plName);
                        tableHeader.add(actionChina.toString());
                        break;
                    } else if (operations[m].equals("query")) {
                        tableHeader.add("查询"); // 注意不要落下写死的“查询”
                        break;
                    } else if (operations[m].endsWith(".query")) {
                        int index = operations[m].indexOf(".query");
                        StringBuilder sb = new StringBuilder(operations[m]);
                        StringBuilder actionChina = sb.replace(index + 1, operations[m].length(), "查询");
                        tableHeader.add(actionChina.toString());
                        break;
                    }
 
                }
                /*
                 * if(sign == allActions.length){ tableHeader.add(operations[m]); }
                 */
            } else {
                if (operations[m].equals("query")) {
                    tableHeader.add("查询"); // 注意不要落下写死的“查询”
                }
                if (operations[m].endsWith(".query")) {
                    int index = operations[m].indexOf(".query");
                    StringBuilder sb = new StringBuilder(operations[m]);
                    StringBuilder actionChina = sb.replace(index + 1, operations[m].length(), "查询");
                    tableHeader.add(actionChina.toString());
                }
            }
 
        }
        LifeCycle lifeCycle = null;
        BtmItem btm = null;
        try {
            btm = BtmProvider.getInstance().getBtmItemByName(typeName);
//            links = ClientCacheFacade.getInstance().getLinkType(btm.name,
//                    ICacheConstant.Direction_From);
            LifeCycle[] lifeCyles = LifeCycleProvider.getInstance().getLifeCyles();
            for (int j = 0; j < lifeCyles.length; j++) {
                if (lifeCyles[j].name.equals(btm.lifeCycle)) {
                    lifeCycle = lifeCyles[j];
                    break;
                }
            }
        } catch (Throwable e) {
            e.printStackTrace();
        }
        TransitionVO[] transitions = lifeCycle != null ? lifeCycle.routes : new TransitionVO[0];
        for (int j = 0; j < transitions.length; j++) {
            tableHeader.add(lifeCycle.name + "." + transitions[j].connect);
        }
        // add by caill end
        // ruleModel.setColumnCount(tableHeader.size());
        ruleModel.setColumnIdentifiers(tableHeader.toArray(new String[tableHeader.size()]));
        // 设置列宽
        // JTable table = funclet.getRightMainPanel().getRuleTable();
        // TableColumnModel columnModel = table.getColumnModel();
        // double maxWidth = 0;
        // for (int i = 0; i < columnModel.getColumnCount(); i++) {
        // TableColumn column = columnModel.getColumn(i);
        // TableCellRenderer cellRenderer = column.getHeaderRenderer();
        // if (cellRenderer == null)
        // cellRenderer = table.getDefaultRenderer(columnModel
        // .getColumn(i).getClass());
        // Object headerValue = column.getHeaderValue();
        // Component columnComp = cellRenderer.getTableCellRendererComponent(
        // (JTable) table, headerValue, false, false, 0, i);
        //
        // maxWidth = Math.max(maxWidth, columnComp.getPreferredSize()
        // .getWidth());
        // }
        // JTableHeader jtableHeader = table.getTableHeader();
        //
        // Dimension size = jtableHeader.getPreferredSize();
        // size.width = (int) maxWidth;
        // jtableHeader.setPreferredSize(size);
        // int i =columnModel.getTotalColumnWidth();
        setPreferSizeColumnWidth(funclet);
 
    }
 
    public static void setPreferSizeColumnWidth(AbstractUIFunclet funclet) {
        JTable table = funclet.getRightMainPanel().getRuleTable();
        JTableHeader jtableHeader = table.getTableHeader();
        TableColumnModel columnModel = table.getColumnModel();
        // double maxWidth = 0;
        for (int i = 0; i < columnModel.getColumnCount(); i++) {
            TableColumn column = columnModel.getColumn(i);
            int col = jtableHeader.getColumnModel().getColumnIndex(column.getIdentifier());
            int width = (int) jtableHeader.getDefaultRenderer()
                    .getTableCellRendererComponent(table, column.getIdentifier(), false, false, -1, col)
                    .getPreferredSize().getWidth();
            for (int row = 0; row < table.getRowCount(); row++) {
                int preferSize = (int) table.getCellRenderer(row, col)
                        .getTableCellRendererComponent(table, table.getValueAt(row, col), false, false, row, col)
                        .getPreferredSize().getWidth();
                width = Math.max(width, preferSize);
            }
            jtableHeader.setResizingColumn(column);
            column.setWidth(width + table.getIntercellSpacing().width);
        }
    }
 
    public static void setRuleConditionDatas(AbstractUIFunclet funclet, int selectedRow, GrandValue value,
            String typeName) {
        if (value == null) {
            return;
        }
        // 设置规则的类型(会触发事件)
        funclet.getRightMainPanel().setRuleType(value.ruleType);
        if (value.ruleType.equals(IRightConstant.RULETYPE__NOTHAS)
                || value.ruleType.equals(IRightConstant.RULETYPE__HAS)) {
            ConditionPanel conditonPanel = (ConditionPanel) funclet.getRightMainPanel().getRightRulePanel();
            if ((conditonPanel instanceof ConditionPanel)) {
                if ((conditonPanel.getRadioBtm().isSelected() && isBtm(funclet, value))
                        || conditonPanel.getRadioLinkType().isSelected() && !isBtm(funclet, value)) {
                    // 重新绘制表达式面板
                    ((ConditionPanel) conditonPanel).setQTUI(getQtWraper(value, typeName, conditonPanel));
                    // 刷新界面
                    ((ConditionPanel) conditonPanel).updateUI();
                }
                addRadioListener(funclet, selectedRow, typeName, conditonPanel.getRadioBtm());
                addRadioListener(funclet, selectedRow, typeName, conditonPanel.getRadioLinkType());
            }
        }
        // 设置规则的名称
        funclet.getRightMainPanel().getRuleNameTextField().setText(value.ruleName);
    }
 
    private static boolean isBtm(AbstractUIFunclet funclet, GrandValue value) {
        ConditionPanel conditonPanel = (ConditionPanel) funclet.getRightMainPanel().getRightRulePanel();
        int flag = conditonPanel.getRadioFlag();
        if ((flag == 0 && value != null && value.ruleText != null && !value.ruleText.equals(""))
                || (flag == 1 && value != null && value.seniorRuleText != null && !value.seniorRuleText.equals(""))) {
            return true;
        }
        return false;
    }
 
    private static void addRadioListener(final AbstractUIFunclet funclet, final int selectedRow, final String typeName,
            JRadioButton radioBtn) {
        // 设置radio的监听事件(保留最初的监听)
        ItemListener[] ls = radioBtn.getItemListeners();
        List<ItemListener> oldLs = new ArrayList<ItemListener>();
        ItemListener old = ls[0];
        for (int i = 0; i < ls.length; i++) {
            oldLs.add(ls[i]);
        }
 
        for (int j = 0; j < oldLs.size(); j++) {
            radioBtn.removeItemListener(oldLs.get(j));
        }
 
        radioBtn.addItemListener(new ItemListener() {
            @Override
            public void itemStateChanged(ItemEvent e) {
                try {
                    BooleanTableModel ruleModel = (BooleanTableModel) funclet.getRightMainPanel().getRuleTable()
                            .getModel();
                    GrandValue value = ((List<GrandValue>) ruleModel.getConditionValueAt(selectedRow)).get(0);
                    BtmItem btm = RightManagerHelper.getResourceType(funclet);
                    if (btm == null || value == null) {
                        return;
                    }
                    // 重新绘制表达式面板
                    ConditionPanel conditonPanel = (ConditionPanel) funclet.getRightMainPanel().getRightRulePanel();
                    if ((conditonPanel.getRadioBtm().isSelected() && isBtm(funclet, value))
                            || conditonPanel.getRadioLinkType().isSelected() && !isBtm(funclet, value)) {
                        // 刷新规则面板数据
                        conditonPanel.setQTUI(getQtWraper(value, typeName, conditonPanel));
                        // 刷新界面
                        conditonPanel.updateUI();
                    }
                } catch (Exception ex) {
                    ex.printStackTrace();
                }
            }
        });
        radioBtn.addItemListener(old);
    }
 
    private static QTInfo getQtWraper(GrandValue value, String typeName, ConditionPanel conditonPanel) {
        QTInfo qtWrapper = new QTInfo();
        qtWrapper.btmName = typeName;
        qtWrapper.qtName = value.ruleName;
        // 业务类型
        if (!conditonPanel.isLinkTypeSelected()) {
            qtWrapper.qtText = value.ruleText;
            qtWrapper.qtUIText = value.seniorRuleText;
            if (value.seniorRuleText == null || value.seniorRuleText.equals(""))
                qtWrapper.levelFlag = 0;
            else
                qtWrapper.levelFlag = 1;
        } else {
            // 链接类型
            qtWrapper.qtText = value.lruleText;
            qtWrapper.qtUIText = value.lseniorRuleText;
            if (value.lseniorRuleText == null || value.lseniorRuleText.equals(""))
                qtWrapper.levelFlag = 0;
            else
                qtWrapper.levelFlag = 1;
        }
        return qtWrapper;
    }
 
    public static void setSubjectDatas(AbstractUIFunclet funclet, GrandValue value) {
        JList selectedSubjects = funclet.getRightMainPanel().getSelectedSubjectComponent();
        Object[] users = value.users.split(",");
        Object[] roles = value.roles.split(",");
        Object[] userGroups = value.userGroups.split(",");
        ListModel selectListModel = (ListModel) selectedSubjects.getModel();
        // 初始化数据模型,清空数据
        selectListModel = new DefaultListModel();
        ((DefaultListModel) selectListModel).setSize(users.length + roles.length + userGroups.length);
        for (int i = 0; i < users.length; i++) {
            if (users[i] != null && !users[i].equals("")) {
                SelectedSubjectItem item = new SelectedSubjectItem();
                item.setCode((String) (users[i]));
                item.setName((String) (users[i]));
                item.setType(IRightConstant.User);
                ((DefaultListModel) selectListModel).setElementAt(item, i);
            }
 
        }
        for (int i = users.length; i < users.length + roles.length; i++) {
            if (roles[i - users.length] != null && !roles[i - users.length].equals("")) {
                SelectedSubjectItem item = new SelectedSubjectItem();
                item.setCode((String) roles[i - users.length]);
                item.setName((String) roles[i - users.length]);
                item.setType(IRightConstant.Role);
 
                ((DefaultListModel) selectListModel).setElementAt(item, i);
            }
        }
 
        for (int i = users.length + roles.length; i < users.length + roles.length + userGroups.length; i++) {
            if (userGroups[i - users.length - roles.length] != null
                    && !userGroups[i - users.length - roles.length].equals("")) {
                SelectedSubjectItem item = new SelectedSubjectItem();
                item.setCode((String) userGroups[i - users.length - roles.length]);
                item.setName((String) userGroups[i - users.length - roles.length]);
                item.setType(IRightConstant.UserGroup);
 
                ((DefaultListModel) selectListModel).setElementAt(item, i);
            }
        }
        selectedSubjects.setModel(selectListModel);
        int selected[] = new int[users.length + roles.length + userGroups.length];
        for (int i = 0; i < users.length; i++) {
            selected[i] = i;
        }
        for (int i = users.length; i < users.length + roles.length; i++) {
            selected[i] = i;
 
        }
        for (int i = users.length + roles.length; i < users.length + roles.length + userGroups.length; i++) {
            selected[i] = i;
 
        }
        selectedSubjects.setSelectedIndices(selected);
        selectedSubjects.updateUI();
    }
 
    public static List<GrandValue> fillOperationsInfo(AbstractUIFunclet funclet, String typeName) {
        List<GrandValue> values = new ArrayList<GrandValue>();
        // 一般操作信息
        OpItem[] ops = ((OrdinaryOpPanel) funclet.getRightMainPanel().getOrdinaryOpPanel()).getOpObject();
        // 关系和跃迁
        OpItem[] rlops = ((RelationAndLifeCycleOpPanel) funclet.getRightMainPanel().getRelationAndLifeCycleOpPanel())
                .getOpObject();
        for (OpItem op : ops) {
            GrandValue value = new GrandValue();
            value.identifier = typeName + "_" + op.getName();
            value.ID = "";
            value.isGrand = (((Boolean) op.getValue()) == false ? (byte)'0' : (byte)'1');
            values.add(value);
        }
        // 关系和跃迁
        for (OpItem op : rlops) {
            GrandValue value = new GrandValue();
            value.identifier = typeName + "_" + op.getName();
            value.ID = "";
            value.isGrand = (((Boolean) op.getValue()) == false ? (byte)'0' : (byte)'1');
            values.add(value);
        }
        return values;
 
    }
 
    public static boolean fillSubjectInfo(AbstractUIFunclet funclet, List<GrandValue> values) {
 
        JList selectedSubjects = funclet.getRightMainPanel().getSelectedSubjectComponent();
        Object[] subjects = selectedSubjects.getSelectedValues();
 
        if (subjects == null || subjects.length == 0) {
            JOptionPane.showMessageDialog(com.vci.client.LogonApplication.frame, "请选择授权主体信息", "提示",
                    JOptionPane.INFORMATION_MESSAGE);
            return false;
        }
 
        // user
        StringBuffer user = new StringBuffer("");
        // role
        StringBuffer role = new StringBuffer("");
        // roleGroup
        StringBuffer userGroup = new StringBuffer("");
        for (int i = 0; i < subjects.length; i++) {
            SelectedSubjectItem vec = (SelectedSubjectItem) subjects[i];
            if (vec == null) {
                continue;
            }
            if (vec.getType().equals(IRightConstant.User)) {
                user.append(vec.getCode()).append(",");
            } else if (vec.getType().equals(IRightConstant.Role)) {
                role.append(vec.getCode()).append(",");
            } else {
                userGroup.append(vec.getCode()).append(",");
            }
        }
 
        for (int i = 0; i < values.size(); i++) {
            values.get(i).roles = role.length() == 0 ? "" : role.toString();
            values.get(i).users = user.length() == 0 ? "" : user.toString();
            values.get(i).userGroups = userGroup.length() == 0 ? "" : userGroup.toString();
        }
        return true;
    }
 
    public static boolean fillObjectInfo(AbstractUIFunclet funclet, List<GrandValue> values) {
        JPanel conditionPanel = funclet.getRightMainPanel().getRightRulePanel();
        QueryTemplate qt = null;
        if ((conditionPanel instanceof ConditionPanel)) {
            ConditionPanel conditionPane = ((ConditionPanel) conditionPanel);
            qt = ((ConditionPanel) conditionPanel).getQT();
            String checkInfo = OQTool.checkQT(qt);
            if (!checkInfo.equals("OK")) {
                return false;
            }
            // 获取规则名称
            if (funclet.getRightMainPanel().getRuleName() == null
                    || funclet.getRightMainPanel().getRuleName().equals("")) {
                JOptionPane.showMessageDialog(com.vci.client.LogonApplication.frame, "请设置规则名称", "提示",
                        JOptionPane.INFORMATION_MESSAGE);
                return false;
            }
 
            qt = conditionPane.getQT();
            qt.setId(funclet.getRightMainPanel().getRuleName());
            qt.setLinkType("");
            for (int i = 0; i < values.size(); i++) {
                values.get(i).ruleName = funclet.getRightMainPanel().getRuleName();
                values.get(i).ruleType = funclet.getRightMainPanel().getRuleType();
                // 业务类型
                if (!((ConditionPanel) conditionPanel).isLinkTypeSelected()) {
                    Document doc = conditionPane.getSeniorTreeDoc();
                    if (doc == null) {
                        values.get(i).seniorRuleText = "";
                    } else {
                        values.get(i).seniorRuleText = doc.asXML();
                    }
                    values.get(i).ruleText = OQTool.qtTOXMl(qt).asXML();
//                    Parser parser = new Parser(qt);
//                    parser.setAddGrandRightFlag(false);
//                    String sql = parser.parseToSql();
//                    values.get(i).expToSQL = sql.substring(sql.indexOf("where") + 6, sql.length());
                    values.get(i).expToSQL = "";
                    // 链接类型属性
                    values.get(i).lruleText = "";
                    values.get(i).lseniorRuleText = "";
                    values.get(i).lexpToSQL = "";
                } else {
                    // 链接类型
                    Document doc = conditionPane.getSeniorTreeDoc();
                    if (doc == null) {
                        values.get(i).lseniorRuleText = "";
                    } else {
                        values.get(i).lseniorRuleText = doc.asXML();
                    }
                    values.get(i).lruleText = OQTool.qtTOXMl(qt).asXML();
//                    Parser parser = new Parser(qt);
//                    parser.setAddGrandRightFlag(false);
//                    String sql = parser.parseToSql();
//                    values.get(i).lexpToSQL = sql.substring(sql.indexOf("where") + 6, sql.length());
                    values.get(i).lexpToSQL = "";
                    // 业务类型属性
                    values.get(i).ruleText = "";
                    values.get(i).seniorRuleText = "";
                    values.get(i).expToSQL = "";
                }
            }
        } else {
            // 获取规则名称
            if (funclet.getRightMainPanel().getRuleName() == null
                    || funclet.getRightMainPanel().getRuleName().equals("")) {
                JOptionPane.showMessageDialog(com.vci.client.LogonApplication.frame, "请设置规则名称", "提示",
                        JOptionPane.INFORMATION_MESSAGE);
                return false;
            }
            for (int i = 0; i < values.size(); i++) {
                values.get(i).ruleText = "";
                values.get(i).seniorRuleText = "";
                values.get(i).expToSQL = "";
                values.get(i).lruleText = "";
                values.get(i).lseniorRuleText = "";
                values.get(i).lexpToSQL = "";
                values.get(i).ruleName = funclet.getRightMainPanel().getRuleName();
                values.get(i).ruleType = funclet.getRightMainPanel().getRuleType();
            }
 
        }
        return true;
    }
 
    public static void setOpDatas(final AbstractUIFunclet funclet, List<OpItem> ops) {
        // 规则table
        JCheckBox[] checkBoxs = ((OrdinaryOpPanel) funclet.getRightMainPanel().getOrdinaryOpPanel()).getOpCheckBoxs();
        for (JCheckBox cb : checkBoxs) {
            for (OpItem op : ops) {
                if (cb.getText().equals(op.getName())) {
                    cb.setSelected((Boolean) op.getValue() == null ? false : (Boolean) op.getValue());
                }
            }
        }
        // 关系和跃迁
        JCheckBox[] rlcheckBoxs = ((RelationAndLifeCycleOpPanel) funclet.getRightMainPanel()
                .getRelationAndLifeCycleOpPanel()).getOpCheckBoxs();
        for (JCheckBox cb : rlcheckBoxs) {
            for (OpItem op : ops) {
                if (cb.getText().equals(op.getName())) {
                    cb.setSelected((Boolean) op.getValue() == null ? false : (Boolean) op.getValue());
                }
            }
        }
    }
 
    public static void initTipPanel(QTD qtd, final AbstractUIFunclet funclet) {
        JDialog dialog = new JDialog();
 
        dialog.add(funclet.getTipPanel());
        // JRadioButton rdGeneral = new JRadioButton();
        // JRadioButton rdSenior = new JRadioButton();
        funclet.getTipPanel().removeAll();
        funclet.getTipPanel().updateUI();
        funclet.getTipPanel().setAutoscrolls(true);
        funclet.getTipPanel().setLayout(new GridBagLayout());
        String[] abNames = "a,s,d,d".split(",");// qtd.abNames;
        if (true) {
            for (int i = 0; i < abNames.length; i++) {
                GridBagConstraints g = new GridBagConstraints();
                g.anchor = GridBagConstraints.WEST;
                g.gridx = 0;
                g.gridy = i;
                final JButton btnRemove = new JButton("x");
                funclet.getTipPanel().add(btnRemove, g);
                final JLabel labName = new JLabel(abNames[i]);
                g.gridx = 1;
                funclet.getTipPanel().add(labName, g);
                g.gridx = 2;
                final JComboBox combCons = new JComboBox();
                combCons.addItem("=");
                combCons.addItem("!=");
                combCons.addItem("鍖呭惈");
                funclet.getTipPanel().add(combCons, g);
                g.gridx = 3;
                g.gridwidth = GridBagConstraints.REMAINDER;
                final JTextField tfValue = new JTextField(10);
                funclet.getTipPanel().add(tfValue, g);
 
                btnRemove.addActionListener(new ActionListener() {
 
                    @Override
                    public void actionPerformed(ActionEvent e) {
                        funclet.getTipPanel().remove(btnRemove);
                        funclet.getTipPanel().remove(labName);
                        funclet.getTipPanel().remove(combCons);
                        funclet.getTipPanel().remove(tfValue);
                        funclet.getTipPanel().updateUI();
                    }
                });
            }
            dialog.setVisible(true);
        }
    }
 
    public static void clear(AbstractUIFunclet funclet) {
        BooleanTableModel ruleModel = (BooleanTableModel) funclet.getRightMainPanel().getRuleTable().getModel();
        // 刷新页面缓存
        ruleModel.RemoveAllConditionValue();
        ruleModel.setRowCount(0);
    }
 
}