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 result = new ArrayList(); //转换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 result = new ArrayList(); //转换list for (PropertyInfo customInfo : customInfos) { result.add(customInfo); } customClassEditpanel.setData(result); } } }