yuxc
2025-01-15 c09f81131e8b7c83937206d7cf76f34d2020be75
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
package com.vci.client.workflow.editor.ui;
 
import java.awt.BorderLayout;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.util.ArrayList;
import java.util.List;
 
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
 
import com.vci.corba.workflow.data.ProcessTaskInfo;
import com.vci.corba.workflow.data.PropertyInfo;
 
public class EventPanel extends JPanel {
    private static final long serialVersionUID = 6236313628549447664L;
    
    private PropertyObject[] events;
    private String label;
 
    private ProcessPropertyEditPanel propertyPanel;
 
    private JComboBox eventComboBox;
    private CustomClassEditPanel customClassEditpanel;
    private String eventType = ""; 
    
    private PropertyInfo[] customInfos;
    public EventPanel() {
    }
    
    public EventPanel(String label, PropertyObject[] events,String eventType) {
        this.label = label;
        this.events = events;
        this.eventType = eventType;
        initUI();
    }
 
    private void initUI() {
        setLayout(new BorderLayout());
 
//        JPanel eventPanel = new JPanel(new GridBagLayout());
//        GridBagConstraints g = new GridBagConstraints();
//        g.insets = new Insets(2, 2, 2, 2);
//        g.anchor = GridBagConstraints.EAST;
//        g.gridx = 0;
//        g.gridy = 0;
//        eventPanel.add(new JLabel(label), g);
//        g.fill = GridBagConstraints.HORIZONTAL;
//        g.weightx = 1;
//        g.gridx = 1;
//        eventComboBox = new JComboBox(events);
//        eventPanel.add(eventComboBox, g);
//        add(eventPanel, BorderLayout.NORTH);
//        propertyPanel = new PropertyEditPanel();
//        add(propertyPanel, BorderLayout.CENTER);
        
//        this.setPreferredSize(new java.awt.Dimension(414, 100));
 
        if("类型".equals(label.toString())){
            JPanel eventPanel = new JPanel(new GridBagLayout());
            GridBagConstraints g = new GridBagConstraints();
            g.insets = new Insets(2, 2, 2, 2);
            g.anchor = GridBagConstraints.EAST;
            g.gridx = 0;
            g.gridy = 0;
            eventPanel.add(new JLabel(label), g);
            
            g.fill = GridBagConstraints.HORIZONTAL;
            g.weightx = 1;
            g.gridx = 1;
        
            eventComboBox = new JComboBox(events);
            eventPanel.add(eventComboBox, g);
            add(eventPanel, BorderLayout.NORTH);
            
            propertyPanel = new ProcessPropertyEditPanel();
            this.add(propertyPanel, BorderLayout.CENTER);
        }else{
            customClassEditpanel = new CustomClassEditPanel(this);
            this.add(customClassEditpanel, BorderLayout.NORTH);
        }
    }
    
    public String getEvent(){
        return ((PropertyObject)eventComboBox.getSelectedItem()).getProperty();
    }
    
    public PropertyInfo[] getPropertyInfos(){
        return propertyPanel.getPropertyInfos();
    }
 
    public void setProcessTaskInfo(ProcessTaskInfo processTaskInfo) {
        if(processTaskInfo != null) {
            int itemCount = eventComboBox.getItemCount();
            for (int i = 0; i < itemCount; i++) {
                PropertyObject obj = (PropertyObject)eventComboBox.getItemAt(i);
                if(obj.getProperty().equals(processTaskInfo.taskType)) {
                    eventComboBox.setSelectedIndex(i);
                    break;
                }
            }
            
            PropertyInfo[] taskTypeProperties = processTaskInfo.taskTypeProperties;
            List<PropertyInfo> result = new ArrayList<PropertyInfo>();
            //转换list
            for (PropertyInfo propertyInfo : taskTypeProperties) {
                result.add(propertyInfo);
            }
            propertyPanel.setData(result);
        }
    }
    public String getEventType() {
        return eventType;
    }
 
    public void setEventType(String eventType) {
        this.eventType = eventType;
    }
    public PropertyInfo[] getCustomInfos() {
        customInfos = customClassEditpanel.getCustomUserInfos();
        return customInfos;
    }
    
    public void setCustomInfos(PropertyInfo[] customInfos) {
        this.customInfos = customInfos;
        if(customInfos!=null){
            List<PropertyInfo> result = new ArrayList<PropertyInfo>();
            //转换list
            for (PropertyInfo customInfo : customInfos) {
                result.add(customInfo);
            }
            customClassEditpanel.setData(result);
        }
    }
}