田源
2025-01-09 8a166a60cfd1a2e593ffa103d10c0dc224fc8628
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
package com.vci.client.workflow.template;
 
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Insets;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.image.BufferedImage;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Hashtable;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
import java.util.zip.ZipInputStream;
 
import javax.imageio.ImageIO;
import javax.swing.ImageIcon;
import javax.swing.JComboBox;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JSplitPane;
import javax.swing.JTextField;
import javax.swing.SwingUtilities;
import javax.swing.border.TitledBorder;
 
import org.dom4j.Document;
import org.dom4j.DocumentHelper;
import org.dom4j.Element;
import org.w3c.dom.Node;
 
import com.mxgraph.io.mxCodec;
import com.mxgraph.model.mxIGraphModel;
import com.mxgraph.swing.mxGraphComponent;
import com.mxgraph.util.mxUtils;
import com.mxgraph.view.mxGraph;
import com.vci.client.LogonApplication;
import com.vci.client.common.VCIBasePanel;
import com.vci.client.framework.rightConfig.object.FunctionObject;
import com.vci.client.framework.util.RightControlUtil;
import com.vci.client.ui.exception.VCIException;
import com.vci.client.ui.swing.KJButton;
import com.vci.client.ui.swing.VCIOptionPane;
import com.vci.client.ui.swing.VCISwingUtil;
import com.vci.client.ui.swing.components.VCIJButton;
import com.vci.client.ui.swing.components.VCIJComboBox;
import com.vci.client.ui.swing.components.VCIJLabel;
import com.vci.client.ui.swing.components.VCIJPanel;
import com.vci.client.ui.swing.components.VCIJScrollPane;
import com.vci.client.ui.swing.components.table.AbstractVCIJTableDataProvider;
import com.vci.client.ui.swing.components.table.VCIJTableNode;
import com.vci.client.ui.swing.components.table.VCIJTablePanel;
import com.vci.client.workflow.commom.ClientHelper;
import com.vci.client.workflow.delegate.ProcessCustomClientDelegate;
import com.vci.client.workflow.editor.EditorCreateXmlToJbpm;
import com.vci.client.workflow.editor.FlowCellRenderer;
import com.vci.client.workflow.editor.FlowDesigner;
import com.vci.client.workflow.editor.TaskDescCObject;
import com.vci.client.workflow.editor.ZipUtil;
import com.vci.client.workflow.template.object.ProcessCategoryObject;
import com.vci.client.workflow.template.object.ProcessDefinitionObject;
import com.vci.corba.common.VCIError;
import com.vci.corba.workflow.data.CustomInfo;
import com.vci.corba.workflow.data.ProcessTaskInfo;
import com.vci.corba.workflow.data.PropertyInfo;
 
public class ProcessCustomDataPanel extends VCIBasePanel{
    private static final long serialVersionUID = 1L;
    
    private VCIJButton addButton = VCISwingUtil.createVCIJButton("","增加" ,"增加" , "add.png",null);
    private VCIJButton editButton = VCISwingUtil.createVCIJButton("","修改","修改", "edit.png",null);
    private VCIJButton deleteButton = VCISwingUtil.createVCIJButton("","删除" ,"删除", "delete.gif" ,null);
    private VCIJButton btnStart = VCISwingUtil.createVCIJButton("start", "启用", "启用", "ruby_get.png", null);
    private VCIJButton btnStop = VCISwingUtil.createVCIJButton("stop", "停用", "停用", "ruby_delete.png", null);
    private VCIJButton btnExp = VCISwingUtil.createVCIJButton("","导出" ,"导出", "export.gif" ,null);//new VCIJButton("导出");
    private VCIJButton btnImport = VCISwingUtil.createVCIJButton("","导入" ,"导入", "import.gif" ,null);//new VCIJButton("导入");
    
    private VCIJButton btncute = VCISwingUtil.createVCIJButton("","剪切" ,"剪切", "cut.gif" ,null);//new VCIJButton("剪切");
    private VCIJButton btnpast = VCISwingUtil.createVCIJButton("","粘贴" ,"粘贴 ", "paste.gif" ,null);//new VCIJButton("粘贴");
    
    //private String userName = LogonApplication.getUserEntityObject().getUserName();
    private VCIJComboBox typeComb = new VCIJComboBox();
    private String processCategoryId = "";
    private String temname = "";
    private String status = "";
    
    private JTextField textField = null;
    private KJButton searchButton = new KJButton("查询","search.png");
    //FunctionObject funcObj = new FunctionObject();
    final JDialog dialog = new JDialog(LogonApplication.frame);
    
    
    public String getTextField() {
        return textField.getText().trim();
    }
    
    private LinkedList<VCIJButton> selfCustomButtons = new LinkedList<VCIJButton>();
    {
        selfCustomButtons.add(addButton);
        selfCustomButtons.add(editButton);
        selfCustomButtons.add(deleteButton);
        selfCustomButtons.add(btnStart);
        selfCustomButtons.add(btnStop);
        selfCustomButtons.add(btncute);
        selfCustomButtons.add(btnpast);
        selfCustomButtons.add(btnExp);
        selfCustomButtons.add(btnImport);
    }
    
    public ProcessCustomDataPanel(FunctionObject funcObj){
        super(funcObj);
        init();
        checkPermission();
    }
    private void init() {
        LogonApplication.getUserEntityObject().setModules(this.getClass().getName());
        initComponents();
        initAction();//初始化按钮点击事件
        if(tablePanel != null){
            if(tablePanel.getTableModel().getList().size() > 0){
                loadFlowImage(0);
            }
        }
    }
    private void initComponents() {
        setLayout(new BorderLayout());
        add(initTablePanel(), BorderLayout.CENTER);
        
        /**加载流程模板分类时,去除空选项**/
//        if(typeComb.getModel().getSize() > 0) {
//            typeComb.setSelectedIndex(0);
//            comboxActionPerformed();
//        }
    }
    /**
     * 加载流程分类
     * @return
     */
    private JComboBox getCombox() {
        ProcessCategoryObject[] processCategories = null;
        ProcessCustomClientDelegate delSrv = new ProcessCustomClientDelegate(LogonApplication.getUserEntityObject());
        try {
            processCategories = delSrv.getProcessCategories("root");
        } catch (VCIException e) {
            e.printStackTrace();
        }
        if(processCategories!=null){
            typeComb.addItem(new ProcessCategoryObject());
            for(int i=0;i<processCategories.length;i++){
                typeComb.addItem(processCategories[i]);
            }
            
        }
        return typeComb;
    }
    private void checkPermission(){
        checkRight(RightControlUtil.CREATE, addButton);
        checkRight(RightControlUtil.UPDATE, editButton);
        checkRight(RightControlUtil.DELETE, deleteButton);
        checkRight(RightControlUtil.UNFREZE,btnStart);
        checkRight(RightControlUtil.FREEZE,btnStop);
        checkRight(RightControlUtil.CUT,btncute);
        checkRight(RightControlUtil.PASTE, this.btnpast);
        checkRight(RightControlUtil.IMPORT, this.btnImport);
        checkRight(RightControlUtil.EXPORT, this.btnExp);
    }
    
    class MyDataProvider extends AbstractVCIJTableDataProvider<ProcessDefinitionObject>{
 
        public ProcessDefinitionObject[] getDatas(int arg0, int arg1) {
            ProcessDefinitionObject[] processDefinitionsCount = null;
            ProcessDefinitionObject[] processDefinitions = null;
            try {
                if(processCategoryId!=null&&!"".equals(processCategoryId)){
                    
                    processDefinitions = new ProcessCustomClientDelegate(LogonApplication.getUserEntityObject()).getProcessDefinitions(processCategoryId);
                    //processDefinitions = new ProcessCustomClientDelegate(LogonApplication.getUserEntityObject()).getProcessDefinitionsByPage(processCategoryId,temname,arg1,arg0);
                    if(temname!=null&&!"".equals(temname)){
                        processDefinitionsCount = new ProcessCustomClientDelegate(LogonApplication.getUserEntityObject()).getProcessDefinitionByProcessDefinitionName(temname,processCategoryId);
                    }else{
                        processDefinitionsCount = new ProcessCustomClientDelegate(LogonApplication.getUserEntityObject()).getProcessDefinitions(processCategoryId);
                    }
                    this.total = processDefinitionsCount.length;
                }else{
                    processDefinitions = new ProcessDefinitionObject[0];
                    this.total = 0;
                }
            }  catch (VCIException e) {
                e.printStackTrace();
            } catch (Throwable e) {
                e.printStackTrace();
            }
            
            Arrays.sort(processDefinitions, new Comparator<ProcessDefinitionObject>(){
                public int compare(ProcessDefinitionObject o1,
                        ProcessDefinitionObject o2) {
                    String n1 = o1.getName();
                    Long v1 = o1.getVersion();
                    
                    String n2 = o2.getName();
                    Long v2 = o2.getVersion();
                    
                    if(n1.equals(n2)){
                        return v1.compareTo(v2);
                    } else {
                        return n1.compareTo(n2);
                    }
                }});
            return processDefinitions;
        }
 
        public VCIJTableNode<ProcessDefinitionObject> getNewRowNode(ProcessDefinitionObject dataObj) {
            VCIJTableNode<ProcessDefinitionObject> node = new VCIJTableNode<ProcessDefinitionObject>(dataObj);
            node.setPropertyValue(getSpecialColumns()[0], dataObj.getName());
            node.setPropertyValue(getSpecialColumns()[1], dataObj.getVersion());
            if("1".equals(dataObj.getStatus())) {
                status = "启用";
            }else{
                status = "停用";
            }
            node.setPropertyValue(getSpecialColumns()[2], status);
            return node;
        }
 
        public String[] getSpecialColumns() {
            return "流程模板名称, 版本,状态".split(",");
        }
 
        public int getTotal() {
            return this.total;
        }
        
    }
    
    MyDataProvider dataProvider = new MyDataProvider();
    VCIJTablePanel<ProcessDefinitionObject> tablePanel = new VCIJTablePanel<ProcessDefinitionObject>(dataProvider);
    private VCIJPanel tablePanel(){
        int startIndex = dataProvider.getDataColumnStartIndex();
        LinkedHashMap<Integer, Integer> widthMaps = new LinkedHashMap<Integer, Integer>();
        widthMaps.put(startIndex++, 250);
        widthMaps.put(startIndex++, 50);
        widthMaps.put(startIndex++, 50);
        tablePanel.setColumnWidthMaps(widthMaps);
        //tablePanel.setCustomButtonFlowAlign(FlowLayout.CENTER);
        //tablePanel.setPageButtonFlowAlign(FlowLayout.CENTER);
        //tablePanel.setCustomButtonAutoScroll(false);
        tablePanel.setCustomButtons(selfCustomButtons);
        tablePanel.setShowPaging(false);
        tablePanel.setShowExport(false);
        tablePanel.buildTablePanel();
        tablePanel.refreshTableData();
        tablePanel.getTable().addMouseListener(new MouseAdapter() {
            @Override
            public void mouseClicked(MouseEvent e) {
                int index = tablePanel.getTable().getSelectedRow();
                loadFlowImage(index);
            }
        });
        return tablePanel;
    }
 
    private void loadFlowImage(int index){
        loadFlowCharPanel(tablePanel.getTableModel().getList().get(index).getObject());
    }
    
    private JPanel initTablePanel(){
        
        JPanel pal = new JPanel();
        pal.setLayout(new BorderLayout());
        pal.setBorder(new TitledBorder("流程模板管理"));
        JLabel labelName = new JLabel("流程分类");
        JLabel queryName = new JLabel("流程模板名称");
        textField = new JTextField();
        labelName.setBounds(30, 5, 80, 25);
        typeComb.setBounds(120, 5, 180, 25);
        queryName.setBounds(310, 5, 80, 25);
        textField.setBounds(400, 5, 180, 25);
        searchButton.setBounds(590, 5, 80, 25);
        
        JPanel searchPal = new JPanel();
        searchPal.setLayout(null);
        searchPal.setPreferredSize(new Dimension(900,35));
        
        searchPal.add(labelName);
        searchPal.add(getCombox());
        searchPal.add(queryName);
        searchPal.add(textField);
        searchPal.add(searchButton);
 
        pal.add(searchPal, BorderLayout.NORTH);
 
        splitPane.setDividerSize(7);
        splitPane.setContinuousLayout(true);
        splitPane.setOneTouchExpandable(true);
        splitPane.setDividerLocation(580);
        splitPane.setLeftComponent(tablePanel());
        splitPane.setRightComponent(jspFlowImage);
        
        pal.add(splitPane, BorderLayout.CENTER);
        pal.setVisible(true);
        return pal;
    }
    private JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, new VCIJPanel(), new VCIJPanel());
    private VCIJLabel lblFlowImage = new VCIJLabel();
    private VCIJScrollPane jspFlowImage  = new VCIJScrollPane(lblFlowImage);
    
    private void loadFlowCharPanel(ProcessDefinitionObject procDecObj){
        ProcessCustomClientDelegate del = new ProcessCustomClientDelegate(LogonApplication.getUserEntityObject());
        String deploymentId  = procDecObj.getJbpmDeploymentId();
        try {
            byte[] chartData = del.getProcessChart(deploymentId);
            InputStream is = new ByteArrayInputStream(chartData, 0, chartData.length);
            BufferedImage bu = ImageIO.read(is);
            ImageIcon icon = new ImageIcon(bu);
            lblFlowImage.setIcon(icon);
            Color color = new Color(255, 251, 255);
            jspFlowImage.getViewport().setBackground(color);
        } catch (VCIException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
    /**
     * 保存剪切的模板 
     */
    private List<String> pastList =new ArrayList<String>();
    /**
     * 事件
     */
    private void initAction(){
        addButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(ActionEvent e) {
//                VCISwingUtil.setLookAndFeel(VCISwingUtil.LOOK_AND_FEEL_AlloyLookAndFeel);
                try {
                    addButton_conform();
                } catch (VCIError e1) {
                    // TODO Auto-generated catch block
                    e1.printStackTrace();
                    JOptionPane.showMessageDialog(null, e1.getMessage(), "addButton_conform", JOptionPane.ERROR_MESSAGE);
 
                }
//                VCISwingUtil.setLookAndFeel(VCISwingUtil.LOOK_AND_FEEL_PlasticLookAndFeel);
            }
        });
        
         editButton.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(ActionEvent e) {
//                    VCISwingUtil.setLookAndFeel(VCISwingUtil.LOOK_AND_FEEL_AlloyLookAndFeel);
                    try {
                        editButton_conform();
                    } catch (Exception e1) {
                        // TODO Auto-generated catch block
                        e1.printStackTrace();
                        JOptionPane.showMessageDialog(null, e1.getMessage(), "editButton_conform", JOptionPane.ERROR_MESSAGE);
 
                    }
//                    VCISwingUtil.setLookAndFeel(VCISwingUtil.LOOK_AND_FEEL_PlasticLookAndFeel);
                }
         });
         
         deleteButton.addActionListener(new java.awt.event.ActionListener() {
             public void actionPerformed(ActionEvent e) {
                 deleteButton_conform();
             }
         });
         typeComb.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent arg0) {
                comboxActionPerformed();
            }
        });
        searchButton.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                searchButton_actionPerformed();
            }
        });
        btncute.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                cuteTem();
            }
 
        });
        btnpast.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                pastTemp();
            }
        });
        btnStart.addActionListener(new java.awt.event.ActionListener() {
             public void actionPerformed(ActionEvent e) {
                 btnStart_conform();
             }
         });
        btnStop.addActionListener(new java.awt.event.ActionListener() {
             public void actionPerformed(ActionEvent e) {
                 btnStop_conform();
             }
         });
        btnExp.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(ActionEvent e) {
                try {
                    exportTemplate();
                } catch (Exception e1) {
                    // TODO Auto-generated catch block
                    e1.printStackTrace();
                    JOptionPane.showMessageDialog(null, e1.getMessage(), "exportTemplate", JOptionPane.ERROR_MESSAGE);
                }
            }
        });
        btnImport.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(ActionEvent e) {
                try {
                    importTemplate();
                } catch (Exception e1) {
                    // TODO Auto-generated catch block
                    e1.printStackTrace();
                    JOptionPane.showMessageDialog(null, e1.getMessage(), "importTemplate", JOptionPane.ERROR_MESSAGE);
 
                }
            }
        });
//        tablePanel.getTable().addMouseListener(new MouseListener() {
//            
//            @Override
//            public void mouseReleased(MouseEvent arg0) {
//                // TODO Auto-generated method stub
//                
//            }
//            
//            @Override
//            public void mousePressed(MouseEvent arg0) {
//                // TODO Auto-generated method stub
//                
//            }
//            
//            @Override
//            public void mouseExited(MouseEvent arg0) {
//                // TODO Auto-generated method stub
//                
//            }
//            
//            @Override
//            public void mouseEntered(MouseEvent arg0) {
//                // TODO Auto-generated method stub
//                
//            }
//            
//            @Override
//            public void mouseClicked(MouseEvent arg0) {
//                int rowIndex = tablePanel.getTable().getSelectedRow();
//                tablePanel.getTableModel().get
//                ProcessDefinitionObject processDefinitionObject = (ProcessDefinitionObject)tablePanel.getTable()getValueAt(rowIndex, 2);
//                textField.setText(processDefinitionObject.getCategroyId());
//                typeComb.setSelectedItem(processDefinitionObject);
//            }
//        });
//        .addTableModelListener(new TableModelListener() {
//            
//            @Override
//            public void tableChanged(TableModelEvent arg0) {
//                int len = tablePanel.getSelectedRowIndexs().length;
//                textField.setText(String.valueOf(len));
//            }
//        });
//        getaddListSelectionListener(new ListSelectionListener(){
//
//              public void valueChanged(ListSelectionEvent e)
//              {
//               int rows=table.getSelectedRow();
//               jid.setText(table.getValueAt(rows, 0).toString());
//               jname.setText(table.getValueAt(rows, 1).toString());
//               jsex.setText(table.getValueAt(rows, 2).toString());
//               jdate.setText(table.getValueAt(rows, 3).toString());
//               jam.setText(table.getValueAt(rows, 4).toString());
//               jbj.setText(table.getValueAt(rows, 5).toString());
//              }
//             });
    }
    /**
     * 模板剪切
     */
    private void cuteTem() {
        ProcessCategoryObject cateObj = (ProcessCategoryObject)typeComb.getSelectedItem();
        pastList =new ArrayList<String>();
        if(cateObj==null||"".equals(cateObj.getId())){
            VCIOptionPane.showMessage(this, "请先选择流程分类!");
            return;
        }
        
        int len = tablePanel.getSelectedRowIndexs().length;
        if(len == 0){
            VCIOptionPane.showMessage(this, 
                    "请选择数据再进行修改操作!");
            return;
        }
        List<ProcessDefinitionObject> selectedObjs = tablePanel.getSelectedRowObjects();
        for(ProcessDefinitionObject o : selectedObjs){
            pastList.add(o.getJbpmDeploymentId());
        }
        VCIOptionPane.showMessage(this, "保存数据到剪切板中!");
    }
    /**
     * 模板粘贴 
     */
    private void pastTemp() {
        ProcessCategoryObject cateObj = (ProcessCategoryObject)typeComb.getSelectedItem();
        String categoryId = cateObj.getId();
        ProcessCustomClientDelegate delegate = new ProcessCustomClientDelegate(LogonApplication.getUserEntityObject());
        try {
            for(int i=0;i<pastList.size();i++){
                delegate.moveDefinition(pastList.get(i), categoryId);
            }
        } catch (VCIException e1) {
            e1.printStackTrace();
        }
        tablePanel.refreshTableData();
    }
    /**
     * 流程模板导入 
     * @throws Exception 
     */
    public void importTemplate() throws Exception{
        ProcessCategoryObject selectedObj = (ProcessCategoryObject)typeComb.getSelectedItem();
        if(selectedObj==null||"".equals(selectedObj.getId())){
            VCIOptionPane.showMessage(this, "请先选择流程分类!");
            return;
        }
        
        if (selectedObj instanceof ProcessCategoryObject) {
            try {
                FileChooseDiaog fileChooserdialog = new FileChooseDiaog(
                        "import");
                String fileName = fileChooserdialog.getFileName();
                String filePath = fileChooserdialog.getFilepath();
                if(filePath==null||"".equals(filePath)){
                    return;
                }
                //读取zip文件
                ZipFile zf = new ZipFile(filePath+"\\"+fileName);
                //zip中文件条数
                int filesize = zf.size();
                Enumeration<? extends ZipEntry> entries = zf.entries();
                //流程图graphXml
                byte[] graphXml = null;
                //流程模板xml
                byte[] processXml = null;
                //objectXml
                byte[] objectXml = null;
                //遍历zip文件
                for (Enumeration e = entries ; e.hasMoreElements() ;) {
                     ZipEntry nextElement = (ZipEntry) e.nextElement();
                     String name = nextElement.getName();
                     System.out.println(name);
                     ZipEntry entry = zf.getEntry(name);
                     InputStream inputStream = zf.getInputStream(entry);
                     if(name.contains(".graph")){
                         graphXml = InputStreamToByte(inputStream);
                     }
                     else if(name.contains(".jpdl.xml")){
                         processXml = InputStreamToByte(inputStream);
                     }
                     else if(name.contains(".xml")){
                         objectXml = InputStreamToByte(inputStream);
                     }
                 }
 
                
//                JDialog dialog = new JDialog(LogonApplication.frame);
                dialog.setTitle("流程自定义");
                dialog.setModal(true);
                FlowDesigner designer = new FlowDesigner();
                designer.setFlowCategory((ProcessCategoryObject) selectedObj);
                ProcessDefinitionObject pd = new ProcessDefinitionObject();
                String substring = fileName.substring(0,fileName.lastIndexOf("."));
                pd.setName(substring);
                pd.setKey(substring);
                pd.setVersion(1);
                designer.setProcessDefinition(graphXml, processXml,pd,objectXml);
                designer.updatePanel(null);
                designer.isEdit(false);
 
                dialog.setContentPane(designer);
                Insets screenInsets = Toolkit.getDefaultToolkit()
                        .getScreenInsets(
                                LogonApplication.frame
                                        .getGraphicsConfiguration());
                Dimension screenSize = Toolkit.getDefaultToolkit()
                        .getScreenSize();
                dialog.setLocation(0, 0);
                // dialog.setResizable(false);
                dialog.setSize((int) screenSize.getWidth(),
                        (int) (screenSize.getHeight() - screenInsets.bottom));
                dialog.setVisible(true);
            } catch (Exception e) {
                e.printStackTrace();
                throw e;
            }
        } else {
            VCIOptionPane.showMessage(LogonApplication.frame,
                    ClientHelper.getI18nStringForWorkflow(this.getClass().getName() + "." + "pleaseChooseProcessCategoryNode", getLocale()));
        }
    }
    /**
     * 将输入流转换为字节数组
     * @param is
     * @return
     * @throws IOException
     */
    private static byte[] InputStreamToByte(InputStream is) throws IOException {
        ByteArrayOutputStream bytestream = new ByteArrayOutputStream();
        int ch;
        while ((ch = is.read()) != -1) {
            bytestream.write(ch);
        }
        byte imgdata[] = bytestream.toByteArray();
        bytestream.close();
        return imgdata;
    }
    /**
     * 模板导出
     * @throws Exception 
     */
    public void exportTemplate() throws Exception{
        ProcessCategoryObject cateObj = (ProcessCategoryObject)typeComb.getSelectedItem();
        if(cateObj==null||"".equals(cateObj.getId())){
            VCIOptionPane.showMessage(this, "请先选择流程分类!");
            return;
        }
        
        int len = tablePanel.getSelectedRowIndexs().length;
        if(len == 0){
            VCIOptionPane.showMessage(this, 
                    "请选择数据再进行操作!");
            return;
        }
        if (len > 1){
            VCIOptionPane.showMessage(this,"一次只能对一个对象进行修改,请重新选择!");
            return;
        }
        ProcessDefinitionObject selectedObj = tablePanel.getSelectedRowObjects().get(0);
        boolean flag = false;
        if (selectedObj instanceof  ProcessDefinitionObject) {
            FileChooseDiaog dialog = new FileChooseDiaog("export");
            String filepath = dialog.getFilepath();
            String zipName = dialog.getFileName();
            if(filepath==null||"".equals(filepath)){
                return;
            }
            ProcessDefinitionObject flowCategory = ( ProcessDefinitionObject) selectedObj;
            String templateName = flowCategory.getName();
            //设置Designer对象
            FlowDesigner designer = new FlowDesigner();
//            VCIBaseTreeNode selectedTreeNode = toolBar.getMainPanel().getCurrentSelectedTreeNode();
//            Object parentObj = ((VCIBaseTreeNode)selectedTreeNode.getParent()).getObj();
            designer.setFlowCategory(cateObj);
            designer.setProcessDefinition((ProcessDefinitionObject) selectedObj);
            //获取graph对象
            mxGraphComponent graphComponent = designer.getGraphComponent();
            mxGraph graph = designer.getGraphComponent().getGraph();
            BufferedImage image = FlowCellRenderer.createBufferedImage(graph, null, 1, Color.decode("#FFFBFF"), graphComponent.isAntiAlias(), graphComponent.getCanvas());
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            try {
                //获取流程图片
                ImageIO.write(image, "png", baos);
                byte[] jbpmImage = baos.toByteArray();
                
                //获取流程模板xml文件
                EditorCreateXmlToJbpm getXml = new EditorCreateXmlToJbpm(designer);
                String jbpmXml = getXml.getsXml();
                
                //获取流程图xml文件
                mxCodec codec = new mxCodec();
                mxIGraphModel model = designer.getGraphComponent().getGraph().getModel();
                Node encode = codec.encode(model);
                String graphXml = mxUtils.getXml(encode);
                
                //创建对象xml
                Document document = DocumentHelper.createDocument();
                Element rootElement = document.addElement("root");
                //流程部署ID
                String jbpmDeploymentId = ((ProcessDefinitionObject) selectedObj).getJbpmDeploymentId();
                
                //获取所有任务名称
                String[] allTaskNames = new ProcessCustomClientDelegate().getAllTaskNames(jbpmDeploymentId);
                for(String taskName :allTaskNames){
                    //流程任务信息
                    ProcessTaskInfo processTaskInfo = new ProcessCustomClientDelegate().findById(jbpmDeploymentId, taskName);
                    CustomInfo[] customUserInfos = processTaskInfo.customUserInfos;
                    PropertyInfo[] taskTypeProperties = processTaskInfo.taskTypeProperties;
                    //任务描述策略信息
                    TaskDescCObject[] taskDescCObject = new ProcessCustomClientDelegate(LogonApplication.getUserEntityObject()).getTaskDescList(jbpmDeploymentId, taskName);                
                    
                    //任务节点
//                    taskName = taskName.replaceAll(" ", "");
//                    Element taskNameElement = rootElement.addElement(taskName);
                    //ProcessTaskInfo节点
                    Element processTaskInfoEle = rootElement.addElement("ProcessTaskInfo");
                    processTaskInfoEle.addAttribute("id", processTaskInfo.id);
                    processTaskInfoEle.addAttribute("deploymentId", processTaskInfo.deploymentId);
                    processTaskInfoEle.addAttribute("taskName", processTaskInfo.taskName);
                    processTaskInfoEle.addAttribute("taskType", processTaskInfo.taskType);
                    processTaskInfoEle.addAttribute("taskDesc", processTaskInfo.taskDesc);
                    processTaskInfoEle.addAttribute("pltreatment", String.valueOf(processTaskInfo.pltreatment));
                    processTaskInfoEle.addAttribute("popUserDialog", processTaskInfo.popUserDialog);
                    
                    //CustomInfo节点
//                    if(customUserInfos.length==0){
//                        Element customInfoEle = processTaskInfoEle.addElement("CustomInfo");
//                        customInfoEle.addAttribute("className", "");
//                        customInfoEle.addAttribute("value", "");
//                    }
                    for(int i =0;i<customUserInfos.length;i++){
                        Element customInfoEle = processTaskInfoEle.addElement("CustomInfo");
                        customInfoEle.addAttribute("className", String.valueOf(customUserInfos[i].className));
                        customInfoEle.addAttribute("value", customUserInfos[i].value);
                    }
                    
                    //PropertyInfo节点
//                    if(taskTypeProperties.length==0){
//                        Element taskpropertyEle = processTaskInfoEle.addElement("PropertyInfo");
//                        taskpropertyEle.addAttribute("property", "");
//                        taskpropertyEle.addAttribute("value", "");
//                    }
                    for(int i =0;i<taskTypeProperties.length;i++){
                        Element taskpropertyEle = processTaskInfoEle.addElement("PropertyInfo");
                        taskpropertyEle.addAttribute("property", String.valueOf(taskTypeProperties[i].property));
                        taskpropertyEle.addAttribute("value", taskTypeProperties[i].value);
                    }
                    
                    //TaskDescCObject节点
//                    if(taskDescCObject.length==0){
//                        Element taskDescEle = processTaskInfoEle.addElement("TaskDescCObject");
//                        taskDescEle.addAttribute("id", "");
//                        taskDescEle.addAttribute("pltaskdesc", "");
//                        taskDescEle.addAttribute("pljbpmdeploymentid", "");
//                        taskDescEle.addAttribute("pltask", "");
//                        taskDescEle.addAttribute("pltreatment", "");
//                        taskDescEle.addAttribute("popUserDialog", "");
//                        taskDescEle.addAttribute("plcustomclassname", "");
//                        taskDescEle.addAttribute("plcustomparam", "");
//                    }
                    for(int i =0;i<taskDescCObject.length;i++){
                        Element taskDescEle = processTaskInfoEle.addElement("TaskDescCObject");
                        taskDescEle.addAttribute("id", String.valueOf(taskDescCObject[i].getId()));
                        taskDescEle.addAttribute("pltaskdesc", taskDescCObject[i].getPltaskdesc());
                        taskDescEle.addAttribute("pljbpmdeploymentid", String.valueOf(taskDescCObject[i].getPljbpmdeploymentid()));
                        taskDescEle.addAttribute("pltask", taskDescCObject[i].getPltask());
                        taskDescEle.addAttribute("pltreatment", String.valueOf(taskDescCObject[i].getPltreatment()));
                        taskDescEle.addAttribute("popUserDialog", taskDescCObject[i].getPopUserDialog());
                        taskDescEle.addAttribute("plcustomclassname", taskDescCObject[i].getPlcustomclassname());
                        taskDescEle.addAttribute("plcustomparam", taskDescCObject[i].getPlcustomparam());
                    }
                    
                }
                
                String taskObjectXML = document.asXML();
                flag = exportWorkFlowTemplate(filepath, zipName, templateName, jbpmImage, jbpmXml, graphXml, taskObjectXML);
            } catch (IOException e) {
                e.printStackTrace();
                flag = false;
            } catch (VCIException e) {
                e.printStackTrace();
                flag = false;
            } catch (VCIError e) {
                e.printStackTrace();
                flag = false;
            }
            if(flag){
                VCIOptionPane.showMessage(LogonApplication.frame, "导出成功");
            }else{
                VCIOptionPane.showMessage(LogonApplication.frame, "导出失败");
            }
        } else {
            VCIOptionPane.showMessage(LogonApplication.frame,
                    "请选择模板进行导出");
        }
    }
    
    /**
     * 工作流模板导出
     * @param name TODO
     * @param taskObjectXML TODO
     * @return
     */
    public boolean exportWorkFlowTemplate(String path,String name, String templateName, final byte[] jbpmImage, String jbpmXml, String graphXml, String taskObjectXML){
        try {
            templateName = "flow" + System.currentTimeMillis();
//            String path = CommonProperties.getStringProperty("workflow.UserDialog") + name;
            // 如果目录不存在,创建目录
//            if (!new File(path).getParentFile().exists()) {
//                new File(path).mkdirs();
//            }
            if(name.contains(".zip")){
               name = name.substring(0,name.lastIndexOf("."));
            }
            Map<String, InputStream> map = new Hashtable<String, InputStream>();
            InputStream is = new ByteArrayInputStream(jbpmImage);
            map.put(templateName + ".png", is);
            InputStream jpdlIs = new ByteArrayInputStream(
                    jbpmXml.getBytes("utf-8"));
            map.put(templateName + ".jpdl.xml", jpdlIs);
            InputStream graphIs = new ByteArrayInputStream(
                    graphXml.getBytes("utf-8"));
            map.put(templateName + ".graph", graphIs);
            InputStream taskObjectIs = new ByteArrayInputStream(
                    taskObjectXML.getBytes("utf-8"));
            map.put(templateName + ".xml", taskObjectIs);
            ZipUtil.saveZip(path+"\\"+name + ".zip", map);
            File file = new File(path+"\\"+name + ".zip");
            FileInputStream fis = new FileInputStream(file);
            ZipInputStream zin = new ZipInputStream(fis);
        } catch (Throwable e) {
            e.printStackTrace();
        }
        return true;
    }
    
    /**
     * 搜索事件
     */
    private void searchButton_actionPerformed(){
        processCategoryId = ((ProcessCategoryObject)typeComb.getSelectedItem()).getId();//获取流程分类  add by liujw
        temname = this.getTextField();
        tablePanel.refreshTableData();
    }
    
    private void comboxActionPerformed() {
        processCategoryId = ((ProcessCategoryObject)typeComb.getSelectedItem()).getId();
        if(processCategoryId!=null&&!"".equals(processCategoryId)){
            this.setProcessCategoryId(processCategoryId);
            this.tablePanel.setPageIndex(1);
            tablePanel.refreshTableData();
            if(tablePanel != null){
                if(tablePanel.getTableModel().getList().size() > 0){
                    loadFlowImage(0);
                }
            }
        }else{
            tablePanel.refreshTableData();
        }
    }
    /**
     * 添加事件
     * @throws VCIError 
     */
    private void addButton_conform() throws VCIError{
        ProcessCategoryObject obj = (ProcessCategoryObject)typeComb.getSelectedItem();
        if(obj==null||"".equals(obj.getId())){
            VCIOptionPane.showMessage(this, "请先选择流程分类!");
            return;
        }
        dialog.setTitle(getI18nString("processCustom"));
        dialog.setModal(true);
        FlowDesigner designer = new FlowDesigner();
        designer.setFlowCategory(obj);
        designer.isEdit(false);
        
        dialog.setContentPane(designer);
        Insets screenInsets  = Toolkit.getDefaultToolkit().getScreenInsets(LogonApplication.frame.getGraphicsConfiguration());
        Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
        dialog.setLocation(0, 0);
        dialog.setResizable(false);
        dialog.setSize((int)screenSize.getWidth(), (int)(screenSize.getHeight() - screenInsets.bottom));
        SwingUtilities.invokeLater(new Runnable() {
            
            public void run() {
                dialog.setVisible(true);
            }
        });
        tablePanel.refreshTableData();
    }
    
    /**
     * 修改事件
     * @throws Exception 
     */
    private void editButton_conform() throws Exception{
        ProcessCategoryObject cateObj = (ProcessCategoryObject)typeComb.getSelectedItem();
        if(cateObj==null||"".equals(cateObj.getId())){
            VCIOptionPane.showMessage(this, "请先选择流程分类!");
            return;
        }
        
        int len = tablePanel.getSelectedRowIndexs().length;
        if(len == 0){
            VCIOptionPane.showMessage(this,  "请选择数据再进行修改操作!");
            return;
        }
        if (len > 1){
            VCIOptionPane.showMessage(this, "一次只能对一个对象进行修改,请重新选择!");
            return;
        }
        ProcessDefinitionObject obj = tablePanel.getSelectedRowObjects().get(0);
        dialog.setTitle(getI18nString("processCustom"));
        dialog.setModal(true);
        FlowDesigner designer = new FlowDesigner();
        ProcessCategoryObject parentObj = (ProcessCategoryObject)typeComb.getSelectedItem();
        designer.setFlowCategory(parentObj);
        designer.setProcessDefinition(obj);
        designer.updatePanel(null);
        designer.isEdit(true);//编辑状态
        
        dialog.setContentPane(designer);
        Insets screenInsets  = Toolkit.getDefaultToolkit().getScreenInsets(LogonApplication.frame.getGraphicsConfiguration());
        Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
        dialog.setLocation(0, 0);
        dialog.setResizable(false);
        dialog.setSize((int)screenSize.getWidth(), (int)(screenSize.getHeight() - screenInsets.bottom));
        SwingUtilities.invokeLater(new Runnable() {
            
            public void run() {
                dialog.setVisible(true);
            }
        });
        tablePanel.refreshTableData();
    }
    /**
     * 删除事件
     */
    private void deleteButton_conform(){
        int len = tablePanel.getSelectedRowIndexs().length;
        if(len == 0){
            VCIOptionPane.showMessage(this, 
                    "请选择要删除的对象!");
            return;
        }
        if (VCIOptionPane.showQuestion(LogonApplication.frame,
                "确定要删除模板吗?") != 0) {
            return;
        }
        
        String[] puids = new String[len];
        Map<String, String> map = new HashMap<String, String>();
        for (int i = 0; i < len; i++) {
            ProcessDefinitionObject processDefinitionObject = tablePanel.getSelectedRowObjects().get(i);
            puids[i] = processDefinitionObject.getId();
            map.put(processDefinitionObject.getId(), processDefinitionObject.getName());
            
            try {
                deleteProcessDefinition(processDefinitionObject.getJbpmDeploymentId(), processDefinitionObject.getId());
            } catch (VCIException exp) {
                VCIOptionPane.showError(LogonApplication.frame, "RMIPWorkflow", exp);
                return;
            } catch (Exception ex) {
                ex.printStackTrace();
            }
        }
        tablePanel.refreshTableData();
    }
    private void deleteProcessDefinition(String deployId, String pdId) throws VCIException {
        ProcessCustomClientDelegate delegate = new ProcessCustomClientDelegate(LogonApplication.getUserEntityObject());
        delegate.deleteProcessDefinition(deployId, pdId);
    }
    //启用流程
    private void btnStart_conform(){
        ProcessCategoryObject cateObj = (ProcessCategoryObject)typeComb.getSelectedItem();
        if(cateObj==null||"".equals(cateObj.getId())){
            VCIOptionPane.showMessage(this, "请先选择流程分类!");
            return;
        }
        
        int len = tablePanel.getSelectedRowIndexs().length;
        if(len == 0){
            VCIOptionPane.showMessage(this, 
                    "请选择数据再进行修改操作!");
            return;
        }
        if (len > 1){
            VCIOptionPane.showMessage(this,"一次只能对一个对象进行修改,请重新选择!");
            return;
        }
        ProcessCustomClientDelegate  processCusDel = new ProcessCustomClientDelegate(LogonApplication.userEntityObject);
        ProcessDefinitionObject obj = tablePanel.getSelectedRowObjects().get(0);
        try {
            boolean res = processCusDel.setProcessHide(obj.getJbpmDeploymentId(), (short)1);
            if(res){
                JOptionPane.showMessageDialog(LogonApplication.frame, "启用成功!");
                tablePanel.refreshTableData();
            }
        } catch (VCIError e) {
            e.printStackTrace();
        }
    }
    //停用流程
    private void btnStop_conform() {
        ProcessCategoryObject cateObj = (ProcessCategoryObject)typeComb.getSelectedItem();
        if(cateObj==null||"".equals(cateObj.getId())){
            VCIOptionPane.showMessage(this, "请先选择流程分类!");
            return;
        }
        int len = tablePanel.getSelectedRowIndexs().length;
        if(len == 0){
            VCIOptionPane.showMessage(this, 
                    "请选择数据再进行修改操作!");
            return;
        }
        if (len > 1){
            VCIOptionPane.showMessage(this,"一次只能对一个对象进行修改,请重新选择!");
            return;
        }
        ProcessCustomClientDelegate  processCusDel = new ProcessCustomClientDelegate(LogonApplication.userEntityObject);
        ProcessDefinitionObject obj = tablePanel.getSelectedRowObjects().get(0);
        try {
            //status为0标识停用流程
            boolean res = processCusDel.setProcessHide(obj.getJbpmDeploymentId(), (short)0);
            if(res) {
                JOptionPane.showMessageDialog(LogonApplication.frame, "停用成功!");
                tablePanel.refreshTableData();
            }
        } catch (VCIError e) {
            e.printStackTrace();
        }
    }
    
    public String getProcessCategoryId() {
        return processCategoryId;
    }
    public void setProcessCategoryId(String processCategoryId) {
        this.processCategoryId = processCategoryId;
    }
    private String getI18nString(String spCode){
        return ClientHelper.getI18nStringForWorkflow(this.getClass().getName() + "." + spCode, Locale.getDefault());
    }
}