package com.vci.client.workflow.task;
|
|
import java.awt.BorderLayout;
|
import java.awt.Color;
|
import java.awt.Dimension;
|
import java.awt.FlowLayout;
|
import java.awt.TextField;
|
import java.awt.Toolkit;
|
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionListener;
|
import java.awt.event.MouseAdapter;
|
import java.awt.event.MouseEvent;
|
import java.util.Map;
|
|
import javax.swing.BorderFactory;
|
import javax.swing.JButton;
|
import javax.swing.JLabel;
|
import javax.swing.JPanel;
|
import javax.swing.JScrollPane;
|
import javax.swing.JTabbedPane;
|
import javax.swing.JTable;
|
|
import com.vci.client.ClientSession;
|
import com.vci.client.LogonApplication;
|
import com.vci.client.common.objects.DeptObject;
|
import com.vci.client.common.objects.RoleObject;
|
import com.vci.client.common.objects.UserObject;
|
import com.vci.client.framework.delegate.RightManagementClientDelegate;
|
import com.vci.client.framework.rightConfig.object.FunctionObject;
|
import com.vci.client.framework.systemConfig.stafforgmanage.RightManagementTreeCellRenderer;
|
import com.vci.client.ui.exception.VCIException;
|
import com.vci.client.ui.locale.LocaleDisplay;
|
import com.vci.client.ui.swing.VCIOptionPane;
|
import com.vci.client.ui.swing.components.VCIJDialog;
|
import com.vci.client.ui.tree.VCIBaseTree;
|
import com.vci.client.ui.tree.VCIBaseTreeModel;
|
import com.vci.client.ui.tree.VCIBaseTreeNode;
|
import com.vci.client.workflow.commom.ClientHelper;
|
import com.vci.client.workflow.delegate.ProcessCustomClientDelegate;
|
import com.vci.corba.common.VCIError;
|
import com.vci.corba.workflow.data.FlowApproveHistoryInfo;
|
import com.vci.corba.workflow.data.FlowTaskInfo;
|
import com.vci.corba.workflow.data.ProcessTaskInfo;
|
|
import java.awt.GridBagLayout;
|
import java.awt.GridBagConstraints;
|
import javax.swing.JComboBox;
|
import java.awt.Insets;
|
import javax.swing.JTextArea;
|
import javax.swing.event.TreeExpansionEvent;
|
import javax.swing.event.TreeExpansionListener;
|
import javax.swing.tree.TreePath;
|
|
/**
|
* 待办任务
|
*
|
* @author Administrator
|
*
|
*/
|
public class TodoTaskByPlatformDialog extends VCIJDialog {
|
|
private static final long serialVersionUID = 1461586100225135416L;
|
|
|
private JTable historyTable;
|
|
private HistoryTableModel historyTableModel;
|
|
private boolean view = false;
|
|
FunctionObject funcObject = new FunctionObject();
|
|
private String executionId;
|
|
private JButton commit;
|
private JButton cancel;
|
private JComboBox outComeComb;
|
|
|
private String outCome;
|
private String desc;
|
private String taskId;
|
|
|
private String taskName;
|
|
private boolean saveFlag = false;
|
|
|
private JTextArea descTextArea;
|
|
|
private String status;
|
|
//下拉树Panel容器
|
private JScrollPane treePanel = new JScrollPane();
|
//下一节点人
|
private TextField nextUserTextField;
|
private String nextUser = "";
|
|
private VCIBaseTreeModel treeModel;
|
private JScrollPane treeScrollPane;
|
private VCIBaseTreeNode rootNode = new VCIBaseTreeNode("人员组织", "root");
|
private VCIBaseTreeNode userNode;
|
private VCIBaseTreeNode roleNode;
|
private VCIBaseTreeNode departmentNode;
|
private VCIBaseTree rightManagementTree;
|
private UserObject userInfo;
|
|
private VCIBaseTreeNode selectNode;
|
|
private String userValue ;
|
private String roleValue ;
|
private String departmentValue ;
|
|
public boolean isSaveFlag() {
|
return saveFlag;
|
}
|
|
public void setSaveFlag(boolean saveFlag) {
|
this.saveFlag = saveFlag;
|
}
|
|
public String getNextUser() {
|
return nextUser;
|
}
|
|
public void setNextUser(String nextUser) {
|
this.nextUser = nextUser;
|
}
|
|
public String getOutCome() {
|
return outCome;
|
}
|
|
public void setOutCome(String outCome) {
|
this.outCome = outCome;
|
}
|
|
public String getDesc() {
|
return desc;
|
}
|
|
public void setDesc(String desc) {
|
this.desc = desc;
|
}
|
|
public TodoTaskByPlatformDialog(String executionId,String taskId,String taskName,String status) {
|
super(LogonApplication.frame, true);
|
this.executionId = executionId;
|
this.taskId = taskId;
|
this.taskName = taskName;
|
this.status = status;
|
initUI();
|
initData();
|
addListener();
|
initOutComeComb();
|
this.setLocationRelativeTo(null);
|
}
|
|
// public TodoTaskByPlatformDialog(Map<String,String> datamap, ProcessTaskInfo frocessTaskInfo, boolean view) {
|
// super(LogonApplication.frame, true);
|
// this.view = view;
|
// setTitle("查看");
|
// this.datamap = datamap;
|
// this.frocessTaskInfo = frocessTaskInfo;
|
// initUI();
|
// initData();
|
// addListener();
|
// }
|
|
private void initData() {
|
ProcessCustomClientDelegate processCustomClientDelegate = new ProcessCustomClientDelegate();
|
FlowApproveHistoryInfo[] historyActivity;
|
String[] allCandidatesForTask = new String[0];
|
try {
|
historyActivity = processCustomClientDelegate.getHistoryActivityByProInsIdbyPLM(executionId);
|
historyTableModel.setData(historyActivity);
|
//解析子流程节点
|
String deployId;
|
deployId = processCustomClientDelegate.getDeploymentIdByExecutionId(executionId);
|
allCandidatesForTask = processCustomClientDelegate.getAllCandidatesForTask(deployId, taskName, "");
|
} catch (VCIError e) {
|
e.printStackTrace();
|
} catch (VCIException e) {
|
// TODO Auto-generated catch block
|
e.printStackTrace();
|
}
|
|
if(allCandidatesForTask.length==1){
|
if("#{process_applicant}".equals(allCandidatesForTask[0])){
|
userValue = null;
|
}else{
|
userValue = allCandidatesForTask[0];
|
}
|
roleValue = null;
|
departmentValue = null;
|
}
|
if(allCandidatesForTask.length==2){
|
userValue = allCandidatesForTask[0];
|
roleValue = allCandidatesForTask[1];
|
departmentValue = null;
|
}
|
if(allCandidatesForTask.length==3){
|
userValue = allCandidatesForTask[0];
|
roleValue = allCandidatesForTask[1];
|
departmentValue = allCandidatesForTask[2];
|
}
|
|
}
|
|
private void addListener() {
|
commit.addActionListener(new ActionListener() {
|
public void actionPerformed(ActionEvent arg0) {
|
saveFlag = true;
|
outCome = (String) outComeComb.getSelectedItem();
|
desc = descTextArea.getText();
|
// ProcessCustomClientDelegate processCustomClientDelegate = new ProcessCustomClientDelegate(
|
// LogonApplication.getUserEntityObject());
|
// String jbpmDeploymentId;
|
// try {
|
// jbpmDeploymentId = new ProcessCustomClientDelegate().getDeploymentIdByExecutionId(executionId);
|
// String[] nextTaskName;
|
// try {
|
// nextTaskName = processCustomClientDelegate.getNextTaskNames(
|
// jbpmDeploymentId, taskName, outCome);
|
// if(nextTaskName!=null){
|
//
|
// }
|
// System.out.println("");
|
// } catch (VCIException e) {
|
// e.printStackTrace();
|
// }
|
// } catch (VCIError e) {
|
// e.printStackTrace();
|
// }
|
dispose();
|
}
|
});
|
|
cancel.addActionListener(new ActionListener() {
|
public void actionPerformed(ActionEvent arg0) {
|
dispose();
|
}
|
});
|
|
/**
|
* 树的展开事件
|
*/
|
rightManagementTree.addTreeExpansionListener(new TreeExpansionListener() {
|
public void treeExpanded(TreeExpansionEvent event) {
|
TreePath treePath = event.getPath();
|
selectNode = (VCIBaseTreeNode) treePath.getLastPathComponent();
|
Object object = selectNode.getObj();
|
// if (!selectNode.isExpand()) {
|
if (selectNode.getChildCount()==0) {
|
selectNode.setExpand(true);
|
if (object instanceof UserObject) {
|
UserObject user = (UserObject) object;
|
if (user.getId().equals("root")) {
|
try {
|
UserObject[] userInfos = new RightManagementClientDelegate(LogonApplication.getUserEntityObject()).fetchUserInfo();
|
for (UserObject userObject : userInfos) {
|
if(userValue!=null&&!"".equals(userValue)){
|
String[] split = userValue.split(",");
|
for(String userSplit : split){
|
if(userSplit.equals(userObject.getUserName())){
|
treeModel.insertNodeInto(new VCIBaseTreeNode(userObject.toString(), userObject), selectNode, selectNode.getChildCount());
|
}
|
}
|
}
|
}
|
} catch (VCIException e) {
|
e.printStackTrace();
|
return;
|
}
|
}
|
}
|
if (object instanceof RoleObject) {
|
RoleObject role = (RoleObject) object;
|
if (role.getId().equals("root")) {
|
try {
|
RoleObject[] roleInfos = new RightManagementClientDelegate(LogonApplication.getUserEntityObject()).fetchRoleInfo();
|
|
for (RoleObject roleObject : roleInfos) {
|
if(roleValue!=null&&!"".equals(roleValue)){
|
String[] split = roleValue.split(",");
|
for(String roleSplit : split){
|
if(roleSplit.equals(roleObject.getId())){
|
treeModel.insertNodeInto(new VCIBaseTreeNode(roleObject.getName(), roleObject), selectNode, selectNode.getChildCount());
|
}
|
}
|
}
|
}
|
|
} catch (VCIException e) {
|
e.printStackTrace();
|
return;
|
}
|
}else{
|
try {
|
UserObject[] fetchUserInfoByRoleId = new RightManagementClientDelegate(LogonApplication.getUserEntityObject()).fetchUserInfoByRoleId(role.getId(), role.getType());
|
for (UserObject userObject : fetchUserInfoByRoleId) {
|
treeModel.insertNodeInto(new VCIBaseTreeNode(userObject.toString(), userObject), selectNode, selectNode.getChildCount());
|
}
|
} catch (VCIException e) {
|
e.printStackTrace();
|
}
|
}
|
|
}
|
if (object instanceof DeptObject){
|
RightManagementClientDelegate del = new RightManagementClientDelegate(LogonApplication.getUserEntityObject());
|
try {
|
DeptObject[] DeptInfos = null;
|
DeptObject deptObject = (DeptObject) object;
|
if (deptObject.getId().equals("root")){
|
DeptInfos= new RightManagementClientDelegate(LogonApplication.getUserEntityObject())
|
.fetchDepartmentInfo();
|
|
}else{
|
DeptInfos = new RightManagementClientDelegate(LogonApplication.getUserEntityObject())
|
.fetchDepartmentInfoByParentId(deptObject.getId());
|
}
|
if (DeptInfos == null){
|
if (!deptObject.getId().equals("root")){
|
UserObject[] objs = del.getUserByDeptId(deptObject.getId());
|
for(int i=0;i<objs.length;i++) {
|
treeModel.insertNodeInto(new VCIBaseTreeNode(objs[i].toString(), objs[i]),selectNode,selectNode.getChildCount());
|
}
|
}else{
|
return;
|
}
|
}
|
if(DeptInfos!=null){
|
int len = DeptInfos.length;
|
for (int i = 0; i < len; i++) {
|
if(departmentValue!=null&&!"".equals(departmentValue)){
|
String[] split = departmentValue.split(",");
|
for(String deptmentSplit : split){
|
if(deptmentSplit.equals(DeptInfos[i].getId())){
|
treeModel.insertNodeInto(new VCIBaseTreeNode(DeptInfos[i].getName(), DeptInfos[i]),selectNode,selectNode.getChildCount());
|
}
|
}
|
}
|
}
|
}
|
|
} catch (VCIException e) {
|
e.printStackTrace();
|
return;
|
}
|
}
|
}
|
}
|
public void treeCollapsed(TreeExpansionEvent event) {
|
|
}
|
});
|
//树点击事件
|
rightManagementTree.addMouseListener(new MouseAdapter() {
|
@Override
|
public void mouseClicked(MouseEvent e) {
|
if(e.getClickCount() != 2) return;
|
TreePath path = rightManagementTree.getPathForLocation(e.getX(), e.getY());
|
VCIBaseTreeNode clickedNode = (VCIBaseTreeNode) rightManagementTree.getLastSelectedPathComponent();
|
if(path == null) return;
|
if(clickedNode.getLevel()<2) return;
|
Object object = clickedNode.getObj();
|
if (object instanceof RoleObject) {
|
VCIOptionPane.showMessage(LogonApplication.frame, "请选择用户");
|
return;
|
// RoleObject role = (RoleObject) object;
|
// UserObject[] fetchUserInfoByRoleId;
|
// try {
|
// fetchUserInfoByRoleId = new RightManagementClientDelegate(LogonApplication.getUserEntityObject()).fetchUserInfoByRoleId(role.getId(), role.getType());
|
// if(fetchUserInfoByRoleId==null||fetchUserInfoByRoleId.length==0){
|
// VCIOptionPane.showMessage(LogonApplication.frame, "该角色下没有用户");
|
// return;
|
// }
|
// } catch (VCIException e1) {
|
// e1.printStackTrace();
|
// }
|
}
|
if (object instanceof DeptObject) {
|
VCIOptionPane.showMessage(LogonApplication.frame, "请选择用户");
|
return;
|
// RightManagementClientDelegate del = new RightManagementClientDelegate(LogonApplication.getUserEntityObject());
|
// DeptObject dept = (DeptObject) object;
|
// UserObject[] objs;
|
// try {
|
// objs = del.getUserByDeptId(dept.getId());
|
// if(objs==null||objs.length==0){
|
// VCIOptionPane.showMessage(LogonApplication.frame, "该部门下没有用户");
|
// return;
|
// }
|
// } catch (VCIException e1) {
|
// e1.printStackTrace();
|
// }
|
}
|
//设置下一节点负责人
|
nextUserTextField.setText(((UserObject)object).getTrueName());
|
nextUser = "user:" + ((UserObject)object).getUserName();
|
treePanel.setVisible(false);
|
}
|
});
|
}
|
private void initUI() {
|
setSize(780, 600);
|
centerToScreen();
|
|
JPanel panel = new JPanel();
|
getContentPane().add(panel, BorderLayout.CENTER);
|
panel.setLayout(new BorderLayout(0, 0));
|
|
JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP);
|
panel.add(tabbedPane, BorderLayout.CENTER);
|
|
JPanel panel_1 = new JPanel();
|
// if(!"Completed".toLowerCase().equals(status.toLowerCase())){
|
tabbedPane.addTab("审批", null, panel_1, null);
|
// }
|
panel_1.setLayout(new BorderLayout(0, 0));
|
|
JPanel panel_2 = new JPanel();
|
panel_1.add(panel_2, BorderLayout.CENTER);
|
panel_2.setLayout(null);
|
|
JLabel label = new JLabel("审批:");
|
label.setBounds(72, 33, 36, 15);
|
panel_2.add(label);
|
|
outComeComb = new JComboBox();
|
outComeComb.setBounds(155, 30, 453, 21);
|
panel_2.add(outComeComb);
|
|
JLabel label_1 = new JLabel("审批意见:");
|
label_1.setBounds(61, 124, 60, 74);
|
panel_2.add(label_1);
|
|
JScrollPane scrollPane_1 = new JScrollPane();
|
scrollPane_1.setBounds(155, 86, 453, 143);
|
panel_2.add(scrollPane_1);
|
|
descTextArea = new JTextArea();
|
scrollPane_1.setViewportView(descTextArea);
|
|
//added by changmk start
|
String nextNodeUser = "";
|
try {
|
nextNodeUser = ClientSession.getWorkflowService().getNextTaskAssigner(executionId, taskName);
|
} catch (VCIError e1) {
|
// TODO Auto-generated catch block
|
e1.printStackTrace();
|
}
|
if ("".equals(nextNodeUser) && !"结束".equals(taskName)) {
|
JLabel nextUserLabel = new JLabel("下一任务负责人:");
|
nextUserLabel.setBounds(41, 250, 100, 15);
|
panel_2.add(nextUserLabel);
|
|
nextUserTextField = new TextField();
|
nextUserTextField.setBounds(155, 250, 300, 20);
|
nextUserTextField.setEditable(false);
|
panel_2.add(nextUserTextField);
|
|
JButton selectNextUserBtn = new JButton("选择");
|
selectNextUserBtn.setBounds(530, 250, 50, 20);
|
panel_2.add(selectNextUserBtn);
|
selectNextUserBtn.addActionListener(new ActionListener() {
|
public void actionPerformed(ActionEvent arg0) {
|
treePanel.setVisible(true);
|
}
|
});
|
}
|
//添加下拉树列表
|
treePanel.setBounds(155, 270, 350, 150);
|
treePanel.setVisible(false);
|
panel_2.add(treePanel);
|
|
JButton treeOkBtn = new JButton("清空");
|
JButton treeCancelBtn = new JButton("取消");
|
|
JPanel treeBtnPanel = new JPanel();
|
|
treeBtnPanel.add(treeOkBtn);
|
treeBtnPanel.add(treeCancelBtn);
|
// treeBtnPanel.setBorder(BorderFactory.createLineBorder(Color.red));
|
treeOkBtn.addActionListener(new ActionListener() {
|
public void actionPerformed(ActionEvent arg0) {
|
nextUserTextField.setText("");
|
nextUser = "";
|
treePanel.setVisible(false);
|
}
|
});
|
treeCancelBtn.addActionListener(new ActionListener() {
|
public void actionPerformed(ActionEvent arg0) {
|
treePanel.setVisible(false);
|
}
|
});
|
|
// treePanel.add(treeBtnPanel, BorderLayout.NORTH);
|
|
// treeScrollPane = new JScrollPane();
|
// treePanel.add(treePanel, BorderLayout.CENTER);
|
|
treeModel = new VCIBaseTreeModel(rootNode);
|
initUserTree(rootNode, "root");
|
initRoleTree(rootNode, "root");
|
initDepartTree(rootNode, "root");
|
rightManagementTree = new VCIBaseTree(treeModel, new RightManagementTreeCellRenderer());
|
treePanel.setViewportView(rightManagementTree);
|
|
//added by changmk end
|
|
JPanel panel_3 = new JPanel();
|
FlowLayout flowLayout = (FlowLayout) panel_3.getLayout();
|
flowLayout.setAlignment(FlowLayout.RIGHT);
|
panel_1.add(panel_3, BorderLayout.SOUTH);
|
|
commit = new JButton("提交");
|
panel_3.add(commit);
|
|
cancel = new JButton("关闭");
|
panel_3.add(cancel);
|
|
|
// RmDataPanel rmDataPanel = new RmDataPanel();
|
// rmDataPanel.init(flowTask);
|
// tabbedPane.addTab(getI18nString("flowData"), null, rmDataPanel, null);
|
|
JPanel historyPanel = new JPanel();
|
tabbedPane.addTab(getI18nString("processHis"), null, historyPanel, null);
|
historyPanel.setLayout(new BorderLayout(0, 0));
|
|
JScrollPane scrollPane = new JScrollPane();
|
historyPanel.add(scrollPane, BorderLayout.CENTER);
|
|
historyTableModel = new HistoryTableModel();
|
historyTable = new JTable(historyTableModel);
|
historyTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
|
scrollPane.setViewportView(historyTable);
|
historyTable.setRowHeight(25);
|
|
String developmentId;
|
try {
|
developmentId = new ProcessCustomClientDelegate().getDeploymentIdByExecutionId(executionId);
|
JPanel viewPanel = new JPanel();
|
if(developmentId!=null&&!"".equals(developmentId)){
|
viewPanel = new ViewExecutionImagePanel(executionId,taskName);
|
}else{
|
viewPanel = new ViewFinishImagePanel(executionId,"");
|
}
|
tabbedPane.addTab(getI18nString("process"), null, viewPanel, null);
|
} catch (VCIError e) {
|
e.printStackTrace();
|
}
|
}
|
|
/**
|
* 居中屏幕
|
*/
|
private void centerToScreen() {
|
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
|
Dimension componentSize = getSize();
|
if (componentSize.height > screenSize.height) {
|
componentSize.height = screenSize.height;
|
}
|
|
if (componentSize.width > screenSize.width) {
|
componentSize.width = screenSize.width;
|
}
|
|
setLocation((screenSize.width - componentSize.width) / 2, (screenSize.height - componentSize.height) / 2);
|
}
|
|
private String getI18nString(String spCode) {
|
return ClientHelper.getI18nStringForWorkflow(this.getClass().getName() + "." + spCode, this.getLocale());
|
}
|
|
private String getI18nStringByCode(String spCode) {
|
return ClientHelper.getI18nStringForWorkflow(spCode, this.getLocale());
|
}
|
private void initOutComeComb(){
|
ProcessCustomClientDelegate processCustomClientDelegate = new ProcessCustomClientDelegate();
|
try {
|
String[] allOutComes = processCustomClientDelegate .getAllOutComes(taskId);
|
for(String outCome : allOutComes){
|
outComeComb.addItem(outCome);
|
}
|
} catch (VCIException e) {
|
e.printStackTrace();
|
}
|
}
|
|
|
protected void initUserTree(VCIBaseTreeNode rootNode, String puid) {
|
String userName = LogonApplication.getUserEntityObject().getUserName();
|
try {
|
userInfo = new RightManagementClientDelegate(LogonApplication.getUserEntityObject()).fetchUserInfoByName(userName);
|
} catch (VCIException e) {
|
e.printStackTrace();
|
return;
|
}
|
UserObject userObject = new UserObject();
|
userObject.setId("root");
|
userNode = new VCIBaseTreeNode("用户", userObject);
|
rootNode.add(userNode);
|
}
|
protected void initRoleTree(VCIBaseTreeNode rootNode, String puid) {
|
String userName = LogonApplication.getUserEntityObject().getUserName();
|
try {
|
userInfo = new RightManagementClientDelegate(LogonApplication.getUserEntityObject()).fetchUserInfoByName(userName);
|
} catch (VCIException e) {
|
e.printStackTrace();
|
return;
|
}
|
RoleObject roleObject = new RoleObject();
|
roleObject.setId("root");
|
roleNode = new VCIBaseTreeNode(LocaleDisplay.getI18nString("rmip.stafforg.menu.role", "RMIPFramework", getLocale()), roleObject);
|
rootNode.add(roleNode);
|
|
}
|
protected void initDepartTree(VCIBaseTreeNode rootNode, String puid) {
|
String userName = LogonApplication.getUserEntityObject().getUserName();
|
try {
|
userInfo = new RightManagementClientDelegate(LogonApplication.getUserEntityObject()).fetchUserInfoByName(userName);
|
} catch (VCIException e) {
|
e.printStackTrace();
|
return;
|
}
|
DeptObject rootDepartment = new DeptObject();
|
rootDepartment.setId("root");
|
departmentNode = new VCIBaseTreeNode(
|
LocaleDisplay.getI18nString("rmip.stafforg.menu.department",
|
"RMIPFramework", getLocale()), rootDepartment);
|
rootNode.add(departmentNode);
|
}
|
}
|