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
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
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.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
 
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
 
import com.vci.client.LogonApplication;
import com.vci.client.ui.locale.LocaleDisplay;
import com.vci.client.ui.swing.VCIOptionPane;
import com.vci.client.workflow.delegate.EventConfClientDelegate;
import com.vci.corba.common.VCIError;
import com.vci.corba.workflow.data.ProcessTaskInfo;
import com.vci.corba.workflow.data.PropertyInfo;
 
public class TaskEventPanel extends JPanel {
    private static final long serialVersionUID = 6236313628549447664L;
    
    private PropertyObject[] events;
    private String label;
 
    private TypePropertyEditPanel typepropertyPanel;
    private PropertyEditPanel propertyPanel;
 
    private JComboBox eventComboBox;
    private TaskCustomClassEditPanel customClassEditpanel;
    private String eventType = ""; 
    
    private PropertyInfo[] customInfos;
    private JPanel panel;
    private JButton save ;
    
    private Map<String,ArrayList<PropertyInfo>> taskeventMap ;
//    private ArrayList<PropertyInfo> taskeventPropertylist ;
    private Map<String ,Map<String,ArrayList<PropertyInfo>>> resultMap ;
    public TaskEventPanel() {
    }
    
    public TaskEventPanel(String label, PropertyObject[] events,String eventType) {
        this.label = label;
        this.events = events;
        this.eventType = eventType;
        initUI();
    }
 
    private void initUI() {
        taskeventMap = new HashMap<String,ArrayList<PropertyInfo>>();
//        taskeventPropertylist = new ArrayList<PropertyInfo>();
        resultMap = new HashMap<String, Map<String,ArrayList<PropertyInfo>>>();
        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);
            
            typepropertyPanel = new TypePropertyEditPanel();
            this.add(typepropertyPanel, BorderLayout.CENTER);
        }else{
            panel = new JPanel();
            propertyPanel = new PropertyEditPanel("",customClassEditpanel,this);
            panel.add(propertyPanel);
            this.add(panel, BorderLayout.EAST);
            
            customClassEditpanel = new TaskCustomClassEditPanel(this,propertyPanel,panel);
            this.add(customClassEditpanel, BorderLayout.CENTER);
            
            JPanel bot = new JPanel();
            save = new JButton("保存");
            bot.add(save);
            this.add(bot,BorderLayout.SOUTH);
            
            save.addActionListener(new ActionListener() {
                
                public void actionPerformed(ActionEvent e) {
                    int selectedRow = customClassEditpanel.getCustomTable().getSelectedRow();
                    int rowCount = customClassEditpanel.getCustomTable().getRowCount();
                    if(selectedRow == -1){
                        if (rowCount == 0) {
                            customClassEditpanel.setCustomTable(customClassEditpanel.getCustomTable());
                            taskeventMap = new HashMap<String, ArrayList<PropertyInfo>>();
                            resultMap = new HashMap<String, Map<String,ArrayList<PropertyInfo>>>();
                        } else {
                            VCIOptionPane.showMessage(LogonApplication.frame, "请选择要保存的数据!");
                        }
                        return;
                    }
//                    int rowCount = customClassEditpanel.getCustomTable().getRowCount();
                    String valueAt =  (String) customClassEditpanel.getCustomTable().getValueAt(selectedRow, 0);
                    String value = "";
                    for(int i=0;i<events.length;i++){
                        if(valueAt.equals(events[i].getValue())){
                            /*value = EventProperties.getStringProperty("workflow.event.type." + events[i].getProperty()+".class");*/
                            //add by caill start 2016.4.8 通过corba连接服务端
                            try {
                                value = new EventConfClientDelegate().getStringProperty("workflow.event.type." + events[i].getProperty()+".class");
                                break;
                            } catch (VCIError en) {
                                // TODO Auto-generated catch block
                                en.printStackTrace();
                            }
                            //add by caill end
                        }
                    }
                    PropertyInfo[] propertyInfos = customClassEditpanel.getPropertyEditPanel().getPropertyInfos();
                    ArrayList<PropertyInfo> arrayList = taskeventMap.get(value);
                    arrayList = new ArrayList<PropertyInfo>();
                    int length = propertyInfos.length;
//                        ArrayList<PropertyInfo> taskeventPropertylist = new ArrayList<PropertyInfo>();
                    if(length>0){
                        for(int i =0;i<length;i++){
                            arrayList.add(propertyInfos[i]);
                        }
                    }
                    taskeventMap.put(value,arrayList);
                    resultMap.put(eventType, taskeventMap);
//                    for(int k=0;k<rowCount;k++){
//                    }
                }
            });
        }
    }
    private String getI18nForEvent(String key) {
        return LocaleDisplay.getI18nString(key, "RMIPWorkflow", getLocale());
    }
    public Map<String, Map<String, ArrayList<PropertyInfo>>> getResultMap() {
        return resultMap;
    }
 
    public void setResultMap(
            Map<String, Map<String, ArrayList<PropertyInfo>>> resultMap) {
        this.resultMap = resultMap;
    }
 
    public Map<String, ArrayList<PropertyInfo>> getTaskeventMap() {
        return taskeventMap;
    }
 
    public void setTaskeventMap(Map<String, ArrayList<PropertyInfo>> taskeventMap) {
        this.taskeventMap = taskeventMap;
    }
 
//    public ArrayList<PropertyInfo> getTaskeventPropertylist() {
//        return taskeventPropertylist;
//    }
//
//    public void setTaskeventPropertylist(
//            ArrayList<PropertyInfo> taskeventPropertylist) {
//        this.taskeventPropertylist = taskeventPropertylist;
//    }
 
    public String getEvent(){
        return ((PropertyObject)eventComboBox.getSelectedItem()).getProperty();
    }
    
    public PropertyInfo[] getTypePropertyInfos(){
        return typepropertyPanel.getPropertyInfos();
    }
    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);
            }
            typepropertyPanel.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);
        }
    }
}