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.io.InputStream;
|
import java.io.Serializable;
|
import java.util.ArrayList;
|
import java.util.Arrays;
|
import java.util.List;
|
import java.util.Map;
|
import java.util.Properties;
|
|
import javax.swing.JComponent;
|
import javax.swing.JLabel;
|
import javax.swing.JPanel;
|
import javax.swing.JTabbedPane;
|
import javax.swing.JTextArea;
|
import javax.swing.JTextField;
|
import javax.swing.event.DocumentEvent;
|
import javax.swing.event.DocumentListener;
|
|
import org.apache.commons.lang3.StringUtils;
|
import org.dom4j.Attribute;
|
import org.dom4j.DocumentHelper;
|
import org.dom4j.Element;
|
|
import com.mxgraph.view.mxGraph;
|
import com.vci.client.ui.locale.LocaleDisplay;
|
import com.vci.client.uif.actions.client.UIFUtils;
|
import com.vci.client.workflow.delegate.EventConfClientDelegate;
|
import com.vci.client.workflow.editor.FlowConstants;
|
import com.vci.client.workflow.editor.FlowNode;
|
import com.vci.client.workflow.editor.user.CustomObject;
|
import com.vci.client.workflow.editor.user.CustomUserPanel;
|
import com.vci.client.workflow.editor.user.DefaultUserComponent;
|
import com.vci.client.workflow.editor.user.IUserComponent;
|
import com.vci.common.resource.CommonProperties;
|
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;
|
|
|
/**
|
* This code was edited or generated using CloudGarden's Jigloo
|
* SWT/Swing GUI Builder, which is free for non-commercial
|
* use. If Jigloo is being used commercially (ie, by a corporation,
|
* company or business for any purpose whatever) then you
|
* should purchase a license for each developer using Jigloo.
|
* Please visit www.cloudgarden.com for details.
|
* Use of Jigloo implies acceptance of these licensing terms.
|
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
|
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
|
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
|
*/
|
public class TaskPanel extends JTabbedPane implements IProcessProperty, Serializable {
|
|
private static final long serialVersionUID = 4691917636318432525L;
|
|
private IUserComponent userComponent;
|
//委托人
|
private IUserComponent constituentComponent;
|
private IUserComponent CCComponent;
|
|
private mxGraph graph;
|
private FlowNode node;
|
|
private JTextField nameField;
|
private JTextArea taskDesArea;
|
|
private TaskEventPanel taskTypePropertyPanel;
|
private TaskEventPanel taskInitEventPropertyPanel;
|
private TaskEventPanel taskEndEventPropertyPanel;
|
private EventPanel taskRevokeEventPropertyPanel;
|
|
private PropertyEditPanel propertyEditPanel;
|
|
private TaskDescPanel taskDescPanel;
|
private TaskTreatmentPanel taskTreatmentPanel;
|
private MailPanel mailPanel;
|
private JPanel propertypanel;
|
/**
|
* 自定义用户面板
|
*/
|
private CustomUserPanel customUserPanel;
|
private Map<String,ArrayList<PropertyInfo>> taskeventMap ;
|
private Map<String ,Map<String,ArrayList<PropertyInfo>>> resultMap ;
|
public void setTaskTreatmentPanel(long flag) {
|
taskTreatmentPanel.setFlag(flag);
|
if(flag==1){
|
taskTreatmentPanel.getRadio2().setSelected(true);
|
// taskTreatmentPanel.setAttribute("com.vci.rmip.workflow.server.event.AssignTask");
|
taskTreatmentPanel.setAttribute(taskTreatmentPanel.string);
|
taskTreatmentPanel.setFlag(1);
|
}else{
|
taskTreatmentPanel.getRadio1().setSelected(true);
|
taskTreatmentPanel.setAttribute("");
|
taskTreatmentPanel.setFlag(0);
|
}
|
}
|
/**
|
* 设置会签比例
|
* @param votePercent 会签比例
|
*/
|
public void setVotePercent(String votePercent){
|
taskTreatmentPanel.getRadio3().setSelected(true);
|
taskTreatmentPanel.getText().setText(votePercent);
|
}
|
/**
|
* @param taskDesc
|
*/
|
public void setTaskDescPanel(String taskDesc,String urlTextArea) {
|
taskDescPanel.setTaskDesArea(taskDesc);
|
taskDescPanel.setUrlTextArea(urlTextArea);
|
}
|
|
public TaskPanel(mxGraph graph, FlowNode node) throws VCIError {
|
super(JTabbedPane.LEFT);
|
this.graph = graph;
|
this.node = node;
|
initUI();
|
}
|
|
//初始化UI
|
private void initUI() throws VCIError {
|
addTab("基本属性", getGeneralPanel());
|
addTab("事件", getEventPanel());
|
addTab("责任人", getOwnerPanel());
|
addTab("委托人", getConstituentPanel());
|
addTab("业务功能", getTaskDesPanel());
|
addTab("控制策略", getTaskTreatmentPanel());
|
|
DocumentListener documentListener = new DocumentListener() {
|
public void removeUpdate(DocumentEvent e) {
|
updateFlow();
|
}
|
public void insertUpdate(DocumentEvent e) {
|
updateFlow();
|
}
|
public void changedUpdate(DocumentEvent e) {
|
updateFlow();
|
}
|
};
|
nameField.getDocument().addDocumentListener(documentListener);
|
}
|
|
private JComponent getGeneralPanel() {
|
JPanel generalPanel = 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;
|
generalPanel.add(new JLabel("名称:"), g);
|
g.fill = GridBagConstraints.HORIZONTAL;
|
g.weightx = 1;
|
g.gridx = 1;
|
nameField = new JTextField();
|
nameField.setText(node.getName());
|
generalPanel.add(nameField, g);
|
|
JPanel resultPanel = new JPanel(new BorderLayout());
|
resultPanel.add(generalPanel, BorderLayout.NORTH);
|
taskTypePropertyPanel = new TaskEventPanel("类型", getTaskTypes(),"");
|
// resultPanel.add(taskTypePropertyPanel, BorderLayout.CENTER);
|
return resultPanel;
|
}
|
|
private PropertyObject[] getTaskTypes() {
|
/*String[] types = EventProperties.getStringProperty("workflow.task.type").split(",");*/
|
//add by caill start 2016.4.8 通过corba连接服务端
|
String[] types = null;
|
try {
|
types = new EventConfClientDelegate().getStringProperty("workflow.task.type").split(",");
|
} catch (VCIError e) {
|
// TODO Auto-generated catch block
|
e.printStackTrace();
|
}
|
//add by caill end
|
List<PropertyObject> taskTypes = new ArrayList<PropertyObject>();
|
for (int i = 0; i < types.length; i++) {
|
/*taskTypes.add(new PropertyObject(types[i], EventProperties.getStringProperty("workflow.task.type." + types[i])));*/
|
//add by caill start 2016.4.8 通过corba连接服务端
|
try {
|
taskTypes.add(new PropertyObject(types[i], new EventConfClientDelegate().getStringProperty("workflow.task.type." + types[i])));
|
} catch (VCIError e) {
|
// TODO Auto-generated catch block
|
e.printStackTrace();
|
}
|
//add by caill end
|
}
|
return taskTypes.toArray(new PropertyObject[0]);
|
}
|
|
// private PropertyObject[] getEventTypes() {
|
// String[] types = getI18nForEvent("workflow.event.type").split(",");
|
// List<PropertyObject> taskTypes = new ArrayList<PropertyObject>();
|
// taskTypes.add(new PropertyObject("", ""));
|
// for (int i = 0; i < types.length; i++) {
|
// taskTypes.add(new PropertyObject(types[i], getI18nForEvent("workflow.event.type." + types[i])));
|
// }
|
// return taskTypes.toArray(new PropertyObject[0]);
|
// }
|
|
private JComponent getEventPanel() {
|
JTabbedPane eventPanel = new JTabbedPane();
|
taskInitEventPropertyPanel = new TaskEventPanel("事件", getEventTypes("start"),"start");
|
taskEndEventPropertyPanel = new TaskEventPanel("事件", getEventTypes("end"),"end");
|
taskRevokeEventPropertyPanel = new EventPanel("事件", getEventTypes("revoke"),"revoke");
|
eventPanel.add("初始事件", taskInitEventPropertyPanel);
|
eventPanel.add("完成事件", taskEndEventPropertyPanel);
|
|
eventPanel.add("收回事件", taskRevokeEventPropertyPanel);
|
|
return eventPanel;
|
}
|
|
//初始化用户
|
private JPanel getOwnerPanel() {
|
JPanel ownerPanel = new JPanel(new BorderLayout());
|
customUserPanel = new CustomUserPanel();
|
userComponent = new DefaultUserComponent(customUserPanel);
|
// CCComponent = new DefaultUserComponent(customUserPanel);
|
|
Properties properties = new Properties();
|
try {
|
ClassLoader cl = TaskPanel.class.getClassLoader();
|
InputStream in = cl.getResourceAsStream("flow-custom.properties");
|
properties.load(in);
|
Object userProperty = properties.get("com.vci.rmip.workflow.usercomponent");
|
Class userComponentClass = Class.forName(userProperty.toString());
|
userComponent = (IUserComponent)userComponentClass.newInstance();
|
|
// Object CCProperty = properties.get("com.vci.rmip.workflow.CCcomponent");
|
// Class CCComponentClass = Class.forName(CCProperty.toString());
|
// CCComponent = (IUserComponent)CCComponentClass.newInstance();
|
} catch (Exception ex) {
|
userComponent = new DefaultUserComponent(customUserPanel);
|
}
|
ownerPanel.add(userComponent.getUserComponent(customUserPanel.getCustomEditPanel()), BorderLayout.CENTER);
|
// ownerPanel.add(CCComponent.getUserComponent(customUserPanel.getCustomEditPanel()), BorderLayout.EAST);
|
return ownerPanel;
|
}
|
//委托人panel
|
private JPanel getConstituentPanel() {
|
JPanel ownerPanel = new JPanel(new BorderLayout());
|
customUserPanel = new CustomUserPanel();
|
constituentComponent = new DefaultUserComponent(customUserPanel);
|
// CCComponent = new DefaultUserComponent(customUserPanel);
|
|
Properties properties = new Properties();
|
try {
|
ClassLoader cl = TaskPanel.class.getClassLoader();
|
InputStream in = cl.getResourceAsStream("flow-custom.properties");
|
properties.load(in);
|
Object userProperty = properties.get("com.vci.rmip.workflow.constituentComponent");
|
Class userComponentClass = Class.forName(userProperty.toString());
|
constituentComponent = (IUserComponent)userComponentClass.newInstance();
|
|
// Object CCProperty = properties.get("com.vci.rmip.workflow.CCcomponent");
|
// Class CCComponentClass = Class.forName(CCProperty.toString());
|
// CCComponent = (IUserComponent)CCComponentClass.newInstance();
|
} catch (Exception ex) {
|
constituentComponent = new DefaultUserComponent(customUserPanel);
|
}
|
ownerPanel.add(constituentComponent.getUserComponent(customUserPanel.getCustomEditPanel()), BorderLayout.CENTER);
|
// ownerPanel.add(CCComponent.getUserComponent(customUserPanel.getCustomEditPanel()), BorderLayout.EAST);
|
return ownerPanel;
|
}
|
private JPanel getTaskDesPanel() throws VCIError {
|
taskDescPanel = new TaskDescPanel();
|
return taskDescPanel;
|
}
|
private JPanel getTaskTreatmentPanel() {
|
taskTreatmentPanel = new TaskTreatmentPanel();
|
return taskTreatmentPanel;
|
}
|
/* private JPanel getOwnerPanel() {
|
JPanel ownerPanel = new JPanel(new BorderLayout());
|
userComponent = new DefaultUserComponent();
|
|
Properties properties = new Properties();
|
String string = TaskPanel.class.getResource("/flow-custom.properties").toString();
|
try {
|
URL url = new URL(string);
|
properties.load(url.openStream());
|
Object userProperty = properties.get("com.vci.rmip.workflow.usercomponent");
|
Class userComponentClass = Class.forName(userProperty.toString());
|
userComponent = (IUserComponent)userComponentClass.newInstance();
|
} catch (Exception ex) {
|
userComponent = new DefaultUserComponent();
|
}
|
ownerPanel.add(userComponent.getUserComponent(), BorderLayout.CENTER);
|
return ownerPanel;
|
}*/
|
|
protected void updateFlow() {
|
graph.refresh();
|
}
|
|
@Override
|
public String toString() {
|
return nameField.getText().trim();
|
}
|
|
public String getNodeType() {
|
return node.getType();
|
}
|
|
public void setValue(String text) {
|
nameField.setText(text);
|
}
|
|
public void createAttribute(Element owner) {
|
Attribute attributeName = DocumentHelper.createAttribute(owner, FlowConstants.XMLNAME, nameField.getText().trim());
|
owner.add(attributeName);
|
|
//事件
|
getTreatmentEventXml(owner);
|
getCustomUserClassXmlForRMCode(owner, customUserPanel,
|
FlowConstants.XMLSTART);
|
setAssginTaskUser(owner);
|
setConstituent(owner);
|
getTaskEventXml(owner, taskInitEventPropertyPanel, FlowConstants.XMLSTART);
|
getTaskEventXml(owner, taskEndEventPropertyPanel, FlowConstants.XMLEND);
|
String urlText = taskDescPanel.getUrlTextArea().getText().trim();
|
if(urlText!=null&&!"".equals(urlText)){
|
Attribute attributeKey = DocumentHelper.createAttribute(owner, FlowConstants.URL_PATH, urlText);
|
owner.add(attributeKey);
|
}
|
|
}
|
|
public Map<String, ArrayList<PropertyInfo>> getTaskeventMap() {
|
return taskeventMap;
|
}
|
|
public void setTaskeventMap(Map<String, ArrayList<PropertyInfo>> taskeventMap) {
|
this.taskeventMap = taskeventMap;
|
}
|
|
public Map<String, Map<String, ArrayList<PropertyInfo>>> getResultMap() {
|
return resultMap;
|
}
|
|
public void setResultMap(String eventType,
|
Map<String, Map<String, ArrayList<PropertyInfo>>> resultMap) {
|
this.resultMap = resultMap;
|
if(FlowConstants.XMLSTART.equals(eventType)){
|
taskInitEventPropertyPanel.setTaskeventMap(resultMap.get(FlowConstants.XMLSTART));
|
}
|
if(FlowConstants.XMLEND.equals(eventType)){
|
taskEndEventPropertyPanel.setTaskeventMap(resultMap.get(FlowConstants.XMLEND));
|
}
|
}
|
|
private void getTaskEventXml(Element owner, TaskEventPanel eventPanel, String eventType) {
|
// String event = eventPanel.getEvent();
|
PropertyInfo[] customClassInfo = eventPanel.getCustomInfos();
|
if (customClassInfo.length > 0) {
|
Element onElement = owner.addElement(FlowConstants.EVENT_ON);
|
Attribute startAttribute = DocumentHelper.createAttribute(owner,
|
FlowConstants.EVENT, eventType);
|
onElement.add(startAttribute);
|
|
resultMap = eventPanel.getResultMap();
|
if(customClassInfo!=null){
|
if(customClassInfo.length>0){
|
for (int i = 0; i < customClassInfo.length; i++) {
|
for(int j =0;j<getEventTypes(eventType).length;j++){
|
String className = customClassInfo[i].property;
|
Map<String, ArrayList<PropertyInfo>> eventAndParamMap = resultMap.get(eventType);
|
String classValue = "";
|
if(getEventTypes(eventType)[j].getValue().equals(className)){
|
classValue = getEventTypes(eventType)[j].getProperty();
|
/*String initEventClass = EventProperties.getStringProperty("workflow.event.type." + classValue
|
+ ".class");*/
|
//add by caill start 2016.4.8 通过corba连接服务端
|
String initEventClass = null;
|
try {
|
initEventClass = new EventConfClientDelegate().getStringProperty("workflow.event.type." + classValue
|
+ ".class");
|
} catch (VCIError e) {
|
// TODO Auto-generated catch block
|
e.printStackTrace();
|
}
|
//add by caill end
|
ArrayList<PropertyInfo> paramList = new ArrayList<PropertyInfo>();
|
if(eventAndParamMap!=null){
|
paramList = eventAndParamMap.get(initEventClass);
|
}
|
Element listenerElement = onElement.addElement(FlowConstants.EVENT_LISTENER);
|
Attribute classAttribute = DocumentHelper.createAttribute(owner,
|
FlowConstants.EVENT_CLASS,initEventClass);
|
listenerElement.add(classAttribute);
|
if(paramList!=null){
|
for (int k = 0; k < paramList.size(); k++) {
|
Element fieldElement = listenerElement.addElement(FlowConstants.EVENT_FIELD);
|
Attribute nameAttribute = DocumentHelper.createAttribute(owner, FlowConstants.XMLNAME, paramList.get(k).property);
|
fieldElement.add(nameAttribute);
|
|
Element stringElement = fieldElement.addElement(FlowConstants.EVENT_STRING);
|
Attribute valueAttribute = DocumentHelper.createAttribute(owner, FlowConstants.EVENT_VALUE, paramList.get(k).value);
|
stringElement.add(valueAttribute);
|
}
|
}
|
}
|
}
|
}
|
}
|
}
|
}
|
}
|
|
/**
|
* 编码专用
|
* @param owner
|
* @param customUserPanel
|
* @param eventType
|
*/
|
private void getCustomUserClassXmlForRMCode(Element owner, CustomUserPanel customUserPanel,
|
String eventType) {
|
// String event = eventPanel.getEvent();
|
CustomInfo[] customClassInfo = customUserPanel.getCustomUserInfos();
|
// if (event.trim().length() > 0) {
|
if (customClassInfo.length > 0) {
|
Element onElement = owner.addElement(FlowConstants.EVENT_ON);
|
Attribute startAttribute = DocumentHelper.createAttribute(owner,
|
FlowConstants.EVENT, eventType);
|
onElement.add(startAttribute);
|
|
|
if(customClassInfo!=null){
|
if(customClassInfo.length>0){
|
String result = "";
|
for (int i = 0; i < customClassInfo.length; i++) {
|
for(int j =0;j<getCustomClassInfo("customUser").length;j++){
|
String className = customClassInfo[i].className;
|
// String classValue = customClassInfo[i].value;
|
if(getCustomClassInfo("customUser")[j].getValue().equals(className)){
|
className = getCustomClassInfo("customUser")[j].getClassName();
|
/*String initEventClass = EventProperties.getStringProperty("workflow.event.type.customUser." + className
|
+ ".class");*/
|
//add by caill start 2016.4.8 通过corba连接服务端
|
String initEventClass = null;
|
try {
|
initEventClass = new EventConfClientDelegate().getStringProperty("workflow.event.type.customUser." + className
|
+ ".class");
|
} catch (VCIError e) {
|
// TODO Auto-generated catch block
|
e.printStackTrace();
|
}
|
//add by caill end
|
Element listenerElement = onElement.addElement(FlowConstants.EVENT_LISTENER);
|
Attribute classAttribute = DocumentHelper.createAttribute(owner,
|
FlowConstants.EVENT_CLASS,initEventClass);
|
listenerElement.add(classAttribute);
|
Attribute flagbute = DocumentHelper.createAttribute(owner,
|
FlowConstants.CUSTOMUSERCLASS_flag,FlowConstants.CUSTOMUSERCLASS);
|
listenerElement.add(flagbute);
|
|
Element fieldElement = listenerElement
|
.addElement(FlowConstants.EVENT_FIELD);
|
Attribute nameAttribute = DocumentHelper.createAttribute(
|
owner, FlowConstants.XMLNAME,
|
"param");
|
fieldElement.add(nameAttribute);
|
|
Element stringElement = fieldElement
|
.addElement(FlowConstants.EVENT_STRING);
|
Attribute valueAttribute = DocumentHelper.createAttribute(
|
owner, FlowConstants.EVENT_VALUE,
|
customClassInfo[i].value);
|
stringElement.add(valueAttribute);
|
}
|
}
|
}
|
}
|
}
|
|
// PropertyInfo[] propertyInfos = eventPanel.getPropertyInfos();
|
// if (propertyInfos.length > 0) {
|
// for (int i = 0; i < propertyInfos.length; i++) {
|
// Element fieldElement = listenerElement
|
// .addElement(FlowConstants.EVENT_FIELD);
|
// Attribute nameAttribute = DocumentHelper.createAttribute(
|
// owner, FlowConstants.XMLNAME,
|
// propertyInfos[i].property);
|
// fieldElement.add(nameAttribute);
|
//
|
// Element stringElement = fieldElement
|
// .addElement(FlowConstants.EVENT_STRING);
|
// Attribute valueAttribute = DocumentHelper.createAttribute(
|
// owner, FlowConstants.EVENT_VALUE,
|
// propertyInfos[i].value);
|
// stringElement.add(valueAttribute);
|
// }
|
// }
|
|
|
}
|
}
|
|
/**
|
* 获取自定义用户类列表
|
* @param eventType
|
* @return
|
*/
|
public CustomObject[] getCustomClassInfo(String eventType) {
|
/*String[] types = EventProperties.getStringProperty("workflow.event.type."+eventType).split(",");*/
|
//add by caill start 2016.4.8 通过corba连接服务端
|
String[] types = null;
|
try {
|
types = new EventConfClientDelegate().getStringProperty("workflow.event.type."+eventType).split(",");
|
} catch (VCIError e) {
|
// TODO Auto-generated catch block
|
e.printStackTrace();
|
}
|
//add by caill end
|
List<CustomObject> taskTypes = new ArrayList<CustomObject>();
|
taskTypes.add(new CustomObject("", ""));
|
for (int i = 0; i < types.length; i++) {
|
if("".equals(types[i].trim())) continue;
|
/*taskTypes.add(new CustomObject(types[i],
|
EventProperties.getStringProperty("workflow.event.type.customUser." + types[i])));*/
|
//add by caill start 2016.4.8 通过corba连接服务端
|
try {
|
taskTypes.add(new CustomObject(types[i],
|
new EventConfClientDelegate().getStringProperty("workflow.event.type.customUser." + types[i])));
|
} catch (VCIError e) {
|
// TODO Auto-generated catch block
|
e.printStackTrace();
|
}
|
//add by caill end
|
}
|
return taskTypes.toArray(new CustomObject[0]);
|
}
|
|
private void getCustomUserClassXml(Element owner, CustomUserPanel customUserPanel,
|
String eventType) {
|
// String event = eventPanel.getEvent();
|
CustomInfo[] customClassInfo = customUserPanel.getCustomUserInfos();
|
// String initEventClass = getI18nForEvent("workflow.event.type." + event
|
// + ".class");
|
// if (event.trim().length() > 0) {
|
if(customClassInfo!=null){
|
Element onElement = owner.addElement(FlowConstants.EVENT_ON);
|
Attribute startAttribute = DocumentHelper.createAttribute(owner,
|
FlowConstants.EVENT, eventType);
|
onElement.add(startAttribute);
|
|
|
if(customClassInfo.length>0){
|
String result = "";
|
for (int i = 0; i < customClassInfo.length; i++) {
|
// for(int j =0;j<getCustomClassInfo(eventType).length;j++){
|
String className = customClassInfo[i].className;
|
// String classValue = customClassInfo[i].value;
|
// if(getCustomClassInfo(eventType)[j].getProperty().equals(className)){
|
// className = getCustomClassInfo(eventType)[j].getProperty();
|
// String initEventClass = getI18nForEvent("workflow.event.type." + className
|
// + ".class");
|
Element listenerElement = onElement.addElement(FlowConstants.EVENT_LISTENER);
|
Attribute classAttribute = DocumentHelper.createAttribute(owner,
|
FlowConstants.EVENT_CLASS,className);
|
listenerElement.add(classAttribute);
|
Attribute flagbute = DocumentHelper.createAttribute(owner,
|
FlowConstants.CUSTOMUSERCLASS_flag,FlowConstants.CUSTOMUSERCLASS);
|
listenerElement.add(flagbute);
|
|
Element fieldElement = listenerElement
|
.addElement(FlowConstants.EVENT_FIELD);
|
Attribute nameAttribute = DocumentHelper.createAttribute(
|
owner, FlowConstants.XMLNAME,
|
"param");
|
fieldElement.add(nameAttribute);
|
|
Element stringElement = fieldElement
|
.addElement(FlowConstants.EVENT_STRING);
|
Attribute valueAttribute = DocumentHelper.createAttribute(
|
owner, FlowConstants.EVENT_VALUE,
|
customClassInfo[i].value);
|
stringElement.add(valueAttribute);
|
// }
|
// }
|
}
|
}
|
|
// PropertyInfo[] propertyInfos = eventPanel.getPropertyInfos();
|
// if (propertyInfos.length > 0) {
|
// for (int i = 0; i < propertyInfos.length; i++) {
|
// Element fieldElement = listenerElement
|
// .addElement(FlowConstants.EVENT_FIELD);
|
// Attribute nameAttribute = DocumentHelper.createAttribute(
|
// owner, FlowConstants.XMLNAME,
|
// propertyInfos[i].property);
|
// fieldElement.add(nameAttribute);
|
//
|
// Element stringElement = fieldElement
|
// .addElement(FlowConstants.EVENT_STRING);
|
// Attribute valueAttribute = DocumentHelper.createAttribute(
|
// owner, FlowConstants.EVENT_VALUE,
|
// propertyInfos[i].value);
|
// stringElement.add(valueAttribute);
|
// }
|
// }
|
|
|
}
|
}
|
// private void getCustomUserClassXml(Element owner, CustomUserPanel customUserPanel) {
|
//// String event = eventPanel.getEvent();
|
// CustomInfo[] customClassInfo = customUserPanel.getCustomUserInfos();
|
//// String initEventClass = getI18nForEvent("workflow.event.type." + event
|
//// + ".class");
|
//// if (event.trim().length() > 0) {
|
//
|
// if(customClassInfo!=null){
|
// Element onElement = owner.addElement(FlowConstants.EVENT_ON);
|
//
|
// if(customClassInfo.length>0){
|
// String result = "";
|
// for (int i = 0; i < customClassInfo.length; i++) {
|
//// for(int j =0;j<getCustomClassInfo(eventType).length;j++){
|
// String className = customClassInfo[i].className;
|
//// String classValue = customClassInfo[i].value;
|
//// if(getCustomClassInfo(eventType)[j].getProperty().equals(className)){
|
//// className = getCustomClassInfo(eventType)[j].getProperty();
|
//// String initEventClass = getI18nForEvent("workflow.event.type." + className
|
//// + ".class");
|
// Element listenerElement = owner.addElement(FlowConstants.CUSTOMUSERCLASS);
|
// Attribute classAttribute = DocumentHelper.createAttribute(owner,
|
// FlowConstants.EVENT_CLASS,className);
|
// listenerElement.add(classAttribute);
|
// Attribute flagbute = DocumentHelper.createAttribute(owner,
|
// FlowConstants.CUSTOMUSERCLASS_flag,FlowConstants.CUSTOMUSERCLASS);
|
// listenerElement.add(flagbute);
|
//
|
// Element fieldElement = listenerElement
|
// .addElement(FlowConstants.EVENT_FIELD);
|
// Attribute nameAttribute = DocumentHelper.createAttribute(
|
// owner, FlowConstants.XMLNAME,
|
// "param");
|
// fieldElement.add(nameAttribute);
|
//
|
// Element stringElement = fieldElement
|
// .addElement(FlowConstants.EVENT_STRING);
|
// Attribute valueAttribute = DocumentHelper.createAttribute(
|
// owner, FlowConstants.EVENT_VALUE,
|
// customClassInfo[i].value);
|
// stringElement.add(valueAttribute);
|
//// }
|
//// }
|
// }
|
// }
|
//
|
//// PropertyInfo[] propertyInfos = eventPanel.getPropertyInfos();
|
//// if (propertyInfos.length > 0) {
|
//// for (int i = 0; i < propertyInfos.length; i++) {
|
//// Element fieldElement = listenerElement
|
//// .addElement(FlowConstants.EVENT_FIELD);
|
//// Attribute nameAttribute = DocumentHelper.createAttribute(
|
//// owner, FlowConstants.XMLNAME,
|
//// propertyInfos[i].property);
|
//// fieldElement.add(nameAttribute);
|
////
|
//// Element stringElement = fieldElement
|
//// .addElement(FlowConstants.EVENT_STRING);
|
//// Attribute valueAttribute = DocumentHelper.createAttribute(
|
//// owner, FlowConstants.EVENT_VALUE,
|
//// propertyInfos[i].value);
|
//// stringElement.add(valueAttribute);
|
//// }
|
//// }
|
//
|
//
|
// }
|
// }
|
/**
|
* 控制策略
|
* @param owner
|
*/
|
private void getTreatmentEventXml(Element owner){
|
String attribute = taskTreatmentPanel.getAttribute();
|
if(attribute!=null&&!"".equals(attribute)){
|
Element handlerElement = owner.addElement(FlowConstants.ASSIFNMENT_HANDLER);
|
// Element handlerElement = owner.addElement(FlowConstants.CUSTOM);
|
Attribute classAttribute = DocumentHelper.createAttribute(handlerElement, FlowConstants.EVENT_CLASS, attribute);
|
handlerElement.add(classAttribute);
|
}
|
if(taskTreatmentPanel.getRadio3().isSelected()){
|
//会签的
|
String votePercent = taskTreatmentPanel.getText().getText();
|
if(StringUtils.isBlank(votePercent)){
|
UIFUtils.showErrorMessage(null, new Exception("您选择的控制策略为会签,请输入会签通过的比例"));
|
}
|
Attribute classAttribute = DocumentHelper.createAttribute(owner, FlowConstants.SIGN_VOTE_PRCENT, votePercent);
|
owner.add(classAttribute);
|
}
|
}
|
/**
|
* 自定义获取用户
|
* @param owner
|
*/
|
private void setAssginTaskUser(Element owner){
|
List<String> users = userComponent.getSelectedUsers();
|
List<String> roles = userComponent.getSelectedRoles();
|
List<String> depts = userComponent.getSelectedDepts();
|
String cuts = userComponent.getSelectedCust();
|
|
StringBuilder usersb = new StringBuilder();
|
StringBuilder rolesb = new StringBuilder();
|
StringBuilder deptsb = new StringBuilder();
|
|
String attribute = "";
|
String userDialogControl = CommonProperties.getStringProperty("workflow.UserDialog");
|
if(userDialogControl!=null&&!"".equals(userDialogControl)){
|
if(users!=null&&users.size()==0){
|
Attribute attributeKey = DocumentHelper.createAttribute(owner,
|
FlowConstants.XMLUSER, FlowConstants.PROCESS_APPLICANT);
|
owner.add(attributeKey);
|
}else{
|
attribute = "com.vci.rmip.workflow.server.event.AssginTaskForExpression";
|
Element handlerElement = owner.addElement(FlowConstants.ASSIFNMENT_HANDLER);
|
// Element handlerElement = owner.addElement(FlowConstants.CUSTOM);
|
Attribute classAttribute = DocumentHelper.createAttribute(handlerElement, FlowConstants.EVENT_CLASS, attribute);
|
handlerElement.add(classAttribute);
|
List<String> selectedUsers = userComponent.getSelectedUsers();
|
String[] array = selectedUsers.toArray(new String[0]);
|
String userSt = Arrays.toString(array);
|
Element fieldElement = handlerElement
|
.addElement(FlowConstants.EVENT_FIELD);
|
Attribute nameAttribute = DocumentHelper.createAttribute(
|
owner, FlowConstants.XMLNAME,
|
"assignee");
|
fieldElement.add(nameAttribute);
|
|
Element stringElement = fieldElement
|
.addElement(FlowConstants.EVENT_STRING);
|
Attribute valueAttribute = DocumentHelper.createAttribute(
|
owner, FlowConstants.EVENT_VALUE,
|
userSt.substring(1,userSt.length()-1));
|
stringElement.add(valueAttribute);
|
}
|
}else{
|
if (users != null) {
|
for (int i = 0; i < users.size(); i++) {
|
usersb.append(users.get(i));
|
if (i != users.size() - 1) {
|
usersb.append(",");
|
}
|
}
|
usersb.append(";");
|
}
|
if (roles != null) {
|
for (int i = 0; i < roles.size(); i++) {
|
rolesb.append(roles.get(i));
|
if (i != roles.size() - 1) {
|
rolesb.append(",");
|
}
|
}
|
rolesb.append(";");
|
}
|
if (depts != null) {
|
for (int i = 0; i < depts.size(); i++) {
|
deptsb.append(depts.get(i));
|
if (i != depts.size() - 1) {
|
deptsb.append(",");
|
}
|
}
|
deptsb.append(";");
|
}
|
// 上面每个数据都已添加;
|
String result = usersb.toString() + rolesb.toString()
|
+ deptsb.toString();
|
// 值不为;;;才是有效的候选人定义
|
if (!"".equals(result) && !result.equals(";;;") && result.length() != 2) {
|
// 如果自定义用户不为空,则直接设置为自定义用户
|
if (cuts != null && !"".equals(cuts)) {
|
Attribute attributeKey = DocumentHelper.createAttribute(owner,
|
FlowConstants.XMLUSER, cuts);
|
owner.add(attributeKey);
|
} else {
|
Attribute attributeKey = DocumentHelper.createAttribute(owner,
|
FlowConstants.XMLUSERS, result);
|
owner.add(attributeKey);
|
}
|
} else {
|
// 如果自定义用户不为空,则直接设置为自定义用户
|
if (cuts != null && !"".equals(cuts)) {
|
Attribute attributeKey = DocumentHelper.createAttribute(owner,
|
FlowConstants.XMLUSER, cuts);
|
owner.add(attributeKey);
|
} else {
|
Attribute attributeKey = DocumentHelper.createAttribute(owner,
|
FlowConstants.XMLUSER, FlowConstants.PROCESS_APPLICANT);
|
owner.add(attributeKey);
|
}
|
}
|
}
|
}
|
/**
|
* 委托人
|
* @param owner
|
*/
|
private void setConstituent(Element owner){
|
List<String> users = constituentComponent.getSelectedUsers();
|
List<String> roles = constituentComponent.getSelectedRoles();
|
List<String> depts = constituentComponent.getSelectedDepts();
|
String cuts = constituentComponent.getSelectedCust();
|
|
StringBuilder usersb = new StringBuilder();
|
StringBuilder rolesb = new StringBuilder();
|
StringBuilder deptsb = new StringBuilder();
|
|
if (users != null) {
|
for (int i = 0; i < users.size(); i++) {
|
usersb.append(users.get(i));
|
if (i != users.size() - 1) {
|
usersb.append(",");
|
}
|
}
|
}
|
String result = usersb.toString();
|
Attribute attributeKey = DocumentHelper.createAttribute(owner,
|
FlowConstants.XMLCONSTITUENT, result);
|
owner.add(attributeKey);
|
// String userDialogControl = CommonProperties.getStringProperty("workflow.UserDialog");
|
// if(userDialogControl!=null&&!"".equals(userDialogControl)){
|
// if(users!=null&&users.size()==0){
|
// Attribute attributeKey = DocumentHelper.createAttribute(owner,
|
// FlowConstants.XMLUSER, FlowConstants.PROCESS_APPLICANT);
|
// owner.add(attributeKey);
|
// }else{
|
// attribute = "com.vci.rmip.workflow.server.event.AssginTaskForExpression";
|
// Element handlerElement = owner.addElement(FlowConstants.ASSIFNMENT_HANDLER);
|
//// Element handlerElement = owner.addElement(FlowConstants.CUSTOM);
|
// Attribute classAttribute = DocumentHelper.createAttribute(handlerElement, FlowConstants.EVENT_CLASS, attribute);
|
// handlerElement.add(classAttribute);
|
// List<String> selectedUsers = userComponent.getSelectedUsers();
|
// String[] array = selectedUsers.toArray(new String[0]);
|
// String userSt = Arrays.toString(array);
|
// Element fieldElement = handlerElement
|
// .addElement(FlowConstants.EVENT_FIELD);
|
// Attribute nameAttribute = DocumentHelper.createAttribute(
|
// owner, FlowConstants.XMLNAME,
|
// "assignee");
|
// fieldElement.add(nameAttribute);
|
//
|
// Element stringElement = fieldElement
|
// .addElement(FlowConstants.EVENT_STRING);
|
// Attribute valueAttribute = DocumentHelper.createAttribute(
|
// owner, FlowConstants.EVENT_VALUE,
|
// userSt.substring(1,userSt.length()-1));
|
// stringElement.add(valueAttribute);
|
// }
|
// }else{
|
// if (users != null) {
|
// for (int i = 0; i < users.size(); i++) {
|
// usersb.append(users.get(i));
|
// if (i != users.size() - 1) {
|
// usersb.append(",");
|
// }
|
// }
|
// usersb.append(";");
|
// }
|
// if (roles != null) {
|
// for (int i = 0; i < roles.size(); i++) {
|
// rolesb.append(roles.get(i));
|
// if (i != roles.size() - 1) {
|
// rolesb.append(",");
|
// }
|
// }
|
// rolesb.append(";");
|
// }
|
// if (depts != null) {
|
// for (int i = 0; i < depts.size(); i++) {
|
// deptsb.append(depts.get(i));
|
// if (i != depts.size() - 1) {
|
// deptsb.append(",");
|
// }
|
// }
|
// deptsb.append(";");
|
// }
|
// // 上面每个数据都已添加;
|
// String result = usersb.toString() + rolesb.toString()
|
// + deptsb.toString();
|
// // 值不为;;;才是有效的候选人定义
|
// if (!"".equals(result) && !result.equals(";;;") && result.length() != 2) {
|
// // 如果自定义用户不为空,则直接设置为自定义用户
|
// if (cuts != null && !"".equals(cuts)) {
|
// Attribute attributeKey = DocumentHelper.createAttribute(owner,
|
// FlowConstants.XMLUSER, cuts);
|
// owner.add(attributeKey);
|
// } else {
|
// Attribute attributeKey = DocumentHelper.createAttribute(owner,
|
// FlowConstants.XMLUSERS, result.replace(";;;", ""));
|
// owner.add(attributeKey);
|
// }
|
// } else {
|
// // 如果自定义用户不为空,则直接设置为自定义用户
|
// if (cuts != null && !"".equals(cuts)) {
|
// Attribute attributeKey = DocumentHelper.createAttribute(owner,
|
// FlowConstants.XMLUSER, cuts);
|
// owner.add(attributeKey);
|
// } else {
|
// Attribute attributeKey = DocumentHelper.createAttribute(owner,
|
// FlowConstants.XMLUSER, FlowConstants.PROCESS_APPLICANT);
|
// owner.add(attributeKey);
|
// }
|
// }
|
// }
|
}
|
public ProcessTaskInfo getProcessTaskInfo(){
|
ProcessTaskInfo info = new ProcessTaskInfo();
|
info.taskName = nameField.getText().trim();
|
info.taskType = taskTypePropertyPanel.getEvent();
|
info.taskDesc = taskDescPanel.getTaskDesArea() ;
|
info.pltreatment = taskTreatmentPanel.getFlag();
|
info.taskTypeProperties = taskTypePropertyPanel.getTypePropertyInfos();
|
// info.taskCCInfos = getTaskInfos();
|
info.popUserDialog = taskTreatmentPanel.getPopUserDialogONOFF()==null?FlowConstants.POPUSERDIALOG_OFF:taskTreatmentPanel.getPopUserDialogONOFF();
|
info.customUserInfos = customUserPanel.getCustomUserInfos();
|
|
info.revoke = taskTreatmentPanel.getRevokeONOFF()==null?FlowConstants.REVOKE_OFF:taskTreatmentPanel.getRevokeONOFF();
|
info.revokeInfos = getTaskrevoke(taskRevokeEventPropertyPanel, "revoke");
|
return info;
|
}
|
private PropertyInfo[] getTaskrevoke(EventPanel eventPanel,
|
String eventType){
|
PropertyInfo[] customClassInfo = taskRevokeEventPropertyPanel.getCustomInfos();
|
for (int i = 0; i < customClassInfo.length; i++) {
|
PropertyInfo info = new PropertyInfo();
|
for(int j =0;j<getEventTypes(eventType).length;j++){
|
String className = customClassInfo[i].property;
|
String classValue = "";
|
String initEventClass = "";
|
if(getEventTypes(eventType)[j].getValue().equals(className)){
|
classValue = getEventTypes(eventType)[j].getProperty();
|
/*initEventClass = EventProperties.getStringProperty("workflow.event.type." + classValue
|
+ ".class");*/
|
//add by caill start 2016.4.8 通过corba连接服务端
|
try {
|
initEventClass = new EventConfClientDelegate().getStringProperty("workflow.event.type." + classValue
|
+ ".class");
|
} catch (VCIError e) {
|
// TODO Auto-generated catch block
|
e.printStackTrace();
|
}
|
//add by caill end
|
}
|
info.property = className;
|
info.value = initEventClass;
|
}
|
customClassInfo[i] = info;
|
}
|
return customClassInfo;
|
}
|
|
private String getI18nForEvent(String key){
|
return LocaleDisplay.getI18nString(key, "RMIPWorkflow", getLocale());
|
}
|
|
public void setProcessTaskInfo(ProcessTaskInfo processTaskInfo) {
|
taskTypePropertyPanel.setProcessTaskInfo(processTaskInfo);
|
}
|
|
public void setEventInfo(ProcessTaskInfo processTaskInfo, String eventType) {
|
updateTaskType(processTaskInfo,eventType);
|
if(eventType.equals("start")) {
|
taskInitEventPropertyPanel.setProcessTaskInfo(processTaskInfo);
|
} else if(eventType.equals("end")) {
|
taskEndEventPropertyPanel.setProcessTaskInfo(processTaskInfo);
|
}else if (eventType.equals("revoke")) {
|
taskRevokeEventPropertyPanel.setProcessTaskInfo(processTaskInfo);
|
}
|
}
|
|
private void updateTaskType(ProcessTaskInfo processTaskInfo,String eventType) {
|
/*String[] types = EventProperties.getStringProperty("workflow.event.type."+eventType).split(",");*/
|
//add by caill start 2016.4.8 通过corba连接服务端
|
String[] types = null;
|
try {
|
types = new EventConfClientDelegate().getStringProperty("workflow.event.type."+eventType).split(",");
|
} catch (VCIError e) {
|
// TODO Auto-generated catch block
|
e.printStackTrace();
|
}
|
//add by caill end
|
for (int i = 0; i < types.length; i++) {
|
/*String eventClass = EventProperties.getStringProperty("workflow.event.type."
|
+ types[i] + ".class");*/
|
//add by caill start 2016.4.8 通过corba连接服务端
|
String eventClass = null;
|
try {
|
eventClass = new EventConfClientDelegate().getStringProperty("workflow.event.type."
|
+ types[i] + ".class");
|
} catch (VCIError e) {
|
// TODO Auto-generated catch block
|
e.printStackTrace();
|
}
|
//add by caill end
|
if (processTaskInfo.taskType.equals(eventClass)) {
|
processTaskInfo.taskType = types[i];
|
return;
|
}
|
}
|
|
}
|
|
public void setTaskOwners(List<String> users) {
|
userComponent.setSelectedUsers(users);
|
}
|
public void setTaskCCs(List<String> users) {
|
CCComponent.setSelectedUsers(users);
|
}
|
public void setconstituents(List<String> users) {
|
constituentComponent.setSelectedUsers(users);
|
}
|
public void setCustomClassInfo( String eventType,PropertyInfo[] customInfos){
|
int length = getEventTypes(eventType).length;
|
PropertyInfo[] res = new PropertyInfo[customInfos.length];
|
for(int j = 0;j<customInfos.length;j++){
|
for(int i=0;i<length;i++){
|
PropertyObject propertyObject = getEventTypes(eventType)[i];
|
PropertyInfo propertyInfo = new PropertyInfo();
|
/*String eventClass = EventProperties.getStringProperty("workflow.event.type."
|
+ propertyObject.getProperty() + ".class");*/
|
//add by caill start 2016.4.8 通过corba连接服务端
|
String eventClass = null;
|
try {
|
eventClass = new EventConfClientDelegate().getStringProperty("workflow.event.type."
|
+ propertyObject.getProperty() + ".class");
|
} catch (VCIError e) {
|
// TODO Auto-generated catch block
|
e.printStackTrace();
|
}
|
//add by caill end
|
if(eventClass.equals(customInfos[j].property)){
|
propertyInfo.property = propertyObject.getValue();
|
res[j] = propertyInfo;
|
}
|
}
|
}
|
if (eventType.equals("start")) {
|
taskInitEventPropertyPanel.setCustomInfos(res);
|
} else if (eventType.equals("end")) {
|
taskEndEventPropertyPanel.setCustomInfos(res);
|
}
|
}
|
public void setCustomInfo(CustomInfo[] customInfo) {
|
customUserPanel.setCustomInfo(customInfo);
|
}
|
/**
|
* 自定义用户
|
*
|
* @param depts
|
*/
|
public void setTaskCustOwners(String cust) {
|
userComponent.setSelectedCust(cust);
|
}
|
public void setTaskRoleOwners(List<String> roles) {
|
userComponent.setSelectedRoles(roles);
|
}
|
|
public void setTaskDeptOwners(List<String> depts) {
|
userComponent.setSelectedDepts(depts);
|
}
|
public void setPopUserDialog(String flag){
|
boolean popuserflag = flag.equals(FlowConstants.POPUSERDIALOG_ON);
|
taskTreatmentPanel.getPopUserDialogCb().setSelected(popuserflag);
|
if(popuserflag){
|
taskTreatmentPanel.setPopUserDialogONOFF(FlowConstants.POPUSERDIALOG_ON);
|
}else{
|
taskTreatmentPanel.setPopUserDialogONOFF(FlowConstants.POPUSERDIALOG_OFF);
|
}
|
}
|
public void setRevoke(String flag){
|
boolean revokeFlag = flag.equals(FlowConstants.REVOKE_ON);
|
taskTreatmentPanel.getRevokeCb().setSelected(revokeFlag);
|
if(revokeFlag){
|
taskTreatmentPanel.setRevokeONOFF(FlowConstants.REVOKE_ON);
|
}else{
|
taskTreatmentPanel.setRevokeONOFF(FlowConstants.REVOKE_OFF);
|
}
|
}
|
public void setRevokeInfos(String eventType,PropertyInfo[] revokeInfos){
|
taskRevokeEventPropertyPanel.setCustomInfos(revokeInfos);
|
}
|
public PropertyObject[] getEventTypes(String eventType) {
|
/*String[] types = EventProperties.getStringProperty("workflow.event.type."+eventType).split(",");*/
|
//add by caill start 2016.4.8 通过corba连接服务端
|
String[] types = null;
|
try {
|
types = new EventConfClientDelegate().getStringProperty("workflow.event.type."+eventType).split(",");
|
} catch (VCIError e) {
|
// TODO Auto-generated catch block
|
e.printStackTrace();
|
}
|
//add by caill end
|
List<PropertyObject> taskTypes = new ArrayList<PropertyObject>();
|
taskTypes.add(new PropertyObject("", ""));
|
for (int i = 0; i < types.length; i++) {
|
if("".equals(types[i].trim())) continue;
|
/*taskTypes.add(new PropertyObject(types[i],
|
EventProperties.getStringProperty("workflow.event.type." + types[i])));*/
|
//add by caill start 2016.4.8 通过corba连接服务端
|
try {
|
taskTypes.add(new PropertyObject(types[i],
|
new EventConfClientDelegate().getStringProperty("workflow.event.type." + types[i])));
|
} catch (VCIError e) {
|
// TODO Auto-generated catch block
|
e.printStackTrace();
|
}
|
//add by caill end
|
}
|
return taskTypes.toArray(new PropertyObject[0]);
|
}
|
}
|