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);
|
}
|
}
|
}
|