wangting
2024-12-26 fa261e8c1220b31af54e8167e4de9c3320b1af27
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
package com.vci.client.workflow.editor.user;
 
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.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.List;
 
import javax.swing.BoxLayout;
import javax.swing.ButtonGroup;
import javax.swing.DefaultListModel;
import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.border.TitledBorder;
 
import com.vci.client.LogonApplication;
import com.vci.client.bof.ClientBusinessObject;
import com.vci.client.bof.ClientBusinessObjectOperation;
import com.vci.client.common.objects.DeptObject;
import com.vci.client.common.objects.RoleObject;
import com.vci.client.common.objects.UserObject;
import com.vci.client.framework.delegate.RightManagementClientDelegate;
import com.vci.client.ui.exception.VCIException;
import com.vci.client.ui.swing.VCIOptionPane;
import com.vci.common.resource.CommonProperties;
import com.vci.corba.common.VCIError;
 
public class RMUserNewComponent extends UserPanel {
 
    private static final long serialVersionUID = -990618910839831914L;
 
    private JPanel userComponent;
 
    private JList list;
 
    private DefaultListModel listModel;
 
    private JList userDepartmentList;
    private JList userRoleList;
    private JList userDeptList;
    private JList userLineList;
    private JList deptAndUserList;
    private DefaultListModel userDepartmentListModel;
    private DefaultListModel userRoleListModel;
    private DefaultListModel userDeptListModel;
    private DefaultListModel userLineListModel;
    private DefaultListModel deptAndUserListModel;
    private List<Object> userDepartmentObjs = new ArrayList<Object>();
    private List<Object> userRoleObjs = new ArrayList<Object>();
    private List<Object> userDeptObjs = new ArrayList<Object>();
    private List<Object> userLineObjs = new ArrayList<Object>();
    private List<String[]> deptAndUserObjs = new ArrayList<String[]>();
    
    private JButton btnNewButton ;
    private JButton btnNewButton_1 ;
    
    private JTextArea custText = new JTextArea();
    JScrollPane scrollPane = new JScrollPane();
    //选中某一按钮,记录下所选按钮的对象名称
    private String radioChoseFlag = "userDepartment";
    
    private CustomEditPanel customUserPanel;
    
    public RMUserNewComponent() {
        setLayout(new BorderLayout(0, 0));
 
        userComponent = new JPanel();
 
        add(userComponent);
        GridBagLayout gbl_panel_3 = new GridBagLayout();
        userComponent.setLayout(gbl_panel_3);
        userComponent.setBorder(new TitledBorder("候选人"));
        
        JPanel userListPanel = new JPanel();
        JPanel radioPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
        userListPanel.setLayout(new BorderLayout());
        JRadioButton userDepartmentBtn = new JRadioButton("用户部门");
        JRadioButton userRoleBtn = new JRadioButton("用户角色");
        JRadioButton userDeptBtn = new JRadioButton("用户群组");
        JRadioButton userLineBtn = new JRadioButton("用户关系");
        JRadioButton deptAndUserBtn = new JRadioButton("部门用户关系");
        JRadioButton custRadioBtn = new JRadioButton("自定义用户规则");
        
        listModel = new DefaultListModel();
        list = new JList(listModel);
        scrollPane.setViewportView(list);
 
        JPanel panel = new JPanel();
        GridBagConstraints gbc_panel = new GridBagConstraints();
        gbc_panel.fill = GridBagConstraints.BOTH;
        gbc_panel.gridx = 1;
        gbc_panel.gridy = 0;
        userComponent.add(panel, gbc_panel);
        panel.setLayout(new BorderLayout(0, 0));
 
        JPanel panel_1 = new JPanel();
        panel.add(panel_1, BorderLayout.WEST);
        panel_1.setLayout(new BoxLayout(panel_1, BoxLayout.Y_AXIS));
 
        btnNewButton = new JButton("添加");
        btnNewButton.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent actionevent) {
                selectUser();
            }
            
        });
        panel_1.add(btnNewButton);
 
        btnNewButton_1 = new JButton("删除");
        btnNewButton_1.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent actionevent) {
                delete();
            }
        });
        panel_1.add(btnNewButton_1);
        
        ButtonGroup bg = new ButtonGroup();
        bg.add(userDepartmentBtn);
        bg.add(userRoleBtn);
        bg.add(userDeptBtn);
        bg.add(userLineBtn);
        bg.add(deptAndUserBtn);
        bg.add(custRadioBtn);
        userDepartmentBtn.setSelected(true);
        radioPanel.add(userDepartmentBtn);
        String userDialogControl = CommonProperties.getStringProperty("workflow.UserDialog");
        if(userDialogControl==null||"".equals(userDialogControl)){
            radioPanel.add(userRoleBtn);
            radioPanel.add(userDeptBtn);
            radioPanel.add(userLineBtn);
            radioPanel.add(deptAndUserBtn);
            radioPanel.add(custRadioBtn);
        }
        //用户部门单选按钮
        userDepartmentBtn.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                radioChoseFlag = "userDepartment";
                scrollPane.setViewportView(userDepartmentList);
                controlBtn(radioChoseFlag);
            }
        });
        //用户角色单选按钮
        userRoleBtn.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                radioChoseFlag = "userRole";
                scrollPane.setViewportView(userRoleList);
                controlBtn(radioChoseFlag);
            }
        });
        //用户群组单选按钮
        userDeptBtn.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                radioChoseFlag = "userDept";
                scrollPane.setViewportView(userDeptList);
                controlBtn(radioChoseFlag);
            }
        });
        //用户关系单选按钮
        userLineBtn.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                radioChoseFlag = "userLine";
                scrollPane.setViewportView(userLineList);
                controlBtn(radioChoseFlag);
            }
        });
        //部门用户部门单选按钮
        deptAndUserBtn.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                radioChoseFlag = "deptAndUser";
                scrollPane.setViewportView(deptAndUserList);
                controlBtn(radioChoseFlag);
            }
        });
        //用户自定义规则单选按钮
        custRadioBtn.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                radioChoseFlag = "cust";
                scrollPane.getViewport().add(customUserPanel);
                controlBtn(radioChoseFlag);
            }
 
        });
        
        userListPanel.add(radioPanel,BorderLayout.NORTH);
        userListPanel.add(scrollPane,BorderLayout.CENTER);
        
        GridBagConstraints gbc_scrollPane = new GridBagConstraints();
        gbc_scrollPane.weighty = 1.0;
        gbc_scrollPane.weightx = 1.0;
        gbc_scrollPane.fill = GridBagConstraints.BOTH;
        gbc_scrollPane.anchor = GridBagConstraints.CENTER;
        gbc_scrollPane.insets = new Insets(0, 0, 0, 5);
        gbc_scrollPane.gridx = 0;
        gbc_scrollPane.gridy = 0;
        userComponent.add(userListPanel, gbc_scrollPane);
        
        listModel = new DefaultListModel();
        list = new JList(listModel);
        
        userDepartmentListModel = new DefaultListModel();
        userRoleListModel = new DefaultListModel();
        userDeptListModel = new DefaultListModel();
        userLineListModel = new DefaultListModel();
        deptAndUserListModel = new DefaultListModel();
        userDepartmentList = new JList(userDepartmentListModel);
        userRoleList = new JList(userRoleListModel);
        userDeptList = new JList(userDeptListModel);
        userLineList = new JList(userLineListModel);
        deptAndUserList = new JList(deptAndUserListModel);
        scrollPane.setViewportView(userDepartmentList);
    }
    
    private void controlBtn(String str) {
        if("cust".equals(str)){
            btnNewButton.setEnabled(false);
            btnNewButton_1.setEnabled(false);
        }else{
            btnNewButton.setEnabled(true);
            btnNewButton_1.setEnabled(true);
        }
    }
    
    private void delete(){
        int userDepartmentIndex = userDepartmentList.getSelectedIndex();
        int userRoleIndex = userRoleList.getSelectedIndex();
        int userDeptIndex = userDeptList.getSelectedIndex();
        int userLineIndex = userDeptList.getSelectedIndex();
        int deptAndUserIndex = userDeptList.getSelectedIndex();
        if(radioChoseFlag.equals("userDepartment")){
            if (userDepartmentIndex == -1) {
                VCIOptionPane.showMessage(LogonApplication.frame, "请选择记录");
                return;
            }
            if(userNameList!=null&&userNameList.size()>0){
                userNameList.remove(userDepartmentIndex);
            }
            int[] selectedNum = userDepartmentList.getSelectedIndices();
            for (int i = 0;i < selectedNum.length;i++) {
                userDepartmentListModel.removeElementAt(selectedNum[i] - i);
                userDepartmentObjs.remove(selectedNum[i] - i);
            }
            userDepartmentList.updateUI();
            
        }
        if(radioChoseFlag.equals("userRole")){
            if (userRoleIndex == -1) {
                VCIOptionPane.showMessage(LogonApplication.frame, "请选择记录");
                return;
            }
            int[] selectedNum = userRoleList.getSelectedIndices();
            for (int i = 0;i < selectedNum.length;i++) {
                userRoleListModel.removeElementAt(selectedNum[i] - i);
                userRoleObjs.remove(selectedNum[i] - i);
            }
            userRoleList.updateUI();
        }
        if(radioChoseFlag.equals("userDept")){
            if (userDeptIndex == -1) {
                VCIOptionPane.showMessage(LogonApplication.frame, "请选择记录");
                return;
            }
            int[] selectedNum = userDeptList.getSelectedIndices();
            for (int i = 0;i < selectedNum.length;i++) {
                userDeptListModel.removeElementAt(selectedNum[i] - i);
                userDeptObjs.remove(selectedNum[i] - i);
            }
            userDeptList.updateUI();
        }
        if(radioChoseFlag.equals("userLine")){
            if (userLineIndex == -1) {
                VCIOptionPane.showMessage(LogonApplication.frame, "请选择记录");
                return;
            }
            int[] selectedNum = userLineList.getSelectedIndices();
            for (int i = 0;i < selectedNum.length;i++) {
                userLineListModel.removeElementAt(selectedNum[i] - i);
                userLineObjs.remove(selectedNum[i] - i);
            }
            userLineList.updateUI();
        }
        if(radioChoseFlag.equals("deptAndUser")){
            if (deptAndUserIndex == -1) {
                VCIOptionPane.showMessage(LogonApplication.frame, "请选择记录");
                return;
            }
            int[] selectedNum = deptAndUserList.getSelectedIndices();
            for (int i = 0;i < selectedNum.length;i++) {
                deptAndUserListModel.removeElementAt(selectedNum[i] - i);
                deptAndUserObjs.remove(selectedNum[i] - i);
            }
        }
    }
    
    private void selectUser() {
        String userDialogControl = CommonProperties.getStringProperty("workflow.UserDialog");
        if(userDialogControl!=null&&!"".equals(userDialogControl)){
            Class<?> cls;
            try {
                cls = Class.forName(userDialogControl);
                CustomUserDialog res = (CustomUserDialog) cls.getConstructor(RMUserNewComponent.class).newInstance(this);
                res.setLocationRelativeTo(null);
                res.setVisible(true);
                
                if(interFaceResult!=null&&!"".equals(interFaceResult)){
                    listModel.addElement(interFaceResult);
                }
            } catch (ClassNotFoundException e) {
                e.printStackTrace();
            } catch (IllegalArgumentException e) {
                e.printStackTrace();
            } catch (SecurityException e) {
                e.printStackTrace();
            } catch (InstantiationException e) {
                e.printStackTrace();
            } catch (IllegalAccessException e) {
                e.printStackTrace();
            } catch (InvocationTargetException e) {
                e.printStackTrace();
            } catch (NoSuchMethodException e) {
                e.printStackTrace();
            }
        }else{
            TaskUserDialog taskUserDialog = new TaskUserDialog();
            taskUserDialog.setLocationRelativeTo(null);
            taskUserDialog.setVisible(true);
            
            List<Object> departobjectlist = taskUserDialog.getDepartresultList();//部门关系值
            List<Object> roleobjectlist = taskUserDialog.getRoleresultList();//角色关系值
            List<Object> deptobjectlist = taskUserDialog.getDeptresultList();//组织关系值
            List<Object> lineobjectlist = taskUserDialog.getLineresultList();//用户关系值
            List<Object> lineShowList = taskUserDialog.getLineShowList();//用户关系显示值
            List<Object> deptUserobjectlist = taskUserDialog.getDeptUserresultList();//部门用户关系值
            if (departobjectlist != null && departobjectlist.size() > 0) {
                for (int i = 0 ; i < departobjectlist.size(); i++) {
                    Object obj = departobjectlist.get(i);
                    if (judgeObjectIsExist(userDepartmentObjs, obj)) {
                        continue;
                    } else {
                        if (obj instanceof ClientBusinessObject) {
                            userDepartmentListModel.addElement(((ClientBusinessObject) obj).getName());
                            userDepartmentObjs.add(obj);
                        }
                    }
                }
            }
            if (roleobjectlist != null && roleobjectlist.size() > 0) {
                for (int i = 0 ; i < roleobjectlist.size(); i++) {
                    Object obj = roleobjectlist.get(i);
                    if (judgeObjectIsExist(userRoleObjs, obj)) {
                        continue;
                    } else {
                        if (obj instanceof ClientBusinessObject) {
                            userRoleListModel.addElement(((ClientBusinessObject) obj).getName());
                            userRoleObjs.add(obj);
                        }
                    }
                }
            }
            if (deptobjectlist != null && deptobjectlist.size() > 0) {
                for (int i = 0 ; i < deptobjectlist.size(); i++) {
                    Object obj = deptobjectlist.get(i);
                    if (judgeObjectIsExist(userDeptObjs, obj)) {
                        continue;
                    } else {
                        if (obj instanceof ClientBusinessObject) {
                            userDeptListModel.addElement(((ClientBusinessObject) obj).getName());
                            userDeptObjs.add(obj);
                        }
                    }
                }
            }
            if ((lineobjectlist != null && lineobjectlist.size() > 0) 
                    && (lineShowList != null && lineShowList.size() > 0)
                    && (lineShowList.size() == lineobjectlist.size())) {
                for (int i = 0 ; i < lineShowList.size(); i++) {
                    Object obj = lineShowList.get(i);
                    Object realObj = lineobjectlist.get(i);
                    if (judgeUserLineObjectIsExist(userLineListModel, obj)) {
                        continue;
                    } else {
                        userLineListModel.addElement(obj.toString());
                        userLineObjs.add(realObj.toString());
                    }
                }
            }
            if (deptUserobjectlist != null && deptUserobjectlist.size() > 0) {
                List showList = taskUserDialog.getDeptAndUserList();
                for (int i = 0 ; i < deptUserobjectlist.size(); i++) {
                    Object obj = deptUserobjectlist.get(i);
                    if (judgeObjectIsExist(deptAndUserObjs, obj)) {
                        continue;
                    } else {
                        if (obj instanceof ClientBusinessObject) {
                            String[] showVal = (String[]) showList.get(i);
                            deptAndUserListModel.addElement(showVal[1]);
                            String[] info = showVal[1].split(":");
                            String[] str = new String[4];
                            str[0] = ((ClientBusinessObject) obj).getOid();
                            str[1] = showVal[0];
                            str[2] = info[2];
                            str[3] = info[3];
                            deptAndUserObjs.add(str);
                        }
                    }
                }
            }
        }
    }
    
    boolean judgeObjectIsExist(List curList, Object curObj) {
        boolean flag = false;
        int size = curList.size();
        for(int i = 0; i < size; i++){
            if(curList.get(i) instanceof ClientBusinessObject && curObj instanceof ClientBusinessObject){
                curObj = (ClientBusinessObject)curObj;
                flag = ((ClientBusinessObject) curObj).getOid().equals(((ClientBusinessObject)curList.get(i)).getOid());
                if(flag) break;
            }
            else if (curList.get(i) instanceof String) {
                flag = curList.get(i).toString().equals(curObj.toString());
                if(flag) break;
            } else {
                String [] str = (String[]) curList.get(i);
                flag = str[0].equals(((ClientBusinessObject) curObj).getOid());
                if(flag) break;
            }
        }
        return flag;
    }
    
    /**
     * 判断用户关系是重复
     * @param curList
     * @param curObj
     * @return
     */
    boolean judgeUserLineObjectIsExist(DefaultListModel curList, Object curObj) {
        boolean flag = false;
        int size = curList.size();
        for(int i = 0; i < size; i++){
            if (curList.get(i) instanceof String) {
                flag = curList.get(i).toString().equals(curObj.toString());
                if(flag) break;
            }
        }
        return flag;
    }
    
    public JComponent getUserComponent() {
        return userComponent;
    }
    
    public JComponent getUserComponent(CustomEditPanel customUserPanel) {
        this.customUserPanel = customUserPanel;
        return userComponent;
    }
 
    /**
     * 获取用户部门列表
     * @return
     * @author cmk
     */
    public List<String> getSelectedUserDepartment() {
        List<String> list = new ArrayList<String>();
        int rolesize = userDepartmentObjs.size();
        for (int i = 0; i < rolesize; i++) {
            ClientBusinessObject obj = (ClientBusinessObject) userDepartmentObjs.get(i);
            if ("department".equals(obj.getBtmName())) {
                list.add("dept:" + ((ClientBusinessObject) obj).getOid());
            } else if ("person".equals(obj.getBtmName())){
                list.add("user:" + ((ClientBusinessObject) obj).getOid());
            }
        }
        return list;
    }
 
    /**
     * 获取用户角色列表
     * @return
     * @author cmk
     */
    public List<String> getSelectedUserRole() {
        List<String> list = new ArrayList<String>();
        int rolesize = userRoleObjs.size();
        for (int i = 0; i < rolesize; i++) {
            ClientBusinessObject obj = (ClientBusinessObject) userRoleObjs.get(i);
            if ("role".equals(obj.getBtmName())) {
                list.add("role:" + ((ClientBusinessObject) obj).getOid());
            } else if ("person".equals(obj.getBtmName())){
                list.add("user:" + ((ClientBusinessObject) obj).getOid());
            }
        }
        return list;
    }
    
    /**获取用户群组列表
     * @return
     */
    public List<String> getSelectedUserOrg() {
        List<String> list = new ArrayList<String>();
        int rolesize = userDeptObjs.size();
        for (int i = 0; i < rolesize; i++) {
            ClientBusinessObject obj = (ClientBusinessObject) userDeptObjs.get(i);
            if ("organization".equals(obj.getBtmName())) {
                list.add("org:" + ((ClientBusinessObject) obj).getOid());
            } else if ("person".equals(obj.getBtmName())){
                list.add("user:" + ((ClientBusinessObject) obj).getOid());
            }
        }
        return list;
    }
    
    /**获取用户关系列表
     * @return
     */
    public List<String> getSelectedUserLine() {
        List<String> list = new ArrayList<String>();
//        int rolesize = userLineListModel.size();
        int rolesize = userLineObjs.size();
        for (int i = 0; i < rolesize; i++) {
//            Object obj = userLineListModel.get(i);
            Object obj = userLineObjs.get(i);
            list.add(obj.toString());
//            if ("所有人".equals(obj.toString())) {
//                list.add("expression:all");
//            } else if ("拟稿人".equals(obj.toString())) {
//                list.add("expression:creator");
//            } else if ("拟稿人所在部门".equals(obj.toString())) {
//                list.add("expression:creator.dept");
//            } else if ("当前处理人所在部门".equals(obj.toString())) {
//                list.add("expression:owner.dept");
//            } else if ("所有领导".equals(obj.toString())) {
//                list.add("expression:allleader");
//            } else if ("所有秘书".equals(obj.toString())) {
//                list.add("expression:allsecretary");
//            } else if ("拟稿人所在部门领导".equals(obj.toString())) {
//                list.add("expression:creator.dept.leader");
//            } else if ("当前处理人所在部门领导".equals(obj.toString())) {
//                list.add("expression:owner.dept.leader");
//            } else if ("当前节点处理人".equals(obj.toString())) {
//                list.add("expression:owner");
//            } else if ("某一级别的所有人".equals(obj.toString())) {
//                list.add("expression:onenode.alluser");
//            } else if ("某一节点处理人".equals(obj.toString())) {
//                list.add("expression:onenode.manager");
//            } else if ("从业务表单中选择".equals(obj.toString())) {
//                list.add("expression:chooseByForm");
//            } else if ("当前人的自定义组".equals(obj.toString())) {//暂不处理
//                list.add("expression:owner.customorg");
//            } else if ("当前处理人的一级部门".equals(obj.toString())) {
//                list.add("expression:owner.childdept");
//            } else if ("反射类名".equals(obj.toString())) {
//                list.add("custom:");
//            }
        }
        return list;
    }
    
    /**获取部门用户关系列表
     * @return
     */
    public List<String> getSelectedDeptAddUser() {
        List<String> list = new ArrayList<String>();
        int rolesize = deptAndUserObjs.size();
        for (int i = 0; i < rolesize; i++) {
            String [] str = deptAndUserObjs.get(i);
            list.add("dept1:" + str[0] + ":" + str[1] + ":" + str[2] + ":" + str[3]);
        }
        return list;
    }
    
    RightManagementClientDelegate rmgrDel = new RightManagementClientDelegate(LogonApplication.getUserEntityObject());
    
    /**
     * 设置用户部门面板数据
     * @param users
     */
    public void setSelectedUserDepartment(List<String> users) {
        userDepartmentListModel.removeAllElements();
        userDepartmentObjs.clear();
        try {
            String[] elements = users.get(0).split(",");
            if (elements != null && elements.length > 0) {
                for (int i = 0 ; i < elements.length; i++) {
                    String ele = elements[i];
                    if (ele.indexOf("user:") == 0) {
                        String userName = ele.substring(ele.indexOf(":") + 1);
                        ClientBusinessObjectOperation cboo = new ClientBusinessObjectOperation();
                        ClientBusinessObject cbo = cboo.readBusinessObjectById(userName, "person");
                        userDepartmentListModel.addElement(cbo.getName());
                        userDepartmentObjs.add(cbo);
                    } else if (ele.indexOf("dept:") == 0) {
                        String deptId = ele.substring(ele.indexOf(":") + 1);
                        ClientBusinessObjectOperation cboo = new ClientBusinessObjectOperation();
                        ClientBusinessObject cbo = cboo.readBusinessObjectById(deptId, "department");
                        userDepartmentListModel.addElement(cbo.getName());
                        userDepartmentObjs.add(cbo);
                    }
                }
            }
            
        } catch (VCIError e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
    
    /**
     * 设置用户角色面板数据
     * @param users
     */
    public void setSelectedUserRole(List<String> users) {
        userRoleListModel.removeAllElements();
        userRoleObjs.clear();
        try {
            String[] elements = users.get(0).split(",");
            if (elements != null && elements.length > 0) {
                for (int i = 0 ; i < elements.length; i++) {
                    String ele = elements[i];
                    if (ele.indexOf("user:") == 0) {
                        String userName = ele.substring(ele.indexOf(":") + 1);
                        ClientBusinessObjectOperation cboo = new ClientBusinessObjectOperation();
                        ClientBusinessObject cbo = cboo.readBusinessObjectById(userName, "person");
                        userRoleListModel.addElement(cbo.getName());
                        userRoleObjs.add(cbo);
                    } else if (ele.indexOf("role:") == 0) {
                        String roleId = ele.substring(ele.indexOf(":") + 1);
                        ClientBusinessObjectOperation cboo = new ClientBusinessObjectOperation();
                        ClientBusinessObject cbo = cboo.readBusinessObjectById(roleId, "role");
                        userRoleListModel.addElement(cbo.getName());
                        userRoleObjs.add(cbo);
                    }
                }
            }
            
        } catch (VCIError e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
    
    /**
     * 设置用户群组面板数据
     * @param users
     */
    public void setSelectedUserDept(List<String> users) {
        userDeptListModel.removeAllElements();
        userDeptObjs.clear();
        try {
            String[] elements = users.get(0).split(",");
            if (elements != null && elements.length > 0) {
                for (int i = 0 ; i < elements.length; i++) {
                    String ele = elements[i];
                    if (ele.indexOf("user:") == 0) {
                        String userName = ele.substring(ele.indexOf(":") + 1);
                        ClientBusinessObjectOperation cboo = new ClientBusinessObjectOperation();
                        ClientBusinessObject cbo = cboo.readBusinessObjectById(userName, "person");
                        userDeptListModel.addElement(cbo.getName());
                        userDeptObjs.add(cbo);
                    } else if (ele.indexOf("org:") == 0) {
                        String deptId = ele.substring(ele.indexOf(":") + 1);
                        ClientBusinessObjectOperation cboo = new ClientBusinessObjectOperation();
                        ClientBusinessObject cbo = cboo.readBusinessObjectById(deptId, "organization");
                        userDeptListModel.addElement(cbo.getName());
                        userDeptObjs.add(cbo);
                    }
                }
            }
            
        } catch (VCIError e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
    
    /**
     * 设置用户关系面板数据
     * @param users
     */
    public void setSelectedUserLine(List<String> users) {
        userLineListModel.removeAllElements();
        userLineObjs.clear();
        String[] elements = users.get(0).split(",");
        if (elements != null && elements.length > 0) {
            for (int i = 0 ; i < elements.length; i++) {
                String ele = elements[i];
                if (ele.indexOf("expression:") == 0) {
                    String expression = ele.substring(ele.indexOf(":") + 1);
                    if ("all".equals(expression)) {
                        userLineListModel.addElement("所有人");
                        userLineObjs.add("all");
                    } else if ("creator".equals(expression)) {
                        userLineListModel.addElement("拟稿人");
                        userLineObjs.add("creator");
                    } else if ("creator.dept".equals(expression)) {
                        userLineListModel.addElement("拟稿人所在部门");
                        userLineObjs.add("creator.dept");
                    } else if ("owner.dept".equals(expression)) {
                        userLineListModel.addElement("当前处理人所在部门");
                        userLineObjs.add("owner.dept");
                    } else if ("allleader".equals(expression)) {
                        userLineListModel.addElement("所有领导");
                        userLineObjs.add("allleader");
                    } else if ("allsecretary".equals(expression)) {
                        userLineListModel.addElement("所有秘书");
                        userLineObjs.add("allsecretary");
                    } else if ("creator.dept.leader".equals(expression)) {
                        userLineListModel.addElement("拟稿人所在部门领导");
                        userLineObjs.add("creator.dept.leader");
                    } else if ("owner.dept.leader".equals(expression)) {
                        userLineListModel.addElement("当前处理人所在部门领导");
                        userLineObjs.add("owner.dept.leader");
                    } else if ("owner".equals(expression)) {
                        userLineListModel.addElement("当前节点处理人");
                        userLineObjs.add("owner");
                        
                    } else if ("onenode.alluser".equals(expression)) {
                        userLineListModel.addElement("某一级别的所有人");
                        userLineObjs.add("onenode.alluser");
                    } else if ("onenode.manager".equals(expression)) {
                        userLineListModel.addElement("某一节点处理人");
                        userLineObjs.add("onenode.manager");
                    } else if ("chooseByForm".equals(expression)) {
                        userLineListModel.addElement("从业务表单中选择");
                        userLineObjs.add("chooseByForm");
                        
                    } else if ("owner.childdept".equals(expression)) {
                        userLineListModel.addElement("当前处理人的一级部门");
                        userLineObjs.add("owner.childdept");
                    } else if ("owner.customorg".equals(expression)) {//暂不处理
                        userLineListModel.addElement("当前人的自定义组");
                        userLineObjs.add("owner.customorg");
                    }
                } else if (ele.indexOf("custom:") == 0) {
                    userLineListModel.addElement("反射类名");
                    userLineObjs.add(ele);
                }
            }
        }
            
    }
    
    /**
     * 设置部门用户关系面板数据
     * 格式--------dept1:部门id:岗位id:Y:N
     * @param users
     */
    public void setSelectedDeptAndUser(List<String> users) {
        deptAndUserListModel.removeAllElements();
        deptAndUserObjs.clear();
        try {
            String[] elements = users.get(0).split(",");
            if (elements != null && elements.length > 0) {
                for (int i = 0 ; i < elements.length; i++) {
                    String ele = elements[i];
                    String[] ids = ele.split(":");
                    String deptId = ids[1];
                    String postId = ids[2];
                    String showSubDept = ids[3];
                    String showDeptPerson = ids[4];
                    ClientBusinessObjectOperation cboo = new ClientBusinessObjectOperation();
                    ClientBusinessObject cboDept = cboo.readBusinessObjectById(deptId, "department");
                    ClientBusinessObject cboPost = cboo.readBusinessObjectById(postId, "post");
                    String deptName = cboDept.getName();
                    String postName = cboPost.getName();
                    deptAndUserListModel.addElement(deptName + ":" + postName + ":" + showSubDept + ":" + showDeptPerson);
                    String [] str = new String[]{ids[1], ids[2], ids[3], ids[4]};
                    deptAndUserObjs.add(str);
                }
            }
            
        } catch (VCIError e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
    
    public void setSelectedUsers(List<String> users) {
        userDepartmentListModel.removeAllElements();
        userDepartmentObjs.clear();
        try {
            String[] userNames = users.get(0).split(",");
            for (int k =0;k<userNames.length;k++) {
                String userDialogControl = CommonProperties.getStringProperty("workflow.UserDialog");
                if(userDialogControl!=null&&!"".equals(userDialogControl)){
                    if(userNames[k].contains(":")){//需不需要对所有的userName判断后再分情况
                        userNameList.add(userNames[k]);
                        userDepartmentListModel.addElement(userNames[k].split(":")[0]);
                    }else{
                        userDepartmentListModel.addElement(userNames[k]);
                    }
                }else{
                    if("".equals(userNames[k].trim())) {
                        continue;
                    }
                    UserObject userObj = rmgrDel.fetchUserInfoByName(userNames[k]);
                    userDepartmentListModel.addElement(userObj);
                    userDepartmentObjs.add(userObj);
                }
                
            }
            
        } catch (VCIException e) {
            e.printStackTrace();
            return;
        }
    }
    public void setSelectedRoles(List<String> roles) {
        userRoleListModel.removeAllElements();
        userRoleObjs.clear();
        try {
            String[] roleNames = roles.get(0).split(",");
            for (int k=0;k<roleNames.length;k++) {
                if("".equals(roleNames[k])) {
                    continue;
                }
                RoleObject roleObj = rmgrDel.fetchRoleInfoById(roleNames[k]);
                userRoleListModel.addElement(roleObj);
                userRoleObjs.add(roleObj);
            }
        } catch (VCIException e) {
            VCIOptionPane.showError(LogonApplication.frame,"RMIPFramework", e);
            return;
        }
    }
    public void setSelectedDepts(List<String> depts) {
        userDeptListModel.removeAllElements();
        userDeptObjs.clear();
        try {
            String[] deptNames = depts.get(0).split(",");
            for (int k=0;k<deptNames.length;k++) {
                if("".equals(deptNames[k])) {
                    continue;
                }
                DeptObject deptObj = rmgrDel.fetchDepartmentInfoById(deptNames[k]);
                userDeptListModel.addElement(deptObj);
                userDeptObjs.add(deptObj);
            }
        } catch (VCIException e) {
            e.printStackTrace();
        }
    }
 
    public String getSelectedCust() {
        return custText.getText().trim();
    }
 
    public void setSelectedCust(String cust) {
        custText.setText(cust);
    }
 
    public List<String> getSelectedUsers() {
        // TODO Auto-generated method stub
        return null;
    }
 
    public List<String> getSelectedRoles() {
        // TODO Auto-generated method stub
        return null;
    }
 
    public List<String> getSelectedDepts() {
        // TODO Auto-generated method stub
        return null;
    }
    
}