xiejun
2023-08-02 8b34692ac1b7cf58a1e1ead92b930d9acb9f86f6
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
package com.vci.ubcs.codeapply;
 
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.vci.base.ui.swing.VCIOptionPane;
import com.vci.base.ui.swing.components.*;
import com.vci.base.ui.tree.VCIBaseTreeNode;
import com.vci.ubcs.code.vo.pagemodel.*;
import com.vci.ubcs.codeapply.object.*;
import com.vci.ubcs.codeapply.swing.IntegerTextField;
import com.vci.ubcs.codeapply.swing.RealTextField;
import com.vci.ubcs.codeapply.swing.VCIJComboxBox;
import com.vci.ubcs.codeapply.utils.ConfigUtils;
import com.vci.ubcs.codeapply.utils.HttpUtil;
import com.vci.ubcs.starter.web.enumpck.VciFieldTypeEnum;
import com.vci.ubcs.starter.web.pagemodel.KeyValue;
import com.vci.ubcs.starter.web.util.BeanUtilForVCI;
import com.vci.ubcs.starter.web.util.VciBaseUtil;
import com.vci.ubcs.system.user.entity.User;
import net.logstash.logback.encoder.org.apache.commons.lang3.StringUtils;
import org.apache.commons.collections4.CollectionUtils;
 
import javax.swing.*;
import javax.swing.text.JTextComponent;
import javax.swing.tree.TreeNode;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.List;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
 
public class CodeApplyFor410MainPanel  extends VCIJPanel {
 
    private String url=ConfigUtils.getConfigValue("410.code.url","http://127.0.0.1:36014/codeApplySwingController");
    //410新需求
    private final String SPECIAL_RULE_NAME="Special.rule.name";
    private final String SPECIAL_SECTION_NAME = "Special.section.name";
    private final String SPECIAL_CONTROL_SECTION_NAME = "Special.control.other.section.name";
    private final String SPECIAL_SECTION_VALUE = "Special.section.val";
 
    private final String MAX_ATTR_IN_LINE_KEY = "RMData.MaxAttrInLine";
    private final String TEXTAREA_ENABLE_KEY = "RMData.TextArea.Enable";
    private final String MAX_STRING_LENGTH_KEY = "RMData.MaxStringLength";
    private final String TEXTAREA_PRE_SIZE_WIDTH = "RMData.TextArea.PreferredSize.Width";
    private final String TEXTAREA_PRE_SIZE_HEIGHT = "RMData.TextArea.PreferredSize.Height";
    private final String TEXTAREA_MIN_SIZE_WIDTH = "RMData.TextArea.MinimumSize.Width";
    private final String TEXTAREA_MIN_SIZE_HEIGHT = "RMData.TextArea.MinimumSize.Height";
    private final String TEXTAREA_MAX_SIZE_WIDTH = "RMData.TextArea.MaximumSize.Width";
    private final String TEXTAREA_MAX_SIZE_HEIGHT = "RMData.TextArea.MaximumSize.Height";
    // 是否启用属性长度过长时,用TextArea显示,true:启用 false:不启用,默认值true
    private boolean isEnableTextArea = false;
    // 启用了TextArea后,此TextArea的PreferredSize、MinimumSize、MaximumSize的Width、Height
    private int textAreaPreSizeWidth = 100;
    private int textAreaPreSizeHeight = 50;
    private int textAreaMinSizeWidth = 100;
    private int textAreaMinSizeHeight = 30;
    private int textAreaMaxSizeWidth = 100;
    private int textAreaMaxSizeHeight = 80;
    // 同一行内,最多加载的属性个数,一行为一组,即一组内最多加载的属性个数,默认值2
    private int maxAttrInLine = 2;
    // 当String类型的属性值的长度大于此值时,该属性就需要用TextArea显示,并占用整行,默认值100
    private int maxStringLength = 100;
    private int levelPositon = -1;
    private TransmitTreeObject transTreeObject = new TransmitTreeObject();
    private  User userObj;
    private String deptName;
    //存储每个实际 码段列对应的码段对象
    protected Map<Integer,CodeBasicSecVO> columnSecMap = new LinkedHashMap<Integer,CodeBasicSecVO>();
    private LinkedHashMap<Integer, JComponent> compMaps = new LinkedHashMap<Integer, JComponent>();
    private Map<String, JComponent> secAndComMap = new LinkedHashMap<String, JComponent>();
 
    private Map<JComponent, JComponent> comtMap = new LinkedHashMap<JComponent, JComponent>();
    private Map<String, VCIJComboBox> secNameAndComtMap = new LinkedHashMap<String, VCIJComboBox>();
    private Map<Integer,String> secIndexAndNameMap = new LinkedHashMap<Integer, String>();
    private List<JComponent> specSecList = new ArrayList<JComponent>();
    private boolean isSpecialRuleFlag = false;
    private String specialSectioName = "";
    private VCIJPanel rulePal = new VCIJPanel();
 
    private String[] specialSecVals = new String[0];
    private RMDataTransmitObject transmitForRMData = null;
 
    /**
     * 属性ID与属性对应的控件之间的映射MAP
     */
    private LinkedHashMap<String, JComponent> attrIdToCtrlMaps = new LinkedHashMap<String, JComponent>();
    /**
     * 属性的内部名称与属性对应的控件之间的映射MAP
     */
    private LinkedHashMap<String, JComponent> attrInnerNameToCtrlMaps = new LinkedHashMap<String, JComponent>();
 
    /**
     * 引用玛段码值与combox元素位置的映射MAP
     */
    private LinkedHashMap<String, Integer>  refSecValueToCombxindex = new LinkedHashMap<String, Integer>();
    /**
     * 码段id与分类码段码值描述对象对应的控件之间的映射MAP
     */
    private LinkedHashMap<String, JComponent> secIdToClsfIdMap = new LinkedHashMap<String, JComponent>();
 
    private List<VCIJTextField> textCompts = new LinkedList<VCIJTextField>();
    /**
     * 当前选择的分类的模板
     */
    private CodeClassifyTemplateVO currentCodeClassifyTemplateVO;
    // 实际的
    private VCIJDialog realDialogInstance = null;
    public CodeApplyFor410MainPanel(TransmitTreeObject transTreeObject, User userObj, CodeClassifyTemplateVO currentCodeClassifyTemplateVO) {
        this.transTreeObject = transTreeObject;
        this.userObj = userObj;
        this.currentCodeClassifyTemplateVO=currentCodeClassifyTemplateVO;
    }
 
    public CodeApplyFor410MainPanel(TransmitTreeObject transTreeObject,User userObj,String deptName,CodeClassifyTemplateVO currentCodeClassifyTemplateVO) {
        this.transTreeObject = transTreeObject;
        this.userObj = userObj;
        this.deptName = deptName;
        this.currentCodeClassifyTemplateVO=currentCodeClassifyTemplateVO;
    }
 
    /**
     *
     * @param type, 1代表申请,2设置流水
     */
    public void buildMainPanel(int type) {
        try {
            init(type);
            if (type == 2) {
                return;
            }
            this.initRMTypeTreeMaps();
            this.initContents();
        }catch (Exception e){
            VCIOptionPane.showMessage(this,e.getMessage());
        }
    }
    private void init(int type){
        this.loadTextAreaEnableEnv(); //add by liujw
        //this.loadSpecialRuleConfig();
        CodeClassify rmType = (CodeClassify) this.transTreeObject.getCurrentTreeNode().getObj();
        //String url= ConfigUtils.getConfigValue("410.PDM.rule.url","http://127.0.0.1:36014/codeApplySwingController/getCodeRuleByClassifyFullInfo");
        /**系统只加载代码项  如果libName不为空,直接获取对应的代码项**/
        Map<String,String> condtionMap=new HashMap<>();
        condtionMap.put("codeClassId", rmType.getOid());
        R r= HttpUtil.sendGet(url+"/getCodeRuleByClassifyFullInfo",condtionMap,new HashMap<>());
        CodeRuleVO codeRuleVO=new CodeRuleVO();
        if(r.isSuccess()){
            Object object= r.getData();
            if(object!=null) {
                ObjectMapper objectMapper = new ObjectMapper();
                try {
                    codeRuleVO = objectMapper.readValue(object.toString(),CodeRuleVO.class);
                } catch (JsonProcessingException e) {
                    e.printStackTrace();
                }
            }
        }else{
            VCIOptionPane.showMessage(this,r.getMsg());
        }
        /**加载规则对应的码段信息**/
        if(codeRuleVO!=null){
            List<CodeBasicSecVO> codeBasicSecVOList=codeRuleVO.getSecVOList();
            if(!CollectionUtils.isEmpty(codeBasicSecVOList) ){
                /**初始化码段panel**/
                initSectionPanel(codeBasicSecVOList, codeRuleVO.getOid(), type);//初始化规则码段
            }
        }
        this.setLayout(new BorderLayout());
        this.add(rulePal,BorderLayout.CENTER);
 
    }
    /**
     * 规则码段主界面
     * <p>Description: </p>
     *
     * @author Administrator
     * @time 2012-8-7
     * @param objs
     * @param cRuleId
     */
    private void initSectionPanel(List<CodeBasicSecVO> objs, String cRuleId, int type)  {
        //循环获取列名
        int column = 0;
        for(int i = 0; i < objs.size(); i++) {
            if(objs.get(i).getSecType().equals("codeserialsec")){//流水码段不在TABLE里显示
                if (type == 1) {
                    continue;
                } else if (type == 2) {
                    break;
                }
            }
            columnSecMap.put(column++,objs.get(i));
        }
        createSectionPanel(objs, type);
    }
    private void createSectionPanel(List<CodeBasicSecVO> secObjs, int type)  {
        /**每次选择代码项后,自动加载规则码段和模板属性信息,清除原来的码段信息**/
        rulePal.removeAll();
        rulePal.updateUI();
 
        /**根据规则获取码段信息界面**/
        VCIJPanel sectionPal = new VCIJPanel(new GridBagLayout());
        GridBagConstraints c = new GridBagConstraints();
        int x = 0;
        int y = 0;
        int maxAttrInLine = 1;
        int column = 2;
 
        List<CodeBasicSecVO> secList = new ArrayList<CodeBasicSecVO>();
        List<VCIJComboxBox> comList = new ArrayList<VCIJComboxBox>();
 
        compMaps.clear();
        secAndComMap.clear();
        secIdToClsfIdMap.clear();
        secNameAndComtMap.clear();
        secIndexAndNameMap.clear();
        // 加载码段列表
        boolean isBreak = false;
        for(int secIndex = 0; secIndex < secObjs.size(); secIndex += maxAttrInLine){//for1
            for(int columnIndex = 0; columnIndex < maxAttrInLine; columnIndex++){ //for2
                if(secIndex + columnIndex >= secObjs.size()){
                    break;
                }
                if(secObjs.get(secIndex).getSecType().equals("codeserialsec")){//流水码段不在TABLE里显示
                    if (type == 1) {
                        continue;
                    } else {
                        isBreak = true;
                        break;
                    }
                } /*else if (secObjs[secIndex].getSecType() == SectionConstant.SectionType.SECCHAR){//是分隔符
                    continue;
                }*/
                CodeBasicSecVO secObj = secObjs.get(secIndex+columnIndex);
 
                VCIJLabel lbl = new VCIJLabel(secObj.getName() + ":");
                lbl.setForeground(new Color(129, 0, 0));
                JComponent compt = null;//码段名称
 
                VCIJComboxBox cbx = new VCIJComboxBox();
                compt = cbx;
                secList.add(secObj);
                comList.add(cbx);
                compMaps.put(column, compt);
                secNameAndComtMap.put(secObj.getName(), cbx);
                secIndexAndNameMap.put(column, secObj.getName());
 
                /**层级码段需要特殊处理:如果是层级码段,下拉框不能编辑,显示的值是选中的树节点的分类名称和代号**/
                if(secObj.getSecType().equals ("codelevelsec")) {//层级码段
                    levelPositon = column;
                    compt.setEnabled(false);
                }
//                relationMap.put(secIndex, column);
                secAndComMap.put(secObj.getId(), cbx);
                column++;
 
                c.gridx = x++;
                c.gridy = y;
                c.gridheight = 1;
                c.gridwidth = 1;
                c.weightx = 0d;
                c.weighty = 0d;
//                c.fill = GridBagConstraints.NONE;
                c.anchor = GridBagConstraints.EAST;
                c.insets = new Insets(1, 1, 10, 10);
                c.ipadx = 3;
                c.ipady = 3;
                lbl.setPreferredSize(new Dimension(100,25));
                sectionPal.add(lbl, c);
 
                c.gridx = x++;
                c.weightx = 0d;
                c.fill = GridBagConstraints.CENTER;
                c.anchor = GridBagConstraints.WEST;
                compt.setPreferredSize(new Dimension(200,25));
                sectionPal.add(compt, c);
                //如果当前码段是需要特殊处理的码段,系统进行记录处理
                if(isSpecialRuleFlag && specialSectioName.equals(secObj.getName())) {
                    specSecList.add(lbl);
                    specSecList.add(compt);
                }
                /**分类码段添加描述信息  410新需求:分类码段码值增加'码值描述'字段 BEGIN***/
                if(secObj.getSecType().equals("codeclassifysec")) {
                    VCIJLabel lblDesc = new VCIJLabel("描述:");
                    c.gridx = x++;
                    c.weightx = 0d;
                    c.fill = GridBagConstraints.NONE;
                    c.anchor = GridBagConstraints.WEST;
                    lblDesc.setPreferredSize(new Dimension(40,25));
                    sectionPal.add(lblDesc, c);
                    VCIJTextField txtDesc = new VCIJTextField("");
                    c.gridx = x++;
                    c.weightx = 0d;
                    c.fill = GridBagConstraints.CENTER;
                    c.anchor = GridBagConstraints.WEST;
                    txtDesc.setPreferredSize(new Dimension(200,25));
                    txtDesc.setEditable(false);
                    sectionPal.add(txtDesc, c);
                    secIdToClsfIdMap.put(secObj.getId(), txtDesc);
                    //详细描述信息的查看
                    VCIJLabel clsfDescLbl = new VCIJLabel();
                    clsfDescLbl.setText("<html><u>"+"详细描述"+"</u><html>");
                    clsfDescLbl.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
                    clsfDescLbl.setForeground(Color.RED);
 
                    comtMap.put(clsfDescLbl,txtDesc);
                    clsfDescLbl.addMouseListener(new MouseAdapter() {
                        public void mouseClicked(MouseEvent e){
                            clsfValDescActionListener(e);
                        }
                    });
                    c.gridx = x++;
                    c.weightx = 0d;
                    c.fill = GridBagConstraints.NONE;
                    c.anchor = GridBagConstraints.WEST;
//                    lblDesc.setPreferredSize(new Dimension(100,25));
                    sectionPal.add(clsfDescLbl, c);
 
                    //如果当前码段是需要特殊处理的码段,系统进行记录处理
                    if(isSpecialRuleFlag && specialSectioName.equals(secObj.getName())) {
                        specSecList.add(lblDesc);
                        specSecList.add(txtDesc);
                        specSecList.add(clsfDescLbl);
                    }
 
                }
                /****************************END**********************************/
 
            }// for 2
            if (isBreak) {
                break;
            }
            x = 0;
            y += 1;
        }// for 1
 
        rulePal.setLayout(new BorderLayout());
        rulePal.add(sectionPal,BorderLayout.CENTER);
        if (type == 1) {
            rulePal.add(createAttrPal(),BorderLayout.SOUTH);
        }
        initCurrentRow(secList.toArray(new CodeBasicSecVO[0]),comList.toArray(new VCIJComboxBox[0]));
    }
    /**加载模板属性信息面板**/
    private VCIJPanel createAttrPal() {
        VCIJPanel attrPal = new VCIJPanel();
        CodeClassify rmTypeObj = (CodeClassify) this.transTreeObject.getCurrentTreeNode().getObj();
        /**选择了代码项**/
        if(rmTypeObj != null) {
            transmitForRMData = loadTemplateAttributes("",rmTypeObj.getId(),"");
            /**代码项下的模板包含属性**/
            if(transmitForRMData.getTempPropObjsList().size() > 0) {
                attrPal = createTemplateAttributePanel(transmitForRMData);
            }
        }
        return attrPal;
    }
    private void loadSpecialRuleConfig() {
        /******added by ligang 是否是特殊规则的判断Begin******/
        /*CodeClassify rmType = (CodeClassify) this.transTreeObject.getCurrentTreeNode().getObj();
        RuleManagerObject ruleObj = ruleDel.getRuleManagerById(rmType.getRuleOid());
 
        String specialRuleName = ConfigUtils.getConfigValue(SPECIAL_RULE_NAME);
        isSpecialRuleFlag = ruleObj.getPlname().toUpperCase().equals(specialRuleName.toUpperCase()) ? true : false;
        specialControlSecName = ConfigUtils.getConfigValue(SPECIAL_CONTROL_SECTION_NAME);
        specialSectioName = ConfigUtils.getConfigValue(SPECIAL_SECTION_NAME);
        specialSecVals = ConfigUtils.getConfigValue(SPECIAL_SECTION_VALUE).split(",");*/
        /*********************End*************************/
    }
 
    /**
     * 加载是否启用TextArea环境参数
     * <p>
     * Description:
     * </p>
     * @author liujw
     * @throws
     * @time 2013-4-16
     */
    private void loadTextAreaEnableEnv()  {
        String textAreaEnable = ConfigUtils.getConfigValue(TEXTAREA_ENABLE_KEY);
        String strAttrInLine = ConfigUtils.getConfigValue(MAX_ATTR_IN_LINE_KEY);
        if (isNumber(strAttrInLine)) {
            Integer iLength = Integer.valueOf(strAttrInLine);
            if (iLength > 0) {
                this.maxAttrInLine = iLength;
            }
        }
        if (textAreaEnable.toLowerCase().equals("true")) {
            this.isEnableTextArea = true;
        }
        if(this.isEnableTextArea){
            String cfgValue = "";
 
            cfgValue = ConfigUtils.getConfigValue(MAX_STRING_LENGTH_KEY);
            if (isNumber(cfgValue)) {
                Integer iLength = Integer.valueOf(cfgValue);
                if (iLength > 0) {
                    this.maxStringLength = iLength;
                }
            }
 
            cfgValue = ConfigUtils.getConfigValue(TEXTAREA_PRE_SIZE_WIDTH);
            if (isNumber(cfgValue)) {
                Integer iValue = Integer.valueOf(cfgValue);
                if (iValue > 0) {
                    this.textAreaPreSizeWidth = iValue;
                }
            }
 
            cfgValue = ConfigUtils.getConfigValue(TEXTAREA_PRE_SIZE_HEIGHT);
            if (isNumber(cfgValue)) {
                Integer iValue = Integer.valueOf(cfgValue);
                if (iValue > 0) {
                    this.textAreaPreSizeHeight = iValue;
                }
            }
 
            cfgValue = ConfigUtils.getConfigValue(TEXTAREA_MIN_SIZE_WIDTH);
            if (isNumber(cfgValue)) {
                Integer iValue = Integer.valueOf(cfgValue);
                if (iValue > 0) {
                    this.textAreaMinSizeWidth = iValue;
                }
            }
 
            cfgValue = ConfigUtils.getConfigValue(TEXTAREA_MIN_SIZE_HEIGHT);
            if (isNumber(cfgValue)) {
                Integer iValue = Integer.valueOf(cfgValue);
                if (iValue > 0) {
                    this.textAreaMinSizeHeight = iValue;
                }
            }
 
            cfgValue = ConfigUtils.getConfigValue(TEXTAREA_MAX_SIZE_WIDTH);
            if (isNumber(cfgValue)) {
                Integer iLength = Integer.valueOf(cfgValue);
                if (iLength > 0) {
                    this.textAreaMaxSizeWidth = iLength;
                }
            }
 
            cfgValue = ConfigUtils.getConfigValue(TEXTAREA_MAX_SIZE_HEIGHT);
            if (isNumber(cfgValue)) {
                Integer iLength = Integer.valueOf(cfgValue);
                if (iLength > 0) {
                    this.textAreaMaxSizeHeight = iLength;
                }
            }
        }
    }
    /**
     * 分类层级注入功能的完善
     * <p>Description: </p>
     *
     * @author ligang
     * @time 2013-5-7
     */
    private void initContents() {
        Iterator<String> keys = transmitForRMData.getTempPropObjsMap().keySet().iterator();
        while(keys.hasNext()){
            String key = keys.next();
            CodeClassifyTemplateAttrVO tempPropObj = transmitForRMData.getTempPropObjsMap().get(key);
            String referConfig=tempPropObj.getReferConfig();//参照配置
            String componentRule=tempPropObj.getComponentRule();//组合规则
            String innerName = tempPropObj.getId();
            if (attrInnerNameToCtrlMaps.containsKey(innerName)) {
                String classifyLevel = tempPropObj.getClassifyInvokeLevel();
                String classifyInvokeAttr= tempPropObj.getClassifyInvokeAttr();
                JComponent compt = attrInnerNameToCtrlMaps.get(innerName);
                if(StringUtils.isNotBlank(classifyLevel)&&!classifyLevel.equals("none")&&!classifyLevel.equals("min")) {
                    compt.setEnabled(false);
                    //ClassifyLevel classifyLevelObj=new ClassifyLevel();
                    //ObjectMapper objectMapper = new ObjectMapper();
                    String value = "";
                    /*classifyLevelObj = objectMapper.readValue(classifyLevel.toString(), ClassifyLevel.class);
                    String set=classifyLevelObj.getSet();
                    String type=classifyLevelObj.getType();*/
                    if (classifyLevel.equals("min")) {
                        CodeClassify rmType = (CodeClassify) this.transTreeObject.getCurrentTreeNode().getObj();
                        if ("name".equals(classifyInvokeAttr)) {
                            value = rmType.getName();
                        } else if ("id".equals(classifyInvokeAttr)) {
                            value = rmType.getId();
                        }
 
                    } else {
                        int intLevel = Integer.parseInt(classifyLevel);
                        if (rmTypeTreeMaps.containsKey(intLevel)) {
                            CodeClassify rmType = rmTypeTreeMaps.get(intLevel);
                            if ("name".equals(classifyInvokeAttr)) {
                                value = rmType.getName();
                            } else if ("id".equals(classifyInvokeAttr)) {
                                value = rmType.getId();
                            }
                        }
                    }
                    if (compt instanceof JTextComponent) {
                        ((JTextComponent) compt).setText(value);
                    }
                }
                //参照配置的设置成只读模式
                if(StringUtils.isNotBlank(referConfig)||StringUtils.isNotBlank(componentRule)){
                    compt.setEnabled(false);
                }
            }
        }
    }
    /**
     * 分类树中的分类对象map
     */
    private LinkedHashMap<Integer, CodeClassify> rmTypeTreeMaps = new LinkedHashMap();
 
    private void initRMTypeTreeMaps(){
        if(transTreeObject != null){
            TreeNode[] nodes = transTreeObject.getTreeModel().getPathToRoot(transTreeObject.getCurrentTreeNode());
            int level = 1;
            int start = 1;
            for(int i = start; i < nodes.length; i++){
                TreeNode node = nodes[i];
                if(node instanceof VCIBaseTreeNode){
                    VCIBaseTreeNode treeNode = (VCIBaseTreeNode) node;
                    Object obj = treeNode.getObj();
                    if((treeNode.isRoot() || (obj instanceof String))){
                        //
                    }else if(obj instanceof CodeClassify){
                        CodeClassify rmType = (CodeClassify)obj;
                        rmTypeTreeMaps.put(level++, rmType);
                    }
                }
            }
        }
    }
 
 
    /**
     * 初始化个码段码值,如果是分类码只加载父分类的分类码值,子分类不加载
     * @param secObjs
     */
    public void initCurrentRow(CodeBasicSecVO[] secObjs,VCIJComboxBox[] secCombos) {
        SectionObject lastSecObj = null;
        VCIJComboxBox hisCombo = null;
        try {
            final Map<String, String> secValMap = getSpecialValMap(specialSecVals);
            Map<String,List<String>> secIdTOListValueOidMap=new HashMap<>();
            for(int k = 0;k < secObjs.length; k++) {
                final CodeBasicSecVO secObj = secObjs[k];
                final VCIJComboxBox secCombo = secCombos[k];
                if(null == secObj) {
                    return;
                }
                if (secObj.getSecType().equals("codeclassifysec")) {// 是分类码
                    String  secOid=secObj.getOid();
                    String parentClassifySecOid= secObj.getParentClassifySecOid();
                    String parentClassifyValueOid="";
                    if(secIdTOListValueOidMap.containsKey(parentClassifySecOid)){
                        List<String> parentClassifyValueList= secIdTOListValueOidMap.get(parentClassifySecOid);
                        parentClassifyValueOid= VciBaseUtil.array2String(parentClassifyValueList.toArray(new String[]{}));
                    }
                    Map<String,String> condtionMap=new HashMap<>();
                    condtionMap.put("secOid", secOid);
                    condtionMap.put("parentClassifyValueOid", parentClassifyValueOid);
                    R r=HttpUtil.sendGet(url+"/listCodeClassifyValueBySecOid",condtionMap,new HashMap<>());
                    List<CodeClassifyValue> codeClassifyValueList=new ArrayList<>();
                    if(r.isSuccess()){
                        Object object= r.getData();
                        if(object!=null) {
                            ObjectMapper objectMapper = new ObjectMapper();
                            try {
                                codeClassifyValueList = objectMapper.readValue(object.toString(), new com.fasterxml.jackson.core.type.TypeReference<List<CodeClassifyValue>>() {});
                            } catch (JsonProcessingException e) {
                                e.printStackTrace();
                            }
                        }
                    }else{
                        VCIOptionPane.showMessage(this,r.getMsg());
                    }
                    List<String>valueOidList=new ArrayList<>();
                    if(!CollectionUtils.isEmpty(codeClassifyValueList)) {
                        if(codeClassifyValueList.size()>1) {
                            secCombo.addItem(new CodeClassifyValue());
                        }
                        codeClassifyValueList.stream().forEach(codeClassifyValue -> {
                            secCombo.addItem(codeClassifyValue);
                            valueOidList.add(codeClassifyValue.getOid());
                        });
                    }
                    secIdTOListValueOidMap.put(secObj.getOid(),valueOidList);
                    /**代码项下拉事件**/
                    secCombo.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent e) {
                            if(secCombo.getSelectedIndex() == -1) {
                                return;
                            }
                            if(secIdToClsfIdMap.containsKey(secObj.getId())){
                                VCIJTextField secDescVcijTextField=(VCIJTextField)secIdToClsfIdMap.get(secObj.getId());
                                CodeClassifyValue codeClassifyValue= (CodeClassifyValue) secCombo.getSelectedItem();
                                secDescVcijTextField.setText(codeClassifyValue.getName());
                            }
                        }
                    });
                    /*if (secCombo.getItemCount() > 10){
                        if (!secCombo.isFlag()){
                            secCombo.setFlag(true);
                            secCombo.getSearchBtn().setVisible(true);
                            secCombo.getSearchBtn().addActionListener(new ActionListener() {
                                @Override
                                public void actionPerformed(ActionEvent e) {
                                    doSearch(secCombo);
                                }
                            });
                        }
                    }else {
                        secCombo.setFlag(false);
                        secCombo.getSearchBtn().setVisible(false);
                    }*/
                } else
                    // 是固定码
                    if (secObj.getSecType() .equals("codefixedsec")) {
                        List<CodeFixedValueVO> fixedValueVOList=secObj.getFixedValueVOList();
                    //如果只有一个值,则系统默认选择,不加空值
                    if(fixedValueVOList.size() >1) {
                        secCombo.addItem(new CodeFixedValue());
                    }
                    fixedValueVOList.stream().forEach(codeFixedValueVO -> {
                        CodeFixedValue codeFixedValue=new CodeFixedValue();
                        BeanUtilForVCI.copyPropertiesIgnoreCase(codeFixedValueVO,codeFixedValue);
                        secCombo.addItem(codeFixedValue);
                    });
                    /**当系统选择的是指定码段值时,组别代号的码段系统不显示 Begin**/
                    /*FixCodeValObject selObj = (FixCodeValObject) secCombo.getSelectedItem();
                    if(isSpecialRuleFlag && (secObj.getName().equals(specialControlSecName) && secValMap.containsKey(selObj.getValue())) || secValMap.containsKey(getControlSecSelectValue())) {
                        setComponentStatus(false);
                    }else {
                        setComponentStatus(true);
                    }*/
                    /*if (secCombo.getItemCount() > 10){
                        if (!secCombo.isFlag()){
                            secCombo.setFlag(true);
                            secCombo.getSearchBtn().setVisible(true);
                            secCombo.getSearchBtn().addActionListener(new ActionListener() {
                                @Override
                                public void actionPerformed(ActionEvent e) {
                                    doSearch(secCombo);
                                }
                            });
                        }
                    }else {
                        secCombo.setFlag(false);
                        secCombo.getSearchBtn().setVisible(false);
                    }*/
                }  else
                        // 是日期码段
                    if (secObj.getSecType().equals("codedatesec")) {
                        String df =secObj.getCodeDateFormatStr();
                        SimpleDateFormat dateFormate = new SimpleDateFormat(df);
                        String curDate = dateFormate.format(Calendar.getInstance().getTime());
                        secCombo.addItem(curDate);
                        /*if(dateObj.getIsModify().equals("Y")){//可以修改
                            secCombo.setEditable(true);
                        }*/
                } else
                        //是引用码段
                    if (secObj.getSecType().equals("coderefersec")) {
                    /*RefSecObject refObj = getRefSecObj(secObj.getId());
                    DefaultComboBoxModel aModel = getRefSecComboBox(refObj);
                    secCombo.setModel(aModel);
                    if(deptName != null && !("".equals(deptName))){
                        Integer index = refSecValueToCombxindex.get(deptName);
                        if(index !=null){
                            secCombo.setSelectedIndex(index);
                        }
                    }
 
                    if (secCombo.getItemCount() > 10){
                        if (!secCombo.isFlag()){
                            secCombo.setFlag(true);
                            secCombo.getSearchBtn().setVisible(true);
                            secCombo.getSearchBtn().addActionListener(new ActionListener() {
                                @Override
                                public void actionPerformed(ActionEvent e) {
                                    doSearch(secCombo);
                                }
                            });
                        }
                    }else {
                        secCombo.setFlag(false);
                        secCombo.getSearchBtn().setVisible(false);
                    }
 
                */} else
                    //层级码段码值显示的是选择的代码项的名称
                    if(secObj.getSecType().equals("coderefersec")) {
                        CodeClassify rmObj = (CodeClassify) this.transTreeObject.getCurrentTreeNode().getObj();
                        secCombo.addItem(rmObj);
                    } else {
                        secCombo.setEditable(true);
                    }
            }
        }catch (Exception e) {
            e.printStackTrace();
            VCIOptionPane.showError(this, "初始化码段码值出现错误!");
        }
    }
    /**
     * 加载模板的定义的属性、属性数据
     * <p>Description: </p>
     *
     * @author xchao
     * @time 2012-6-7
     * @param libId
     * @param classifyId
     * @param templateId
     * @return
     */
    public RMDataTransmitObject loadTemplateAttributes(String libId, String classifyId, String templateId) {
        RMDataTransmitObject transmit=new RMDataTransmitObject();
        transmit.setLibId(libId);
        transmit.setClassifyId(classifyId);
        CodeClassify rmType = (CodeClassify) this.transTreeObject.getCurrentTreeNode().getObj();
        transmit.setRmTypeObject(rmType);
        if(currentCodeClassifyTemplateVO!=null) {
            transmit.setTemplateId(templateId);
            Map<String, CodeClassifyTemplateAttrVO> tempPropObjMapsByInnerName = currentCodeClassifyTemplateVO.getAttributes().stream().collect(Collectors.toMap(s -> s.getId().toLowerCase(Locale.ROOT), t -> t));
            transmit.setClassifyCode(rmType.getId());
            transmit.setTempPropObjMapsByInnerName(tempPropObjMapsByInnerName);
            Map<String, CodeClassifyTemplateAttrVO> tempPropObjsMap = currentCodeClassifyTemplateVO.getAttributes().stream().collect(Collectors.toMap(s -> s.getOid().toLowerCase(Locale.ROOT), t -> t));
            transmit.setTempPropObjsMap(tempPropObjsMap);
            transmit.setTemplateObject(currentCodeClassifyTemplateVO);
            transmit.setTempPropObjsList(this.currentCodeClassifyTemplateVO.getAttributes());
        }
        return transmit;
    }
 
    /****
     * 加载代码项对应的模板属性信息列表
     * <p>Description: </p>
     *
     * @author Administrator
     * @time 2013-3-23
     * @param transmitForRMData :模板属性,分类等信息
     * @return
     */
    private VCIJPanel createTemplateAttributePanel(final RMDataTransmitObject transmitForRMData)  {
        //int maxAttrInLine = 2;
        VCIJPanel pal = new VCIJPanel();
        pal.setLayout(new GridBagLayout());
        int gridx = -1;
        int gridy = -1;
        int gridwidth = 1;
        double weighty = 0.0;
        CodeClassifyTemplateAttrVO[] realAttrs = getRealAttributeObjects(transmitForRMData);
        Map<String, String> attrMaps = getTempPropMap(transmitForRMData);
 
        attrIdToCtrlMaps.clear();
        attrInnerNameToCtrlMaps.clear();
 
        for (int attrIndex = 0; attrIndex < realAttrs.length; attrIndex += maxAttrInLine) {// for1
            gridx = 0;
            gridy += 1;
            boolean leastNewLine = checkLeastNewLine(attrIndex, maxAttrInLine,attrMaps,realAttrs);
            for (int columnIndex = 0; columnIndex < maxAttrInLine; columnIndex++) { // for2
                int index = columnIndex + attrIndex;
                if (index >= realAttrs.length) {
                    break;
                }
                CodeClassifyTemplateAttrVO attrObj = realAttrs[index];
 
                /***如果模板配置了引用模板,属性名称列表添加链接进行处理 BEGIN**/
                //ADD BY liujw
                VCIJLabel lbl = null;
                if(StringUtils.isNotBlank(attrObj.getReferConfig())) {//引用模板属性值
                    lbl = new VCIJLabel("<html><u>"+(attrObj.getName() + ":")+"</u><html>");
                    lbl.setForeground(Color.MAGENTA);
                    lbl.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
                    lbl.setToolTipText("点击此处加载引用模板属性数据");
                    lbl.addMouseListener(new MouseAdapter() {
                        public void mouseClicked(MouseEvent e){
                            getReferTempRMData(attrObj,attrIdToCtrlMaps,transmitForRMData.getTempPropObjsList());
                        }
                    });
                } else if(!"".equals(attrObj.getComponentRule())) {//模板规则的组合
                    String lblName = "☆"+attrObj.getName() + "☆:";
                    lbl = new VCIJLabel("<html><u>"+lblName+"<u></html>");
                    lbl.setForeground(Color.BLUE);
                    lbl.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
                    lbl.setToolTipText("点击此处获取模板对应规则的值");
                    lbl.addMouseListener(new MouseAdapter() {
                        public void mouseClicked(MouseEvent e){
                        //    getComptAttrValue(attrObj,attrIdToCtrlMaps,transmitForRMData.getTempPropObjsList());
 
                        }
                    });
                } else if(attrObj.getKeyAttrFlag().equals("true")) {//关键属性
                    lbl = new VCIJLabel(attrObj.getName() + ":");
                    lbl.setForeground(new Color(255, 0, 0));
                }
                else {
                    lbl = new VCIJLabel(attrObj.getName() + ":");
                    lbl.setForeground(attrObj.getRequireFlag().equals("true") ? new Color(0, 120, 0) : new Color(129, 0, 0));
                }
                JComponent compt = createComponent(attrObj);
                JComponent comptAddToPanel = compt;
 
                //by liujw
                boolean isMultiLineFlag = attrObj.getTextAreaFlag().equals("true") ? true : false;
                if (this.isEnableTextArea && isMultiLineFlag // 启用TextArea显示处理,且属性长度超过一定范围
                    && attrObj.getAttributeDataType().toUpperCase().equals("VTstring".toUpperCase()) // String类型
                ) {
                    VCIJTextArea textArea = new VCIJTextArea("", attrObj.getRequireFlag().equals("true"));
                    VCIJScrollPane textAreaScroll = createTextAreaScrollPane(textArea);
                    textArea.setEnabled(compt.isEnabled());
                    comptAddToPanel = textAreaScroll;
                    if(compt instanceof JTextComponent){
                        textArea.setText(((JTextComponent)compt).getText());
                    }
                    compt = textArea;
                }
                /**
                 * 方案:V1 属性组件加载、显示策略 1、每行(一组)最多显示maxAttrInLine个属性
                 * 2、如果isEnableTextArea为true,则是启用TextArea
                 * 3、启用TextArea后,如果一组内的属性,只要任意一个属性定义的属性长度大于或等于maxStringLength
                 * ,则该组内的每个属性都将独占一整行
                 * 此方案存在的问题:因为除TextArea之外的属性也将占整行显示,如果一组内的属性个数较多
                 * (大于2)时,界面显示层面不太,友好,尤其是连续出现多个TextArea时此现象更加明显
                 * 因此建议配置:启用TextArea时,RMData.MaxAttrInLine=2,即一组内最多加载两个属性。
                 */
                // 一组至少存在着一个TextArea时,该组内其它属性也将占整个宽度(独占一行),
                if (leastNewLine) {
                    gridwidth = maxAttrInLine * 2;
                    gridx = 0;
                    gridy += 1;
//                        weighty = 1.0;
                    weighty = 0.0;
                } else {
                    gridwidth = 1;
                    weighty = 0.0;
                }
                pal.add(lbl,createGridBagConstraints(gridx, gridy, 1, 1, 0.0, 0.0,GridBagConstraints.NORTHEAST,GridBagConstraints.NONE));
                pal.add(comptAddToPanel,createGridBagConstraints(gridx + 1, gridy, gridwidth,1, 1.0, weighty, GridBagConstraints.NORTHWEST,GridBagConstraints.BOTH));
                // 如果这一组内不存在着需要占整行显示的,则计算横坐标
                //gridx += 2;
                if (!leastNewLine) {
                    gridx += 2;
                }
                /*********************** 方案:V1 End ***********************/
 
                // 缓存各属性对应的控&组件
                String key = attrObj.getId();
                if (!attrIdToCtrlMaps.containsKey(key)) {
                    attrIdToCtrlMaps.put(key, compt);
                }
                // 存储属性内部名称与控件的关系
                key = attrObj.getId();
                if (!attrInnerNameToCtrlMaps.containsKey(key)) {
                    attrInnerNameToCtrlMaps.put(key, compt);
                }
            }// for 2
        }// for 1
        // 在底部添加一行,占据全部的空余区域,其它控件自动从对齐到顶部
        pal.add(new VCIJLabel(""),createGridBagConstraints(0, gridy + 1, maxAttrInLine * 2, 1,1.0, 10.0, GridBagConstraints.NORTHWEST,GridBagConstraints.BOTH));
        this.setTextComptList(textCompts);
        return pal;
    }
    /**根据属性组合规则获取属性的值 **/
    //add by liujw
    private void getComptAttrValue(CodeClassifyTemplateAttrVO attrObj, LinkedHashMap<String, JComponent> attrIdToCtrlMaps) {
        Map<String, String> attrNameMap = new LinkedHashMap<String, String>();
        Map<String, String> tempProMap = new LinkedHashMap<String, String>();
 
        // 各属性的内部名称
        LinkedList<String> listInnerNames = new LinkedList<String>();
        // 各属性对应的数据值
        LinkedList<String> listValues = new LinkedList<String>();
        // 各属性的类型
        LinkedList<String> listDataTypes = new LinkedList<String>();
 
        Iterator<String> keys = attrIdToCtrlMaps.keySet().iterator();
        JComponent compt = null;
        while (keys.hasNext()) {
            String attrOid = keys.next();
            compt = attrIdToCtrlMaps.get(attrOid);
            String value = "";
            if (compt instanceof JTextComponent) {
                value = ((JTextComponent) compt).getText();
            } else if (compt instanceof VCIJCalendarPanel) {
                value = ((VCIJCalendarPanel) compt).getDateString();
                value = value == null ? "" : value;
            } else if (compt instanceof VCIJComboBox) {
                Object objItem = ((VCIJComboBox) compt).getSelectedItem();
                if (objItem instanceof AttrRangObjectWarper) { // 属性取值范围
                    value = ((AttrRangObjectWarper) objItem).getKeyValue().getValue();
                } else if (objItem instanceof String) { // Boolean类型的会提供0\1选择
                    value = (String) objItem;
                }
            }
 
            // 全部验证通过
            listInnerNames.add(attrObj.getId());
            listValues.add(value);
            listDataTypes.add(attrObj.getAttributeDataType());
 
            /**修复属性定义中'/'不能支持的bug**/
            String attrName = attrObj.getName();
            if(attrName.indexOf("/") != -1) {
                attrName = attrObj.getName().replaceAll("/", "_");
            }
 
            attrNameMap.put(attrName, value);
            /****************End******************/
            tempProMap.put(attrObj.getOid(), attrObj.getId());
        }
        /**根据模板中配置的属性规则,根据规则对属性数据进行组合或者拆分 BEGIN***/
        List<CodeClassifyTemplateAttrVO> list = transmitForRMData.getTempPropObjsList();
        for(CodeClassifyTemplateAttrVO obj : list) {
            if(!"".equals(obj.getComponentRule())) {
                try {
                    /**修复属性定义中'/'不能支持的bug Begin**/
                    String tempRule = obj.getComponentRule();
                    if(tempRule.indexOf("/") != -1) {
                        tempRule = obj.getComponentRule().replaceAll("/", "_");
                    }
                    String value = "";//FreeMarkerCommon.getValueByTempRule(attrNameMap,tempRule);
                    /****************End******************/
                    JComponent comp = attrInnerNameToCtrlMaps.get(tempProMap.get(obj.getOid()));
                    if(comp instanceof JTextComponent) {
                        ((JTextComponent) comp).setText(value);
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
 
        }
    }
    /**
     * 获取真实的、实际的需要加载到UI的属性列表
     * <p>
     * Description:
     * </p>
     *
     * @author xchao
     * @time 2012-11-6
     * @param transmitForRMData
     *            当前上下数据传递对象
     * @return
     */
    private CodeClassifyTemplateAttrVO[] getRealAttributeObjects(RMDataTransmitObject transmitForRMData) {
        // 取模板的属性
        CodeClassifyTemplateAttrVO[] tempAttrs = transmitForRMData.getTempPropObjsList().toArray(new CodeClassifyTemplateAttrVO[0]);
        LinkedList<CodeClassifyTemplateAttrVO> attrsList = new LinkedList<CodeClassifyTemplateAttrVO>();
        // 进行过滤,隐藏的不显示,企业代码不显示,其它的允许录入
        for (CodeClassifyTemplateAttrVO attrObj : tempAttrs) {
            String attrId = attrObj.getOid();
            // 判断属性是否隐藏,隐藏的不需要提供录入项
            if (attrObj.getFormDisplayFlag().equals("false")) {
                continue;
            }
            // 如果是代码列,则也隐藏,通过代码申请框架录入
            else if (attrObj.getId().toUpperCase().equals("id".toUpperCase())) {
                continue;
            }
            attrsList.add(attrObj);
        }
        // 有效的、需要显示录入框的属性列表
        CodeClassifyTemplateAttrVO[] attrs = attrsList.toArray(new CodeClassifyTemplateAttrVO[] {});
        return attrs;
    }
    /**
     * 创建属性在UI中呈现的组件
     * <p>
     * Description:
     * </p>
     *
     * @author xchao
     * @time 2012-11-6
     * @param attrObj
     *            属性在模板中对应的属性对象
     * @return
     */
    private JComponent createComponent(CodeClassifyTemplateAttrVO attrObj)  {
        JComponent compt = null;
        String attrId = attrObj.getId();
        // 查出属性的取值范围
        if(StringUtils.isNotBlank(attrObj.getEnumString())||StringUtils.isNotBlank(attrObj.getEnumId())){
            KeyValue[] keyValues = getAttrRangeObjects(attrObj.getOid());
            // 如果存在取值范围,只能从取值范围里选择
            if (keyValues.length != 0) {
                AttrRangObjectWarper[] objs = new AttrRangObjectWarper[keyValues.length];
                VCIJComboBox cbx = new VCIJComboBox();
                DefaultComboBoxModel model = new DefaultComboBoxModel();
                //存在取值范围,如果可以为空,则添加一个空值
                int comboBoxIndex = 1;
                KeyValue keyValue = new KeyValue();
                keyValue.setValue("");
                keyValue.setKey("");
                AttrRangObjectWarper wrapper = new AttrRangObjectWarper(keyValue);
                model.addElement(wrapper);
                /*** 如果模板属性不是必填项,加入空值后修改时功能的完善 **/
                LinkedHashMap<String, Integer> specMap = new LinkedHashMap<String, Integer>();
                for (int i = 0; i < objs.length; i++) {
                    objs[i] = new AttrRangObjectWarper(keyValues[i]);
                    model.addElement(objs[i]);
 
                    specMap.put(objs[i].toString(), comboBoxIndex++);
                }
                cbx.setModel(model);
                compt = cbx;
            }
        } else if(StringUtils.isNotBlank(attrObj.getReferConfig())){//参照的需要设置成下拉框,并且只读
            VCIJComboBox cbx = new VCIJComboBox();
            DefaultComboBoxModel model = new DefaultComboBoxModel();
            KeyValue keyValue = new KeyValue();
            keyValue.setValue("");
            keyValue.setKey("");
            AttrRangObjectWarper wrapper = new AttrRangObjectWarper(keyValue);
            model.addElement(wrapper);
            cbx.setModel(model);
            compt = cbx;
        } else { // 不存在取值范围则按类型生成不同的控件
             if (attrObj.getAttributeDataType().equals(VciFieldTypeEnum.VTBoolean)) { // Boolean类型
                VCIJComboBox cbx = new VCIJComboBox();
                DefaultComboBoxModel model = new DefaultComboBoxModel();
                model.addElement("0");
                model.addElement("1");
                cbx.setModel(model);
                compt = cbx;
            } else if (attrObj.getAttributeDataType().equals(VciFieldTypeEnum.VTDate)) { // 日期类型
                compt = new VCIJCalendarPanel("yyyy-MM-dd",
                    attrObj.getRequireFlag().equals("true"), true, false);
            } else if (attrObj.getAttributeDataType().equals(VciFieldTypeEnum.VTDateTime)) { // 日期类型
                 compt = new VCIJCalendarPanel("yyyy-MM-dd HH:mm:ss",
                     attrObj.getRequireFlag().equals("true"), true, false);
             }else if (attrObj.getAttributeDataType().equals(VciFieldTypeEnum.VTTime)) { // 日期类型
                 compt = new VCIJCalendarPanel("HH:mm:ss",
                     attrObj.getRequireFlag().equals("true"), true, false);
             }
             else if (attrObj.getAttributeDataType().equals(VciFieldTypeEnum.VTDouble)||attrObj.getAttributeDataType().equals(VciFieldTypeEnum.VTLong)) { // Real类型
                RealTextField txt = new RealTextField("");
                txt.setRequired(attrObj.getRequireFlag().equals("true"));
                compt = txt;
            } else if (attrObj.getAttributeDataType().equals(VciFieldTypeEnum.VTInteger)) { // Integer类型
                IntegerTextField txt = new IntegerTextField("");
                txt.setRequired(attrObj.getRequireFlag().equals("true"));
                compt = txt;
            }
             else{
                 VCIJTextField txt = new VCIJTextField(this,attrObj.getRequireFlag().equals("true"));
                 compt = txt;
                 textCompts.add(txt);
             }
            boolean enabled = true;
 
            /*// 集团代码、集团附加码不可以手工录入数据
            if (attrObj.getId().equals(Constants.GROUP_CODE_INNERNAME)|| attrObj.getInternalname().equals(Constants.GROUP_ADD_CODE_INNERNAME)) {
                enabled = false;
            }*/
 
            compt.setEnabled(enabled);
        }
 
        return compt;
    }
    /****
     * 根据属性id获取属性取值范围的值
     * <p>Description: </p>
     *
     * @author Administrator
     * @time 2013-3-23
     * @param attrId
     * @return
     */
    private KeyValue[] getAttrRangeObjects(String attrId){
        KeyValue[] res = new KeyValue[0];
        //String url= ConfigUtils.getConfigValue("410.PDM.attrKeyValue.url","http://127.0.0.1:36014/codeApplySwingController/listComboboxItems");
        /**系统只加载代码项  如果libName不为空,直接获取对应的代码项**/
        Map<String,String> condtionMap=new HashMap<>();
        condtionMap.put("oid", attrId);
        R r=HttpUtil.sendGet(url+"/listComboboxItems",condtionMap,new HashMap<>());
        List<KeyValue> keyValueList=new ArrayList<>();
        if(r.isSuccess()){
            Object object= r.getData();
            if(object!=null) {
                ObjectMapper objectMapper = new ObjectMapper();
                try {
                    keyValueList = objectMapper.readValue(object.toString(), new com.fasterxml.jackson.core.type.TypeReference<List<KeyValue>>() {
                    });
                } catch (JsonProcessingException e) {
                    e.printStackTrace();
                }
            }
        }else{
            VCIOptionPane.showMessage(this,r.getMsg());
        }
        return keyValueList.toArray(new KeyValue[]{});
    }
    /**
     * 检查需要在一行中显示的那些组件(控件)中,是否至少存在着一个需要换行(占整行)显示的组件
     * <p>
     * Description:
     * </p>
     *
     * @author liujw
     * @time 2013-4-16
     * @param attrIndex
     *            循环属性的索引
     * @param maxAttrInLine
     *            需要换行显示的判断条件,属性的长度
     * @param realAttrs
     *            真实的需要加载的属性列表
     * @return
     */
    private boolean checkLeastNewLine(int attrIndex, int maxAttrInLine,Map<String, String> attrMaps, CodeClassifyTemplateAttrVO[] realAttrs){
        boolean res = false;
        int attrsLength = realAttrs.length;
        for(int columnIndex = 0; columnIndex < maxAttrInLine; columnIndex++){
            int index = attrIndex + columnIndex;
            if(index < attrsLength){
                CodeClassifyTemplateAttrVO attrObj = realAttrs[index];
                boolean isStringType = attrObj.getAttributeDataType().toUpperCase().equals("VTstring".toUpperCase());
                // 启用TextArea时才进行判断
                if(this.isEnableTextArea && isStringType && attrMaps.size() > 0 && attrMaps.containsKey(attrObj.getId())){
                    res = true;
                    break;
                }
            }
        }
        return res;
    }
 
    /***获取属性模板对象  @author liujw**/
    private Map<String, String> getTempPropMap(RMDataTransmitObject transmitForRMData) {
        Map<String, String> map = new LinkedHashMap<String, String>();
        List<CodeClassifyTemplateAttrVO> propObjs = transmitForRMData.getTempPropObjsList();
        for(CodeClassifyTemplateAttrVO obj : propObjs) {
            if(obj.getTextAreaFlag().equals("true")) {
                map.put(obj.getOid(), "Y");
            }
        }
        return map;
    }
    /**码段码值描述信息的详细说明**/
    private void clsfValDescActionListener(MouseEvent e) {
        VCIJTextField txt = (VCIJTextField) comtMap.get(e.getComponent());
        DescViewDialog dialog = new DescViewDialog(this, txt.getText());
        dialog.bulidDialog();
        dialog.setVisible(true);
 
    }
    /**
     * 创建与TextArea相关联的ScrollPane对象
     * <p>
     * Description:
     * </p>
     *
     * @author liujw
     * @time 2013-4-16
     * @param txtArea
     *            VCIJTextArea
     * @return
     */
    private VCIJScrollPane createTextAreaScrollPane(VCIJTextArea txtArea) {
        txtArea.setWrapStyleWord(true);
        txtArea.setLineWrap(true);
        VCIJScrollPane txtScroll = new VCIJScrollPane();
        txtScroll.getViewport().add(txtArea);
        txtScroll.setPreferredSize(new Dimension(textAreaPreSizeWidth, textAreaPreSizeHeight));
        txtScroll.setMinimumSize(new Dimension(textAreaMinSizeWidth, textAreaMinSizeHeight));
        txtScroll.setMaximumSize(new Dimension(textAreaMaxSizeWidth, textAreaMaxSizeHeight));
        txtScroll.setBorder(null);
        return txtScroll;
    }
 
    /**
     * 返回GridBagLayout布局管理的Constraints对象
     * <p>
     * Description:
     * </p>
     *
     * @author xchao
     * @time 2012-11-6
     * @param gridx
     * @param gridy
     * @param gridwidth
     * @param gridheight
     * @param weightx
     * @param weighty
     * @param anchor
     * @param fill
     * @return
     */
 
    private GridBagConstraints createGridBagConstraints(int gridx, int gridy,
                                                        int gridwidth, int gridheight, double weightx, double weighty,int anchor, int fill) {
        int padxy = 5;
        return new GridBagConstraints(gridx, gridy, gridwidth, gridheight,weightx, weighty, anchor, fill, new Insets(padxy, padxy, padxy,padxy), padxy, padxy);
    }
 
 
 
    /**
     * 根据引用模板的id获取引用模板对象包含的数据
     * <p>Description: </p>
     *
     * @author liujw
     * @time 2012-11-29
     * @param //referTempId 引用模板id
     */
    private void getReferTempRMData(final CodeClassifyTemplateAttrVO tempPropObj,final LinkedHashMap<String, JComponent> attrIdToCtrlMaps,
                                    final List<CodeClassifyTemplateAttrVO>  tempPropList) {
        // 本空窗口调用 有可能来自两处
        // 流程任务引用
        // 一般的数据录入、修改
        // 不同的来源,需要维护好Owner父
        /*VCIJDialog ownerDialog = realDialogInstance;
        if(ownerDialog == null){
            ownerDialog = new VCIJDialog();
            ownerDialog.setSize(880, 500);
        }*/
        //final String referTempId = tempPropObj.getReferBtmId();
        final RMDataReferTempDialog dialog = new RMDataReferTempDialog(this,tempPropObj);
        dialog.setDialogCallback(new Runnable() {
            @Override
            public void run() {
                KeyValue keyValue=new KeyValue();
                /*if(dialog.isFromTableDoubleClick()){
                    int index = dialog.getRMDataMainPanel().getTablePanel().getTable().getSelectedRow();
                    list.clear();
                    list.add(dialog.getRMDataMainPanel().getTablePanel().getTableModel().getList().get(index).getObject());
                }*/
                keyValue= dialog.getKeyValue();
                //for(CodeClassifyTemplateAttrVO obj : tempPropList) {
                    if(attrIdToCtrlMaps.containsKey(tempPropObj.getId())) {
                        JComponent comp = attrIdToCtrlMaps.get(tempPropObj.getId());
                        /*if(comp instanceof VCIJTextField) {
                            int index = innnerNamesMaps.get(tempPropObj.getInternalname());
                            ((VCIJTextField) comp).setText(datas[index]);
                        }else if (comp instanceof VCIJCalendarPanel) {
                            int index = innnerNamesMaps.get(tempPropObj.getInternalname());
                            ((VCIJCalendarPanel) comp).setDateString(datas[index]);
                        } else */
                        if (comp instanceof VCIJComboBox) {
                            //DefaultComboBoxModel model = new DefaultComboBoxModel();
                            if(keyValue!=null) {
                                AttrRangObjectWarper wrapper = new AttrRangObjectWarper(keyValue);
                                ((VCIJComboBox) comp).getModel().setSelectedItem(wrapper);
                            }
                            //model.addElement(wrapper);
                             //((VCIJComboBox) comp).setModel(model);
                        }
                    }
                //}
 
            }
        });
        //dialog.initDialogSize(ownerDialog.getWidth(), ownerDialog.getHeight());
        Dimension dime = Toolkit.getDefaultToolkit().getScreenSize();
        int x = dime.width/2 - 400;
        int y = dime.height/2 -300;
        dialog.setLocation(x, y);
        dialog.setSize(new Dimension(900, 600));
        dialog.setModal(true);
        dialog.setVisible(true);
    }
 
 
    //获取系统配置的码段码值
    private Map<String, String> getSpecialValMap(String[] vals) {
        Map<String, String> map = new LinkedHashMap<String, String>();
        for (String val : vals) {
            map.put(val, "Y");
        }
        return map;
    }
    private boolean isNumber(String value) {
        return Pattern.matches("[0-9]+", value);
    }
}